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

int main()
{
	int n,i;
	double x[1000];
	double v,ans,sum,average;
	while(1){
		scanf("%d", &n);
		if(!n){
			break;
		}
		sum=0;
		for(i=0; i<n; i++){
			scanf("%lf", &x[i]);
			sum+=x[i];
		}
		average=sum/(double)n;
		sum=0;
		for(i=0; i<n; i++){
			x[i]-=average;
			x[i]*=x[i];
			sum+=x[i];
		}
		v=sum/(double)n;
		ans=sqrt(v);
		printf("%f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2052
using System;
using System.Collections.Generic;

namespace ABC047_A_Fighting_over_Candys
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			List<int> numbers = new List<int>();
			numbers.Add(int.Parse(input[0]));
			numbers.Add(int.Parse(input[1]));
			numbers.Add(int.Parse(input[2]));
			
			numbers.Sort();

			if (numbers[0] + numbers[1] == numbers[2])
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-10-29
#

# Usage
#
"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import

def read_input():
    min_len = int(input())
    first_str = list(input())
    end_str = list(input())

    return min_len, first_str, end_str


def check_dup(first_str, end_str, min_len):
    """

    >>> check_dup("expr", "expr", 4)
    4
    >>> check_dup("a", "z", 1)
    2
    >>> check_dup("abc", "cde", 3)
    5
    >>> check_dup("expr", "expr", 5)
    8
    """
    for char_num in range(len(end_str), 0, -1):
        sub_f = first_str[char_num * -1:]
        sub_e = end_str[: char_num]

        if sub_f == sub_e:
            result = len(sub_f) + (len(end_str) - char_num) * 2
            if result < min_len:
                continue
            else:
                return result

    return len(first_str) + len(end_str)



if __name__ == "__main__":
    #import doctest
    #doctest.testmod()

    min_len, f, e = read_input()

    print(check_dup(f, e, min_len))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 12345
int a[N] = {};

int main(){
	FOR(i, 1, 101){
		FOR(j, 1, 101){
			FOR(k, 1, 101){
				int p = i*i + j*j + k*k + i*j + j*k + k*i;
				if(p < N) a[p]++;
			}
		}
	}
	int n; scanf("%d", &n);
	FOR(i, 1, n+1) printf("%d\n", a[i]);
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;

void solve() {
   ll n;
   cin>>n;

   vi vec(n);
   fo(i,0,n) cin>>vec[i];

   if(n == 2) {
        cout<<vec[1]<<" "<<vec[0]<<"\n";
        return;
   }
   ll xorr = 0;
   fo(i,0,n) xorr = xorr ^ vec[i];

   fo(i,0,n) {
     vec[i] = xorr ^ vec[i];
   }
   for(int i : vec) cout<<i<<" ";
   cout<<"\n";
}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=1e5+5,mod=1e9+7;
int n;
ll A,B,x[maxn];
int sum[maxn<<2][2],tag[maxn<<2][2];
void M(int x,int l,int r,int num,int id){
	tag[x][id]=num;
	sum[x][id]=1ll*num*(r-l+1)%mod;
}
void PD(int x,int l,int r){
	rep(i,0,1)if(tag[x][i]!=-1){
		M(ls,l,mid,tag[x][i],i);
		M(rs,mid+1,r,tag[x][i],i);
		tag[x][i]=-1;
	}
}
void U(int x){
	rep(i,0,1)sum[x][i]=(sum[ls][i]+sum[rs][i])%mod;
}
void M(int x,int l,int r,int ll,int rr,int num,int id){
	if(l==ll&&r==rr){
		M(x,l,r,num,id);
		return;
	}
	PD(x,l,r);
	if(rr<=mid)M(ls,l,mid,ll,rr,num,id);
	else if(ll>mid)M(rs,mid+1,r,ll,rr,num,id);
	else M(ls,l,mid,ll,mid,num,id),M(rs,mid+1,r,mid+1,rr,num,id);
	U(x);
}
int Q(int x,int l,int r,int ll,int rr,int id){
	if(l==ll&&r==rr)return sum[x][id];
	PD(x,l,r);
	if(rr<=mid)return Q(ls,l,mid,ll,rr,id);
	else if(ll>mid)return Q(rs,mid+1,r,ll,rr,id);
	else return (Q(ls,l,mid,ll,mid,id)+Q(rs,mid+1,r,mid+1,rr,id))%mod;
}
int main(){
	memset(tag,-1,sizeof tag);
	read(n);
	read(A);read(B);
	rep(i,1,n)read(x[i]);
	x[0]=-1e18;
	M(1,0,n,0,0,1,0);
	M(1,0,n,0,0,1,1);
	rep(i,1,n-1){
		ll mind=x[i+1]-(B-1);
		int pos=min(i-1,int(lower_bound(x,x+n+1,mind)-x-1));
		M(1,0,n,i,i,Q(1,0,n,0,pos,0),1);
		if(x[i+1]-x[i]<A)M(1,0,n,0,i-1,0,0);
		
		mind=x[i+1]-(A-1);
		pos=min(i-1,int(lower_bound(x,x+n+1,mind)-x-1));
		M(1,0,n,i,i,Q(1,0,n,0,pos,1),0);
		if(x[i+1]-x[i]<B)M(1,0,n,0,i-1,0,1);
	}
	printf("%d\n",(Q(1,0,n,0,n-1,0)+Q(1,0,n,0,n-1,1))%mod);
	return 0;
}

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

int N;
int a = 0, b = 0;

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        if(t % 4 == 0) a++;
        if(t % 2 == 1) b++;
    }
    if(a + b == N) {
        if(b <= a + 1) cout << "Yes";
        else cout << "No";
    }
    else {
        if(b <= a) cout << "Yes";
        else cout << "No";
    }
}


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


int main(void)
{
    int K, A, B;

    cin >> K >> A >> B;

    int ans = B/K - (A-1)/K;

    if(ans == 0){
        cout << "NG" << endl;
    } else {
        cout << "OK" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    LL(n, k);
    VEC(ll, a, n);
    sort(rall(a));
    ll ok = INF, ng = 0;
    while(ok - ng > 1){
        ll cnt = 0;
        ll mid = (ok + ng) / 2;
        REP(i, n) cnt += Roundup_div(a[i], mid) - 1;
        if(cnt > k) ng = mid;
        else ok = mid;
    }
    print(ok);
}

Measured memory_bytes: 4768
#lines = <<'EOS'
# 4
# 1 0 -1
# 0 2 -1
# 2 3 -1
# 3 -1 -1
#EOS

lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
Node = Struct.new(:parent, :left, :right)

nodes = Array.new(N) { Node.new }

def get_depth(id, nodes)
  d = 0
  while ! nodes[id].parent.nil? do
    id = nodes[id].parent
    d += 1
  end
  d
end

def get_height(id, nodes)
  #
  # puts "id = #{id}, left = #{nodes[id].left}, right = #{nodes[id].right}"
  #
  return -1 if nodes[id].nil? or id == -1

  left_id  = nodes[id].left.nil? ? -1 : nodes[id].left
  right_id = nodes[id].right.nil? ? -1 : nodes[id].right

  lefth  = get_height(left_id, nodes)
  righth = get_height(right_id, nodes)

  height = if lefth > righth
             lefth + 1
           else
             righth + 1
           end
  height
end

def get_sibling(id, nodes)
  if nodes[id].parent.nil?
    -1
  else
    pid = nodes[id].parent
    p = nodes[pid]

    #puts "p.right => #{p.right.class}, p.left #{p.left.class}"

    if p.left.nil? and p.right.nil?
      -1
    else
      if p.right == id
        return p.left.nil? ? -1 : p.left
      end
      if p.left  == id
        return p.right.nil? ? -1 : p.right
      end
    end
  end
end

for i in 1...(array.size)
  carray = array[i].split(" ")
  id    = carray[0].to_i
  left  = carray[1].to_i
  right = carray[2].to_i

  # puts "id #{id}, left #{left}, right #{right}"

  # set parents for each children
  nodes[left].parent  = id if left  != -1
  nodes[right].parent = id if right != -1

  # set left/right nodes
  nodes[id].left  = left if left != -1
  nodes[id].right = right if right != -1
end

for index in 0...nodes.size

  node = nodes[index]
  parent  = node.parent.nil? ? -1 : node.parent
  depth   = get_depth(index, nodes)
  sibling = get_sibling(index, nodes)

  degree = 0
  degree += node.right.nil? ? 0 : 1
  degree += node.left.nil?  ? 0 : 1

  height  = get_height(index, nodes)

  type = if node.parent.nil?
           "root"
         elsif degree == 0
           "leaf"
         else
           "internal node"
         end

  puts "node #{index}: parent = #{parent}, sibling = #{sibling}, degree = #{degree}, depth = #{depth}, height = #{height}, #{type}"
end

# node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
# node 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node
# node 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf
# node 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf
# node 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node
# node 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node
# node 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf
# node 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf
# node 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf

Measured memory_bytes: 8720
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int a, b, c; cin >> a >> b >> c;
  int ans = 100 * a + 10 * b + c;
  if(ans % 4 == 0) cout << "YES\n";
  else cout << "NO\n";
  return;
}

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


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b,c,s;
    scanf("%d%d%d",&a,&b,&c);
    s = 0;
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            s++;
        }
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2740
#create date: 2020-06-29 15:39

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    a_abs = list()
    zero = False
    minus = 0
    for ai in a:
        if ai < 0:
            minus += 1
        elif ai == 0:
            zero = True
        a_abs.append(abs(ai))
    
    if minus % 2 == 0 or zero:
        print(sum(a_abs))
    else:
        print(sum(a_abs) - 2 * min(a_abs))
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 20032
import bisect
from itertools import accumulate


N, M = map(int, input().split())
A = sorted(map(int, input().split()))

S = [0] + list(accumulate(A))


def calc(x):
    _total = 0
    _num = 0
    for i in range(N):
        j = bisect.bisect_left(A, x - A[i])
        _num += N - j
        _total += S[N] - S[j]
        _total += A[i] * (N - j)
    return _total, _num


left = 0
right = 200005

while right - left > 1:
    center = (left + right) // 2
    if calc(center)[1] >= M:
        left = center
    else:
        right = center

total, num = calc(left)
ans = total
ans -= (num - M) * left
print(ans)


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

using namespace std;
typedef pair<int, int> ii;

int n;
int arr[3001];

long long dp[3001][3001][2];
bool visited[3001][3001][2];

long long funct(int i, int j, bool mx) {

    if(i == j) {
        if(!mx) return -arr[i];
        return arr[i];
    }
    if(visited[i][j][mx]) {
        return dp[i][j][mx];
    }
    visited[i][j][mx] = 1;



    long long a = funct(i, j-1, mx^1);
    long long b = funct(i + 1, j, mx^1);
    if(mx) {
        dp[i][j][mx] = max(a + arr[j], arr[i] + b);
    } else {
        dp[i][j][mx] =  min(-arr[j] + a, -arr[i] + b);
    }

    return (dp[i][j][mx]);
}


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


    long long ans = funct(0, n-1, 1);
    // cout << dp[0][1][0] << " ";
    cout << ans ;
}

Measured memory_bytes: 158208
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N=300005;
LL q[N],c[N],f[N],g[N],f1[N],f2[N],sum1[N],sum2[N],ans[N];
int a[N],n,m;
void dp(LL *sum){
	memset(f,-0x3f,sizeof f);
	f[0]=0;
	int t=0;q[0]=c[0]=0;
	for (LL i=1;i<=n;i++){
		for (;t && (c[t]-c[t-1])<i*(q[t]-q[t-1]);t--);
		f[i]=max(f[i-1],i*(i+1)/2-sum[i]+c[t]-q[t]*i);
		LL j=f[i]+i*(i-1)/2+sum[i];
		for (;t && (c[t]-c[t-1])*(i-q[t])<(j-c[t])*(q[t]-q[t-1]);t--);
		q[++t]=i;c[t]=j;
	}
}
void dp2(LL *ff,LL *sum,int l,int mid,int r){
	int t=0;
	for (LL i=l-1;i<mid;i++){
		LL j=ff[i]+i*(i-1)/2+sum[i];
		for (;t>1 && (c[t]-c[t-1])*(i-q[t])<(j-c[t])*(q[t]-q[t-1]);t--);
		q[++t]=i;c[t]=j;
	}
	for (LL i=mid+1;i<=r;i++){
		for (;t>1 && (c[t]-c[t-1])<i*(q[t]-q[t-1]);t--);
		f[i]=i*(i+1)/2-sum[i]+c[t]-q[t]*i;
	}
}
void solve(int l,int r){
	if (l==r){
		ans[l]=max(ans[l],f1[l-1]+f2[n-l]+1-a[l]);
		return;
	}
	int mid=(l+r)>>1;
	dp2(f1,sum1,l,mid,r);
	for (int i=r;i>mid;i--) g[i]=f[i]+f2[n-i];
	for (int i=r-1;i>mid;i--) g[i]=max(g[i],g[i+1]);
	dp2(f2,sum2,n-r+1,n-mid,n-l+1);
	for (int i=l;i<=mid;i++) g[i]=f[n-i+1]+f1[i-1];
	for (int i=l+1;i<=mid;i++) g[i]=max(g[i],g[i-1]);
	for (int i=l;i<=r;i++) ans[i]=max(ans[i],g[i]);
	solve(l,mid);solve(mid+1,r);
}
int main(){
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) sum1[i]=sum1[i-1]+a[i];
	dp(sum1);
	memcpy(f1,f,sizeof f);
	for (int i=1;i<=n;i++) sum2[i]=sum2[i-1]+a[n-i+1];
	dp(sum2);
	memcpy(f2,f,sizeof f);
	memset(ans,-0x3f,sizeof ans);
	solve(1,n);
	scanf("%d\n",&m);
	for (int i=1;i<=m;i++){
		int p,x;
		scanf("%d%d",&p,&x);
		printf("%lld\n",max(f1[p-1]+f2[n-p],ans[p]+a[p]-x));
	}
}

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

int numDigits(int n){
	int digits = 0;
	while(n>0){
		digits++;
		n = n/10;
	}
	return digits;
}

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

	int n;
	cin >> n;
	int ans = 0;
	for(int i=1; i<=n; i++){
		if(numDigits(i)%2) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	string S,T;
	cin >> S >> T;
	/////////////////////
	
	int out = 0;
	rep( i, S.length() ) {
		if( S[i] != T[i] ) {
			++out;
		}
	}
	
	//////// 出力 ////////
	cout << out;
	/////////////////////
	
	return 0;
}
#if 0
#endif


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,s=0,a;
    cin>>n;
    a=n;
    while(n!=0)
    {
        s+=n%10;
        n/=10;
    }
    cout<<(a%s==0?"Yes":"No")<<endl;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, m;
    cin >> n >> m;

    int n2 = 2 * m + 1;

    int j1 = (m % 2 == 0 ? n2 - 1 - m / 2 : m + m / 2);
    int j2 = j1 + 1;
    for (int i = 0; i < m; i++) {
        cout << j1 + 1 << " " << j2 + 1 << newl;

        j1 = (j1 + n2 - 1) % n2;
        j2 = (j2 + 1) % n2;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int a, b; cin >> a >> b;

	cout << max({ a + b,a - b,a*b }) << endl;


	return 0;
}

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


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

    int ans=0;
    rep(i,n){
        int cnt=0;
        //forループはchar型でもできる
        for(char c='a'; c<='z'; c++){
            bool left=false, right=false;
            rep(j,i){
                if(s[j] == c)left=true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c)right =true;
            }
            if(left && right) cnt++;
        }
        if(ans<cnt) ans=cnt;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int def(int x, int y)
{
	if (y == 0)
	{
		return x;
	}
	else
	{
		return def(y, x%y);
	}
}
int main()
{
	int W, H, C, k, ans;
	cin >> W >> H >> C;
	if (W > H)
	{
		k=def(W, H);
	}

	{
		k=def(H, W);
	}
	ans = (W / k)*(H / k)*C;
	cout << ans << endl;
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  CIN(char, C);
  COUT(++C);
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b < c+d)
    cout << "Right" << endl;
  if(a+b > c+d)
    cout << "Left" << endl;
  if(a+b == c+d)
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, K;
    cin >> N >> K;
    vint d(K);
    vint snuke(N);
    for (size_t i = 0; i < K; i++)
    {
        cin >> d[i];
        for (size_t j = 0; j < d[i]; j++)
        {
            int a;
            cin >> a;
            a--;
            snuke[a]++;
        }
    }
    int ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (snuke[i] == 0)
            ans++;
    }

    cout << ans;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int N=3000;
int n,tot,ans;
ll prm[10005],a[100005],now[100005],tar[100005];
bool fl[10005],vis[100005];
map<ll,int> v;

void getprime(){
	fl[1]=1;
	for(int i=2;i<=N;i++){
		if(!fl[i]) prm[++tot]=i;
		for(int j=1;j<=tot&&i*prm[j]<=N;j++){
			fl[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

int main(){
	getprime();
	n=readint();
	for(int i=1;i<=n;i++) a[i]=readint();
	for(int i=1;i<=n;i++){
		ll tmp=a[i]; now[i]=tar[i]=1;
		for(int j=1;j<=tot&&prm[j]<=tmp;j++){
			if(tmp%prm[j]) continue;
			int cnt=0;
			while(tmp%prm[j]==0) tmp/=prm[j],cnt++;
			cnt%=3;
			if(cnt==1) now[i]*=prm[j],tar[i]*=prm[j]*prm[j];
			else if(cnt==2) now[i]*=prm[j]*prm[j],tar[i]*=prm[j];
			if(tar[i]>1e10){
				vis[i]=true,ans++,tmp=1;
				break;
			}
		}
		if(tmp>1){
			ll tst=sqrt(tmp);
			if(tmp<N*N){
				if(!vis[i]&&tmp>100000) ans++,vis[i]=true;
				else if(!vis[i]&&tmp>=0) now[i]*=tmp,tar[i]*=tmp*tmp;
			}
			else if(tst*tst!=tmp) vis[i]=true,ans++;
			else now[i]*=tst*tst,tar[i]*=tst;
		}
		if(!vis[i]) v[now[i]]++;
	}
//	cout<<"test "<<ans<<endl;
//	for(int i=1;i<=n;i++) cout<<now[i]<<' '<<tar[i]<<endl;
	for(int i=1;i<=n;i++){
		if(now[i]==1&&v[1]){
			ans++,v[1]=0;
			continue;
		}
		ans+=max(v[now[i]],v[tar[i]]);
		v[now[i]]=v[tar[i]]=0;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
 	cin.tie(0);  
	int mx = 450;
	int inf = 1e8;
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vector<vector<int>> d(mx, vector<int>(mx, inf));
	d[0][0] = 0;
	for(int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		for(int j = mx - a - 1; j >= 0; j--) {
			for(int k = mx - b - 1;  k >= 0; k--) {
				d[j + a][k + b] = min(d[j][k] + c, d[j + a][k + b]);
			}
		}
	}
	int ans = inf;
	for(int i = 1; i < mx; i++) {
		for(int j = 1; j < mx; j++) {
			if(i * mb == j * ma) {
				ans = min(ans, d[i][j]);
			}
		}
	}
	if(ans == inf) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int X;
  int sum = 0;
  rep(i, N) {
    cin >> vec.at(i);
  }
  rep(i, N) {
      cin >> X;
  vec.at(i) -= X;
    if(vec.at(i) > 0) {
      sum += vec.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
struct ufds {
    vector<int> p;
    ufds(int n) : p(n + 1) {
        iota(p.begin(), p.end(), 0);
    }
    int find(int u) {
        return p[u] == u ? u : p[u] = find(p[u]);
    }
    void onion(int u, int v) {
        if(find(u) != find(v)) {
            p[find(u)] = find(v);
        }
    }
};
struct ufds_with_rank : public ufds {
    template <typename signature> using f = const function<signature>;
    vector<int> rank;
    f<void(int, int)> merge; // merge u into v
    ufds_with_rank(int n, f<void(int, int)> merge = [](int, int) {}) : ufds(n), rank(n + 1, 1), merge(merge) {}
    void onion(int u, int v) {
        int u_root = find(u), v_root = find(v);
        if(u_root != v_root) {
            if(rank[v_root] < rank[v_root]) swap(u_root, v_root);
            rank[v_root] += rank[u_root];
            merge(u_root, v_root);
            ufds::onion(u_root, v_root);
        }
    }
    int get_rank(int u) {
        return rank[find(u)];
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edges;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        edges.push_back({u, v});
    }
    ufds_with_rank uf(n);
    vector<ll> ans(m);
    ans[m - 1] = (ll) n * (n - 1) / 2;
    for(int i = m - 1; i >= 1; i--) {
        if(uf.find(edges[i].first) == uf.find(edges[i].second)) {
            ans[i - 1] = ans[i];
        } else {
            ans[i - 1] = ans[i] - (ll) uf.get_rank(edges[i].first) * uf.get_rank(edges[i].second);
            uf.onion(edges[i].first, edges[i].second);
        }

    }
    for(int i = 0; i < m; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int dp[5000][5000];

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	string s; cin >> s;
	int mod = 1e9 + 7;
	dp[0][1] = 1;
	dp[0][2] = 1;
	dp[0][3] = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i - 1] == '>')
			for (int j = 1; j <= i + 1; ++j)
				dp[i][j] = ((dp[i - 1][i] - dp[i - 1][j - 1]) + mod) % mod;
		else
			for (int j = 1; j <= i + 1; ++j)
				dp[i][j] = dp[i - 1][j - 1];
		for (int j = 1; j <= i + 2; ++j)
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
	}
	cout << dp[n - 1][n];
}

Measured memory_bytes: 117376
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Integer> que = new PriorityQueue<Integer>();
		for(int i = 0; i < n; i++) {
			que.add(-1 * sc.nextInt());
		}
		for(int i = 0; i < m; i++) {
			int max = que.poll()/2;
			que.add(max);
		}
		long sum = 0;
		for(int i = 0; i < n; i++) {
			sum -= que.poll();
		}
		System.out.println(sum);
		sc.close();
	}

}

Measured memory_bytes: 61952
#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>
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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h;
  while(cin>>h,h) {
    int in[h][5];
    FOR(i,0,h) {
      FOR(j,0,5) {
        cin >> in[i][j];
      }
    }
    vector<queue<int> > Q(5);
    for(int i = h - 1; i >= 0; i--) {
      FOR(j,0,5) {
        Q[j].push(in[i][j]);
      }
    }
    // ?¶??????????0
    bool end = true;
    int ans = 0;
    FOR(x,0,6) {
      // ?¶?????????????0
      int num[h][5];
      FOR(i,0,h) {
        FOR(j,0,5) {
          num[i][j] = Q[j].empty() ? 0 : Q[j].front();
          if(!Q[j].empty()) Q[j].pop();
        }
      }
      FOR(i,0,h) {
        int cnt = 1;
        FOR(j,0,4) {
          if(num[i][j] != 0 && num[i][j] == num[i][j+1]) cnt++;
          else {
            if(cnt >= 3) {
              end = false;
              int k = j;
              while(cnt--) {
                ans += num[i][k];
                num[i][k] = 0;
                k--;
              }
            }
            cnt = 1;
          }
        }
        if(cnt >= 3) {
          end = false;
          int k = 4;
          while(cnt--) {
            ans += num[i][k];
            num[i][k] = 0;
            k--;
          }
        }
      }
      if(end) break;
      // ????????????
      FOR(i,0,h) FOR(j,0,5) {
        if(num[i][j] != 0) Q[j].push(num[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int N;
int A, B, C;
vector<int> l(8);
int v = 100000;

void dfs(int cost, int n, int a, int b, int c){
    if(n == N){
        if(a == 0 || b == 0 || c == 0)return;
        cost += abs(A - a) + abs(B - b) + abs(C - c) - 30;
        v = min(cost, v);
        return;
    }
    dfs(cost+10, n+1, a+l[n], b, c);
    dfs(cost+10, n+1, a, b+l[n], c);
    dfs(cost+10, n+1, a, b, c+l[n]);
    dfs(cost, n+1, a, b, c);
}

int main(){
    
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }

    dfs(0, 0, 0, 0, 0);
    cout << v << endl;
   
    return 0;
}

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

using namespace std;
using ll = long long;

int digits[5];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(digits, -1, sizeof(digits));
    int n, m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int s, c;
        cin>>s>>c;
        if(s==1 && c==0){
            if(n!=1) {
                cout << -1;
                return 0;
            }
        }
        if(digits[s]!=-1 && digits[s] != c){
            cout<<-1;
            return 0;
        }
        digits[s] = c;
    }
    for(int i=1;i<=n;i++){
        if(digits[i] == -1) {
            if(i==1 && n!=1) cout<<1;
            else cout<<0;
        }
        else cout<<digits[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll N, K;

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

  ll ans = 0;
  for (int m = 1; m*K <= 2*N; ++m) {
    if (m*K % 2 == 1) continue;
    ll a = m*K/2;
    ll tmp = (N+a)/K - (a+K)/K +1;
    ans += tmp*tmp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
S = input()

ans = 1
for x in Counter(S).values():
	ans *= x+1
	ans %= mod
print((ans-1)%mod)



Measured memory_bytes: 10644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=100050;
int n,m;
ll a[maxn],b[maxn<<1],c[maxn<<1];
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(register int i=1;i<n;i++){
		if(a[i+1]==a[i])continue;
		if(a[i+1]<a[i])b[a[i+1]+m+1]--,b[a[i]+1]++,c[a[i+1]+m+1]-=a[i+1]+m-a[i];
		else b[a[i]+1]++,b[a[i+1]+1]--,c[a[i+1]+1]-=a[i+1]-a[i];
	}
	ll tot=0;
	for(register int i=1;i<=2*m;i++)b[i]+=b[i-1];
	for(register int i=1;i<=2*m;i++)c[i]+=c[i-1]+b[i];
	for(register int i=1;i<=m;i++)b[i]+=b[i+m],c[i]+=c[i+m],tot+=b[i];
	ll ans=99999999999999LL;
	for(register int i=1;i<=m;i++)ans=min(ans,tot-c[i]+b[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int ans,h,w,f,g,k;
bool canvis[810][810],vis[810][810];
queue<pair<int,int> > Q;
queue<int> lenQ;
void BFS(int y,int x,int len){
	if(vis[y][x]==true)return;
	vis[y][x]=true;
	int pnt=min(x,y);
	pnt=min(pnt,h-y-1);
	pnt=min(pnt,w-x-1);
	ans=min(ans,pnt);
	if(len==k)return;
	
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	for(int i=0;i<4;i++){
		f=y+dy[i],g=x+dx[i];
		if(f>=0&&g>=0&&f<h&&g<w){
			if(canvis[f][g]&&!vis[f][g]){
				Q.push(make_pair(f,g));
				lenQ.push(len+1);
			}
		}
	}
}
int main(){
	cin>>h>>w>>k;
	ans=1145141919;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char z;
			cin>>z;
			canvis[i][j]=true;
			if(z=='#')canvis[i][j]=false;
			if(z=='S')f=i,g=j;
			vis[i][j]=false;
		}
	}
	Q.push(make_pair(f,g));
	lenQ.push(0);
	while(!Q.empty()){
		BFS(Q.front().first,Q.front().second,lenQ.front());
		Q.pop(),lenQ.pop();
	}
	int outs=ans/k+1;
	if(ans%k>0)outs++;
	cout<<outs<<endl;
	return 0;
}


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func main() {
	sc = initScanner(os.Stdin)
	A, B, M := scanInt(sc), scanInt(sc), scanInt(sc)

	a := make([]int, A)
	for i := 0; i < A; i++ {
		a[i] = nextInt(sc)
	}

	b := make([]int, B)
	for i := 0; i < B; i++ {
		b[i] = nextInt(sc)
	}

	min := math.MaxInt64
	for i := 0; i < M; i++ {
		tmp := a[scanInt(sc)-1] + b[scanInt(sc)-1] - scanInt(sc)

		if min > tmp {
			min = tmp
		}

	}

	sort.Ints(a)
	sort.Ints(b)
	tmp := a[0] + b[0]
	if min > tmp {
		min = tmp
	}

	fmt.Println(min)
}

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
string a[5];
int main(void)
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[1]+a[2]+a[3]=="557")cout<<"YES";else cout<<"NO";
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif
 
int main(){
	std::string buf;
	std::vector<int> vec;
	std::vector<int> tmp;


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		vec.resize(buf.size(), 0);
		for(int i = 0; i < buf.size(); i++){
			vec[i] = buf[i] - '0';
		}

		while(vec.size() >= 2){
			tmp.resize(vec.size() - 1, 0);
			for(int i = 0; i < vec.size() - 1; i++){
				tmp[i] = (vec[i] + vec[i + 1]) % 10;
			}
			vec = tmp;
		}
		std::cout << vec[0] << std::endl;
	}
 

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
const double eps=1e-10;
const int maxn = 100;

struct Point
{
    double x,y;
};

Point p[maxn];

double dist(Point A,Point B)
{
    return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}

/***返回三角形的外心 */
Point circumcenter(Point A,Point B,Point C)
{
    Point ret;
    double a1=B.x-A.x,b1=B.y-A.y,c1=(a1*a1+b1*b1)/2.0;
    double a2=C.x-A.x,b2=C.y-A.y,c2=(a2*a2+b2*b2)/2.0;
    double d=a1*b2-a2*b1;
    ret.x=A.x+(c1*b2-c2*b1)/d;
    ret.y=A.y+(a1*c2-a2*c1)/d;
    return ret;
}

/***c为圆心，r为半径 */
void min_cover_circle(Point *p,int n,Point &c,double &r)
{
    random_shuffle(p,p+n);      //将n个点随机打乱
    c=p[0]; r=0;
    for(int i=1;i<n;i++)
    {
        if(dist(p[i],c)>r+eps)   //第一个点
        {
            c=p[i]; r=0;
            for(int j=0;j<i;j++)
                if(dist(p[j],c)>r+eps)  //第二个点
                {
                    c.x=(p[i].x+p[j].x)/2.0;
                    c.y=(p[i].y+p[j].y)/2.0;
                    r=dist(p[j],c);
                    for(int k=0;k<j;k++)
                        if(dist(p[k],c)>r+eps)  //第三个点
                        {   //求外接圆圆心，三点必不共线
                            c=circumcenter(p[i],p[j],p[k]);
                            r=dist(p[i],c);
                        }
                }
        }
    }
}

int main()
{
	//freopen("a.txt", "r", stdin);
    int n;
    Point c;
    double r;
    scanf("%d", &n);
    for(int i=0; i< n; i++)
        scanf("%lf%lf",&p[i].x,&p[i].y);
    min_cover_circle(p, n, c, r);
    printf("%.10lf\n", r);
    return 0;
}

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

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  tuple<double, double, double> s,t;
  double xs, ys, xt, yt;
  cin >> xs >>  ys >>  xt >>  yt;
  s=make_tuple(xs, ys,0);
  t=make_tuple(xt, yt,0);
  ll N;
  cin >> N;
  tuple<double, double, double> cor[N+2];
  double x,y,r;
  rep(i,N){
    cin >> x>> y>> r;
    cor[i] = make_tuple(x,y,r);
  }
  cor[N] = make_tuple(xs, ys,0);
  cor[N+1] = make_tuple(xt, yt,0);
  WeightedGraph<double> g(N+2);
  rep(i,N+2){
    for(int j=i+1;j<N+2;j++ ){
      double dist = sqrt((get<0>(cor[i]) -get<0>(cor[j])) * (get<0>(cor[i]) -get<0>(cor[j])) +
		     (get<1>(cor[i]) -get<1>(cor[j])) * (get<1>(cor[i]) -get<1>(cor[j])))
	- (get<2>(cor[i]) + get<2>(cor[j]));
      if(dist < 0) dist =0;
      g[i].emplace_back(j,dist);
      g[j].emplace_back(i,dist);    
    }
  }
  cout << std::fixed;
  cout << std::setprecision(10) << dijkstra(g, N)[N+1] << endl;
  return 0;
    

}


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

int main()
{
    double a,b;
    cin>>a>>b;
    double c=(a/b);
    int d=a, e=b;
    printf("%d %d %.7f\n", d/e, d%e, c);
    return 0;
}



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


int main() {
    ll n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> v(s.length()+1,0);
    rep(i,n){
        if(s[i] == 'A' && s[i+1] == 'C'){
            s[i] = 'a';
            v[i+1] += v[i] + 1;
        }
    }
    rep(i,n)if(i!=0)v[i] += v[i-1];
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        cout << v.at(r-1) - v.at(l-1)<< endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main() {
string ans="No";
	int N,M;
	cin>>N>>M;
  vector<string> A(N),B(M);
	for(int i=0; i<N; i++){
      cin>>A.at(i);}
  for(int i=0; i<M; i++){
      cin>>B.at(i);}
  
  for(int i=0; i<N-M+1; i++){
    for(int k=0; k<N-M+1;k++){
    if(A.at(i).at(k)==B.at(0).at(0)){
         for(int j=0; j<M; j++){
              for(int l=0; l<M; l++){
           if(A.at(i+j).at(k+l)!=B.at(j).at(l)) goto next;}}
    ans="Yes";goto last;  next :  ans=ans;}}}    
      last:
      cout<<ans<<endl;
}


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

int main()
{
    int n,a[100];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    cout << *max_element(a,a+n) - *min_element(a,a+n) << endl;

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	#define MAXN 200*1000
	vector<bool> comp(MAXN);
	
	for(int i = 2; i < MAXN; i++) {
		if(comp[i]) continue;
		for(int j = 2*i; j < MAXN; j += i) {
			comp[j] = true;
		}
	}
	
	int x;
	cin >> x;
	for(int i = x; i < MAXN; i++) {
		if(!comp[i]) {
			cout << i << endl;
			return 0;
		}
	}
	assert(false);
}


Measured memory_bytes: 256
from collections import defaultdict
import sys

h,w=map(int,input().split())
costs=[]
for _ in range(10):
  costs.append(list(map(int,input().split())))
dd=defaultdict(lambda:0)
for i in map(int,sys.stdin.read().split()):
  dd[i]+=1
  
min_costs=[float("inf")]*10
for y in range(10):
  min_costs[y]=costs[y][1]

for _ in range(100):
  for x in range(10):
    if x==1:
      continue
    for y in range(10):
      min_costs[y]=min(min_costs[y], min_costs[x]+costs[y][x])

ans=0
for i in range(10):
  ans+=dd[i]*min_costs[i]
print(ans)


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

int main() {
  int n;
  cin >> n;
  int r = 0;
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    if (i % 2 == 0 && e % 2 != 0) r++;
  }
  cout << r << endl;
}


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


int main(){

  int N, K;
  cin >> N >> K;
  int l[60];

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

  sort(l,l + N, greater<int>());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += l[i];
  }
  cout << ans << endl;

  return 0; 
}

Measured memory_bytes: 256
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	long long k;cin>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	vector<int> v;
	v.push_back(0);
	vector<int> used(n,0);
	used[0]=1;
	long long s;
	while(1){
		v.push_back(a[v.back()]);
		used[v.back()]++;
//		cout<<v.back()<<endl;
		if(used[v.back()]==2){
			s=v.size()-1;
			break;
		}

	}
//	cout<<s<<endl;
//	cout<<v[s]<<endl;
	long long f;
	for(int i=0;i<v.size();i++){
		if(v[i]==v[s]){
			f=i;
			break;
		}
	}
//	cout<<f<<endl;
	if(k<f){
		cout<<v[k]+1<<endl;
		return 0;
	}
	k-=f;
	k%=s-f;
//	k=k%(s-f)-f;
	int ans=v[f+k];
//	for(int i=0;i<v.size();i++){
//		cout<<v[i]<<' ';
//	}cout<<endl;
//	cout<<f<<' '<<s<<endl;
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 5888