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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


int solve(int N, vi& a) {
    int cnt = 1;
    int hst = a[0];
    for (int i=1; i<N; ++i){
        if (hst <= a[i]) ++cnt;
        amax(hst, a[i]);
    }
    return cnt;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


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

using namespace std;

int main()
{
   int a,b,k;
   cin >> a >> b >>k;
   
   for (int i=1;i<=k;i++)
   {
       if(i%2==1)
       {
           if(a%2==1)
           {
               a-=1;
               a=a/2;
               b=b+a;
               
           }
           else
           {
               a=a/2;
               b=b+a;
           }
       }
       else
       {
           if(b%2==1)
           {
               b-=1;
               b=b/2;
               a=a+b;
               
           }
           else
           {
               b=b/2;
               a=a+b;
           }
       }
       
       
   }
   
   
   
             cout << a <<" " << b  <<endl; 
   
   
   
   return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    n = int(input())
    if n == 0:
        break
    else:
        aa = inpl()
        aa.sort()
        ans = INF
        for i in range(1,n):
            ans = min(aa[i] - aa[i-1],ans)
        print(ans)



Measured memory_bytes: 7524
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
LL dp[2001][2001];
int main(void){
	int n;
	int cut[2001];
	int i,j;
	int l,r;
	int ll,rr;
	int k;
	cin>>n;
	for(i=0;i<n;i++)	cin>>cut[i];		
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			dp[i][j]=-1;
			if(i==j)	dp[i][j]=cut[i];
		}
	}
	// for(int a=0;a<n;a++){
		// for(int b=0;b<n;b++){
			// cout<<dp[a][b]<<" ";
		// }
		// cout<<endl;
	// }
	// cout<<endl;
	bool flg=false;
	j=0;
	while(1){
		// cout<<"J="<<j<<endl;
		for(i=0;i<n;i++){
			k=i+j;
			if(i+j>n-1)	k=((-1)+(i+j)-(n-1));
			if((abs(i-k)==1)||(i==0&&j==n-1)||(i==0&&j==n)){
				flg=true;
				break;
			}
			if((i-k!=1)||(i!=0&&j!=n-1)||(i!=n-1&&j!=0)){
				if(dp[i][k]!=-1){
					l=i-1;
					if(l<0)		l=n-1;
					r=k+1;
					if(r>n-1)	r=0;
					// cout<<cut[l]<<"  "<<cut[r]<<endl;
					//for(int x=0;x<=100000000;x++)
					if(cut[l]>cut[r]){
						ll=l-1;
						if(ll<0)	ll=n-1;
						dp[ll][k]=max(dp[ll][k],dp[i][k]+cut[ll]);
						dp[l][r]=max(dp[l][r],dp[i][k]+cut[r]);
					}
					if(cut[l]<cut[r]){
						rr=r+1;
						if(rr>n-1)	rr=0;
						dp[i][rr]=max(dp[i][rr],dp[i][k]+cut[rr]);
						dp[l][r]=max(dp[l][r],dp[i][k]+cut[l]);
					}
				}
			}
			// for(int a=0;a<n;a++){
				// for(int b=0;b<n;b++){
					// cout<<dp[a][b]<<" ";
				// }
				// cout<<endl;
			// }
			// cout<<endl;
		}
		if(flg)	break;
		
		j+=2;
	}
	
	// for(i=0;i<n;i++){
		// for(j=0;j<n;j++){
			// if(dp[i][j]==114055)	cout<<"OK"<<endl;
			// cout<<dp[i][j]<<" ";
		// }
		// cout<<endl;
	// }
	// cout<<endl;
	
	LL MAX=-1;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			MAX=max(MAX,dp[i][j]);
		}
	}
	cout<<MAX<<endl;
	return 0;
}


Measured memory_bytes: 34392
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    // input
    ll X;
    cin >> X;

    // process
    if (X == 2) {
        cout << X << endl;
    } else {
        if (X % 2 == 0) {
            X++;
        }
        for (ll i = X; i <= 110000; i += 2) {
            ll k = 0;
            for (ll j = 3; j <= sqrt(i); j += 2) {
                if (i % j == 0) {
                    k = 1;
                    break;
                }
            }
            if (k == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }

}

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

using namespace std;
/*******************************************
****************** BY **********************
******* FUTURE GOOGLE EMPLOYEE *************
****** KARTHICK KUPPURAJ M *****************
********************************************/
#define ms(s, n) memset(s, n, sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define prec(n) fixed<<setprecision(n)
#define sll(x) scanf("%lld",&x);
#define pll(x) printf("%lld",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int ll;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;

int add(int x, int y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}

int mult(int x, int y) {
    return ((ll) x * y) % MOD;
}

int bin_pow(int x, int p) {
    if (p == 0) return 1;
    if (p == 2 || (p & 1)) return mult(x, bin_pow(x, p - 1));
    return bin_pow(bin_pow(x, p / 2), 2);
}

int rev(int x) {
    return bin_pow(x, MOD - 2);
}

const int N = 200100;
const int K = 4010;
const int Z = 2002;
int n;
int a[N][2];
int C[K][K];
ll b[K];
int f[2 * K], rf[2 * K];
int ans = 0;

void init() {
    f[0] = 1;
    for (int i = 1; i < 2 * K; i++)
        f[i] = mult(f[i - 1], i);
    rf[2 * K - 1] = rev(f[2 * K - 1]);
    for (int i = 2 * K - 1; i > 0; i--)
    {
        rf[i - 1] = mult(rf[i], i);
    }


    for (int i = 0; i < K; i++)
    {
        C[i][0] = C[i][i] = 1;
    }
    for (int i = 1; i < K; i++)
    {
        for (int j = 1; j < i; j++)
        {
            C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
        }
    }

    return;
}

void solve(int x, int y) {

    for (int i = -x; i <= y; i++)
    {
        b[Z - i] += C[x + y][x + i];
    }

    return;
}

int getC(int n, int k) {
    return mult(f[n], mult(rf[k], rf[n - k]));
}

int main() {

    init();

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

    for (int i = 0; i < n; i++)
    {
        solve(a[i][0], a[i][1]);
    }

    for (int i = -Z; i <= Z; i++)
    {
        b[Z + i] %= MOD;
    }

    for (int i = -Z; i <= Z; i++)
    {
        ans = add(ans, mult(b[Z + i], b[Z - i]));
    }

    for (int i = 0; i < n; i++)
    {
        ans = sub(ans, getC(2 * (a[i][0] + a[i][1]), 2 * a[i][0]));
    }

    if (ans & 1) ans += MOD;
    ans /= 2;

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 63232
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC  -B Half and Half

int main(void) {
	int     a, b,c, x, y;

	scanf("%d %d %d %d %d", &a,&b,&c,&x,&y);

	long cx = 2 * c * x,
	 	cy = 2 * c * y,
		ab = a * x + b * y;

    //if (a * x > cx && b * y > cy) {
	//	printf("%ld\n",2 * (long)c * (long)((x < y) ? y : x));
	//	return 0;
	//}
	long abc = 2 * c * (long)((x < y) ? y : x);
	long ac  = 2 * c * x +  b * ((y - x < 0) ? 0 : y - x);
	long bc  = 2  *c * y +  a* ((x - y < 0) ? 0 : x - y);
	//printf("%ld %ld %ld", ab,ac, bc);
	long    ans;

	ans = _min(ab, _min(ac, _min(abc,bc)));

	printf("\n%ld\n", ans);
	return 0;
}


Measured memory_bytes: 2084
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int m = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        String s;
        String ans[] = new String[2];
        int i,j;
      	for(i = 2;i <= m;i++){
          for(j = 22;j <= d;j++){
            s = String.valueOf(j);
            ans = s.split("");
            if(i == Integer.parseInt(ans[0]) * Integer.parseInt(ans[1])
              && Integer.parseInt(ans[0]) >= 2 && Integer.parseInt(ans[1]) >= 2){
             count += 1; 
            }
          }
        }
         System.out.println(count);
    }
}

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

int main()
{	
	int n, m;
	std::cin >> n;
	int* A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	std::cin >> m;
	int* B = new int[m];
	for (int i=0; i<m; i++) std::cin >> B[i];
	
	int* C = new int[n+m];
	for (int i=0; i<n+m; i++) C[i] = -1;
	std::set_union(A, A+n, B, B+m, C);
	
	for (int i=0; i<n+m; i++) {
		if (C[i] < 0) break;
		std::cout << C[i] << std::endl;
	}
	
	delete[] A;
	delete[] B;
	delete[] C;
	
	return 0;
}



Measured memory_bytes: 5972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc064_b
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 13396
s=input()
a=int(s[:2])
b=int(s[2:])
if(1<=a<=12):
    if(1<=b<=12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif(1<=b<=12):
    print('YYMM')    
else:
    print('NA')


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

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

P GetPair(int n)
{
    //下一桁
    int l = n%10;
    P ret = P(l,0);
    while(n)
    {
        ret.second = n;
        n /= 10;
    }
    return ret;
}

int main(void) 
{
    int n;
    cin >> n;
    map<P,int> m;
    int ans =0;
    rep(i,n){
        //ペアの数をカウントする
        P pair = GetPair(i+1);
        m[pair]++;
    }
    rep(i,n){
      
        P a = GetPair(i+1);
        //入れ替えたものをb
        P b = P(a.second,a.first);
        ans += m[b];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

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

#define TR(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define IN(c, x) ((c).find(x) != (c).end())   //O(log n)
#define IN_L(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define FOR(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define MOD(x, m) ((((x) % (m)) + (m)) % (m))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define READ ({int t;cin >> t;t;})
#define EB emplace_back
#define fcout cout << fixed << setprecision(12)
#define fcerr cerr << fixed << setprecision(12)
#define print(x) cout << (x) << endl

#ifdef DEBUG
#define ERR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); _err(cerr,_it, args); }
#define DBG(x) cerr << #x << " is " << x << endl;
#else
#define DBG(x) {};
#define ERR(args...) {};
#endif
void _err(std::ostream& cerr,istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void _err(std::ostream& cerr, istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    _err(cerr,++it, args...);
}

const double pi = 2 * acos(.0);
const int inf = 0x3f3f3f3f;
const ll mod = (ll) (1e9) + 7;
//const ll mod = (ll) 998244353 ;
const double eps = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const deque<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template<class T>bool Chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool Chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//#define int ll

class AX {
public:

void solve(std::istream& cin, std::ostream& cout, std::ostream& cerr) {
    int a,b;
    cin >> a >> b;
    cout << max({a+b, a-b,a*b}) << endl;
}


};


#undef int
int main() {

	AX solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
    std::ostringstream err;
	in.tie(0); ios::sync_with_stdio(0);
//	solver.solve(in, out);
    solver.solve(in, out,err);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	string S; cin >> S;

	ll ans = 0;
	ll ma = 0;

	FOR(i, 0, sz(S)) {
		if (
				S[i] == 'A' ||
				S[i] == 'C' ||
				S[i] == 'G' ||
				S[i] == 'T') {
			ma ++;
		} else {
			ma = 0;
		}
		ans = max(ma, ans);
	}
	cout << ans << endl;
} //cin.tie(0) bei schnellem Wechseln


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

int main(void){
  
  int N ,i;
  cin >> N;
  int a[N];
  int b[N];
  int c = 0;
  for(i = 0 ; i < N ; i++){
    cin >> a[i];
    b[i] = a[i];
  }
    
  sort(a,a + N);

  for(i=0;i<N;i++){
    if(c == 3){
      cout << "NO" << endl;
      break;
    }
    if(a[i] != b[i])
      c ++;
    
    
  }

  if(c <= 2)
    cout << "YES" << endl;
  
  
return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>

template <class Value> class SegmentTree {
public:
  using value_type = Value;
  using operator_type = std::function<Value(Value, Value)>;

private:
  int n;
  std::vector<value_type> data;
  std::vector<int> lidx;
  std::vector<int> ridx;
  const operator_type op;
  const value_type id;

public:
  SegmentTree(const operator_type op, const value_type id,
              const std::vector<value_type> &a)
      : op(op), id(id) {
    n = 1;
    while (n < a.size())
      n *= 2;
    data.assign(2 * n - 1, id);
    lidx.assign(2 * n - 1, -1);
    ridx.assign(2 * n - 1, -1);
    for (int i = 0; i < n; ++i) {
      if (i < a.size())
        data[i + n - 1] = a[i];
      lidx[i + n - 1] = i;
      ridx[i + n - 1] = i + 1;
    }
    build();
  }

  void build() {
    for (int i = n - 2; i >= 0; --i) {
      data[i] = op(data[2 * i + 1], data[2 * i + 2]);
      lidx[i] = lidx[2 * i + 1];
      ridx[i] = ridx[2 * i + 2];
    }
  }

  void set(int i, const value_type &x) {
    i += n - 1;
    data[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = op(data[2 * i + 1], data[2 * i + 2]);
    }
  }

  value_type get(int l, int r) { return _get(l, r, 0); }

private:
  value_type _get(int l, int r, int k) {
    if (ridx[k] <= l || r <= lidx[k])
      return id;
    if (l <= lidx[k] && ridx[k] <= r)
      return data[k];
    value_type res1 = _get(l, r, 2 * k + 1);
    value_type res2 = _get(l, r, 2 * k + 2);
    return op(res1, res2);
  }
};

int main() {
  int n, q;
  std::cin >> n >> q;
  long long inf = (1LL << 31) - 1;
  std::vector<long long> a(n, inf);

  SegmentTree<long long> seg(
      [](long long a, long long b) { return std::min(a, b); }, inf, a);
  for (int i = 0; i < q; ++i) {
    int c, x, y;
    std::cin >> c >> x >> y;
    if (c == 0)
      seg.set(x, y);
    else
      std::cout << seg.get(x, y + 1) << std::endl;
  }
}



Measured memory_bytes: 7768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXNUM 1000000
int main(void){
	int flag[MAXNUM + 1];
	int judge[MAXNUM + 1], food[30], i, j, n, x;
	for(i = 2;i <= MAXNUM;i++)
		flag[i] = 1;
	flag[0] = flag[1] = 0;
	for(i = 2;i <= sqrt(MAXNUM);i++){
		for(j = 2 * i;j <= MAXNUM && flag[i] != 0;j += i)
			flag[j] = 0;
	}
	scanf("%d %d",&n,&x);
	while(n != 0 && x != 0){
		for(i = 0;i < n;i++)
			scanf("%d",&food[i]);
		for(i = 0;i <= x;i++)
			judge[i] = 0;
		judge[0] = 1;
		for(i = 0;i <= x;i++){
			if(judge[i] == 1){
				for(j = 0;j < n;j++){
					if(i + food[j] <= x)
						judge[i + food[j]] = 1;
				}
			}
		}
		for(i = x;i >= 0;i--){
			if(flag[i] == 1 && judge[i] == 1){
				printf("%d\n",i);
				break;
			}
		}
		if(i == -1)
			printf("NA\n");
		scanf("%d %d",&n,&x);
	}
		return 0;
}

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

int main() {
	int dice[6];
	for (int i = 0;i < 6;++i) {
		cin >> dice[i];
	}
	int n;
	cin >> n;
	while (n--) {
		int top,front;
		cin >> top >> front;
		// check top
		if (top == dice[0] || top == dice[2] || top == dice[3] || top == dice[5]) {
			// roll the dice in the direction of east till "top == dice[0]"
			while (top != dice[0]) {
				int temp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = temp;
			}
		} else {
			// roll the dice in the direction of north till "top == dice[0]"
			while (top != dice[0]) {
				int temp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}
		}
		// rotate the dice till "front == dice[1]"
		while (front != dice[1]) {
			int temp = dice[1];
			dice[1] = dice[2];
			dice[2] = dice[4];
			dice[4] = dice[3];
			dice[3] = temp;
		}
		cout << dice[2] << endl;
	}
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
int h,w,c[26];
char a;
signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>a;
			c[a-'a']++;
		}
	}
	multiset<int> mt;
	if(h%2&&w%2){
		rep(i,h/2){
			rep(j,w/2)mt.insert(4);
		}
		rep(i,h/2){
			mt.insert(2);
		}
		rep(i,w/2){
			mt.insert(2);
		}
		mt.insert(1);
	}
	else if(h%2){
		rep(i,h/2){
			rep(j,w/2)mt.insert(4);
		}
		rep(i,w/2)mt.insert(2);
	}
	else if(w%2){
		rep(i,h/2){
			rep(i,w/2){
				mt.insert(4);
			}
		}
		rep(i,h/2)mt.insert(2);
	}
	else{
		rep(i,h/2){
			rep(j,w/2)mt.insert(4);
		}
	}
	rep(i,26){
		while(c[i]){
			if(c[i]>=4){
				if(mt.find(4)!=mt.end()){
					c[i]-=4;
					mt.erase(mt.find(4));
				}
				else if(mt.find(2)!=mt.end()){
					c[i]-=2;
					mt.erase(mt.find(2));
				}
				else if(mt.find(1)!=mt.end()){
					c[i]--;
					mt.erase(mt.find(1));
				}
				else{
					puts("No");
					return 0;
				}
			}
			else if(c[i]>=2){
				if(mt.find(2)!=mt.end()){
					c[i]-=2;
					mt.erase(mt.find(2));
				}
				else if(mt.find(1)!=mt.end()){
					c[i]--;
					mt.erase(mt.find(1));
				}
				else{
					puts("No");
					return 0;
				}
			}
			else if(c[i]){
				if(mt.find(1)!=mt.end()){
					c[i]--;
					mt.erase(mt.find(1));
				}
				else{
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	ggr;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kamol Paul
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;

class DHandstand2 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long n;
	    in>>n;
	    map< pair < long , long > , long > data;
	    for(int i=1;i<=n;i++){
	        int last=i%10;
	        int first;
	        int x= i;
	        while (x){
	            first = x%10;
	            x/=10;

	        }
	        data[{first,last}]++;
	    }
	    long ans=0;
        for(int i=1;i<=n;i++){
            int last=i%10;
            int first;
            int x= i;
            while (x){
                first = x%10;
                x/=10;

            }
            ans+= data[{last,first}];
        }
        out<<ans<<endl;

	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	DHandstand2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x, y, z;
int main() {
	int i, n;
	cin >> n;
	for (i = 0;i <= n + 1;i++) {
		if (n < i * i) {
			cout << (i-1)*(i-1) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a+b>=a-b&&a+b>=a*b){
    printf("%d",a+b);
  }else if(a-b>=a+b&&a-b>=a*b){
    printf("%d",a-b);
  }else{
    printf("%d",a*b);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

int main(){
	int n, m;
	long long ans=0;
	std::vector<int> aList;
	std::vector<int> deltaList;

	std::cin>>n>>m;

	aList.resize(m);
	deltaList.resize(m-1);

	for(int i=0; i<m; i++)
		std::cin>>aList[i];

	std::sort(aList.begin(), aList.end(), [](int x, int y){return x<y;});

	for(int i=0; i<m-1; i++)
		deltaList[i]= std::abs(aList[i+1]-aList[i]);

	std::sort(deltaList.begin(), deltaList.end(), [](int x, int y){return x<y;});

	for(int i=0; i<m-n; i++)
		ans+= deltaList[i];

	std::cout<< ans<<std::endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String contest = sc.nextLine();

		if (contest.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}

}

Measured memory_bytes: 35760
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N);
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  map<pair<int, int>, int> amap;
  map<int, int> bmap;
  queue<int> que;
  int state;
  que.push(0);
  vector<int> ans, ans1;
  while(!que.empty()) {
    state = que.front();que.pop();
    if(bmap[state]>0) continue;
    ans.push_back(state+1);
    bmap[state]++;
    for(int i=0;i<edge[state].size();++i) {
      if(amap[mp(state, edge[state][i])]>0) continue;
      if(bmap[edge[state][i]]>0) continue;
      que.push(edge[state][i]);
      amap[mp(state, edge[state][i])]++;
      amap[mp(edge[state][i], state)]++;
      break;
    }
  }
  que.push(0);
  bmap[0] = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    if(bmap[state]>0) continue;
    ans1.push_back(state+1);
    bmap[state]++;
    for(int i=0;i<edge[state].size();++i) {
      if(amap[mp(state, edge[state][i])]>0) continue;
      if(bmap[edge[state][i]]>0) continue;
      que.push(edge[state][i]);
      amap[mp(state, edge[state][i])]++;
      amap[mp(edge[state][i], state)]++;
      break;
    }
  }
  cout<<ans.size()+ans1.size()-1<<endl;
  for(int i=ans1.size()-1;i>0;--i) cout<<ans1[i]<<" ";
  for(int i=0;i<ans.size();++i) cout<<ans[i]<<" ";
  cout<<endl;
}



Measured memory_bytes: 26040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int M, a, b, c;
 cin >> M;
  
 c = M % 10;
 b = (M % 100 - c) / 10;
 a = (M - b - c) / 100;
   
 cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
ll dp[1000005][2];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

	string s; cin >> s;
    reverse(all(s));
    s += '0';

    int N = s.size();

    
    rep(i,N+1) rep(j,2) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i,N) rep(j,2) {
        int x = s[i] - '0';
        x += j;
        rep(a,10) {
            int ni = i + 1, nj = 0;
            int b = a - x;
            if(b < 0) {
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
        }
    }
    ll ans = dp[N][0];
    cout << ans << endl;


    
}

Measured memory_bytes: 17052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;

    ll now = 1, ans = 0;
    while(N / now){
        now *= K;
        ++ans;
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=2000+5;
typedef long long ll;
int n,a[N];
int gcd(int x,int y){
    if(!y)
        return x;
    return gcd(y,x%y);
}
int G[N][N];
struct node{
    int u,v,nxt;
}edge[N*2];
int head[N],mcnt;
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
bool vis[N];
int rudu[N];
void dfs(int u){
    vis[u]=1;
    for(int v=1;v<=n;v++){
        if(G[u][v]&&!vis[v]){
            add_edge(u,v);
            rudu[v]++;
            dfs(v);
        }
    }
}
int ans[N];
typedef pair<int,int>pi;
priority_queue<pi>q;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(gcd(a[i],a[j])>1)
                G[i][j]=G[j][i]=1;
    for(int i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(!rudu[i])
            q.push(pi(a[i],i));
    while(!q.empty()){
        int w=q.top().first,u=q.top().second;
        q.pop();
        ans[++cnt]=w;
        for(int i=head[u];i;i=edge[i].nxt){
            int v=edge[i].v;
            rudu[v]--;
            if(!rudu[v])
                q.push(pi(a[v],v));
        }
    }
    for(int i=1;i<=n;i++)
        printf("%d ",ans[i]);
}


Measured memory_bytes: 16128
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000000
int P[MAX],F[MAX]={0},i,j,c,p,m,N,r,t;
int main()
{
	for(i=2,c=0;i<MAX;i++)
		if(!F[i])
		{
			P[c++]=i;
			for(j=i;j<MAX;j+=i)
				F[j]=1;
		}
	for(;scanf("%d",&N),N;)
	{
		for(i=r=0;i<N;i++)
		{
			scanf("%d%d",&p,&m);
			for(j=t=0;j<c&&P[j]<=p+m;j++)
				if(P[j]>=p-m)
					t++;
			r+=t-1;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if(a % 2 == 0) {
            if(a%3 == 0 || a%5==0) continue;
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */


template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */
int n;
int k;
vi arr;
vi dp(100010, -1);

int dfs(int i){

	if(i >= n - 1) return 0;

	if(dp[i] > - 1) return dp[i];

	int ans = inf;
	rep(j,1,k + 1){
		if(i + j >= n) continue;
		chmin(ans, abs(arr[i] - arr[i + j]) + dfs(i + j));
	}

	return dp[i] = ans;


	



}



signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

	cin >> n >> k;
	rep(i,0,n) arr.push_back(input());

	print(dfs(0));




    



	








    



    





    


    

}



Measured memory_bytes: 8180
import itertools
n=int(input())
name=dict()
for c in "MARCH":
    name[c]=0
for i in range(n):
    t=input()
    if t[0] in "MARCH":
        name[t[0]]+=1

ans=0
for hey in itertools.combinations("MARCH",3):
    ans+=name[hey[0]]*name[hey[1]]*name[hey[2]]
print(ans)

Measured memory_bytes: 9144
import java.util.Scanner;

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

        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
        }

        int minDiff = 100000;
        for (int t = 1; t < N; t++) {
            int s1 = 0;
            int s2 = 0;
            for (int g1 = 0; g1 < t; g1++) {
                s1 += w[g1];
            }

            for (int g2 = t; g2 < N; g2++) {
                s2 += w[g2];
            }
            
            minDiff = Math.min(Math.abs(s2 - s1), minDiff);
        }
        
        System.out.println(minDiff);
    }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n,a,b;
    cin>>n>>a>>b;
    vector<int> v(3);

    for (int i=0; i<n; i++) {
	int x;
	cin>>x;
	if (x<=a) {
	    v[0]++;
	} else if (x>=b+1) {
	    v[2]++;
	} else {
	    v[1]++;
	}
    }


    cout<<(*min_element(v.begin(),v.end()))<<endl;    
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;
}


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

int main(void) {
  long long int a, b, c, k, sum1, sum2, sum3;
  long long int big;

  big = (long)pow(10.0,18.0);

  scanf("%d %d %d %d", &a, &b, &c, &k);

  if (((a - b) > big) || ((a - b) < -big)) {
    printf("Unfare\n");
    return 1;
  }else if (((b - a) > big) || ((b - a) < -big)) {
    printf("Unfare\n");
    return 1;
  }

  if (k % 2 == 0) {
    printf("%d\n", a - b);
  }else {
    printf("%d\n", b - a);
  }

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int *pre, *in, *post, pos, target, n;

int Lsearch(int);
void Rec(int, int);

int main(void)
{
  int i;
  scanf("%d", &n);
  pre = (int*)malloc(sizeof(int) * n);
  in = (int*)malloc(sizeof(int) * n);
  post = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &pre[i]);
  for (i = 0; i < n; i++) scanf("%d", &in[i]);
  Rec(0, n - 1);
  for (i = 0; i < n- 1; i++) printf("%d ", post[i]);
  printf("%d\n",post[i]);
  free(pre);
  free(in);
  free(post);
}

int Lsearch(int data)
{
  int i;
  for (i = 0; i < n; i++) {
    if (in[i] == data) return i;
  }
  return n;
}

void Rec(int left, int right)
{
  int root, dis;
  if (left > right) return;
  root = pre[pos++];
  dis = Lsearch(root);
  Rec(left, dis - 1);
  Rec(dis + 1, right);
  post[target++] = root;
}


Measured memory_bytes: 2100
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int N,X;
    cin>>N>>X;
    int T;
    T=0;
    int m,n;
    n=1000;
    for (int i=0; i<N; i++) {
        cin>>m;
        T=T+m;
        if(m<n){
            n=m;
        }
        
    } 
    int ans;
    ans=N+(X-T)/n;
    cout<<ans<<endl;
    
    
    return 0;
    
}

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


int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<int>> A(N, vector<int>(D));
  for(auto& a : A){
    for(auto& x : a){
      cin >> x;
    }
  }

  int ans=0;
  for(int ii=0; ii<N; ii++){
    for(int jj=ii+1; jj<N; jj++){
      int sum2 = 0;
      for(int kk=0; kk<D; kk++){
        sum2 += (A[ii][kk] - A[jj][kk]) * (A[ii][kk] - A[jj][kk]);
      }
      int sum = sqrt(sum2);
      if(sum*sum == sum2) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using ll = long long;
using namespace std;
int main() {
    int N,M; cin >> N >> M;
    int min_id,max_id;
    for (int i=0;i<M;i++){
        int L,R; cin >> L >> R;
        if (i==0){
            min_id = L;
            max_id = R;
            continue;
        }
        if (R<min_id||max_id<L) {
            cout << 0 << endl;
            return 0;
        } 
        min_id = max(L,min_id);
        max_id = min(R,max_id);
    }
    cout << max_id - min_id + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
N , A , B = map(int, input().split())
c = 0

if A%2 == B%2:
    print((B-A)//2)
else:
    if N - B < A-1:
        c += N - B
        c += 1
        c += (B-A-1)//2
        print(c)

    else:
        c += A-1
        c += 1
        c += (B-A-1)//2
        print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100000+10;
int x,y,a,b,c;
int p[N],q[N],r[N];
int main() {
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;i++)scanf("%d",&p[i]);
	for(int i=1;i<=b;i++)scanf("%d",&q[i]);
	for(int i=1;i<=c;i++)scanf("%d",&r[i]);
	multiset<LL> s1,s2,s3;
	sort(p+1,p+1+a);
	LL ans=0;
	for(int i=a;i>a-x;i--) {s1.insert(p[i]); ans+=p[i];}
	sort(q+1,q+1+b);
	for(int i=b;i>b-y;i--) {s2.insert(q[i]); ans+=q[i];}

	for(int i=1;i<=c;i++) s3.insert(r[i]);
	//printf("%lld\n", ans);
	while( (s3.size()>0) && (s1.size()>0||s2.size()>0) ){
		int v1=s1.size()?(*s1.begin()):1e9+1;
		int v2=s2.size()?(*s2.begin()):1e9+1;
		int v3=*s3.rbegin();
		if(v3<min(v1,v2)) break;
		//printf("# %d %d\n", v3,min(v1,v2));
		if(v1<v2) {
			s1.erase(s1.begin()); ans-=v1;
		} else {
			s2.erase(s2.begin()); ans-=v2;
		}
		s3.erase(s3.find(v3)); ans+=v3;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 14592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint=long long;
int MOD=1000000007;
struct UnionFind {
    int n;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> group;
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        n=N;
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void calc(){
        group.resize(n,0);
        for(int i=0;i<n;i++){
            group[root(i)]++;
        }
    }
    int size(int x){
        return group[root(x)];
    }
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
 
};

signed main(){
    int n,m;cin>>n>>m;
    UnionFind tree(n+1);
    rep(i,m){
        int a,b;cin>>a>>b;
        tree.unite(a,b);
    }
    tree.calc();
    int res=0;
    rep1(i,n){
        res=max(res,tree.group[i]);
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 11084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n;
  int s1 = n /100;
  int s2 = (n- s1*100)/10;
  int s3 = (n- s1*100 -s2*10);

  //cout << s1 << endl;
  //cout << s2 << endl;
  //cout << s3 << endl;
  cout << (s1+s2+s3) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}
   
      


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 200010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    create_table(200010);
    n++;
    vector<P> coord(n);
    vector<ll> dp(n,0);
    coord[0] = (P(h,w));
    for (int i = 1;i < n;++i) cin >> coord[i].first >> coord[i].second;
    sort(coord.begin(),coord.end());
    for (int i = 0;i < n;++i) {
        dp[i] = combi(coord[i].first+coord[i].second-2,coord[i].first-1);
        for (int j = 0;j < i;++j) if (coord[i].first >= coord[j].first && coord[i].second >= coord[j].second) {
            (dp[i] -= dp[j]*combi(coord[i].first-coord[j].first+coord[i].second-coord[j].second,coord[i].first-coord[j].first)%mod) %= mod;
        }
    }
    cout << (dp[n-1]+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 4992