akhauriyash/Code-Regression huggingface dataset:
local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end
table.sort(a)

local k=10^9+1
local l=0
for i=1,n do
    local diff=math.abs(a[n]/2-a[i])
    if k>diff then
        k=diff
        l=a[i]
    end
end
print(a[n],l)

Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816],s[225816],l[225816],r[225816];
map<ll, int> mp;
vector<P> v[225816];

int main(void){
	int n,i,j,p,m;
	bool flag;
	ll x,d,q,ans=0ll;
	cin >> n >> a[0] >> d;
	for(i=1; i<n; ++i){
		a[i] = a[i-1]+d;
	}
	if(!d){
		cout << (a[0]?(n+1):1) << endl;
		return 0;
	}
	if(d<0){
		reverse(a,a+n);
		d = -d;
	}
	for(i=0; i<n; ++i){
		a[i] *= 2;
		s[i+1] = s[i]+a[i];
	}
	x = a[0]; d *= 2;
	x %= d; x += d; x %= d;
	mp[0] = 0;
	v[0].push_back(P(-d,1));
	v[0].push_back(P(0ll,-1));
	for(i=1; i<=n; ++i){
		q = x*i%d;
		if(mp.find(q) == mp.end()){
			mp[q] = i;
		}
		p = mp[q];
		l[i] = s[i]-d;
		r[i] = s[n]-s[n-i];
		v[p].push_back(P(l[i],1));
		v[p].push_back(P(r[i],-1));
	}
	for(i=0; i<=n; ++i){
		m = v[i].l_ength();
		sort(v[i].begin(),v[i].end());
		for(j=1; j<m; ++j){
			v[i][j].second += v[i][j-1].second;
		}
		flag = false; q = 0ll;
		for(j=0; j<m; ++j){
			if((!flag) && v[i][j].second){
				q -= v[i][j].first;
				flag = true;
			}else if(flag && (!v[i][j].second)){
				q += v[i][j].first;
				flag = false;
			}
		}
		ans += q/d;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n+1);
    for(int i = 0; i < n; i++) cin >> h[i];
    h[n] = h[n-1]+1;
    int ans = 0;
    for(int i = 1, start = 0; i <= n; i++){
        if(h[i-1] >= h[i]){
            ;
        }else{
            if(i-start-1 > ans) ans = i-start-1;
            start = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int SIZE = (1e5 * 2) + 13;

vector<int> a;
vector<int> cnt(SIZE);

int main(){
    int n, k;
    cin>>n>>k;
    for(int i = 0; i < n; ++i){
        int x;
        cin>>x;
        cnt[x]++;
    }
    for(int i = 0; i < cnt.size(); ++i){
        if(cnt[i] > 0)
            a.push_back(cnt[i]);
    }
    int ans = 0;
    sort(a.begin(), a.end());
    int m = a.size() - k;
    for(int i = 0; i < m; ++i){
        ans += a[i];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 2168
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	ans := "No"
	for c := 0; c <= x; c++ {
		t := x - c
		if c*2+4*t == y {
			ans = "Yes"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,sum=0;cin>>n;
    for(ll i=0,x;i<n;i++)cin>>x,sum+=x-1;
    cout<<sum;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 200000

int main(){
  int i,n,A[N],maxv,minv;;

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

  minv = A[0];
  maxv = A[1] - A[0];
  for(i=1;i<=n-1;i++){
    if(maxv < A[i]-minv)
      maxv = A[i]-minv;
    if(minv > A[i])
      minv = A[i];
  }
  printf("%d\n",maxv);
  return 0;
}


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


int main()
{
    int n;
    scanf("%d",&n);

    vector<long long> arr(n);
    vector<long long > distance(n,INT_MAX);

    for(int i = 0; i < n; i++)
        cin >> arr[i];


    distance[0] = 0ll;

    for(int i = 1; i < n; i++)
    {
        if(i == 1)
            distance[1] = abs(arr[i] - arr[i-1]);
        else
        {
            distance[i] = min(distance[i-2] + abs(arr[i] - arr[i-2]), distance[i-1] + abs(arr[i] - arr[i-1]));
        }
    }

    cout <<  distance[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int n,h,a[200005],b[200005],ax=0,cou=0;
	cin >> n>>h;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (ax < a[i]) { ax = a[i]; }
	}

	sort(b, b + n);

	for (int i = n-1; i >=0; i--) {
		
		if (ax < b[i]) { cou++; h -= b[i]; }

		if (h <= 0) { cout << cou; return 0; }
	}
	cout << cou + (h - 1) / ax + 1;
}


Measured memory_bytes: 3072
using System;
public class Hello{
    static void Count(string input){
        int count = 0;
        for(int x = 0;x < input.Length;x++){
            if(input.Substring(x,1) == "1"){
                count++;
            }
        }
        Console.WriteLine(count);
    }
    public static void Main(){
        string marble = Console.ReadLine();
        Count(marble);
        
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int n, m, l, r;

int main()
{
    cin >> n >> m >> l >> r;
    for (int i = 1, x, y; i < m; ++i) {
        cin >> x >> y;
        l = max(l, x), r = min(r, y);
    }
    if (r < l || l > n) cout << 0;
    else cout << r - l + 1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,ans = 0;
    int dp[1100][1100];
    char field;
    while(scanf("%d",&n),n)
    {
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
            {
                scanf(" %c",&field);
                dp[j + 1][i + 1] = 0;
                if(field == '*')dp[j + 1][i + 1] = -1;
            }
        for(int i = 1; i < n + 1; i++)
        {
            for(int j = 1; j < n + 1; j++)
            {
                if(dp[j][i] == -1);
                else if(j == 1 || i == 1)dp[j][i] = 1;
                else dp[j][i] = max(1,min(dp[j - 1][i - 1],min(dp[j - 1][i],dp[j][i - 1])) + 1);
                ans = max(ans,dp[j][i]);
            }
        }
        /*for(int i = 1; i < n + 1; i++)
        {
            for(int j = 1; j < n + 1; j++)
            {
                printf("%2d",dp[j][i]);
            }
            printf("\n");
        }*/
        printf("%d\n",ans);
        ans = 0;
    }
    return 0;
}

Measured memory_bytes: 6880
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>


using namespace std;
struct data{ int A, B, O;};
const int MAX = 50001;
const int Row = 0;
const int Col = 1;

bool fin[2][MAX];
int r,c,q;

int main(){

  while(cin >> r >> c >> q && r+c+q){
    memset(fin,false,sizeof(fin));

    vector<data> V(q);

    for(int i = 0; i < q; i++) cin >> V[i].A >> V[i].B >> V[i].O;

    int delR = 0, delC = 0;
    long long ans = 0;

    for(int i = V.size()-1; i >= 0; i--){
      if(V[i].A){
	// column

	if(fin[Col][V[i].B]) continue;

	if(V[i].O){
	  ans += r-delC;
	  fin[Col][V[i].B] = true;
	  delR++;
	}else{
	  delR++;
	  fin[Col][V[i].B] = true;
	}
	
      }else{
	// row

	if(fin[Row][V[i].B]) continue;

	if(V[i].O){
	  ans += c-delR;
	  fin[Row][V[i].B] = true;
	  delC++;
	}else{
	  delC++;
	  fin[Row][V[i].B] = true;
	}

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

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a, b, c;
  std::cin >> a >> b >> c;
  std::cout << std::min(b / a, c) << std::endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
if N <= 7:
	print(ans)
else:
	for i in range(8, N + 1):
		temp = 0
		for j in range(1, N + 1):
			if i % 2 == 1 and i % j == 0:
				temp += 1
		if temp == 8:
			ans += 1
	print(ans)

Measured memory_bytes: 3060
import math


N = int(input())
As = list(map(int, input().split(" ")))
Asdouble = list(map(lambda x:x * 2,As))
AsdoubleRev = Asdouble[::-1]
temp = AsdoubleRev[1] - AsdoubleRev[0]
for a,b in zip(AsdoubleRev[1:-2],AsdoubleRev[2:-1]):
    temp = b -temp
M1 =Asdouble[0] - temp
M1 //=2

ans = [M1]
temp = M1
for a in Asdouble[:-1]:
    temp = a - temp
    ans.append(temp)
ans = list(map(str,ans))
print(" ".join(ans))

Measured memory_bytes: 24136
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int d, t, s;
  cin>>d>>t>>s;
  if(d <= t * s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
const int N=1e5+5;
typedef long long ll;
ll b[60],a[N];
void insert(ll x) {
    for(int i=59;~i;i--) if(x>>i&1) {
        if(!b[i]) {
            b[i]=x;
            break;
        }
        x^=b[i];
    }
}
int main() {
    ll sum=0;
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    ll ans=0;
    for(int j=0;j<60;j++) {
        int cnt=0;
        for(int i=1;i<=n;i++) cnt+=(a[i]>>j&1);
        if(cnt&1) {
            ans+=1LL<<j;
            for(int i=1;i<=n;i++) if(a[i]>>j&1) a[i]^=1LL<<j;
        }
    }
    for(int i=1;i<=n;i++) insert(a[i]);
    ll res=0;
    for(int i=59;~i;i--) if(b[i]) {
        if((res^b[i])>res) res^=b[i];
    }
    printf("%lld\n",ans+(res<<1));
    return 0;
}


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

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int main(void)
{
	ll all_time=0;
	ll N,M;
	cin>>N;
	vector<ll> T(N+1);
	rep(i,N) cin>>T[i+1];
	cin>>M;
	rep(i,N)all_time+=T[i+1];

	vector<ll> P(M);
	vector<ll> X(M);
	rep(i,M) cin>>P[i]>>X[i];
	rep(i,M){
		cout<<all_time-T[P[i]]+X[i]<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli ans,scnt=0;
    string x;
    lli i,j;
    cin>>x;
    ans=x.size();
    rep(i,0,x.size()){
        if(x[i]=='S'){
            scnt++;
        }
        else if(scnt!=0){
            if(x[i]=='T'){
                scnt--;
                ans-=2;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc012/tasks/abc012_4
// Warshall Floyd
// next permutation (sortしてから)

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;

#define MAX_V 210
ll d[MAX_V][MAX_V];
int V;
vector<int> r;

void warshall_floyd()
{
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void Main()
{
	int N, M, R; cin >> N >> M >> R;
	V = N;
	rep(i,R) {
		int _r; cin >> _r;
		--_r;
		r.push_back(_r);
	}
	rep(i,N) {
		rep(j,N) {
			if (i == j) {
				d[i][i] = 0;
			} else {
				d[i][j] = 1e18;
			}
		}
	}
	rep(i,M) {
		int a, b, t; cin >> a >> b >> t;
		--a, --b;
		d[a][b] = t;
		d[b][a] = t;
	}
	warshall_floyd();
	ll res = 1e18;
	sort(r.begin(), r.end());
	do {
		ll sum = 0;
		rep(i, r.size() - 1) {
			sum += d[r[i]][r[i + 1]];
		}
		res = min(res, sum);
    } while(next_permutation(r.begin(), r.end()));
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(x >= a && x <= a+b) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll P;
    cin >> P;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}

    //dp[i][j]はi袋目までであまりjの場合の数
    vector<vector<ll>> dp(N, vector<ll>(2, 0));
    if(A[0]%2==0)dp[0][0]=2;
    else {dp[0][1]=1;dp[0][0]=1;}
    for(ll i=1;i<N;i++){
        if(A[i]%2==0){
            dp[i][0]=dp[i-1][0]*2;
            dp[i][1]=dp[i-1][1]*2;
        }
        else{
            dp[i][0]=dp[i-1][1]+dp[i-1][0];
            dp[i][1]=dp[i-1][0]+dp[i-1][1];

        }
    ;}
    cout<<dp[N-1][P]<<endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
opes = []
for _ in range(N):
  opes.append(tuple(map(int, input().split())))
opes.sort(key=lambda x:x[0])
sum_ope = 0
for ope in opes:
  sum_ope += ope[1]
  if sum_ope >= K:
    print(ope[0])
    break

Measured memory_bytes: 18180
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
/* -- template -- */
bool dp[100001];//dp[i] : 残石数がiのとき，勝てるか否か
int main() {
    int N, K; cin >> N >> K;
    int a[N]; rep(i, N) cin >> a[i];

    rep(k, K + 1) {
        dp[k] = false;
        rep(i, N) {
            if(k - a[i] >= 0) {
                if(dp[k - a[i]] == false)dp[k] = true;
            }
        }
    }
    cout << ((dp[K]) ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> cnt(100005, 0);
	int n;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		++cnt[a+2];
		++cnt[a+1];
		++cnt[a];
	}
	int ans = 0;
	rep(i,100003) chmax(ans, cnt[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,c,k; cin >> a >> b >> c >> k;
  ll ans=0;
  ans+=min(a,k);
  ans-=max(k-a-b,0);
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	rep(i, n) cin >> v[i];
	sort(all(v));
	cout << v[n - 1] - v[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int t[100005], x[100005], y[100005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  FOR(i,0,N) cin >> t[i+1] >> x[i+1] >> y[i+1];
  t[0] = x[0] = y[0] = 0;
  FOR(i,0,N) {
    int dt = t[i+1] - t[i];
    int dd = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    int nokori = dt - dd;
    if(nokori < 0) {
      cout << "No" << endl;
      return 0;
    }
    if(nokori % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)

	fmt.Println(strings.ToUpper(s1[0:1]) + strings.ToUpper(s2[0:1]) + strings.ToUpper(s3[0:1]))
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int ans = N;

		for (int i = 0; i < M; i++){
			int A = scan.nextInt();
			ans -= A;
		}
		if (ans < -1){
			System.out.println(-1);
		}else {
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 46392
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < (1 << 3); i++) {
		int ans = s[0] - '0';
		string t = "";
		t += s[0];
		for (int j = 0; j < 3; j++) {
			if (i & (1 << j)) {
				ans += s[j + 1] - '0';
				t += '+';
			} else {
				ans -= s[j + 1] - '0';
				t += '-';
			}
			t += s[j + 1];
		}
		if (ans == 7) {
			cout << t + "=7\n" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

P split(int l, int r, CumulativeSum &cs) {
    int floor = l + 1, ceil = r;

    while (floor + 1 < ceil) {
        int mid = (floor + ceil) / 2;
        ll l_sum = cs.getSectionSum(l, mid - 1);
        ll r_sum = cs.getSectionSum(mid, r - 1);
        if (l_sum > r_sum) ceil = mid;
        else floor = mid;
    }

    ll diff = INF;
    for (int mid = max(floor - 5, l + 1); mid < min(ceil + 5, r); mid++) {
        ll l_sum = cs.getSectionSum(l, mid - 1);
        ll r_sum = cs.getSectionSum(mid, r - 1);
        ll now_diff = abs(l_sum - r_sum);
        cmin(diff, now_diff);
    }

    for (int mid = max(floor - 5, l + 1); mid < min(ceil + 5, r); mid++) {
        ll l_sum = cs.getSectionSum(l, mid - 1);
        ll r_sum = cs.getSectionSum(mid, r - 1);
        ll now_diff = abs(l_sum - r_sum);
        if(now_diff == diff) return P(l_sum, r_sum);
    }
    __throw_runtime_error("konai");
}

ll solve(int n, int i, CumulativeSum &cs) {
    P bc = split(0, i, cs);
    P de = split(i, n, cs);

    vector<ll> tmp = {bc.first, bc.second, de.first, de.second};
    sort(tmp.begin(), tmp.end());
    return tmp.back() - tmp.front();
}

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, v[i]);
    cs.build();

    ll ans = INF;
    for (int i = 2; i <= n - 2; i++) {
        ll now = solve(n, i, cs);
        cmin(ans, now);
    }
    cout << ans << endl;


}


Measured memory_bytes: 8024
//
//  main.cpp
//  ABC_084_D
//
//  Created by Joe Mori on 2020/06/12.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<bits/stdc++.h>
int main() {
    std::vector<int>a(100100,1);
    a[0]=0;
    a[1]=0;
    for(int i=2;i<a.size();i++){
        if(!a[i])continue;
        for(int j=2;j*i<a.size();j++){
            a[j*i]=0;
        }
    }
    std::vector<int>ans(100100,0);
    for(int i=3;i<a.size();i++){
        if(!a[i]){
            ans[i]=ans[i-1];
            continue;
        }
        if(a[i]==1&&a[(i+1)/2]==1){
            ans[i]=ans[i-1]+1;
            continue;
        }else ans[i]=ans[i-1];
    }
    int Q;
    std::cin>>Q;
    for(int i=0;i<Q;i++){
        int l,r;
        std::cin>>l>>r;
//        std::cout<<ans[r]<<" "<<ans[l]<<std::endl;
        std::cout<<ans[r]-ans[l-1]<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(M);
    for(int a = M/N;a >= 0 ;a--){
        if(M%a == 0){
            COUT(a);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--)
	{
		if(m%i==0)
		{
			int t=m/i;
			if(t>=n)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]!='0' || s[0]!='1'){
		cout<<-1<<endl;
		return;
	}
	fr(i,0,n/2){
		if(s[i]!=s[n-1-i-1]){
			cout<<-1<<endl;
			return;
		}
	}
	vpii edges;
	edges.pb({1,2});
	int cur=2,par=1;
	fr(i,1,n-1){
		if(s[i-1]=='1'){
			edges.pb({cur,i+2});
			par=cur;
			cur=i+2;
		}
		else{
			edges.pb({par,i+2});
			cur=i+2;
		}
	}
	for(auto e: edges){
		cout<<e.first<<" "<<e.second<<endl;
	}
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 4504
/**
*   @author Mustafa Khaled.
**/
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;

#define REP(i, n) for(int i = 0 ; i < n ; ++i )

string to_string(string s){return '"' + s + '"';}string to_string(const char* s){return to_string((string) s);}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v){bool first = true;string res = "{";for (const auto &x : v){if (!first){res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out(){cerr << endl;}template <typename Head, typename... Tail>void debug_out(Head H, Tail... T){cerr << " " << to_string(H);debug_out(T...);}/*input*/inline void in(const char *t) {}template <typename Head, typename... Tail>inline void in(const char *t,Head &H, Tail&... T){scanf(t,&H);in(t,T...);}
#define D(...)    in(  "%d",__VA_ARGS__);
#define LLD(...)  in("%lld",__VA_ARGS__);

#ifndef ONLINE_JUDGE
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define dbg(...) {}
#endif
/// start driven program
const int OO = 0x3f3f3f3f, N=3e5+7  , MOD= 1000000007;

int beforW[N];
int afterE[N];
char s[N];
int main(){
    int n ; D(n); scanf(" %s",s);
    for ( int i =0;  i<n ; ++i){
        if(s[i]=='W'){
            beforW[i+1]=1;
        }
    }
    for(int i=0 ; i < n ; ++i){
        beforW[i+1]+=beforW[i];
    }


    for ( int i =n-1;  ~i ; --i){
        if(s[i]=='E'){
            afterE[i+1]=1;
        }
    }
    for ( int i =n-1;  ~i ; --i){
        afterE[i+1]+=afterE[i+2];
    }
    int mn =OO , x=0;

    for(int i=0 ; i < n ; ++i){
        x=(beforW[i+1]-(s[i]=='W')) + (afterE[i+1]-(s[i]=='E') );
        dbg(i , x);
        mn = min(mn ,x);
    }

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

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
#include<math.h>
char s1[1000000],s2[1000002];
#define ll long long int
ll ar1[100000],ar2[100000];
int main()
{
    ll a,b,c,d;
    cin>>a>>b;
    if(a*500>=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int main(void)
{
	int N, a[100010],b[100010];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a, a + N);
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != b[i]) {
			count++;
		}
	}
	if (count > 2) {
		printf("NO");
		return 0;
	}
	printf("YES");
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

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

	int e_count = 0, w_count = 0;
	int ans = 100000000, min = 0;
	for(int i = 0; i < N; ++i){
		if(S[i] == 'E'){
			e_count++;
		}
	}
	for(int i = 0; i < N; ++i){
		if(S[i] == 'W'){
			min = e_count + w_count;
			w_count++;
		} else if(S[i] == 'E'){
			e_count--;
			min = e_count + w_count;
		}

		ans = MIN(ans, min);
	}
	cout << ans << endl;
}


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

using namespace std;

const int N=1e5+233;
long long father[N*2];
long long n;
long long l=0;
long long ans=0;
struct zyy1
{
    long long x,y,num;
}a[N*10];

struct zyy2
{
	long long s,t,val;
}b[N*10];

bool cmp1(zyy1 a,zyy1 b)
{
	return a.x>b.x;
}

bool cmp(zyy2 a,zyy2 b)
{
	return a.val<b.val;
}
bool cmp2(zyy1 a,zyy1 b)
{
	return a.y>b.y;
}

inline long long find(long long x)
{
	if(father[x]==x)return x;
	father[x]=find(father[x]);
	return father[x];
}

int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)father[i]=i;
	for(long long i=1;i<=n;i++)a[i].num=i;
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
	}
	sort(a+1,a+n+1,cmp1);
	

	

	
	
	
	
	
	for(long long i=1;i<=n-1;i++)
	{
		b[++l].s=a[i].num;
		b[l].t=a[i+1].num;
		b[l].val=abs(a[i].x-a[i+1].x);
	}
	sort(a+1,a+n+1,cmp2);
	
	
	for(long long i=1;i<=n-1;i++)
	{
		b[++l].s=a[i].num;
		b[l].t=a[i+1].num;
		b[l].val=abs(a[i].y-a[i+1].y);
	}
	
	
	sort(b+1,b+l+1,cmp);
	
/*	for(int i=1;i<=l;i++)
	{
		cout<<b[i].s<<" ";
	}
	cout<<endl;
	for(int i=1;i<=l;i++)
	{
		cout<<b[i].t<<" ";
	}
	cout<<endl;
	for(int i=1;i<=l;i++)
	{
		cout<<b[i].val<<" ";
	}
	cout<<endl;*/
	
	
	for(long long i=1;i<=l;i++)
	{
		if(find(b[i].s)!=find(b[i].t))
		{
			long long fx=find(b[i].s);
			long long fy=find(b[i].t);
			father[fx]=fy;
			ans+=b[i].val;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13184
<?php
list($a, $b) = ints();
$n = intval(strval($a) . strval($b));
echo pow(intval(sqrt($n)), 2) === $n ? 'Yes' : 'No';

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct Edge{
    ll from;
    ll to;
    ll cost;
};
void dfs(int now, vector<int> &canarrive, vector<vector<int>> &g){
    canarrive[now] = 1;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(canarrive[next]) continue;
        dfs(next, canarrive, g);
    }
}
int main(void){
    ll n, m, p;
    cin >> n >> m >> p;
    vector<Edge> e;
    vector<vector<int>> rg(n);
    rep(i, m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c *= -1;
        c += p;
        Edge tmp;
        tmp.cost = c;
        tmp.from = a;
        tmp.to = b;
        e.push_back(tmp);
        rg[b].push_back(a);
        //g[a].push_back(b);
    }

    vector<ll> dist(n, INF);
    dist[0] = 0;
    rep(i, n + 1){
        bool update = false;
        rep(j, e.size()){
            if(dist[e[j].to] > dist[e[j].from] + e[j].cost){
                dist[e[j].to] = dist[e[j].from] + e[j].cost;
                update = true;
            }
        }
    }

    vector<int> canarrive(n, 0);
    dfs(n - 1, canarrive, rg);

    bool ok = true;
    rep(i, n + 1){
        rep(j, e.size()){
            if(dist[e[j].to] > dist[e[j].from] + e[j].cost){
                if(canarrive[e[j].to] && dist[e[j].to] <= (ll)1e10){
                    dist[e[j].to] = dist[e[j].from] + e[j].cost;
                    ok = false;
                }
            }
        }
    }


    if(!ok){
        cout << -1 << endl;
    } else {
        cout << max(0ll, dist[n - 1] * -1) << endl;
    }


}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    bool flg = true;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        if( a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0 ) ) flg = false;

    }
    if( flg ) cout << "APPROVED";
    else cout << "DENIED";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    string s;
    cin>>s;
    ll ans = 0;
    rep(i,(1<<3)){
        ll tmp = s[0]-'0';
        repl(j,1,4) {
            if((1<<(j-1)) & i) tmp += s[j]-'0';
            else tmp -= s[j]-'0';
        }
        if(tmp==7){
            ans = i;
        }
    }
    cout<<s[0];
    rep(i,3) {
        if(ans & (1<<i)) cout<<"+"<<s[i+1];
        else cout<<"-"<<s[i+1];
    }
    cout<<"=7"<<endl;
    return 0;
}

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

int main()
{
    int a,b,c,x,y;
    std::cin>>a>>b>>c>>x>>y;

    c *= 2;
    int res1 = a*x + b*y;
    int res2 = std::min(x,y) * c;
    if(x < y){
        res2 += (y - x) * b;
    }
    if(x > y){
        res2 += (x - y) * a;
    }
    int res3 = std::max(x,y) * c;
    res2 = std::min(res2,res3);
    std::cout<<std::min(res1,res2)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
w,h,n = map(int,input().split())
arr = [[1 for _ in range(w)] for _ in range(h)]
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(h):
            for k in range(x):
                arr[j][k] = 0
    elif a == 2:
        for j in range(h):
            for k in range(x, w):
                arr[j][k] = 0
    elif a == 3:
        for j in range(y):
            for k in range(w):
                arr[j][k] = 0
    elif a == 4:
        for j in range(y, h):
            for k in range(w):
                arr[j][k] = 0
ans = 0
for i in range(h):
    ans += sum(arr[i])
print(ans)

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

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		int num = (100 * r) + (10 * g) + b;
		String message = "NO";
		if(num % 4 == 0) {
			message = "YES";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21716
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int x = Integer.parseInt(sc.next());
    pw.println(x >= 30 ? "Yes" : "No");
  }
}


Measured memory_bytes: 35556
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K, p[1111];

  std::cin >> N >> K;

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

  std::sort(p, p + N);

  std::cout << std::accumulate(p, p + K, 0LL) << std::endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  ll cnt = 0;
  ll n = s.size();
  ll prev = -1;
  REP(i,n) {
    if (s[i] == 'W') {
      cnt += i - prev - 1;
      ++prev;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;


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

	vector<char> ch = { 'M', 'A', 'R','C','H' };
	vector<int> ct(5);
	for (int i = 0; i < N; ++i)
	{
		string str;
		cin >> str;
		for (int j = 0; j < 5; ++j)
		{
			if (ch[j] == str[0])
			{
				++ct[j];
			}
		}
	}
	sort(ct.begin(), ct.end());
	int n = 5 - distance(ct.begin(), upper_bound(ct.begin(), ct.end(), 0));
	if (n < 3)
	{
		cout << 0 << endl;
		return;
	}
	vector<int> ctp(upper_bound(ct.begin(), ct.end(), 0), ct.end());
	ull ttl = 0;
	for (int i = 2; i < static_cast<int>(ctp.size()); ++i)
	{
		for (int j = 1; j < i; ++j)
		{
			for (int k = 0; k < j; ++k)
			{
				ttl += static_cast<ull>(ctp[k]) * ctp[j] * ctp[i];
			}
		}
	}

	cout << ttl << endl;
}

int main()
{
	ABC089C();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 rep(i, n) for (int i = 0; i < (int)n; i++)
typedef long long ll;
const ll MOD = 1e9+7;
const int inf = -10000;

void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();
int main(void){

    solve();
    return 0;
}

void solve(){
    string S, T;
    cin >> S >> T;
    int N, M;
    N = S.size();
    M = T.size();
    // dp[i][j] := S[i], T[j]まで見たときの編集距離
    // ans = dp[N][M]
    int dp[1010][1010] = {0};
    dp[0][0] = 0;
    for (int i = 0; i <= N; i++) dp[i][0] = i;
    for (int j = 0; j <= M; j++) dp[0][j] = j;
    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= M; j++){
            int c = 1;
            if (S[i-1] == T[j-1]) c = 0;
            dp[i][j] = min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + c});
        }
    }
    cout << dp[N][M] << endl;
}



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

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, A, B, P1, P2;

            var word = Console.ReadLine().Split(' ');

            N = int.Parse(word[0]);
            A = int.Parse(word[1]);
            B = int.Parse(word[2]);

            P1 = A * N;
            P2 = B;
            
            if (P1 < P2)
            {
                Console.WriteLine(P1);
            }
            else
            {
                Console.WriteLine(P2);
            }

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
INF = float('inf')
N = int(input())
a = [list(map(int, input().split())) for i in range(N)]
b = [[INF] * N for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            b[i][j] = min(b[i][j], a[i][k] + a[k][j])
for i in range(N):
    for j in range(N):
        if b[i][j] < a[i][j]:
            print(-1)
            quit()
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        flag = 1
        for k in range(N):
            if a[i][j] == a[i][k] + a[k][j] and k != i and k != j:
                flag = 0
                break
        if flag: ans += a[i][j]
print(ans)


Measured memory_bytes: 124892
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		
		double S = r * r * Math.PI;
		double L = 2 * r * Math.PI;
		
		System.out.printf("%f %f",S,L);
	}
}

Measured memory_bytes: 19032
#わかったこと　2~N**0.5まで素数関係なく調べればいい
n=int(input())
bunkai=[]

def different_value(e):
    cnt=0
    i=1
    while e-i>=0:
        e-=i
        i+=1
        cnt+=1
    return cnt

def soinsuu(x):
    for i in range(2,int(n**0.5)+1):
        cnt=0
        while x%i==0:
            x//=i
            cnt+=1
        if cnt==0:
            continue
        bunkai.append([i,cnt])
    if x!=1:
        bunkai.append([n,1])
soinsuu(n)

ans=0
for num,e in bunkai:
    ans+=different_value(e)

print(ans)

#print(bunkai)

Measured memory_bytes: 9476
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Edge { int to, cost; };
bool operator<(const Edge& e1, const Edge& e2) { return e1.cost < e2.cost; }
int N, M, Z, p, a, b, w, s[7], t[7], y[15], p1[7], p2[7], r[15], x[2][7], d[1111][1111]; vector<Edge> G[1111];
int main() {
	cin >> N >> M >> Z >> p; p--; r[0] = p;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> w; a--, b--;
		G[a].push_back(Edge{ b, w });
		G[b].push_back(Edge{ a, w });
	}
	for (int i = 0; i < Z; i++) {
		cin >> s[i] >> t[i]; s[i]--, t[i]--;
	}
	y[0] = p;
	for (int i = 0; i < Z; i++) y[i + 1] = s[i];
	for (int i = 0; i < Z; i++) y[i + Z + 1] = t[i];
	for (int g = 0; g < Z * 2 + 1; g++) {
		int i = y[g];
		priority_queue<Edge> que; que.push(Edge{ i, 0 });
		fill(d[i], d[i] + N, 99999999); d[i][i] = 0;
		while (!que.empty()) {
			int v = que.top().to; que.pop();
			for (auto &e : G[v]) {
				if (d[i][e.to] > d[i][v] + e.cost) {
					d[i][e.to] = d[i][v] + e.cost;
					que.push(Edge{ e.to, d[i][e.to] });
				}
			}
		}
	}
	int ret = 99999999;
	for (int i = 0; i < (1 << (2 * Z)); i++) {
		int dep = 0; bool flag = true;
		for (int j = 0; j < 2 * Z; j++) {
			if (i & (1 << j)) dep--;
			else dep++;
			if (dep < 0) flag = false;
		}
		if (dep != 0) flag = false;
		if (!flag) continue;
		for (int j = 0; j < Z; j++) p1[j] = p2[j] = j;
		do {
			int cr1 = 0;
			for (int j = 0; j < 2 * Z; j++) {
				if (!(i & (1 << j))) {
					x[0][p1[cr1]] = j;
					r[j + 1] = s[p1[cr1++]];
				}
			}
			do {
				int cr2 = 0;
				for (int j = 0; j < 2 * Z; j++) {
					if (i & (1 << j)) {
						x[1][p2[cr2]] = j;
						r[j + 1] = t[p2[cr2++]];
					}
				}
				bool e = true;
				for (int j = 0; j < Z; j++) {
					if (x[0][j] > x[1][j]) {
						e = false;
						break;
					}
				}
				if (!e) continue;
				bool ok = true;
				int res = 0;
				for (int j = 0; j < 2 * Z; j++) {
					res += d[r[j]][r[j + 1]];
				}
				ret = min(ret, res);
			} while (next_permutation(p2, p2 + Z));
		} while (next_permutation(p1, p1 + Z));
	}
	if (ret == 99999999) cout << "Cannot deliver" << endl;
	else cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3308