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

typedef long long LL;
typedef unsigned long long ULL;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

const int maxn = 3e5 + 7;
const int inf  = 2e9 + 7;
const int mod  = 1e9 + 7;

struct{
    int u,v,w,next;
}edge[maxn];
int head[maxn];
int cnt=0;
void add(int u,int v,int w)
{
    edge[cnt].u=u;
    edge[cnt].v=v;
    edge[cnt].w=w;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
LL dis[maxn];
void dfs(int from,int now,LL tot)
{
   if(dis[now]==-1)
       dis[now]=tot;
   for(int i=head[now];i!=-1;i=edge[i].next) 
       if(edge[i].v!=from)
       dfs(now,edge[i].v,tot+edge[i].w);
}

int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    //ios::sync_with_stdio(false);
    memset(head,-1,sizeof(head));
    memset(dis,-1,sizeof(dis));
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        add(a,b,c);
        add(b,a,c);
    }
    int q,k;
    scanf("%d%d",&q,&k);
    dfs(-1,k,0);
    while(q--)
    {
        int x,y;
       scanf("%d%d",&x,&y);
       printf("%lld\n",dis[x]+dis[y]);
    }
    return 0;
}



Measured memory_bytes: 14720
#include <iostream>


int main()
{
    int n,m,tes;
    std::cin >> n >> m;
    int vec[n][m];
    int ret[m];
    for(int a=0;a<n;a++){
        for(int b=0;b<m;b++){
            std::cin >> vec[a][b];
        }
    }
    for(int c=0;c<m;c++){
        std::cin >> ret[c];
    }

    for(int d=0;d<n;d++){
        int co=0;
        for(int e=0;e<m;e++){
            tes=vec[d][e]*ret[e];
            co=co+tes;
        }
        std::cout << co << std::endl;
    }
}

Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A < B && A <= C && C <= B || A > B && B<=C && C<=A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int m;
  cin >> m;
  i64 sum = 0;
  i64 keta = 0;
  rep(i, m) {
    i64 d, c;
    cin >> d >> c;
    sum += d * c;
    keta += c;
  }
  cout << (sum - 1) / 9 + (keta - 1) << endl;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    map<ll, ll> m;
    vector<ll> A;
    ll sum = 0;
    cin >> N;
    A.resize(N);
    for(ll i = 0;i < N;i++) {
        cin >> A[i];
        m[A[i]] += 1;
    }
    for(auto &a: m) sum += a.second * (a.second - 1) / 2;
    for(ll i = 0;i < N;i++) {
        ll temp = m[A[i]] - 1;
        cout << sum - temp << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
def getlist():
	return list(map(int, input().split()))

N, K = getlist()

if N == 2:
	if K == 0:
		print(1)
		print(1, 2)
	else:
		print(-1)
else:
	if K > int((N - 1) * (N - 2) // 2):
		print(-1)
	else:
		M = N - 1 + (int((N - 1) * (N - 2) // 2) - K)
		print(M)
		for i in range(1, N):
			print(i, N)
		x = int((N - 1) * (N - 2) // 2) - K
		v = 1
		for i in range(1, N):
			for j in range(i + 1, N):
				if v <= x:
					print(i, j)
					v += 1
				else:
					break


Measured memory_bytes: 3616
n, m, x, y =map(int,input().split(" ")) 
li_x = list(map(int,input().split(" ")))
li_y = list(map(int,input().split(" ")))

li_x.extend([x])
li_y.extend([y])

max_x = max(li_x)
min_y = min(li_y)

if max_x < min_y:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3064
input_line = gets.to_i
line = readlines.map(&:chomp)
input_line.times do |i|
  if i > 0 then
    if line[i-1][(line[i-1].size)-1].eql? line[i][0] then
      0.upto(i-1) do |j|
        if line[i].eql? line[j] then
          puts "No"
          exit
        end
      end
    else
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 1788
#include <stdio.h>

int main(){
	int stock[11];
	int i = 0;
	int n;
	
	while(scanf("%d",&n) != EOF){
		if(n == 0){
			printf("%d\n",stock[i]);
			i--;
		}else{
			i++;
			stock[i] = n;
		}
	}
	
	return 0;
}

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

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

using namespace std;

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

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

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

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

    }
}

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

}

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

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

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

    int x;
    cin >> x;
    int t = 1;
    int c = 2;
    while( t < x ) {
        t += c;
        ++c;
    }
    cout << c - 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#define max(a,b) ((a)>=(b)?(a):(b))
int main() {
	int s=0,t=0,p;
	for(int i=0;i<4;i++)
		scanf("%d",&p),s+=p;
	for(int i=0;i<4;i++)
		scanf("%d",&p),t+=p;
	printf("%d\n",max(s,t));
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
string s;

ll digit(ll p){
	ll r = 0;
	while(p > 0){
		p /= 10;
		r++;
	}
	return r;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll ans = 10;
	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			ans = min(max(digit(i), digit(n/i)), ans);
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    rep(i, A + 1) {
        rep(j, B + 1) {
            rep(k, C + 1) {
                if (i * 500 + j * 100 + k * 50 == X) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
A,B,C = map(int,input().split())

# maxのeven/oddが他の2つとあってれば、2ずつ進めればOK
# maxのeven/oddが他の2つと完全相違（他の2つは一致）なら、その2つを1ずつ増加させて上に帰着
# maxのeven/oddが他の2つのうち片方とあってたら、maxと合致した2つを1ずつ増加させて上に帰着
# というか整理するとmax/min関係なく、まず3つの偶奇をそろえる
# その上でmaxとの距離を2ずつ進める
cnt = 0

p,q,r = A%2, B%2, C%2

if p+q+r == 1:
  if p == 0:
    A += 1
  if q == 0:
    B += 1
  if r == 0:
    C += 1
  cnt += 1

if p+q+r == 2:
  if p == 1:
    A += 1
  if q == 1:
    B += 1
  if r == 1:
    C += 1
  cnt += 1

maxn = max(A,B,C)

cnt += (3*maxn - (A+B+C))//2

print(cnt)

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

int main() {
  int64_t N;
  cin>>N;
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  bool age;
  for(int i=1;i<N;i++){
    if(vec.at(i)==vec.at(i-1)) continue;
    else if(vec.at(i)>vec.at(i-1)){
      age=true;
      break;
    }
    else{
      age=false;
      break;
    }
  }
  int64_t kai=1;
  for(int i=1;i<N;i++){
    if(age){
      if(vec.at(i)>=vec.at(i-1)) continue;
      else{
        kai++;
        for(int j=i+1;j<N;j++){
          if(vec.at(j)==vec.at(j-1)) continue;
          else if(vec.at(j)>vec.at(j-1)){
            age=true;
            break;
          }
          else{
            age=false;
            break;
          }
        }
      }
    }
    else{
      if(vec.at(i)<=vec.at(i-1)) continue;
      else{
        kai++;
        for(int j=i+1;j<N;j++){
          if(vec.at(j)==vec.at(j-1)) continue;
          else if(vec.at(j)>vec.at(j-1)){
            age=true;
            break;
          }
          else{
            age=false;
            break;
          }
        }
      }
    }
  }
  cout<<kai<<endl;
        
    
  
}

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

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

  int N;
  cin >> N;
  vector<pair<int, int>> task;
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(b, a);
    task.push_back(p);
  }
  sort(task.begin(), task.end());
  int time = 0;
  for(int i = 0; i < N; i++){
    time += task.at(i).second;
    if(time > task.at(i).first){
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
}

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

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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> p(N);
    rep(i, N) cin >> p[i].second >> p[i].first;
    int ans;
    sort(p.begin(), p.end());

    int nowtime = 0;
    rep(i, N){
        if(nowtime > p[i].first - p[i].second){
            cout << "No" << endl;
            return 0;
        }

        nowtime += p[i].second;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 1e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) {return lower_bound(C + 1, C + len, v) - C;}
void initC() { sort(C + 1, C +1+ clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

int l[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
    int n; cin >> n;
    f(i, 1, n)cin >> l[i];
    sort(l + 1, l + 1 + n);
    int ans = 0;
    f(i, 1, n)f(j, i + 1, n)f(k, j + 1, n) {
        if(l[i]!=l[j]&&l[j]!=l[k])
        if (l[i] + l[j] > l[k])ans++;
    }
    cout << ans;

#ifdef local
    int end = clock();
    cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int i,j;
        int a,b;
        while(true) {
            str = scan.nextLine();
            String[] num = str.split(" ", 0);
            a = Integer.valueOf(num[0]);
            b = Integer.valueOf(num[1]);
            if(a==0&&b==0){
                break;
            }
            
            for (i = 0; i < a; i++) {
                for (j = 0; j < b; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
        scan.close();
    }
}


Measured memory_bytes: 33284
package main

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

type MyScanner struct {
	sc *bufio.Scanner
}

type MyWriter struct {
	stdout io.Writer
}

type MyPut interface{}

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func (mysc *MyScanner)String() string {
	mysc.sc.Scan()
	return mysc.sc.Text()
}

func (mysc *MyScanner)Int() int {
	i, _ := strconv.Atoi(mysc.String())
	return i
}

func (mysc *MyScanner)Int64() int64 {
	i, _ := strconv.ParseInt(mysc.String(), 10, 64)
	return i
}

func (mysc *MyScanner)Float64() float64 {
	i, _ := strconv.ParseFloat(mysc.String(), 64)
	return i
}

func (mw MyWriter)Puts(v MyPut) {
	_, _ = fmt.Fprintf(mw.stdout, "%v\n", v)
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := MyScanner{getScanner(stdin)}
	mw := MyWriter{stdout}

	n := sc.Int()

	ans := 1

	for i := 0; i < 3; i++ {
		ans *= n
	}

	mw.Puts(ans)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 640
S = input()

ans = 0
for i in range(2 ** (len(S)-1)):
    s = S[0]
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            s += '+' + S[j+1]
        else:
            s += S[j+1]
    ans += eval(s)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "No"; return;}

void solve() {
    int n, k, c = 0;
    string s;
    cin >> n >> k >> s;
    loop(i, n)
        c += i && s[i] != s[i - 1];
    cout << (c <= k * 2 ? n - 1 : n - 1 - c + k * 2);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3768
#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 z(int a){
  if(a<1)a*=-1;
  return 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;
}
int main(void){
  int t,n,a,b;
  while(1){
    scanf("%d",&t);
    if(!t)break;
    scanf("%d",&n);
    int sum=0;
    FOR(n){
      scanf("%d %d",&a,&b);
      sum+=b-a;
    }
    if(sum>=t){
      PRS("OK");
    }else{
      PRN(t-sum);
    }
  }
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}
const ll INF = 1LL<<60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, R;
    cin >> n >> m >> R;

    vvll d(n, vll(n, INF));
    rep(i, n) d[i][i] = 0;

    vi r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    } 
    rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
    ll ans = INF;
    sort(all(r));
    do {
        ll now = 0;
        rep(i, R-1) {
            now += d[r[i]][r[i+1]];
        } 
        chmin(ans, now);
    } while (next_permutation(all(r)));
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, r, n) for (int i = (r); i <= (n); i++)

using ll = long long;
using namespace std;

ll a[500], sum[500], ans[500][500];
const ll INF = 100100100100100;

ll solve(int left, int right){
    if(right - left <= 1) return 0;
    if(ans[left][right] != 0) return ans[left][right];
    ll res = INF;
    loop(i, left+1, right-1) res = min(res, solve(left,i) + solve(i,right));
    res += sum[right] - sum[left];
    return ans[left][right] = res;
}

int main(){
    int n; cin >> n;
    rep(i,n) cin >> a[i], sum[i+1] = a[i]+sum[i];
    cout << solve(0,n) << endl;
    return 0;
}

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

int main(void){
	std::ios_base::sync_with_stdio(false);
	list<int> l;
	int n;
	string s;
	int d;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		if(s == "insert"){
			cin >> d;
			l.push_front(d);
		}else if(s == "delete"){
			cin >> d;
			list<int>::iterator it = l.begin();
			while(it != l.end()){
				if(*it == d){
					l.erase(it);
					break;
				}
				++it;
			}
		}else if(s == "deleteFirst"){
			l.pop_front();
		}else if(s == "deleteLast"){
			l.pop_back();
		}
	}

	list<int>::iterator it = l.begin();
	while(it != l.end()){
		if(it != l.begin())cout << " ";
		cout << *it;
		++it;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 32472
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 4*1001001001001001001;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    vector<int> t(4, 0);
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (i != j && s[i] == s[j]) {
                t[i]++;
            } 
        }
    }
    for (int i = 0; i < 4; i++) {
        if (t[i] != 1) {
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;


    return 0;
}



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


int main()
{
	vector<vector<int>> c(3,vector<int>(3));
	rep(i,3) rep(j,3) cin>>c[i][j];
	for(int a=0;a<=c[0][0];a++)
	{
		vector<int> b(3);
		rep(j,3)
		{
			b[j]=c[0][j]-a;
		}
		bool flag=true;
		rep(i,2)
		{
			vector<int> A(3);
			rep(j,3)
			{
				A[j]=c[i+1][j]-b[j];	
			}
			rep(j,2)
			{
				if(A[j]!=A[j+1])
				{
					flag=false;
					break;
				}
			}
		}
		if(flag)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

using namespace std;
using namespace atcoder;

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    vector<pair<int, pair<int, int>>> Query(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> Query.at(i).first >> Query.at(i).second.first >> Query.at(i).second.second;
    }

    fenwick_tree<int64_t> fw(N);
    for (int i = 0; i < N; i++)
    {
        fw.add(i, a.at(i));
    }
    for (int i = 0; i < Q; i++)
    {
        if (Query.at(i).first == 0)
        {
            fw.add(Query.at(i).second.first, Query.at(i).second.second);
        }
        else
        {
            cout << fw.sum(Query.at(i).second.first, Query.at(i).second.second) << endl;
        }
    }

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

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

    string str,str2;
    cin >> str >> str2;
    for(int i=0;i<='z'-'a';i++){
        if(str2 == str + (char)((int)'a' + i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        while(a%2==0){
            ans++;
            a/=2;
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

int top, s[MAX];

void initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int main(){
  int x, y;
  char s[MAX];

  initialize();

  while(scanf("%s", s) != EOF ){
    
    if (s[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if (s[0] == '-' ){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if (s[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      push(atoi(s));
    }
  }

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

  return 0;
}

void initialize(){
  top = 0;
}

int isEmpty(int top){
  if(top == 0)  return 0;
  else return 1;
}

int isFull(int top){
  if(top >= MAX -1)  return 0;
  else return 1;
}

void push(int x){
  if(isFull(top) == 0)   printf("??¨?????????????????????????????????\n");
  else{
    top++;
    s[top] = x;
  }
}
  
int pop(){
  if(isEmpty(top) == 0) printf("??¨???????????¢?????????????????????\n");
  else top--; 
  return s[top+1];
}

Measured memory_bytes: 548
a,b,ab,x,y=map(int,input().split())
price=0
if a+b <= ab*2:
    price+=a*x+b*y
else:
    if x>y:
        price+=2*ab*y
        if a>=2*ab:
            price+=2*ab*(x-y)
        else:
            price+=a*(x-y)
    else:
        price+=2*ab*x
        if b>=2*ab:
            price+=2*ab*(y-x)
        else:
            price+=b*(y-x)
print(price)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int age = 0;

		age = Integer.parseInt(next());
		switch (age) {
		case 1:
			out.println("Hello World");
			break;
		case 2:
			int numA = nextInt();
			int numB = nextInt();
			out.println(numA + numB);
			break;
		}

	}

	private void solveB() {
		int numN = 0;

		numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveC() {
		int numN = 0;

		numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveD() {
		int numN = 0;

		numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveE() {
		int numN = 0;

		numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveF() {
		int numN = 0;

		numN = Integer.parseInt(next());

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21076
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a, k, mod = 998244353;
vec<ll> m;
ll xp[3005][3005];

int main() {
    fast;
    memset(xp, 0, sizeof(xp));
    cin>>a>>k;
    m = vec<ll>(a+1);
    for(int q=1; q<=a; q++) cin>>m[q];
    sort(m.begin(), m.end());
    xp[0][0] = 1;
    for(int q=1; q<=a; q++){
        for(int w=0; w<=k; w++){
            xp[q][w] += xp[q-1][w] + (xp[q-1][w] + (w>=m[q] ? xp[q-1][w-m[q]] : 0));
            xp[q][w] %= mod;
        }
    }
    cout<<xp[a][k];
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

vector<pair<ll,ll>> yx;
vector<pair<ll,ll>> xy;

int main(){
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i,N) {
        ll x, y;
        cin >> x >> y;
        yx.pb(make_pair(y, x));
        xy.pb(make_pair(x, y));
    }
    sort(yx.begin(), yx.end());
    sort(xy.begin(), xy.end());
   
    ll minimum_taiseki = 4 * INF * INF;
    
    // 左端と右端を選ぶ
    REP(i,N-1) FOR(j,i+1,N){
        ll lx = xy[i].first;
        ll rx = xy[j].first;
        // 上端と下端を選ぶ
        REP(k,N-1) FOR(l,k+1,N) {
            ll ly = yx[k].first;
            ll uy = yx[l].first;
            int cnt = 0;
            FOR(m,i,j+1) {
                ll y = xy[m].second;
                if (ly<=y&&y<=uy) {
                    cnt++;
                }
            }
            if (K <= cnt) {
                minimum_taiseki = min(minimum_taiseki, (uy-ly)*(rx-lx));
            }
        }
    }
    
    cout << minimum_taiseki << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a[4],b[4],tmp;
    int i,j;
    int hit,blow;

    while(1){

        hit=0;
        blow=0;

        for(i=0;i<4;i++){

            if(scanf("%d",&tmp)==EOF)goto END;
            a[i]=tmp;
        }
        for(i=0;i<4;i++){
            scanf("%d",&tmp);
            b[i]=tmp;

        }

        for(i=0;i<4;i++){
            if(a[i]==b[i])hit++;
        }

        blow -= hit;

        for(i=0;i<4;i++){
            for(j=0;j<4;j++){
                if(a[i]==b[j]){
                    blow++;
                }
            }
        }

        printf("%d %d\n",hit,blow);
    }
    END:

    return 0;
}

Measured memory_bytes: 596
from operator import mul
from functools import reduce

def cmb(n,r):
    if n < r: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
ss = [input() for _ in range(n)]
march = ['M','A','R','C','H']
d = dict(zip(march, [0]*5))

nn = 0

for s in ss:
    if s[0] in march:
        d[s[0]] += 1
        nn += 1
if nn < 3:
    print(0)
    exit()

ans = cmb(nn, 3)
for i in d.values():
    if i >= 2:
        if i > 3:
            ans -= cmb(i, 3)
        ans -= cmb(i,2)*(nn-i)

print(int(ans))



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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	string s,t;
	cin>>s>>t;
	ll ans=1e9;
	for(ll i=0;i<=(ll)s.length()-(ll)t.length();i++)
	{
		ll cnt=0;
		for(ll j=0;j<t.length();j++)
		{
			if(s[i+j]!=t[j]) cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <deque>

using namespace std;

bool yes;
int ball[10];

void print(deque <int> a){
	for (int i = 0; i < a.size(); i++){
		cout << a[i] << " ";
	}
	cout << endl;
}

void rec(deque <int> b, deque <int> c, int num)
{
	if (num >= 10){
		yes = true;
		return;
	}

	if (b.back() < ball[num]){
		b.push_back(ball[num]);
		rec(b, c, num + 1);
		b.pop_back();
	}
	if (c.back() < ball[num]){
		c.push_back(ball[num]);
		rec(b, c, num + 1);
		c.pop_back();
	}

	return;
}

int main(void)
{
	int n;
	cin >> n;
	while (n--){
		for (int i = 0; i < 10; i++){
			cin >> ball[i];
		}

		yes = false;
		deque <int> b, c;
		b.push_back(-1);
		c.push_back(-1);
		rec(b, c, 0);
		if (yes){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1204
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

auto main() -> int {
  std::size_t N;
  std::cin >> N;

  double ans = 0;
  for (auto i = 0ul; i < N; ++i) {
    double xi;
    std::string ui{};
    std::cin >> xi >> ui;

    if (ui == "JPY") {
      ans += xi;
    } else {
      ans += xi * 380000.0;
    }
  }

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


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/



int main(){
    IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        cout<<(1000-n%1000)%1000;
    }
    return 0;
} 

Measured memory_bytes: 3632
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]

ans=0
for i in range(n):
  for j in range(n):
    if i>j:
      goukei=0
      for k in range(d):
        goukei+=(x[i][k]-x[j][k])**2
      distance=goukei**0.5
      if distance.is_integer()==True:
        ans+=1
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
int gcd(int a,int b){
	if(a%b==0) return b;
	return gcd(b,a%b);
}
int _gcd(int a,int b,int c){
	return gcd(gcd(a,b),c);
}
int main(){
	int k,ans=0;
	scanf("%d",&k);
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				ans+=_gcd(i,j,l);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1728
def f(x, I, n):
  while x[-1]<=n:
    a = [x[I[0]]*2, x[I[1]]*3, x[I[2]]*5]
    b = min(a)
    c = a.index(b)
    if b > x[-1]: x += [b]
    I[c] += 1
  return

while 1:
  try: m,n = map(int, raw_input().split())
  except: break
  x = [1]
  I = [0, 0, 0]
  f(x, I, m-1)
  a = len(x)
  f(x, I, n)
  print len(x)-a

Measured memory_bytes: 4244
package main

import (
    "fmt"
    "sort"
)

func main() {
    var q, h, s, d, n int

    fmt.Scan(&q, &h, &s, &d, &n)

    slice := []int{q*4, h*2, s}
    sort.Sort(sort.IntSlice(slice))

    t := slice[0]

    if t*2 <= d {
        fmt.Println(t*n)
    } else {
        fmt.Println( d*(n/2) + t*(n%2) )
    }
}

Measured memory_bytes: 512
#include<stdio.h> 
int main()
{
	int a[100][100];
	int b[100];
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	
	for(int j=0;j<m;j++)
	{
		scanf("%d", &b[j]);
	}
	
	int c[100]={0};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			c[i]+=a[i][j]*b[j];
		}
	}
	
	for(int i=0;i<n;i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		ch.push_back(make_pair(b,a));
	}
	sort(ch.begin(),ch.end());
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=ch[i].second;
		if(ans>ch[i].first){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	// your code goes here
	return 0;
}

Measured memory_bytes: 7456
prime = {1:False}
for i in range(2,100001):
    if i not in prime:
        prime[i] = True
        for j in range(i*2,100001,i):
            prime[j] = False

like = {0:0}
for i in range(1,100001):
    like[i] = like[i-1] + int((i%2==1) and prime[i] and prime[int((i+1)/2)])

Q = int(input())
for i in range(Q):
    LR = list(map(int,input().split()))
    print("%d"%(like[LR[1]]-like[LR[0]-1]))

Measured memory_bytes: 29140
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

signed f(int num){
    if(num%2==0)return num/2;
    else return num*3+1;
}

void run(){
    int n;
    cin >> n;
    vi p(n);
    int sum=0;
    rep(i,n)
    {
        cin >> p[i];
        sum+=p[i];
    }
    RSORT(p);
    cout << sum-p[0]/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n + 1];
		int b[] = new int[n];
		for(int i = 0; i < n + 1; ++i)
			a[i] = sc.nextInt();
		for(int i = 0; i < n; ++i)
			b[i] = sc.nextInt();
		sc.close();
		long ans = 0;
		for(int i = 0; i < n; ++i) {
			long tmp = (long)a[i] + (long)a[i + 1];
			if(b[i] >= tmp) {
				ans += tmp;
				a[i + 1]=0;
			}
			else {
				if(a[i] <= b[i]) 
					a[i + 1] -= (b[i] - a[i]);
				ans += (long)b[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66508
#include<stdio.h>
int main(){
  int d[(1<<16)+20],i,j,k,t[20][20],n;
  while(scanf("%d",&n),n){
    for(i=0;i<((1<<n)+10);i++)d[i]=1000000010;
    for(i=0;i<n;i++){
      scanf("%d",&d[1<<i]);
      for(j=0;j<n;j++)scanf("%d",&t[i][j]);
    }
    for(i=1;i<(1<<n);i++){
      for(j=0;j<n;j++){
	if(i&(1<<j))continue;
	if(d[i|(1<<j)]>d[i]+d[1<<j])d[i|(1<<j)]=d[i]+d[1<<j];
	for(k=0;k<n;k++){
	  if((i&(1<<k))==0)continue;
	  if(d[i|(1<<j)]>d[i]+t[j][k])d[i|(1<<j)]=d[i]+t[j][k];
	}
      }
    }
    printf("%d\n",d[(1<<n)-1]);
  }
  return 0;
}

Measured memory_bytes: 856
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

cnt=0

for i in range(n):
  taoshita=min(A[i],B[i])
  #print(taoshita)
  a=min(A[i+1],B[i]-taoshita)
  #print(a)
  A[i+1]-=a
  cnt+=(taoshita+a)

print(cnt)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int N, Z, W;
   cin >> N >> Z >> W;
   vec<ll> v(N);
   rep (i, N) cin >> v[i];

   if (N >= 2) {
      cout << max(abs(v[N-1]-W), abs(v[N-2]-v[N-1])) << endl;
   } else {
      cout << abs(v[0] - W) << endl;
   }


   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ( c <= a-b){
    cout << 0 << endl;
  }
  
  else{
    cout << c - (a-b) << endl;
  }

}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(lambda s: int(s)-1, input().split()))

n = 0
visit = {0}
ls = [0]
for _ in range(K):
    n = A[n]
    if n not in visit:
        visit.add(n)
        ls += [n]
    else:
        loop_start = 0
        loop_length = 0
        flag = False
        m = 0
        for _ in range(N):
            if n == m:
                if flag:
                    break
                else:
                    flag = True
            if flag:
                loop_length += 1
            else:
                loop_start += 1
            m = A[m]

        print(ls[loop_start + ((K-loop_start) % loop_length)]+1)
        break
else:
    print(n+1)

Measured memory_bytes: 32380
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

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

    int l = s.length();
    int ans = INF;
    for (int i = 0; i < l; i++) {
        int a = 0, b = 0;
        for (int j = 0; j < l; j++) {
            if (s[j] == s[i]) {
                a = max(a, b);
                b = 0;
            } else
                b++;
        }

        a = max(a, b);
        ans = min(ans, a);
    }

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


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

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


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 100001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
ll n, m;
string s;
vector<int> a;

int to[256];



void solve()
{
    to['R'] = 0; to['G'] = 1; to['B'] = 2;
    cin >> n;
    cin >> s;
    a.resize(n);
    for(int i = 0; i < n; i++)
        a[i] = to[s[i]];

    vector<vector<int> > cnt(3, vector<int>(n, 0));

    cnt[a[0]][0]++;

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < 3; ++j) cnt[j][i] = cnt[j][i - 1];
        cnt[a[i]][i]++;
    }
    ll ans = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(a[i] == a[j]) continue;
            int f = 3 - a[i] - a[j];
            ll cur = cnt[f][n - 1] - cnt[f][j];
            if(j + (j - i) < n && a[j + (j - i)] == f) cur--;
            ans += cur;
        }
    }

    cout << ans;

    return;
}


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

//    cin >> T;

    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3676
def solve():
    items=list(input().split())
    T_health=int(items[0])
    T_strength=int(items[1])
    A_health=int(items[2])
    A_strength=int(items[3])
    while(T_health>0 and A_health>0):
        A_health-=T_strength
        if(A_health>0):
            T_health-=A_strength
    if(T_health<=0):
        print("No")
    if(A_health<=0):
        print("Yes")
    return
solve()

Measured memory_bytes: 9124
import java.math.BigInteger
import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)
    var ans: BigInteger = BigInteger.ONE
    val limit: BigInteger = BigInteger.valueOf(1_000_000_000_000_000_000)
    val inputs = mutableListOf<BigInteger>()

    repeat(scanner.nextInt()) {
        inputs += scanner.nextBigInteger(10)
    }

    if (BigInteger.ZERO in inputs) {
        println(0)
    } else {
        for (n in inputs) {
            ans *= n

            if (ans > limit) {
                ans = BigInteger.valueOf(-1)
                break
            }
        }

        println(ans)
    }
}



Measured memory_bytes: 67160
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {
	int x, y,z,c=0;
	cin >> x >> y >> z;
	for (int i = x; i <= y; i++) {
		if (z % i == 0) {
			c++;
		}
	}
	cout << c<<endl;
}



Measured memory_bytes: 3092
#include<stdio.h>

int prime[1000000],sum[1000000];

int main(void){
	const int MAX_V = 1000000;
	int i,j,n,ans;
	for(i=2;i<MAX_V;i++){
		prime[i]=1;
		sum[i]=0;
	}
	for(i=2;i*i<MAX_V;i++){
		if(prime[i]){
			for(j=i*i;j<MAX_V;j+=i){
				prime[j]=0;
			}
		}
	}
	while(scanf("%d",&n)!=EOF){
		ans=0;
		for(i=0;i<=n;i++){
			ans+=prime[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8408