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

int main(void)
{
    int X, N;
    cin >> X >> N;
    int p;
    int arrP[102] = {};
    for (int i = 0; i < N; i++) {
        cin >> p;
        arrP[p]++;
    }

    int minDiff = X;
    int ans = 0;
    for (int i = 1; i < 102; i++) {
        if (arrP[i] == 0) {
            if (minDiff > abs(X - i)) {
                minDiff = abs(X - i);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define pi 3.14159265359

const int maxn = (i64)1e9+7;

int arr[200005];
int main()
{
    //read;
    int n;
    cin>>n;
    n=n%10;
    if(n==0||n==1||n==6||n==8) cout<<"pon";
    else if(n==3) cout<<"bon";
    else cout<<"hon";
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long[,] A = new long[N,3];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i,0] = long.Parse(str[0]);
			A[i,1] = long.Parse(str[1]);
			A[i,2] = long.Parse(str[2]);
		}
		long it = 0;
		long jt = 0;
		while(true){
			long amin = Math.Abs(it-A[0,0])+Math.Abs(jt-A[0,1])+A[0,2];
			long amax = Math.Abs(it-A[0,0])+Math.Abs(jt-A[0,1])+A[0,2];
			if(A[0,2] == 0){
				amin = 1;
			}
			bool flag = true;
			for(var i=1;i<N;i++){
				if(A[i,2] != 0){
					amin = Math.Max(amin,Math.Abs(it-A[i,0])+Math.Abs(jt-A[i,1])+A[i,2]);
				}
				amax = Math.Min(amax,Math.Abs(it-A[i,0])+Math.Abs(jt-A[i,1])+A[i,2]);
				if(amin > amax){
					flag = false;
					break;
				}
			}
			if(amin != amax){
				flag = false;
			}
			if(flag == true){
				for(var i=0;i<N;i++){
					if(Math.Max(0,amin - (Math.Abs(it-A[i,0])+Math.Abs(jt-A[i,1]))) != A[i,2]){
						flag = false;
						break;
					}
				}
			}
			if(flag == true){
				Console.WriteLine(it+" "+jt+" "+amin);
				break;
			}
			jt += 1;
			if(jt >= 101){
				it += 1;
				if(it >= 101){
					break;
				}
				jt = 0;
			}
		}
	}
}

Measured memory_bytes: 13268
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 3
		// 10 2 5
		// 6 3 4
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		int[] net = new int[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			net[i] = v[i] - c[i];
		}
		Arrays.sort(net);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (net[i] > 0) {
				ans += net[i];
			}
		}
		System.out.println(ans);
	}
}

 
 

 
 
 
 


Measured memory_bytes: 35704
import numpy as np
n,m = map(int, input().split())
h = np.array([int(i) for i in input().split()])
h_i = np.ones((n))
for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        h_i[a-1] = 0
    elif h[b-1] < h[a-1]:
        h_i[b-1] = 0
    elif h[a-1] == h[b-1]:
        h_i[a-1] = 0
        h_i[b-1] = 0
ans = (h_i > 0).sum()
print(ans)

Measured memory_bytes: 38572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> H(n); rep(i, n) cin >> H[i];
  rrep(i, n-1) {
    if(H[i] > H[i+1]+1) {
      cout << "No\n";
      return 0;
    } else if(H[i] == H[i+1]+1) {
      H[i]--;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3928
import copy

S = list(input())
T = list(input())
Stmp = copy.copy(S)

if S == T:
    print("Yes")
else:
    flg = False
    s = S.pop(-1)
    S.insert(0, s)
    if S == T:
        flg = True

    while Stmp != S:
        s = S.pop(-1)
        S.insert(0, s)
        if S == T:
            flg = True
            break

    if flg:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int x,n; cin>>x>>n;
    vector<bool> exist(202, false);

    if(n==0) {
        cout << x << endl;
        return 0;
    }

    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        exist[a+100] = true;
    }

    for (int j = 0; x+j < 202; ++j) {
        if(!exist[x-j+100]) {
            cout << x-j << endl;
            break;
        } else if (!exist[x+j+100]){
            cout << x+j << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  bool f[n];
  
  for(int i=1; i<=n; i++){
    int p;
    cin >> p;
    if(i==p) f[i]=true;
    else f[i]=false;
  }
  
  int ans=0;
  for(int i=1; i<=n; i++){
    if(f[i]){
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#if __cplusplus > 199711L      /* C++11 */
#include <unordered_map>
#include <unordered_set>
#include <forward_list>
#include <array>
#endif                         /* C++11 */
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/









int main()
{
  IOS; /* making cin faster */
  int N,K;
  string S;
  CIN3(N,S,K);

  -- K;
  
  REP(i,N)
    {
      if( S[i] != S[K] )
	{
	  S[i] = '*';
	  
	}
    }

  COUT(S);
  
  
  
  

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, shu;
	cin >> a >> b;
	shu = b - a + 1;
	if (a > 0)
	{
		cout << "Positive" << endl;
		return 0;
	}
	if (a < 0 && b < 0 && shu % 2 == 1)
	{
		cout << "Negative" << endl;
		return 0;
	}
	if (a <= 0 && b >= 0)
	{
		cout << "Zero" << endl;
		return 0;
	}
	cout << "Positive" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();
        int sum = 0;
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            sum += a;
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(sum-(arr.get(n-1)/2));
    }
}

Measured memory_bytes: 35752
class union_find:
    def __init__(self, n):
        self.num_list = [i for i in range(n)]


    def root(self, n):
        if self.num_list[n] == n:
            return n
        else:
            self.num_list[n] = self.root(self.num_list[n])
            return self.num_list[n]

    def merge(self, a, b):
        a_root = self.root(a)
        b_root = self.root(b)
        tmp = min(a_root, b_root)
        self.num_list[a_root] = tmp
        self.num_list[b_root] = tmp
        return


n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

ans = 0
U = union_find(n)
for i in range(m):
    U.__init__(n)
    for j in range(m):
        if i == j:
            continue
        U.merge(edge[j][0]-1, edge[j][1]-1)
    setE = set()
    for k in range(n):
        setE.add(U.root(k))
    if len(setE) > 1:
        # print(setE)
        ans += 1
print(ans)

Measured memory_bytes: 3064
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.insert(0,0)
dp = [0 for _ in range(N+1)]
dp[N-1] = abs(H[N]-H[N-1])
for i in range(N-2,0,-1):
    dp[i] = abs(H[i+1]-H[i])+dp[i+1]
    for k in range(2,K+1):
        if i+k<=N:
            dp[i] = min(dp[i],abs(H[i+k]-H[i])+dp[i+k])
print(dp[1])

Measured memory_bytes: 56032
n = int(input())
s = [input() for i in range(n)]
if len(set(s)) < n:
	print("No")
else:
	flag = True
	for i in range(1,n):
		if s[i-1][-1] != s[i][0]:
			flag = False
	print("Yes" if flag else "No")

Measured memory_bytes: 3060
#include <cstdio>
const int SIZE = 33554432;
#define HASH(A) char* c = A; Hash = 1; while(*c){ Hash <<= 2; Hash += Key[*c]; c++; }

int main() {
  bool dic[SIZE];
  int Hash;
  char Key[85]; Key['A'] = 0; Key['C'] = 1; Key['G'] = 2; Key['T'] = 3;
  int n; std::scanf("%d\n", &n);
  char str[21];
  for( int i = 0; i < n; i++ ) {
    std::fgets(str, 21, stdin);
    if( str[0] == 'i' ) {
      HASH(str+7);
      dic[Hash] = 1;
    } else {
      HASH(str+5);
      std::puts(dic[Hash] ? "yes" : "no");
    }
  }
  return 0;
}


Measured memory_bytes: 8108
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int N,K;
  cin >> N;
  cin >> K;

  vector<int> h(N);

  for(int i=0;i<N;i++){
    cin >> h[i];
    //cout << h[i] << endl;
  }


  sort(h.begin(),h.end());

  for(int i=0;i<N;i++){
    //cout << h[i] << endl;
  }

  int val=(1 << 30);
  for(int i=K;i<N+1;i++){
    //cout << h[i] << endl;
    if(val > (h[i-1] - h[i-K]) ){
      val = (h[i-1] - h[i-K]);
    }
  }

  cout << val << endl;

  return 0;
}


Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int main(){
	int n;
	cin>>n;
	map<int,int>ma1,ma2;
	rep(i,n){
		int a;
		cin>>a;
		if(i%2)ma1[a]++;
		else ma2[a]++;
	}
	vp a,b;
	for(auto it:ma1)a.pb({-it.second,it.first});
	for(auto it:ma2)b.pb({-it.second,it.first});
	sort(all(a));
	sort(all(b));
	rep(i,a.size())a[i].first*=-1;
	rep(i,b.size())b[i].first*=-1;
	int out=inf;
	rep(i,min(2,(int)a.size())){
		rep(j,min(2,(int)b.size())){
			int co=0;
			if(a[i].second!=b[j].second){
				co+=((n+1)/2)-a[i].first;
				co+=((n)/2)-b[j].first;
			}else{
				co=n-max(a[i].first,b[j].first);
			}
			out=min(out,co);
		}
	}
	
	cout<<out<<endl;
}









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

int main(){
    int H ;
    int W;
    int h;
    int w;
    cin >> H >> W;
    cin >> h >> w;
    int a;
    int b;
    a = H - h;
    b = W - w;
    int c;
    c = a * b;
    cout << c;}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	ans := a + b
	if ans < a - b {
		ans = a - b
	}
	if ans < a * b {
		ans = a * b
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>

int check_intersection(const double xa, const double ya, const double ra,
                            const double xb, const double yb, const double rb)
{
    double distance = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
    if(distance < (ra - rb) * (ra - rb)){
        if(ra > rb)
            return 2;
        else
            return -2;
    }
    else if(distance > (ra + rb) * (ra + rb))
        return 0;
    else return 1;
}

int main ()
{
    double xa, ya, ra, xb, yb, rb;
    u_int N;
    
    std::cin >> N;
    for(u_int i = 0; i < N; ++i){
        std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
        std::cout << check_intersection(xa, ya, ra, xb, yb, rb) << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

template <class T>
vector<T> make_v(size_t size, const T &init) {
    return vector<T>(size, init);
}
template <class... Ts>
auto make_v(size_t size, Ts... rest) {
    return vector<decltype(make_v(rest...))>(size, make_v(rest...));
}

int main() {
    int n, k, s;
    while (cin >> n >> k >> s, n) {
        auto dp = make_v(n + 1, k + 1, s + 1, 0);
        dp[0][0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= k; j++) for (int k = 0; k <= s; k++) {
                if (j && k - i >= 0) dp[i][j][k] += dp[i - 1][j - 1][k - i];
                dp[i][j][k] += dp[i - 1][j][k];
            }
        }
        cout << dp[n][k][s] << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "RRR")
        cout << 3;
    else if (s == "SRR" || s == "RRS")
        cout << 2;
    else if (s == "SSS")
        cout << 0;
    else
        cout << 1;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end



int main(){
    int n,k; scanf("%d%d",&n,&k);
    ll a[200010],ans=0;
    rep(i,0,n){
        scanf("%lld",&a[i]); a[i]--;
    }
    rep(i,0,n-1)a[i+1]+=a[i];
    rep(i,0,n)a[i]%=k;
    map<int,vector<int>> val;
    rep(i,0,n)val[a[i]].push_back(i);
    val[0].push_back(-1);
    for(auto p:val){
        vector<int> b=p.second;
        sort(ALL(b));
        rep(i,0,b.size()){
            int idx=lower_bound(ALL(b),b[i]+k)-b.begin();
            idx--; ans+=idx-i;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <fstream>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
    long long N;
    cin >> N;
    int counter = 1;
    long long sum = 0;
    long long division = 2;
    
    if(N%2 == 1) cout << 0 << endl;
    else{
        while(counter <= 25){
            division *= 5;
            sum += N/division;
            counter++;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
while 1:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    S = []
    for i in range(N):
        S.append(list(map(int, input().split())))
    S.sort(key=lambda x:x[1], reverse=True)
    ans = 0
    for d in S:
        if M >= d[0]:
            M -= d[0]
        else:
            d[0] -= M
            M = 0
            ans += d[0] * d[1]
    print(ans)
 


Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,res=0;
char x;
scanf("%d %c %d",&a,&x,&b);
if(x=='+'){
res=a+b;
printf("%d",res);
}
if(x=='-'){
res=a-b;
printf("%d",res);
}


}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int i,a[4],b[4],a_total=0,b_total=0,put;
	for(i=0;i<4;i++)
	{
		scanf("%d",&a[i]);
		a_total+=a[i];
	}
	for(i=0;i<4;i++)
	{
		scanf("%d",&b[i]);
		b_total+=b[i];
	}
	put=a_total<b_total?b_total:a_total;
	printf("%d\n",put);
	//Sleep(1000);
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

struct Bipartite_Graph : UnionFind {
  vector< int > color;

  Bipartite_Graph(int v) : color(v + v, -1), UnionFind(v + v) {}

  bool bipartite_graph_coloring() {
    for(int i = 0; i < color.size() / 2; i++) {
      int a = find(i);
      int b = find(i + (int) color.size() / 2);
      if(a == b) return (false);
      if(color[a] < 0) color[a] = 0, color[b] = 1;
    }
    return (true);
  }

  bool operator[](int k) {
    return (bool(color[find(k)]));
  }
};


int main() {
  int N;
  cin >> N;
  Bipartite_Graph uf(N);
  for(int i = 1; i < N; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    if(w & 1) {
      uf.unite(u, N + v);
      uf.unite(v, N + u);
    } else {
      uf.unite(u, v);
      uf.unite(u + N, v + N);
    }
  }
  uf.bipartite_graph_coloring();
  for(int i = 0; i < N; i++) {
    cout << uf[i] << endl;
  }
}





Measured memory_bytes: 2048
// https://atcoder.jp/contests/abc087/tasks/arc090_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int INF = 1e9;

template <typename T> struct WeightedUnionFind {
    vector<int> data;
    vector<T> ws;

    WeightedUnionFind() {}

    WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}

    int find(int k) {
        if (data[k] < 0)
            return k;
        auto par = find(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }

    T weight(int t) {
        find(t);
        return ws[t];
    }

    bool unite(int x, int y, T w) {
        w += weight(x);
        w -= weight(y);
        x = find(x), y = find(y);
        if (x == y)
            return false;
        if (data[x] > data[y]) {
            swap(x, y);
            w *= -1;
        }
        data[x] += data[y];
        data[y] = x;
        ws[y] = w;
        return true;
    }

    T diff(int x, int y) { return weight(y) - weight(x); }
};

struct edge {
    int to, cost;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    WeightedUnionFind<int> T(n);
    while (m--) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        --r;
        if (!T.unite(l, r, d)) {
            if (T.diff(l, r) != d) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

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

typedef long long ll;

// vector<string> s = {"y", "x"};
// vector<string> t = {"a", "x", "y"};

// string s = "yx";
// string t = "axy";
string s, t;

int main() {
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    // int diff = t.size() - s.size(); 
    // if (diff > 0) {
    //     string a(diff, '0');
    //     s += a; 
    // }
    int loop_size = min(s.size(), t.size());

    // cout << s << endl;
    // cout << t << endl;

    string ans = "No";
    int cnt = 0;
    for (int i = 0; i < loop_size; i++) {
        // cout << s[i] << endl;
        // cout << t[i] << endl;
        if (s[i] < t[i]) {
            ans = "Yes";
            break;
        } else if (s[i] == t[i]) {
            cnt++;
        }
    }

    if (cnt == loop_size && s.size() < t.size()) {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;


int main(){
  ll k;
  cin >> k;
  cout << 50 << endl;
  REP(i, k % 50){
    cout << k / 50 + 49 - k%50 + 51 << " ";
  }
  REP(i, 50 - k % 50){
    cout << k / 50 + 49 - k%50 << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(0);

	int n; cin >> n; 
	vector<vector<pair<int,int>>> g(n);
	for(int i=0; i<n-1; ++i){
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		w %= 2;
		g[u].push_back(make_pair(v,w));
		g[v].push_back(make_pair(u,w));
	}

	vector<int> dst(n,0);
	vector<int> visit(n,0);
	stack<int> st;
	visit[0]=1;
	st.push(0);
	while(!st.empty()){
		int z=st.top();
		st.pop();

		for(auto i : g[z]){
			if(!visit[i.first]){
				visit[i.first]=1;
				dst[i.first]=i.second+dst[z];
				st.push(i.first);
			}
		}
	}

	for(int i : dst) cout << i%2 << endl;
}

Measured memory_bytes: 7168
#include <stdio.h>
#include <string.h>

#define M 1046527
#define L 14

char H[M][L];

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+(key%(M-1));
}

int getChar(char ch){
    if(ch=='A'){
        return 1;
    }
    else if(ch=='C'){
        return 2;
    }
    else if(ch=='G'){
        return 3;
    }
    else if(ch=='T'){
        return 4;
    }
    else{
        return 0;
    }
}

long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int find(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0){
            return 1;
        }
        else if(strlen(H[h])==0){
            return 0;
        }
    }
}

int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0){
            return 1;
        }
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}



int main(){
    int n;
    char str[L],com[9];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",com,str);
        if(com[0]=='i'){
            insert(str);
        }else{
            if(find(str)==1){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


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

int N,Q;
char s[1000000];
char t[1000000];
char d[1000000];
int main(void){
  cin>>N>>Q>>s;

  for(int i=0;i<Q;i++){
    cin>>t[i]>>d[i];
  }

  int lcnt=0, rcnt=0;
  for(int i=Q-1;i>=0;i--){
    if(s[lcnt]==t[i] && d[i]=='L') lcnt++;
    if(lcnt>0) if(s[lcnt-1]==t[i] && d[i]=='R') lcnt--;
    if(s[N-1-rcnt]==t[i] && d[i]=='R') rcnt++;
    if(rcnt>0) if(s[N-rcnt]==t[i] && d[i]=='L') rcnt--;
  }
  cout<<N-lcnt-rcnt<<endl;

  return 0;
}


Measured memory_bytes: 896
#include <iostream>

int main(void){
    int w,h,x,y,r;
    std::cin >> w >> h >> x >> y >> r;
    int x0,x1,y0,y1;
    x0=r, x1=w-r, y0=r, y1=h-r;
    if(x0 <= x && x <= x1 && y0 <= y && y <= y1){
        std::cout << "Yes" << std::endl; 
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

long long myPow(long long x, long long n, long long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
    ll n;
    cin >> n;
    ll al = 1;
    rep(i, n){
        al *= 10;
        al %= mod;
    }
    ll zenbu = 1;
    rep(i, n){
        zenbu *= 9;
        zenbu %= mod;
    }
    zenbu *= 2;
    zenbu %= mod;
    ll tmp = 1;
    rep(i, n){
        tmp *= 8;
        tmp %= mod;
    }
    zenbu = (zenbu+mod-tmp) % mod;
    al = (al+mod-zenbu) % mod;
    cout << al << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define sz(x) (int)((x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << "$ " << #x << " => " << x << endl
using namespace std;
typedef long long ll;

#define pb push_back
typedef vector<int> vi;
typedef vector<int>::iterator it_vi;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;


///----------------------------------------------
ll gcd(ll a,ll b) {
    ll ret=(a/b)*b*2;
    if (a%b==0) return ret-b;
        else return ret+gcd(b,a%b);
}
int main() {

    //freopen ( "xx.in"  , "r" , stdin  );

    ll n,x; cin>>n>>x;
    cout << n+gcd(max(n-x,x),min(n-x,x));



}













Measured memory_bytes: 256
from math import factorial as step
n,m=map(int,input().split())

def combination(n,r):
  if n < 0 or r < 0 or n-r<0:
    return 0
  return step(n) // (step(r) * step(n-r))

res = combination(n,2) + combination(m,2)
print(res)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 50
//---------------------

ll n,x[MAXN],y[MAXN];
ll curx,cury,ret;
ll dp[MAXN];
set<pii> points;
int main(){
	cin>>n;
	if(n==1){cout<<1<<endl;return 0;}
	REP(i,n)
	{
		cin>>x[i]>>y[i];
		points.insert(pii(x[i],y[i]));
	}
	ret=50;
	REP(i,n){
		REP(j,n){
			if(i==j){continue;}
			curx=x[i]-x[j];
			cury=y[i]-y[j];
			ll cost=n;
			REP(k,n){
				if(points.find(pii(x[k]+curx,y[k]+cury))!=points.end()){
					cost--;
				}
			}
			ret=min(ret,cost);
		}
	}
	cout<<ret<<endl;
	return 0;
}

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

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

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

const ll INF = 1LL << 60;

//input
int N;

//dpTable

int main(){
    cin >> N;
    int A = N % 10;
    if (A == 2 || A == 4 || A == 5 || A == 7 || A == 9) cout << "hon" << endl;
    else if (A == 0 || A == 1 || A == 6 || A == 8) cout << "pon" << endl;
    else if (A == 3) cout << "bon" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int64_t> p(A);
    vector<int64_t> q(B);
    vector<int64_t> r(C);
    for (int i = 0; i < A; i++)
        cin >> p.at(i);
    for (int i = 0; i < B; i++)
        cin >> q.at(i);
    for (int i = 0; i < C; i++)
        cin >> r.at(i);
    sort(p.begin(), p.end(), greater<int64_t>());
    sort(q.begin(), q.end(), greater<int64_t>());
    sort(r.begin(), r.end(), greater<int64_t>());
    
    vector<int64_t> s(X + Y);
    
    for (int i = 0; i < X; i++)
        s.at(i) = p.at(i);
    for (int i = 0; i < Y; i++)
        s.at(X + i) = q.at(i);
    sort(s.begin(), s.end(), greater<int64_t>());
    
    for (int i = 0; i < C; i++){
        if (s.at(X + Y - 1 - i) < r.at(i))
            s.at(X + Y - 1- i) = r.at(i);
        else
            break;
    }
    
    int64_t max = 0;
    for (int i = 0; i < X + Y; i++)
        max += s.at(i);
    cout << max << endl;
}


Measured memory_bytes: 3968
n = int(input())

num = n - 2

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

a = sorted(a, reverse=True)

ans = a[0]
t = 1
while num > 0:
    if num >=2 :
        ans += a[t]*2
        t +=1
        num -= 2
    else :
        ans += a[t]
        num -=1

print(ans)

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

int main() {
  
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string A;
    cin >> A;      
    cout << "#" << A << "#" << endl;
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(N);
  intmax_t sum=0;
  for (size_t i=0; i<N; ++i) {
    scanf("%jd", &a[i]);
    sum += a[i];
  }

  intmax_t x=a[0], y=sum-a[0];
  intmax_t res=std::abs(x-y);
  for (size_t i=1; i+1<N; ++i) {
    x += a[i];
    y -= a[i];
    res = std::min(res, std::abs(x-y));
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<utility>
#include<stack>
#include<cstring>
using namespace std;

int main(){
    unsigned N;
    scanf("%u", &N);
    vector<pair<unsigned, bool> > adj[N];
    for (size_t i = 1; i < N; i++){
        unsigned u, v, w;
        scanf("%u %u %u", &u, &v, &w);
        u--;v--;
        bool tmp = w&1;
        adj[u].push_back(make_pair(v, tmp));
        adj[v].push_back(make_pair(u, tmp));
    }
    int color[N];
    memset(color, -1, sizeof color);
	stack<unsigned> S;
	S.push(0);
	color[0] = 0;
	while(!S.empty()){
		unsigned u = S.top(); S.pop();
		for (unsigned i = 0; i < adj[u].size(); ++i){
			int v = adj[u][i].first;
			if(color[v] < 0){
				color[v] = color[u] ^ adj[u][i].second;
				S.push(v);
			}
		}
	}
    for (size_t i = 0; i < N; i++){
        printf("%d\n", color[i]);
    }
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b = 0, D, h, n, w, ans = 0, count = 0;
  string t;

  cin >> D;
  vlli c(26), r(26), f(26, 0);
  // vvli s(D, vlli(26));
  set<lli> g;

  rep(i, 0, 26)
  {
    cin >> c[i];
  }
  rep(i, 0, D)
  {
    b++;
    w = 0;
    ans = 0;
    count = 0;
    vector<pair<lli, lli>> pr;
    repe(j, 1, 26)
    {
      cin >> a;
      // cout << "w: " << j << " " << w << endl;
      if (g.count(j))
      {
        w = f[j - 1];
        count = c[j - 1] * (b - w);
      }
      else
      {
        count = c[j - 1] * (b - 0);
      }
      a -= count;
      // cout << "a: " << a << " j:" << j << " count: " << count << endl;
      pr.eb(make_pair(-a, j));
    }
    SORT(pr);
    ans = pr[0].first;
    // cout << "ans: " << ans << endl;
    for (auto x : pr)
    {
      if (x.first == ans)
      {
        cout << x.second << endl;
        g.insert(x.second);
        f[x.second - 1] = b;
        break;
      }
    }
  }
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int x = 1; x < N - x; x++) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();
		if ((b - a) % 2l == 0) {
			System.out.println((b - a) / 2l);
		} else {
			System.out.println(Math.min(((b - a) + 2l * (n - b) + 1l) / 2l, ((b - a) + 2l * (a - 1l) + 1l) / 2l));
		}
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static long arrayMax(long[] array) {
		long ans = Long.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}

	public static String[] arrayString(Scanner sc, int n) {
		String[] array = new String[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.next();
		}
		return array;
	}

	static String nextPermutation(String s) {

		ArrayList<Character> list = new ArrayList<>();
		for (int i = 0; i < s.length(); i++)
			list.add(s.charAt(i));

		int pivotPos = -1;
		char pivot = 0;
		for (int i = list.size() - 2; i >= 0; i--) {
			if (list.get(i) < list.get(i + 1)) {
				pivotPos = i;
				pivot = list.get(i);
				break;
			}
		}

		if (pivotPos == -1 && pivot == 0)
			return "Final";

		int L = pivotPos + 1, R = list.size() - 1;
		int minPos = -1;
		char min = Character.MAX_VALUE;
		for (int i = R; i >= L; i--) {
			if (pivot < list.get(i)) {
				if (list.get(i) < min) {
					min = list.get(i);
					minPos = i;
				}
			}
		}

		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R + 1));

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < list.size(); i++)
			sb.append(list.get(i));

		return sb.toString();
	}
}


Measured memory_bytes: 21844
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

from functools import lru_cache

n = ni()
mod = 10**9+7

@lru_cache(maxsize=10000)
def dfs(n, l):
    rt = 0
    if n == 0:
        return 1
    if l[1:3] == 'AG' or l[1:3] == 'GA' or (l[0] == 'A' and l[2] == 'G') or l[:2] == 'AG':
        pass
    else:
        rt += dfs(n-1, l[1:]+'C')
    if l[1:] != 'AC':
        rt += dfs(n-1,l[1:]+'G')
    rt += dfs(n-1,l[1:]+'T')
    rt += dfs(n-1,l[1:]+'A')
    return rt%mod

print(dfs(n,'TTT')%mod)

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

int main() {
  int X, A, B, day;
  cin >> X >> A >> B;
  day = A-B;
  
  if (day >= 0) cout << "delicious" << endl;
  else if (day + X >= 0) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import numpy as np
n, x = map(int, input().split())
pos = [int(i) for i in input().split()]
pos.append(x)
pos = np.array(pos)
pos = pos - x
diff = np.abs(np.diff(pos))

def gcd(number):
    import fractions
    from functools import reduce
    return reduce(fractions.gcd, number)

print(gcd(diff))

Measured memory_bytes: 23076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();//南北方向にまっすぐに伸びる 道路
		int H = sc.nextInt();//東西方向にまっすぐに伸びる 道路
		int N = sc.nextInt();//観光スポットの数
		int i;
		int j = 0;
		int x[] = new int[N];
		int y[] = new int[N];
		int c = 0;
		
		for(i = 0; i < N; i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		
		
		
		while(true){//斜め移動上
			if(x[N-2] == x[N-1] && y[N-2] == y[N-1])break;
			if(x[j] < x[j+1] && y[j] < y[j+1]){
				x[j]++;
				y[j]++;
				c++;
			}
			
			else if(x[j] > x[j+1] && y[j] > y[j+1]){//斜め移動下
				x[j]--;
				y[j]--;
				c++;
			}
				
			else if(x[j] < x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が左側でy軸は等しい
				x[j]++;
				c++;
			}
				
			else if(x[j] == x[j+1] && y[j] < y[j+1]){//目的地よりも現在地が下側でx軸は等しい
				y[j]++;
				c++;
			}
				
			else if(x[j] > x[j+1] && y[j] == y[j+1]){//目的地よりも現在地が右側でy軸は等しい
				x[j]--;
				c++;
			}
				
			else if(x[j] == x[j+1] && y[j] > y[j+1]){//目的地よりも現在地が上側でx軸は等しい
				y[j]--;
				c++;
			}
				
			else if(x[j] > x[j+1] && y[j] < y[j+1]){
				x[j]--;
				y[j]++;
				c+=2;
			}
				
			else if(x[j] < x[j+1] && y[j] > y[j+1]){
				x[j]++;
				y[j]--;
				c+=2;
			}
				
			if(x[j] == x[j+1] && y[j] == y[j+1]){
				j++;
			}
			

		}

		System.out.println(c);
		
		
		
	}

}

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

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

    int C[N] = {};
    int V[N] = {};
    long long result = 0;
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
        int tmp = V[i] - C[i];
        if(tmp > 0){
            result += tmp;
        }
    }
    cout << result;


	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Control.Monad
import Data.List
import Debug.Trace

solve :: [Int] -> (Int, Int)
solve arr = (minC, maxC)
    where
        (colored, freeChoice) = partition (< 3200) arr
        colorCount = length $ nub $ map (`div` 400) colored
        freeCount = length freeChoice
        minC = max colorCount 1
        maxC = colorCount + freeCount

main :: IO ()
main = do
    _ <- BS.getLine
    arr <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    let (minC, maxC) = solve arr
    putStrLn $ (show minC) ++ " " ++ (show maxC)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  if (A+K-1<B-K+1){
    for (int i=0;i<K;i++){
      cout << A+i << endl;
    }
    for (int i=0;i<K;i++){
      cout << B-K+1+i << endl;
    }
  }
  else {
    for (int i=0;i<B-A+1;i++){
      cout << A+i << endl;
    }
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - Maximum Difference


"""
import sys
from sys import stdin
input = stdin.readline


def solve(arr):
    return max(arr) - min(arr)


def main(arg):
    N = int(input())
    arr = [int(a) for a in input().split()]
    ans = solve(arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3060