akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;

int q;

int main(){
	multimap<string, int> mma;
	cin >> q;
	for(int i = 0; i < q; i++){
		char query;
		cin >> query;
		if(query == '0'){
			string key;
			int x;
			cin >> key >> x;
			mma.insert(make_pair(key, x));
		}else if(query == '1'){
			string key;
			cin >> key;
			multimap<string, int>::iterator itr;
			pair<multimap<string, int>::iterator, multimap<string, int>::iterator> itr1 = mma.equal_range(key);
			for(itr = itr1.first; itr != itr1.second; itr++){
				cout << itr -> second << endl;
			}
		}else if(query == '2'){
			string key;
			cin >> key;
			pair<multimap<string, int>::iterator, multimap<string, int>::iterator> itr1 = mma.equal_range(key);
			mma.erase(itr1.first, itr1.second);
		}else if(query == '3'){
			string L, R;
			cin >> L >> R;
			multimap<string, int>::iterator itr, itr1, itr2;
			itr1 = mma.equal_range(L).first;
			itr2 = mma.equal_range(R).second;
			for(itr = itr1; itr != itr2; itr++){
				cout << itr -> first << ' ' << itr -> second << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 24748
N, M = map(int, input().split())
acCheck = [False] * (N + 1)
waCntList = [0] * (N + 1)
waCnt = 0
for i in range(M):
    query = list(input().split())
    idx = int(query[0])
    if acCheck[idx]:
        continue
    if query[1] == "AC":
        waCnt += waCntList[idx]
        acCheck[idx] = True
    else:
        waCntList[idx] += 1
print(str(acCheck.count(True)), str(waCnt))


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

map<long long, long long> ball;
vector<long long> num;

int main()
{
    int i, j;
    int n;

    cin >> n;

    for (i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        num.push_back(tmp);
        ball[tmp] += 1;
    }

    long long cnt = 0;
    for (i = 1; i <= n; i++) {
        cnt += (ball[i] * (ball[i] - 1)) / 2;
    }

    for (i = 0; i < n; i++) {
        long long ans = cnt - (ball[num[i]] - 1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 16880
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long root = (long) Math.ceil(Math.sqrt(n));

        long sum = 0;

        for (int x = 1; x < root; x++) {
            if (n % x == 0) {
                long m = n / x - 1;
                if (x < m) sum += m;
            }
        }
        // write your code
        System.out.println(sum);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23764
N, D = map(int, input().split())
X = []
cnt = 0
for i in range(N):
  X.append(list(map(int, input().split())))
  
for i in range(N):
  if (int(X[i][0])**2+int(X[i][1])**2)**(1/2) <= D:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 45844
// In the name of god
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const long long inf=1e15+5;
long long n,k,h[maxn],x,dp[maxn];
int main(){
	cin>>n;
	k=2;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(i==0){
	
		}
		else{
			dp[i]=inf;
			for(int j=1;j<=k;j++){
				if(i-j<0){
					break;
				}
				dp[i]=min(dp[i],(dp[i-j]+abs(h[i]-h[i-j])));
			}
		}
	}
	cout<<dp[n-1];
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    ll d[3];
    d[0] = b - 1;
    d[1] = n - a;
    d[2] = b - a;

    if(d[2]%2!=0){
        d[2] = min({a,n-b+1});
        d[2] += (b - a - 1)/2;

    }else{
        d[2] /= 2;
    }

    ll ans = min({d[0],d[1],d[2]});

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
		vector<ll> lis;
		lis.resize(6);
		ll i;
		for(i=1;i<6;i++)
		{
			cin>>lis[i];
			if(lis[i]==0)
			{
				cout<<i<<"\n";
			}
		}
	return 0;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


auto solve() {
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    int max_v = N * 1000 + 100;

    const ll LMAX = 1ll << 60;
    vector<vll> dp(N + 1, vll(max_v, LMAX));
    dp[0][0] = 0;

    REP(i, N) {
        REP(j, max_v) {
            if (j - v[i] < 0)
                dp[i + 1][j] = dp[i][j];
            else
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
        }
    }

    int result = 0;
    REP(j, max_v) {
        if (dp[N][j] <= W)
            result = j;
    }

    return result;
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=6e2+10;
const int mod=1e9+7;
int c[maxn][maxn],dp[maxn][maxn],tmp[maxn],g[maxn];
int main() {
    int n,K,a,b; scanf("%d%d",&n,&K);
    for(int i=1;i<=K;i++) {
        scanf("%d%d",&a,&b);
        g[a]=b,g[b]=a;
    } n<<=1;
    for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) c[i][j]=c[i][j-1]+(g[j]==0);
    tmp[0]=1;
    for(int i=2;i<=n;i+=2) tmp[i]=1ll*tmp[i-2]*(i-1)%mod;
    for(int i=1;i<=n;i++) {
        for(int j=i;j<=n;j++) {
            bool flag=0;
            for(int k=i;k<=j;k++) {
                flag|=(g[k]&&(g[k]<i||g[k]>j));
                if (flag) break;
            }
            if (flag) continue;
            dp[i][j]=tmp[c[i][j]];
            for(int k=i+1;k<=j-1;k++) {
                (dp[i][j]+=mod-1ll*dp[i][k]*tmp[c[k+1][j]]%mod)%=mod;
            }
        }
    } ll ret=0;
    for(int i=1;i<=n;i++) {
        for(int j=i;j<=n;j++) {
            (ret+=1ll*dp[i][j]*tmp[n-2*K-c[i][j]]%mod)%=mod;
        }
    }
    printf("%lld\n",(ret%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
a = list(int(i) for i in input().split())
b = list(int(i) for i in input().split())
d = []
for i in range(n):
    d.append(a[i]-b[i])
d = sorted(d)
if sum(d)<0:
    print(-1)
else:
    dif = 0
    count = 0
    for i in range(n):
        if d[i]<0:
            dif -= d[i]
            count += 1
        else:
            break
    if dif>0:
        for i in range(n):
            dif -= d[n-1-i]
            count += 1
            if dif <=0:
                break
    print(count)

Measured memory_bytes: 18524
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define MAX_N 200005
#define LL long long
int n,m,k;
string s;
int sum[12][1005];
bool mp[12][1005];
int ans=99999999;
int a[12];

bool check(int cnt,int j,int la){  //判断需不需要切。
    int s=0;
    for(int i=1;i<=cnt;i++){
        s=sum[a[i]][j]-sum[a[i]][la]-sum[a[i-1]][j]+sum[a[i-1]][la];
        if(s>k)return 0;
    }
    return 1;
}

void work(int t){     //枚举竖着切。
    int s=t,la=0;
    a[t+1]=n;
    for(int i=1;i<=m;i++)if(!check(t+1,i,la))s++,la=i-1;
    if(check(t+1,m,m-1))ans=min(ans,s); //细节，最后1列可能超过K个，需特判。
}

void dfs(int now,int t){ //枚举横着切。
    if(now==n){
        work(t);
        return;
    }
    a[t+1]=now,dfs(now+1,t+1);
    dfs(now+1,t);
}
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>s;
        for(int j=1;j<=m;j++)
            mp[i][j]=s[j-1]-'0',sum[i][j]=sum[i][j-1]+mp[i][j]+sum[i-1][j]-sum[i-1][j-1];
    }
    dfs(1,0);
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  bool ans = true;
  
  for(int i=0;i<S.size();i++)
  {
    if(i%2)
    {
      if(S.at(i)=='R')ans=false;
    }
    else
    {
      if(S.at(i)=='L')ans = false;
    }    
  }
  
  if(ans)cout << "Yes" << endl;else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
r=h*w
if h==0 and w==0:
    print(0)
elif h==0 or w==0:
    print(1)
else:
    if h==1 or w==1:
        print(1) 
    elif r%2==0:
        print(r//2)
    else:
        print(r//2+1)
    

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int n,k;
char s[1000];

int main()
{
    cin>>n>>k;
    for (int i=1; i<=n; ++i)
    {
        cin>>s[i];
        if (i==k)
            s[i] = s[i] - ('A' - 'a');
    }
    for (int i=1; i<=n; ++i)
    {
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String p = scan.next();
		
		String S = s + s;
		
		if (S.matches(".*" + p + ".*")) {
		    System.out.println("Yes");
		}
		else {
		    System.out.println("No");
		}
		
		
	}

}

Measured memory_bytes: 26228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using ll = long long;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    Bint sum = 1;
    REP(i, n) {
        sum *= a[i];
        if (sum > 1000000000000000000) {
            sum = -1;
            break ;
        }
    }

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

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int a;
  cin >> a;
  vector<vector<int>> hoge(a);
  vector<vector<int>> fuga(a);
  vector<int> tmphoge;
  vector<int> tmpfuga;
  int itmp;
  rep_i(i, a){
    cin >> itmp;
    int x, y;
    rep_i(v, itmp){
      cin >> x >> y;
      tmphoge.push_back(x);
      tmpfuga.push_back(y);
    }
    hoge[i] = tmphoge;
    fuga[i] = tmpfuga;
    tmphoge.clear();
    tmpfuga.clear();
  }
  // cout << hoge[0][0] << endl;
  int ans = 0;
  for (int i = 1; i < (1 << a); i++){
    bool f = true;
    // cout << bitset<3>(i) << endl;
    for (int v = 0; v < a; v++){
      if(i & (1 << v)){
        // cout << "v " << v << endl;
        // cout << "hoge[v]size "<< hoge[v].size() << endl;
        for (int e = 0; e < hoge[v].size(); e++){
          int aa = (i >> (hoge[v][e] - 1) & 1);
          int bb = fuga[v][e];
          // cout << "aa " << aa << endl;
          // cout << "bb " << bb << endl;
          if(aa != bb){
            f = false;
          }
        }
      }
    }
    // if(f){
    //   cout << bitset<3>(i) << endl;
    // }
    int count = 0;
    if(f){
      // cout << bitset<15>(i) << endl;
      int t = 1;
      while(t <= i){
        if(i & t){
          count += 1;
        }
        t = t << 1;
      }
      ans = max(ans, count);
    }
  }
  say(ans);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
r, d, x = map(int, input().split())
x_list = [0] * 11
x_list[0] = x
for i in range(10):
    x_list[i+1] = (r * x_list[i]) - d
for _ in range(10):
    print(x_list[_+1])


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    s = set([A, B ,C])
    if len(s) == 2:
        # print(YES)
        return(YES)
    else:
        # print(NO)
        return(NO)
    # return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    ans = solve(A, B, C)
    if ans is not None:
        print(ans)

if __name__ == '__main__':
    main()


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

#define MAX 2147483647
void chmin(int *a,int b){
    if(*a > b){
        *a = b;
    }
}

int main(void){
    // Your code here!
    int N;
    int h[100000];
    int N_[100000];
    int i;
    
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
    }
    
    N_[0] = 0;
    for(i=1;i<N;i++){
        N_[i] = MAX;
    }
    
    chmin(&N_[1],abs(h[0]-h[1]));
    for(i=2;i<N;i++){
        chmin(&N_[i],N_[i-1]+abs(h[i-1]-h[i]));
        chmin(&N_[i],N_[i-2]+abs(h[i-2]-h[i]));
    }
    
    printf("%d\n",N_[N-1]);
    
}


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

int main(){
  string S,T;
  cin>>S;
  
  reverse(S.begin(),S.end());
  for(int i=0;i<S.size();i++){
    if(S[i]=='r'){
      if(S.substr(i,7)=="remaerd"){
	T+="remaerd";
	i+=6;
      }else if(S.substr(i,6)=="resare"){
	T+="resare";
	i+=5;
      }
    }else if(S[i]=='m'&&S.substr(i,5)=="maerd"){
      T+="maerd";
      i+=4;
    }else if(S[i]=='e'&&S.substr(i,5)=="esare"){
      T+="esare";
      i+=4;
    }
  }
  if(T==S) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll unsigned long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

void solve()
{
    vector<ll> v(9, 0);
    ll chk = 0;
    ll key = 0;
    ll tmp = 0;
    unsigned int carry = 0;
    rep(i, 9)
    {
        string s;
        cin >> s;
        //cerr << s << endl;
        v[i] = stoull(s, nullptr, 16);
    }
    rep(i, 8)
    {
        tmp += v[i];
        tmp &= 1;
    }
    chk = v[8];
    if (tmp == (chk & 1))
    {
        key = 0;
    }
    else
    {
        key = 1;
    }
    rep(i, 8)
    {
        if (((v[i] ^ key) & 1) == 1)
        {
            carry++;
        }
    }
    carry /= 2;
    rep(i, 1, 32)
    {
        tmp = 0;
        rep(j, 8)
        {
            tmp += (v[j] >> i);
            tmp &= 1;
        }
        if ((tmp + carry) % 2 == ((chk >> i) & 1))
        {
            key |= (0 << i);
        }
        else
        {
            key |= (1 << i);
        }
        unsigned int ncarry = carry;
        rep(j, 8)
        {
            if (((v[j] ^ key) >> i) & 1)
            {
                ncarry++;
            }
        }
        carry = ncarry / 2;
    }
    cout << hex << (key & 0xffffffff) << endl;
}

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

    rep(_, n)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
    char s1[5], s2[5];
    cin >> s1;
    cin >> s2;
    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)cout<<"Yes\n";
    else cout<<"No\n";
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 12
#define MAX_V 100

int
main(int argc, char **argv)
{
	int s[MAX_N];
	int c[MAX_V];
	int n, i;

	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		for (i = 0; i < MAX_V; ++i)
			c[i] = 0;

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

		int count = 0;
		while (true)
		{
			for (i = 0; i < MAX_V; ++i)
				c[i] = 0;

			for (i = 0; i < n; ++i)
				c[s[i]] += 1;

			for (i = 0; i < n; ++i)
			{
				if (s[i] != c[s[i]])
					break;
			}

			if (i >= n)
				break;

			count++;
			for (i = 0; i < n; ++i)
				s[i] = c[s[i]];
		}

		printf("%d\n", count);
		for (i = 0; i < n; ++i)
			printf("%d%c", s[i], (i < n - 1) ? ' ' : '\n');
	}

	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	unordered_map<string , int> c;
	while(n--){
		string s;
		cin>>s;
		c[s]++;
	}
	cout<<"AC x "<<c["AC"]<<endl<<"WA x "<<c["WA"]<<endl<<"TLE x "<<c["TLE"]<<endl<<"RE x "<<c["RE"]<<endl;
}

Measured memory_bytes: 3604
readint()=parse(Int,readline())
readints()=parse.(Int,split(readline()))
N=readint()
A=readints()

function ABC_B()
    s=1
    for i in A
        tmp=s*i
        if (tmp < 0 ) || (tmp>10^18) || (log(10^18)<(log(s)+log(i)))
            s=-1
            break
        end
        s*=i
    end
    s
end
if sum(A.==0)>0
    print(0)
else
    print(ABC_B())
end

Measured memory_bytes: 203252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, d[51];

    cin >> n;
    REP(i, n)
    cin >> d[i];

    ll res = 0;

    REP(i, n)
    {
        for (int j = i + 1; j < n; j++)
        {
            res += d[i] * d[j];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#define MAX_N 105
#define INF 1000000000
#define int long long

using namespace std;

struct Edge
{
	int dst,cap,rev;
	Edge(int _dst,int _cap,int _rev) { dst=_dst,cap=_cap,rev=_rev; }
	Edge(){}
};

int n,s,t,tot,sum=0;
int a[MAX_N];
int lv[MAX_N];
int it[MAX_N];
vector<Edge> edge[MAX_N];
queue<int> q;

void read()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
}

inline void add(int s,int t,int c)
{
	edge[s].push_back(Edge(t,c,edge[t].size()));
	edge[t].push_back(Edge(s,0,edge[s].size()-1));
}

void build()
{
	s=n+1,t=s+1,tot=t;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>0) add(s,i,a[i]),sum+=a[i];
		else add(i,t,-a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+i;j<=n;j+=i)
		{
			add(j,i,INF);
		}
	}
}

void bfs(int s)
{
	memset(lv+1,0,sizeof(int)*tot);
	q.push(s),lv[s]=1;
	while(!q.empty())
	{
		int x=q.front(); q.pop();
		for(int i=0;i<edge[x].size();i++)
		{
			Edge temp=edge[x][i];
			if(temp.cap>0 && !lv[temp.dst])
			{
				lv[temp.dst]=lv[x]+1;
				q.push(temp.dst);
			}
		}
	}
}

int dfs(int x,int t,int f)
{
	if(x==t) return f;
	for(int &i=it[x];i<edge[x].size();i++)
	{
		Edge &temp=edge[x][i];
		if(temp.cap>0 && lv[x]<lv[temp.dst])
		{
			int d=dfs(temp.dst,t,min(f,temp.cap));
			if(d>0)
			{
				temp.cap-=d,edge[temp.dst][temp.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t)
{
	int ans=0,f;
	while(true)
	{
		bfs(s);
		if(!lv[t]) return ans;
		memset(it+1,0,sizeof(int)*tot);
		while((f=dfs(s,t,INF))>0) ans+=f;
	}
}

void work()
{
	build();
	printf("%lld\n",sum-max_flow(s,t));
}

signed main()
{
	read();
	work();
}


Measured memory_bytes: 256
# TLEするっぽいなー
Q = int(input())
LR = [tuple(map(int,input().split())) for _ in range(Q)]

N = 100010
# まずは素数列挙
P = []
A = [True]*N
for i in range(2,N):
    if A[i]:
        P.append(i)
        j = 2
        while i*j < N:
            A[i*j] = False
            j += 1

# 整数iまでの「2017数」を数える
Ans = [0]*N
for p in P:
    if p==2:
        continue
    if (p+1)//2 in P:
        Ans[p] = 1

for i in range(1,N):
    Ans[i] += Ans[i-1]

for (l,r) in LR:
    print(Ans[r] - Ans[l-1])

Measured memory_bytes: 21468
#include <iostream>
using namespace std;
long long N, A[87],Money = 1000;
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)
  		cin >> A[i];
	for (int i = 1; i <= N - 1; i++) {
	long long Stocks = 0;
	if (A[i] < A[i + 1]) Stocks =Money / A[i];
	Money += (A[i + 1] - A[i]) * Stocks;
	}
	cout << Money << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

#define WINDOW(X,W) \
  ( (X) <= ( (W) / 2 ) + ( (W) % 2 ) ? (X) : (W) + 1 - (X) )
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int N, K;

  scanf ( "%d %d", &N, &K );

  while ( K-- )
  {
    int a, b;

    scanf ( " %d %d", &a, &b );
    a = WINDOW( a, N ); b = WINDOW( b, N );
    printf ( "%d\n", ( MIN( a, b ) - 1 ) % 3 + 1 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
        int g[] = new int[n];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (g[a - 1] < h[b - 1])
                g[a - 1] = h[b - 1];
            if (g[b - 1] < h[a - 1])
                g[b - 1] = h[a - 1];
        }
        sc.close();
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] > g[i]) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 59664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

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

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,a,b; cin>>n>>a>>b;
  int d = b-a;
  if(d%2) cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;

  return 0;
}


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

int cal_bound(int n, int x, int i, vector<int>& l, vector<int>& d);
 
int main(){
  int N, X; // N + 1 : 跳ねる回数、X : 領域
  int i = 1;
  cin >> N >> X;
  int count = 0; //現時点で跳ねた回数

  vector<int> L(N); 
  vector<int> D(N + 1);
  
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  D.at(0) = 0;

  count = cal_bound(N, X, i, L, D);
  cout << count << endl;

  return 0;
}

int cal_bound(int n, int x, int i, vector<int>& l, vector<int>& d){
  d.at(i) = l.at(i - 1) + d.at(i - 1);
  if(i < n && d.at(i) <= x){
    i++;
    return cal_bound(n, x, i, l, d);
  }else if(d.at(i) > x){
    return i;
  }else if(i >= n){
    return i + 1;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_V 100001

int perm[MAX_V], clr[MAX_V];

int find(int x) {
    if (x != clr[x]) {
        clr[x] = find(clr[x]);
    }
    return clr[x];
}

int main(void) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> perm[i];
        clr[i] = i;
    }
    for (int i = 0; i < m; ++i) {
        int aa, bb;
        cin >> aa >> bb;
        if (find(aa) == find(bb)) continue;
        clr[clr[bb]] = clr[aa];
    }
    for (int i = 1; i <= n; ++i) {
        find(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (clr[i] == clr[perm[i]]) ans++;
    }

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

Measured memory_bytes: 1024
import math
from itertools import combinations_with_replacement

n, p = map(int, input().split())
A = list(map(int, input().split()))
odd = []
even = []


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for a in A:
    if a % 2 == 0:
        even.append(a)
    else:
        odd.append(a)
even_count = []
for i in range(len(even)+1):
    even_count.append(combinations_count(len(even), i))
odd_odd_count = []
odd_even_count = []
for i in range(len(odd)+1):
    cnt = combinations_count(len(odd), i)
    if i % 2 == 1:
        odd_odd_count.append(cnt)
    else:
        odd_even_count.append(cnt)
ans = 0
if p == 0:
    for i in even_count:
        for j in odd_even_count:
            ans += i*j
else:
    for i in even_count:
        for j in odd_odd_count:
            ans += i*j

print(ans)


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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl

#define eps 1e-14

int main() {

	fast_cin;
	
	long long a,b,c,lf,ri;

	cin >> a >> b >> c;

	lf = (a * b * 4LL);
	ri = (c-a-b) * (c-a-b);

	if(c-a-b < 0) {
		cout << "No" << endl;
	} else if(lf < ri) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    R = int(readline())
    G = int(readline())
    ans = 2*(G-R)+R
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	LL n,x,ans=0,ans1=0,ans2=0;
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(x%4==0)
			ans+=2;
		else if(x%2==0)
			ans++;
	}
	printf(ans>=(n/2)*2?"Yes\n":"No\n");
    return 0;
}


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

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

      System.out.println(s.charAt(0) == s.charAt(1) && s.charAt(0) == s.charAt(2) ? "No" : "Yes");
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void yes(){
   cout<<"APPROVED"<<endl;
   //exit (0);
}
void no(){
   cout<<"DENIED"<<endl;
   //exit (0);   
}

int32_t main(){_

   cin >> n;

   for (int i = 0; i < n; ++i)
   {
      int x;
      cin >> x;
      if(x % 2)continue;
      if(x % 3 == 0 or x % 5 == 0){

      }
      else{
         no();
         exit(0);
      }
   }
   
   yes();
   // int a, b, c;
   // cin >> a >> b >> c;

   // set<int> s;
   // s.insert(a);
   // s.insert(b);
   // s.insert(c);

   // if ((int)(s.size()) == 2){
   //    yes();
   // }
   // else{
   //    no();
   // }
   

   return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a) cin >> i;
	ll ans = 1e18;
	for (int x = 1; x <= 100; ++x)
	{
		ll cur = 0;
		for (auto i : a)
			cur += (x - i) * (x - i);
		ans = min(ans, cur);
	}
	cout << ans << "\n";

	return 0;
}


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

int64_t PON(vector<int>a){
  int64_t sum = 0;
  int size = a.size()/3;
  for(int i = 0; i < size; ++i){
    sum += a.at(2*i + 1);
  }
  return sum;
}
  
int main(){
  int64_t N;
  cin >> N;
  vector<int>a(3*N);
  for(int i = 0; i < 3*N; ++i) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int64_t sum = PON(a);
  cout << sum << endl;
}
  

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll ans = 700;
  rep(i, 3) if (s[i] == 'o') ans += 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
b = [[0] * n for _ in range(2)]
b[0][0] = a[0][0]
for i in range(1, n):
  b[0][i] = b[0][i - 1] + a[0][i]
b[1][0] = b[0][0] + a[1][0]
for i in range(1, n):
  b[1][i] = max(b[1][i - 1], b[0][i]) + a[1][i]
print(b[1][n -1])


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

#define ll long long

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

    int x=0, ans =0;
    for(int i=0; i<n; ++i){
        if(s[i] =='I')
            x++;
        else
            x--;

        ans = max(ans, x);
    }
    cout << ans;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<P> vc(n);
    rep(i, n) cin>>vc[i].first;
    rep(i, n) cin>>vc[i].second;
    ll ans = 0;
    rep(i, n) {
        int d = vc[i].first - vc[i].second;
        if (d > 0) ans += d;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++)
	{
		int t;
		cin>>t;
		mp[t]=1;
	}
	int s1=0,s2=0;
	for(int i=0;i<x;i++)
	{
		s1+=mp[i];
	}
	for(int i=x+1;i<n;i++)
	{
		s2+=mp[i];
	}
	cout<<min(s1,s2)<<endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	string s; ll k;
	cin >> s >> k;
	int ans = 0;
	if(s[0] != '1'){
		cout << s[0] << endl;
		return;
	}
	ll f;
	rep(i,100) {
		if(s[i] != '1') {
			f = (ll)i; 
			break;
        }
	}
	if(f<k) cout << s[f] << endl;
	else cout << 1 << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	string s,s2 = "";
	cin >> s;
	s2=s;

	int ans1 = 0;
	int ans2 = 0;
	for(int i=0; i<s.length(); i++){
		if(i%2 == 0 && s[i] == '1'){
			s[i] = 0;
			ans1++;
		}
		if(i%2 == 1 && s[i] == '0'){
			s[i] = 1;
			ans1++;
		}
	}


	for(int i=0; i<s.length(); i++){
		if(s[i] == s2[i]) ans2++;
	}
	if(ans2 > ans1) cout << ans1 << endl;
	else cout << ans2 << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n; cin >> n;
   vector<ll> v(n+1, 0);
   v[1] = 1;
   for (int i = 2; i <= n; i++)
   {
      v[i] += 2;
      int j = i+i;
      for (; j <= n; j+=i){
         v[j] += 1;
      }
   }
   ll ans = 0;
   for (int i = 1; i <= n; i++)
      ans += i*v[i];
   cout << ans << endl;
}

Measured memory_bytes: 81344
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll ds(int b,ll n){
  ll sum=0;
  while(n){
    sum+=n%b;
    n/=b;
  }
  return sum;
}
int main(void){
  int n;
  ll x;
  scanf("%d %lld",&n,&x);
  ll a[n];
  FOR(n)scanf("%lld",&a[i]);
  ll ans=0;
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  }
  FOR(n-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      a[i+1]=x-a[i];
    }
  }
  PRL(ans);
  return 0;
}


Measured memory_bytes: 896
n = int(input())
abc = []
for i in range(n):
    abc.append(list(map(int,input().split())))
dp = [[0]*3 for i in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1,n):
    for j in range(3):
        for k in [1,2]:#j以外を選ぶ
            dp[i][j] = max(dp[i][j],\
            dp[i-1][(j+k)%3] +abc[i][j])
print(max(dp[-1]))


Measured memory_bytes: 47332
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

typedef vector<P> G;

double compare_x(const P &a, const P &b){
  return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}

double compare_y(const P &a, const P &b){
  return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
}

double convex_radius(P *a, int n){
    if(n <= 1) return INF;
    int m = n / 2;
    double x = a[m].X;
    double d = min(convex_radius(a, m), convex_radius(a + m, n - m));
    sort(a, a + n, compare_y);
    vector<P> b;
    for(int i = 0; i < n; ++i){
        if(fabs(a[i].X - x) >= d) continue;
        for(int j = 0; j < b.size(); ++j){
            double dx=a[i].X-b[b.size()-j-1].X;
            double dy=a[i].Y-b[b.size()-j-1].Y;
            if(dy >= d)break;
            d=min(d,sqrt(dx*dx+dy*dy));
              
        }
        b.push_back(a[i]);
    }
    return d;
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    double x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  sort(g.begin(), g.end(), compare_x);
  printf("%.10lf\n", convex_radius(&g[0], N));
  return 0;
}

Measured memory_bytes: 5616
import random
import math

def calc(D, solution):
    satisfaction = 0
    for i in range(D):
        satisfaction = S[i][solution[i]-1] + satisfaction - \
                       sum([C[k] * ((i + 1) - last[k]) for k in range(26)]) \
                       + C[solution[i]-1] * ((i + 1) - last[solution[i]-1])

    return satisfaction


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
satisfaction = 0
last = [0]*26
solution = []
# solution初期解
for i in range(D):
    best_sat = -100000000000
    for t in range(26):
        t_sat = S[i][t] + satisfaction - \
                sum([C[k]*((i+1)-last[k]) for k in range(26)]) + C[t]*((i+1)-last[t])
        # print(str(t)+'t:'+str(t_sat)+', b:'+str(best_sat))
        if t_sat > best_sat:
            best_T = t
            best_sat = t_sat

    satisfaction = best_sat
    last[best_T] = i + 1
    solution.append(best_T+1)

for i in range(100):
    r = math.ceil(random.random()*26)
    if r == 0:
        r = 1
    f = math.floor(random.random()*D)
    f_solution = solution
    f_solution[f] = r
    present_sat = calc(D,solution)
    new_sat = calc(D,f_solution)
    if new_sat > present_sat:
        solution = f_solution

for i in range(D):
    print(solution[i])

# print(satisfaction)


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

void bubbleSort(int l[], int N){
  int flag;

  flag = 1;
  for( int i = 0; flag; i++){
    flag = 0;
    for(int j = N-1; j > i; j--){
      if(l[j] < l[j-1]) {
        swap(l[j],l[j-1]);
        flag = 1;
      }
    }
  }
}

int main(){
  int N, K;
  int l[50],length = 0;

  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> l[i];

  //昇順にソートして、後ろからK本の和を出力
  bubbleSort(l, N);
  for( int i = N-1; i > N-K-1; i--) length += l[i];

  cout << length << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
  
  fscanf(STDIN,"%d %d %d",$W,$a,$b);




  if($b>$a+$W){
    echo $b-($a+$W)."\n";
  }elseif($b<$a){
    echo $a-($b+$W)."\n";
  }else{
    echo "0\n";
  }



  
  






Measured memory_bytes: 4604
#include<stdio.h>

int main()
{
	long n, b, i;
	long max = 0;
	long a[100000] = { 0 };
	scanf("%ld", &n);
	for (i = 0; i < n; i++) {
		scanf("%ld", &b);
		a[b - 1]++;
		a[b]++;
		a[b + 1]++;
	}
	for (i = 1; i < 100001; i++) {
		if (a[i] > max) {
			max = a[i];
		}
	}
	printf("%ld", max);
	return 0;
}

Measured memory_bytes: 896
#include<string>
#include<cctype>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 36 + 8;
/*template<class T>
void swap(T &a,T &b)
{
    T c = a;
    a = b;
    b = c;
}
*/
struct node{
    char c;
    int n;
};

node x[maxn],y[maxn],z[maxn];

int n,minj;
void bubbleSort(node y[])
{
    for(int i = 0; i < n; i++){
        for(int j = n-1; j >= i+1; --j){
            if(y[j].n < y[j-1].n){
                swap(y[j],y[j-1]);
            }
        }
    }
    return;
}

void  selectSort(node z[])
{
    for(int i = 0; i < n-1; ++i){
        minj = i;
        for(int j = i; j < n; ++j){
            if(z[j].n < z[minj].n){
                minj = j;
            }
        }
        swap(z[minj],z[i]);
    }
    return;
}

void see(node m[])
{
    for(int i = 0; i < n; ++i){
        printf("%s%c%d",i == 0 ? "" : " ",m[i].c,m[i].n);
    }
    printf("\n");
}

bool judge(node a[],node b[])
{
    int num = 0;
    for(int i = 0; i < n ;++i){
        if(a[i].c == b[i].c && a[i].n == b[i].n){
            num++;
        }
    }
    if(num == n) return true;
    return false;
}
int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; ++i){
        char ch = (char)getchar();
        scanf("%c%d",&x[i].c, &x[i].n);
        y[i].c = z[i].c = x[i].c;
        y[i].n = z[i].n = x[i].n;
    }
    bubbleSort(y);
    see(y);
    cout << "Stable" << endl;
    selectSort(z);
    see(z);
    printf("%s\n",judge(y,z) == 0 ? "Not stable" : "Stable");
    return 0;
}

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

int main(){

  string s;
  cin>>s;
  
  int a=s[0]-48;
  int b=s[1]-48;
  int c=s[2]-48;
  int d=s[3]-48;

  
  if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;

}




Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string S; cin >> S;
    
    ll ans = LINF;
    REP(i, 26){
        char c = i+'a';
        vl vcnt; ll idx = 0;
        while(idx < S.size()){
            ll cnt = 0;
            while(idx < S.size() && S[idx] != c){
                idx++; cnt++;
            }
            vcnt.pb(cnt);
            while(idx < S.size() && S[idx] == c) idx++;
        }
        ll tmp = 0;
        REP(k, vcnt.size()) tmp = max(tmp, vcnt[k]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() {
	char x, y; cin >> x >> y;
	int xx, yy;
	int a = 10, b = 11, c = 12;
	int d = 13, e = 14, f = 15;
	if(x=='A'){
		xx = a;
	}

	if(x=='B'){
		xx = b;
	}

	if(x=='C'){
		xx = c;
	}

	if(x=='D'){
		xx = d;
	}

	if(x=='E'){
		xx = e;
	}

	if(x=='F'){
		xx = f;
	}
	if(y=='A'){
		yy = a;
	}

	if(y=='B'){
		yy = b;
	}

	if(y=='C'){
		yy = c;
	}

	if(y=='D'){
		yy = d;
	}

	if(y=='E'){
		yy = e;
	}

	if(y=='F'){
		yy = f;
	}
	if(xx-yy<0){
		cout << '<' << endl;
		return 0;
	}
	if(xx-yy>0){
		cout << '>' << endl;
		return 0;
	}
	if(xx-yy==0){
		cout << '=' << endl;
	}
	return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;

    if(A <= 5){
        cout << 0 << endl;
    }else if(A <= 12){
        B /= 2;
        cout << B << endl;
    }else{
        cout << B << endl;
    }

}

Measured memory_bytes: 256