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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  ll d = c - b - a;
  if (d > 0 && 4*a*b < d*d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long int ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	vi v(1000010, 1);
	vi copy(1000011, 1);
	ll n, c = 0;
	double rt;

	v[0] = 0;

	while (cin >> n){
		rt = sqrt(n);
		FOR(i, 1, rt){
			if (v[i] == 1){
				for (int j = i + 1; (i + 1)*j <= n; j++){
					v[(i + 1)*j - 1] = 0;
				}
			}
		}
		REP(i, n){
			if (v[i] == 1)c++;
		}
		cout << c << "\n";
		c = 0;
	}
}

Measured memory_bytes: 16704
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 998244353;

int main() {
    // source
    ll n;
    cin >> n;
    ll d[n];
    rep(i, n) { cin >> d[i]; }
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll num[n] = {};

    rep(i, n) { num[d[i]]++; }
    if (num[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    ll d_max = 0;
    rep(i, n) { d_max = max(d_max, d[i]); }

    Bint ans = 1;
    repd(i, 1, d_max + 1) {
        rep(j, num[i]) { ans *= num[i - 1]; }
    }
    cout << ans % mod << endl;
    return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n,k;
vector<int> cnt(100100);

int main(){
    cin>>n>>k;
    vector<int> a(n);
    rep(i,0,n){
        cin>>a[i];
        cnt[a[i]]++;
    }

    sort(a.begin(),a.end());
    int num=k;
    int ans=1;
    while(num<n){
        num+=k-1;
        ans++;
    }

    cout<<ans-cnt[a[0]]+1<<"\n";
    return 0;
}


Measured memory_bytes: 3976
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] ds_ori = new int[n];

            for(int i=0; i<n; i++)
            {
                ds_ori[i] = sc.intarr[0];
            }

            int[] ds = ds_ori.Distinct().ToArray();

            wr.wri(ds.Length);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define print(x) printf("%d ", x);
#define println(x) printf("%d\n", x);
#define printarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1]);
#define scan(x) scanf("%d", &x);
#define scanarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}

void selectionsort(int *a, int n);

int main() {
    int n;
    scan(n);
    int a[n];
    scanarray(a,n);

    selectionsort(a,n);

    return 0;
}

void selectionsort(int *a, int n) {
    int minj = 0;
    int swapcount = 0;
    rep(i,0,n-1) {
        minj = i;
        rep(j,i,n-1) {
            if(a[j] < a[minj]) {
                minj = j;
            }
        }
        if(i != minj) {
            swap(a[i],a[minj]);
            swapcount++;
        }
    }
    printarray(a,n);
    println(swapcount);

}



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

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
           

            while (true)
            {
                long q = long.Parse(Console.ReadLine());

               
                if (q == -1)
                {
                    break;
                }

                double a = q / 2.0;
                double b = 0;

                while (true)
                {
                    b = a - (a * a * a - q) / (3 * a * a);

                    if ((b * b * b - q < 0 ? q - b * b * b : b * b * b - q) < 0.00001 * q)
                    {
                        break;
                    }
                    a = b;
                }

                Console.WriteLine(String.Format("{0:f6}", b));

            }

        }
    }
}



Measured memory_bytes: 17948
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)
	tiles := strings.Split(str, "")

	var oddSum, evenSum int
	for i, tile := range tiles {
		if strconv.Itoa(i%2) == tile {
			evenSum++
		} else {
			oddSum++
		}
	}
	if oddSum < evenSum {
		fmt.Println(oddSum)
	} else {
		fmt.Println(evenSum)
	}
}


Measured memory_bytes: 3072
import math
from fractions import Fraction

n = int(input())
t, a = [int(x) for x in input().split()]
for i in range(1, n):
    t2, a2 = [int(x) for x in input().split()]
    x = math.ceil(max(Fraction(t, t2), Fraction(a, a2)))
    t, a = x * t2, x * a2

print(t + a)


Measured memory_bytes: 5692
N = int(input())
a = []
b = []
for i in range(1,10**6+1):
	if N % i == 0:
		b.append(N // i)
		a.append(i)
	if i > N:
		break
ab = 10**13
for i in range(len(a)):
	ab = min(ab,(a[i]-1)+(b[i]-1))
print(ab)

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; cin >> N;
	V<int> A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	ll s = 0;
	ll rem = 0;
	int cnt = 0;

	V<int> vec;

	rep(i, N) {
		if (A[i] < B[i]) {
			s += B[i] - A[i];
			++cnt;
		} else {
			vec.eb(A[i] - B[i]);
			rem += A[i] - B[i];
		}
	}
	if (rem < s) {
		puts("-1");
		return 0;
	}
	if (cnt == 0) {
		puts("0");
		return 0;
	}
	
	sort(ALL(vec));
	reverse(ALL(vec));

	rep(i, vec.size()) {
		s -= vec[i];
		if (s <= 0) {
			cout << i + 1 + cnt << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()


struct SegmentTree{
    private:
        int n;
        vector<map<char,int>> node;
    
    public:
        SegmentTree(string v){
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2 * n - 1);
            for(int i = 0; i < sz; i++) node[i+n-1][v[i]]++;
            for(int i = n - 2; i >= 0; i--){
                for(auto e: node[2*i+1]) node[i][e.first] += e.second;
                for(auto e: node[2*i+2]) node[i][e.first] += e.second;
            }
        }

        void update(int x, char val){
            x += n - 1;
            if(node[x][val] == 1) return;
            char E = '0';
            for(auto e: node[x])if(e.second > 0){
                E = e.first;
                node[x][E]--;
            }
            node[x][val]++;
            while(x > 0){
                x = (x - 1) / 2;
                node[x][E]--;
                node[x][val]++;
            }
        }

        map<char, int> get(int a, int b, int k = 0, int l = 0, int r = -1){
            if(r < 0) r = n;
            map<char,int> MP;
            if(r <= a || b <= l) return MP;
            if(a <= l && r <= b) return node[k];

            auto vl = get(a, b, 2*k+1, l, (l+r)/2);
            auto vr = get(a, b, 2*k+2, (l+r)/2, r);
            for(auto e: vl) if(e.second > 0) MP[e.first] += e.second;
            for(auto e: vr) if(e.second > 0) MP[e.first] += e.second;
            return MP;
        }
};

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    SegmentTree seg(S);
    while(Q--){
        int q; cin >> q;
        if(q == 1){
            int i; char c; cin >> i >> c; i--;
            seg.update(i, c);
        }else{
            int l, r; cin >> l >> r; l--, r--;
            auto M = seg.get(l, r + 1);
            int cnt =0;
            for(auto e: M) if(e.second > 0) cnt++;
            cout << cnt << endl;
        }
    }
    return 0;
}


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

int cnt = 0;

void func(int ans, int a[], int i, char s[]) {
	if (i == 3) {
		if (ans == 7 && cnt==0) {
			printf("%d%c%d%c%d%c%d=7\n", a[0], s[0], a[1], s[1], a[2], s[2], a[3]);
			cnt++;
			return;
		}
		return;
	}
	
	s[i] = '+';
	func(ans + a[i+1], a, i+1, s);
	s[i] = '-';
	func(ans - a[i + 1], a, i + 1, s);
}


int main() {
	char t[44];
	cin >> t;

	int a[4];
	a[0] = t[0] - '0';
	a[1] = t[1] - '0';
	a[2] = t[2] - '0';
	a[3] = t[3] - '0';

	char s[3];

	func(a[0], a, 0, s);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        int ans=0;


            for (int j = n + 1; j <= 2 * n ; j++) {
                bool f = true;
                for (int i = 2; i <= sqrt(j); i++) {
                    if (j % i == 0) {
                        f = false;
                        break;
                    } else {

                    }
                }
                if (f)ans++;
            }
        
        cout<<ans<<endl;
    }



}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int main()
{
	int n,m;
	LL ans;
	while(~scanf("%d %d",&n,&m))
	{
		ans = 100*(n-m) + 1900*m;
		while(m)
		{
			ans *= 2;
			m--;
		}
		printf("%lld\n",ans);
	}
	return 0;
}



Measured memory_bytes: 764
#include<stdio.h>

int main()
{
	int a,b,tmp;
	
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		printf("%d %d\n",a,b);
	}
	
	return 0;
}
		
		


Measured memory_bytes: 1960
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans+=i;
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3632
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
r=[]
b=[]
G=[[] for i in range(n*2+2)]

def add_edge(fm,to,cap):
  global G
  G[fm].append( [to,cap,len(G[to])]);
  G[to].append( [fm,0,len(G[fm])-1]);

def dfs(v,t,f,used):
	if v==t:
	  return f
	used[v] = 1
	for i in range(len(G[v])):
		e = G[v][i]
		if used[e[0]]==0 and e[1]>0:
			d = dfs(e[0], t, min(f,e[1]),used);
			if d > 0:
				e[1] -= d;
				
				G[e[0]][e[2]][1] += d
                                
				return d
			
		
	
	return 0


def max_flow(s,t):
        
	flow = 0
	while(1):
		used=[0 for i in range(2*n+2)]
		f = dfs(s, t, float("inf"),used)
		if f==0:
			return flow
		
		flow += f
	
for i in range(n):
 r.append(i2())
for i in range(n):
 b.append(i2())
for i in range(n):
 add_edge(0,i+1,1)
for i in range(n):
 add_edge(n+1+i,2*n+1,1)
for i in range(n):
 for j in range(n):
   if r[i][0]<b[j][0] and r[i][1]<b[j][1]:
       add_edge(1+i,n+1+j,1)
print(max_flow(0,2*n+1))

Measured memory_bytes: 46812
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(){
	string str;

	int count[26] = { 0 };
	while (getline(cin, str)) {
		int length = str.length();
		for (int i = 0; i < length; i++) {
			if (str[i] - 'a' >= 0 && str[i] - 'a' <= 25) {
				count[str[i] - 'a']++;
			}
			else if (str[i] - 'A' >= 0 && str[i] - 'A' <= 25) {
				count[str[i] - 'A']++;
			}
		}
	}
	char moji;
	for (int i = 0; i < 26; i++) {
		moji = 'a';
		moji += i;
		cout << moji << " : " << count[i] << endl;
	}

	//system("pause");
    return 0;
}




Measured memory_bytes: 3168
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

vector<int> ans;
int solve(int N){
    int ma = -1;
    int mi = 1001;
    int sum = 0;
    for (int i = 0; i < N; i++){
        int s; cin >> s;
        sum += s;
        mi = min(mi, s);
        ma = max(ma, s);
    }
    return (sum - mi - ma)/(N-2);
}

int main(){
    cin.tie(0);

    int N;
    while (1){
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << *itr << endl;
    }

}




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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
        int n,num,min,max;
        long sum = 0;
        n = sc.nextInt();
        num = sc.nextInt();
        min = num;
        max = num;
        sum += num;
        for(int i=1; i<n; i++) {
            num = sc.nextInt();
            min = Math.min(min, num);
            max = Math.max(max, num);
            sum += num;
        }
        System.out.println(min + " " + max + " " + sum);
    }
}


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

int main() {
	int x, y, z;
	string s;
	cin >> x >> y>>z;
	if (x == 5 && y == 5 && z == 7)cout << "YES"<<endl;
	else if (x == 5 && y == 7 && z == 5)cout << "YES" << endl;
	else if (x == 7 && y == 5 && z == 5)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

template<typename T> struct Graph {
  struct Edge { int from, to; T cost; };
  size_t n;
  vector<T> dist;
  vector<int> hasPath;
  vector<Edge> es;
  Graph(size_t n_, T INF) : n(n_), dist(n_, INF + INF), hasPath(n_, 0), es(n_) {}

  void addEdge(int u, int v, T w) {
    es.push_back({u, v, w});
    //g[v].push_back({u, w});
  }
  bool bellmanFord(int s) {
    dist[s] = 0;
    hasPath[s] = 1;
    for (int i = 0; i < n; ++i) {
      for (auto&& e : es) {
        if (dist[e.to] > dist[e.from] + e.cost) {
          dist[e.to] = dist[e.from] + e.cost;
          hasPath[e.to] |= hasPath[e.from];
          if (i == n - 1 && hasPath[e.to]) return false;
        }
      }
    }
    return true;
  }
};

const int INF = 1e9;

int main() {
  int n, m, r; cin >> n >> m >> r;
  Graph<int> g(n, INF);
  while (m--) {
    int s, t, d; cin >> s >> t >> d;
    g.addEdge(s, t, d);
  }
  if (!g.bellmanFord(r)) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; ++i) {
      cout << ( (g.dist[i] >= INF || !g.hasPath[i]) ? "INF" : to_string(g.dist[i]) ) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3348
A = []
B = []
C = []

for i in range(1,101):
    t0 = i
    t1 = i*100
    t2 = i*100*100
    A.append(t0)
    B.append(t1)
    C.append(t2)

d,n = map(int,input().split())

if d == 0:
    if n == 100:
        print(101)
    else:
        print(A[n-1])
elif d == 1:
    if n == 100:
        print(100*101)
    else:
        print(B[n-1])
else:
    if n == 100:
        print(100*100*101)
    else:
        print(C[n-1])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, d;
    int ans = 0;

    cin >> n >> d;

    long double x[n][d];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            long double tmp = 0;
            for (int k = 0; k < d; k++) {
                tmp += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
            }
            tmp = sqrt(tmp);
            if (tmp == (int)tmp) {
                ans++;
            }
        }
    }

    cout << ans/2 << endl;
}


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

#define out(ans) cout << (int)(ans) << endl;
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); ++i)

int calc(string A){
    int B=0;
    REP(i,0,A.size()){
        B+=A.at(i)-'0';
    }
    if(B==1) return 10;
    else return B;
}

int main(){
    string N;
    cin >> N;
    int ans = calc(N);
    out(ans);
    return 0;
}

Measured memory_bytes: 256
#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 <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

	int h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
		exit(0);
	}
	cout << (h * w + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    int x,x1,x2;cin>>x>>x1>>x2;
    if(x==x1 && x1!=x2 && x!=x2) cout<<"Yes\n";
    else if(x1==x2 && x!=x1 && x!=x2) cout<<"Yes\n";
    else if(x==x2 && x!=x1 && x1!=x2) cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    int a, b; cin >> a >> b;
    cout << max({a + a - 1, a + b, b + b - 1}) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class _0100
{
    public static void Main()
    {
        bool flag;
        string[] data;
        long sum, val;
        Dictionary<string, long> d = new Dictionary<string, long>();
        Queue<string> keyQ = new Queue<string>();
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            d.Clear();
            flag = false;
            for (int i = 0; i < n; i++)
            {
                data = Console.ReadLine().Split();
                sum = long.Parse(data[1]) * long.Parse(data[2]);
                if (d.TryGetValue(data[0], out val))
                {
                    d.Remove(data[0]);
                    d.Add(data[0], val + sum);
                }
                else
                {
                    keyQ.Enqueue(data[0]);
                    d.Add(data[0], sum);
                }
            }
            while (keyQ.Count != 0)
            {
                string key = keyQ.Dequeue();
                if (d[key] >= 1000000)
                {
                    flag = (!flag) ? true : flag;
                    Console.WriteLine(key);
                }
            }
            if (!flag) Console.WriteLine("NA");
            n = int.Parse(Console.ReadLine());
        }
    }
}

Measured memory_bytes: 6004
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    rep(i, n){
        rep(j, i){
            sum += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    CST(10);
    cout << sum / n * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

int main(void)
{
	char s[100000+2];

	while(scanf("%100000[01]\n", s)==1)
	{
		int n0=0, n1=0;

		for(int i=0;s[i];i++)
		{
			if(s[i]=='0') n0++;
			if(s[i]=='1') n1++;
		}
		printf("%d\n", std::min(n0, n1)*2);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s;
	cin >> s;
	for (int i = s.length() - 2; i >= 0; i -= 2) {
		bool f = true;
		REP(j, i / 2) f &= (s[j] == s[i / 2 + j]);
		if (f) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    string s; cin >> s;
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    int ans;
    for(int bit = 0; bit < (1<<3); bit++){
        int tmp = a;
        if(bit & (1 << 0)){
            tmp += b;
        }else{
            tmp -= b;
        }
        if(bit & (1 << 1)){
            tmp += c;
        }else{
            tmp -= c;
        }
        if(bit & (1 << 2)){
            tmp += d;
        }else{
            tmp -= d;
        }
        if(tmp == 7){
            ans = bit;
            break;
        }
    }
    cout << a;
    rep(i,3){
        if(ans & (1<<i)){
            cout << '+';
        }else{
            cout << '-';
        }
        if(i == 0) cout << b;
        if(i == 1) cout << c;
        if(i == 2) cout << d;
    }
    cout << "=7";
}


Measured memory_bytes: 256
import heapq

N, M = list(map(int,input().split()))
A = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append([in1, in2])

A = sorted(A)
ans = 0
day = 1
cnt = 0
x = []

for i in range(M):
    while(cnt < N):
        if A[cnt][0] == day:
            heapq.heappush(x, -A[cnt][1])
            cnt += 1
        else:
            break
    if x:  ans -= heapq.heappop(x)
    day += 1

print(ans)

Measured memory_bytes: 93900
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
total = sum(A)

Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    v = c.get(B)
    if v:
        c[B] = 0
        c[C] += v
        total += (C-B) * v

    print(total)

Measured memory_bytes: 93968
#include <iostream>

using namespace std;

int main()
{

    int P , Q , R ;
cin >> P >> Q >> R ;

    int w , e , r ;
    w= P+Q ;
    e=Q+R ;
    r= P+R ;
    if (w<=e && w<=r)
        cout << w ;
    else if (e<=w && e<=r)
        cout << e;
    else if (r<=w && r<=e)
        cout << r;




    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

double dp[303][303][303];
void solve(long long N, std::vector<long long> a){
    vll C(4, 0);
    REP(i, N) C[a[i]]++;
    REP(c3, N+1){
        REP(c2, N+1){
            REP(c1, N+1){
                ll sum = c1 + c2 + c3;
                if(sum == 0) continue;

                dp[c1][c2][c3] = 1.0 * N / sum;

                if(c1) dp[c1][c2][c3] += dp[c1-1][c2][c3] * c1 / sum;
                if(c2) dp[c1][c2][c3] += dp[c1+1][c2-1][c3] * c2 / sum;
                if(c3) dp[c1][c2][c3] += dp[c1][c2+1][c3-1] * c3 / sum;
            }
        }
    }
    cout <<setprecision(14) <<  dp[C[1]][C[2]][C[3]] <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 217344
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin >> n;
    int a[n+1];
    for(int i=0;i<=n;i++) a[i]=0;
    for(int i=1;i*i<=n-1;i++){
        for(int j=1;j*j<=n-1;j++){
            for(int k=1;k*k<=n-1;k++){
                int sum=i*i+j*j+k*k+i*j+j*k+k*i;
                if(sum<=n) a[sum]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout << a[i] << endl;
    
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
const double INF = 1e10;
//const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

struct D {
    vector<double> l, r;

    D() : l(3, INF), r(3, -INF) {}

    void add(double x, int v) {
        ++v;
        mins(l[v], x);
        maxs(r[v], x);
    }

    double get(double t) {
        double nl = INF, nr = -INF;
        rep(i, 3) {
            mins(nl, l[i] + i * t);
            maxs(nr, r[i] + i * t);
        }
        return nr - nl;
    }

    vector<double> events() {
        vector<double> ts;
        rep(i, 3)
            rep(j, i) {
                {
                    double t = (l[j] - l[i]) / (i - j);
                    if (t > 0) {
                        ts.push_back(t);
                    }
                }
                {
                    double t = (r[j] - r[i]) / (i - j);
                    if (t > 0) {
                        ts.push_back(t);
                    }
                }
            }
        return ts;
    }

};

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

    D xd, yd;

    rep(i, n) {
        int x, y;
        char d;
        cin >> x >> y >> d;
        if (d == 'L') xd.add(x, -1), yd.add(y, 0);
        if (d == 'R') xd.add(x, 1), yd.add(y, 0);
        if (d == 'U') xd.add(x, 0), yd.add(y, 1);
        if (d == 'D') xd.add(x, 0), yd.add(y, -1);
    }

    vector<double> ts;
    ts.push_back(0);
    ts.push_back(INF);

    {
        auto nts = xd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    {
        auto nts = yd.events();
        ts.insert(ts.end(), nts.begin(), nts.end());
    }
    sort(ts.begin(), ts.end());
    double ans = 1e18;
    for (double t: ts) {
        double now = xd.get(t) * yd.get(t);
        mins (ans, now);
    }

    printf("%.10f\n", ans);
}


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

typedef long long lli;
const lli mod = 1000000007LL;

lli lcm(lli a, lli b) {
  return a / __gcd(a, b) * b;
}

lli mod_pow(lli x, lli n) {
  if(n == 0) return 1;
  lli p = mod_pow(x, n/2);
  if(n & 1) return p * p % mod * x % mod;
  else return p * p % mod;
}

typedef lli elm;
const elm INF = 1LL<<60LL;

class RMQ {
private:
  int n;
  vector<elm> dat;

public:
  RMQ(int _n) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<elm>(2*n-1, 0);
  }

  void update(int k, elm a) {
    k += n-1;
    a %= mod;
    elm d = ((a - dat[k]) % mod + mod) % mod;
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      ( dat[k] += d ) %= mod;
    }
  }

  elm query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if(r == -1) r = n;
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return dat[k];
    else {
      elm v1 = query(a, b, k*2+1, l, (l + r) / 2);
      elm v2 = query(a, b, k*2+2, (l + r) / 2, r);
      return (v1 + v2) % mod;
    }
  }
};

class RMQ2 {
private:
  int n;
  vector<elm> dat;

public:
  RMQ2(int _n) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<elm>(2*n-1, 1);
  }

  void update(int k, elm a) {
    k += n-1;
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = lcm(dat[k*2+1], dat[k*2+2]);
    }
  }

  elm query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if(r == -1) r = n;
    if(r <= a || b <= l) return 1;
    if(a <= l && r <= b) return dat[k];
    else {
      elm v1 = query(a, b, k*2+1, l, (l + r) / 2);
      elm v2 = query(a, b, k*2+2, (l + r) / 2, r);
      return lcm(v1, v2);
    }
  }
};

int main() {
  vector<lli> inv(41);
  for(lli i = 1; i <= 40; ++i) {
    inv[i] = mod_pow(i, mod - 2);
  }

  lli N, Q; cin >> N >> Q;
  vector<lli> p(N+1);
  for(lli i = 1; i <= N; ++i) {
    cin >> p[i];
  }

  vector<lli> vis(N+1);
  RMQ rmq(N+1);
  RMQ2 rmq2(N+1);
  for(lli i = 1; i <= N; ++i) {
    if(vis[i]) continue;
    lli k = i, s = 0, t = 0;
    do {
      k = p[k];
      vis[k] = true;
      s += k;
      ++t;
    } while(k != i);
    do {
      k = p[k];
      rmq.update(k, s * inv[t] % mod);
      rmq2.update(k, t);
    } while(k != i);
  }
  
  while(Q--) {
    lli l, r;
    cin >> l >> r;
    cout << (rmq.query(l, r+1)%mod) * (rmq2.query(l, r+1)%mod) % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 8732
x, n = map(int, input().split())
if n != 0:
    P = list(map(int, input().split()))
else:
    print(x)
    exit()

d = 0
while True:
    if (x - d) not in P:
        print(x - d)
        exit()
    elif (x + d) not in P:
        print(x + d)
        exit()
    d += 1

Measured memory_bytes: 8884
#include<iostream>
#include<cmath>
using namespace std;
bool hw[1405][1405];
int dp[1405][1405];
int main()
{
	int h;
	int w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>hw[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(hw[i][j]==0)
				dp[i][j]=1;
			else
				dp[i][j]=0;
		}
	}
	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(hw[i][j]==0)
				dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
			else
				dp[i][j]=0;
		}
	}
	int maxx=0;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			
				maxx=max(dp[i][j],maxx);
			
		}
	}
	cout<<maxx*maxx<<endl;
	return 0;
} 


Measured memory_bytes: 12692
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

ll uni[60];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}
void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]>uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    ll n;
    cin>>n;
    ll x[n],y[n];
    ll ans=1e9;
    if(n==1){
        cout << 1<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    ll a,b,num=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            a=x[i]-x[j];
            b=y[i]-y[j];
            for(ll k=0;k<n;k++){
                for(ll g=k+1;g<n;g++){
                    if((x[k]-x[g]==a && y[k]-y[g]==b)||(x[k]-x[g]==-a && y[k]-y[g]==-b)){
                        connect(k,g);
                    }
                }
            }
            for(int k=0;k<n;k++){
                if(uni[k]<0){
                    num++;
                }
            }
            for(int k=0;k<60;k++){
                uni[k]=-1;
            }
            ans=min(ans,num);
            num=0;
        }
    }
    cout << ans<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int hand[10]={},ba=0;
		char s[101]; scanf("%s",s);
		rep(i,100){
			int a=i%n;
			switch(s[i]){
				case 'M': hand[a]++; break;
				case 'S': ba+=hand[a]+1; hand[a]=0; break;
				case 'L': hand[a]+=ba+1; ba=0; break;
			}
		}
		sort(hand,hand+n);
		rep(a,n) printf("%d ",hand[a]); printf("%d\n",ba);
	}
	return 0;
}

Measured memory_bytes: 1048
#include<stdio.h>

int main(void) {
	int n, nums[1227], count = 0;

	scanf("%d", &n);

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

	for (int j = 0; j < n - 2; j++) {
		if (nums[j] < nums[j + 1] && nums[j + 1] < nums[j + 2]) {
			count++;
		}
		else if (nums[j] > nums[j + 1] && nums[j + 1] > nums[j + 2]) {
			count++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
import time
from math import factorial

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=1
    for i in range(n, n-k, -1):
        a=a * i % mod
    b=framod(k, mod)
    return (a * power(b, mod-2, mod)) % mod

n,a,b=map(int, input().split())
mo=10**9+7

fn=2*10**5
fac=[0]*fn
fac[1]=n

print((power(2, n, mo)-1-comb(n,a,mo)-comb(n,b,mo))%mo)




Measured memory_bytes: 4592
#include <iostream>
#include <vector>

using namespace std;

long long res;
void dfs(int d, vector<int>& now, vector< vector<int> >& F, vector< vector<int> >& P, bool used) {
	if (d == 10) {
		if (used) {
			long long score = 0;
			for (int i = 0; i < (int)now.size(); ++i) {
				score += P[i][now[i]];
			}
			res = max(score,res);
		}
		return;
	}

	vector<int> temp = now;
	for (int i = 0; i < (int)now.size(); ++i) {
		temp[i] += F[i][d];
	}
	dfs(d+1,now,F,P,used);
	dfs(d+1,temp,F,P,true);
}

int main(void) {
	int N;
	cin >> N;
	vector< vector<int> > F(N,vector<int>(10));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> F[i][j];
		}
	}
	vector< vector<int> > P(N,vector<int>(11));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin >> P[i][j];
		}
	}
	vector<int> now(N,0);
	res = N * (-10000000);
	dfs(0,now,F,P,false);

	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a, p;

int main() {
	cin >> a >> p;
	
	cout << (a * 3 + p) / 2 << endl;
	
	return 0;
}


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

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

using lint = long long;

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

    std::vector<mint> cnt(60, 0);
    for (int i = 0; i < n; ++i) {
        lint a;
        std::cin >> a;
        for (int j = 0; j < 60; ++j) {
            cnt[j] += ((a >> j) & 1);
        }
    }

    mint ans = 0;
    for (int j = 0; j < 60; ++j) {
        ans += cnt[j] * (mint(n) - cnt[j]) * (1LL << j);
    }

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


Measured memory_bytes: 256
# ダイクストラ
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from heapq import heappush, heappop

    N, M, S = map(int, input().split())
    S = min(S, 2500)
    graph = [[] for _ in range(N)]

    for u, v, a, b in (map(int, input().split()) for _ in range(M)):
        graph[u-1].append((v-1, a, b))
        graph[v-1].append((u-1, a, b))

    for i, (c, d) in enumerate(map(int, input().split()) for _ in range(N)):
        graph[i].append((i, -c, d))

    hq = [(0, 0, S)]
    INF = 10**18
    # dp[v][silver]
    # 都市vにsilverを使って到達したときの時間の最小値
    dp = [[INF]*2501 for _ in range(N)]
    dp[0][S] = 0

    while hq:
        time, v, silver = heappop(hq)
        if dp[v][silver] < time:
            continue

        for dest, a, b in graph[v]:
            next_s = silver-a if silver-a < 2500 else 2500
            if next_s < 0 or dp[dest][next_s] <= time+b:
                continue
            for i in range(next_s, -1, -1):
                if dp[dest][i] > time+b:
                    dp[dest][i] = time+b
                else:
                    break
            heappush(hq, (time+b, dest, next_s))

    print(*(min(dp[i]) for i in range(1, N)), sep='\n')

main()



Measured memory_bytes: 16000
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
    int a,b,w;
    while(scanf("%d%d%d",&w,&a,&b)==3)
    {
        if(a < b)
        {
            if(a + w > b)
                printf("0\n");
            else
                printf("%d\n",b-a-w);
        }
        else
        {
            if(b + w > a)
                printf("0\n");
            else
                printf("%d\n",a-b-w);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
int p[100005];
int main(){
    int n,m;
    cin>>n>>m;
    int i;
    int sign;
    priority_queue<int> q;
    for(i=1;i<=n;i++){
    	cin>>sign;
    	q.push(sign);
	}
	for(i=1;i<=m;i++){
		int t=q.top();
		q.pop();
		t/=2;
		q.push(t);
	}
	long long sum=0;
	while(q.size()){
		
	  int t=q.top();
	  sum+=t;
	  q.pop();
		
	}
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    sort(A,A+N);
    int ans=0;
    int co=0;
    if(N%2==0){
        int x=N/2-1;
        rep(i,x){
            ans-=2*A[i];
        }
        for(int i=N-1;i>N-1-x;i--){
            ans+=2*A[i];
        }
        ans+=A[x+1]-A[x];
    }else{
        int x=(N-2)/2;
        rep(i,x+1){
            ans-=2*A[i];
        }
        for(int i=N-1;i>N-1-x;i--){
            ans+=2*A[i];
        }
        ans+=A[x]+A[x+2];
        ans+=max(A[x+2]-A[x+1],A[x+1]-A[x]);
    }
    cout << ans << endl;



}


Measured memory_bytes: 1024