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

typedef unsigned long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;
const ll N=3e5 + 5;

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

    n-=1;
    cout<<(n*(n+1))/2;
}



Measured memory_bytes: 256
n=int(input())
lis=list(int(x) for x in input().split() )
ans=0
x=10**9+7
su=0
for i in range(len(lis)) :
    su=su+lis[i]
for i in lis :
    su=su-i
    ans=(ans+su*i)%x

print(ans)


Measured memory_bytes: 31616
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		while(true){
			final int H = sc.nextInt();
			final int W = sc.nextInt();
			
			if(H == 0 && W == 0){
				break;
			}
			
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

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

int main() {
  int N; cin >> N;
  int W[N]; for (int i = 0; i < N; i++) cin >> W[i];
  int C[N+1]; C[0] = 0;
  for (int i = 0; i < N; i++) C[i+1] = C[i] + W[i];
  int min_dif = C[N];
  for (int i = 1; i <= N; i++)
    min_dif = min(min_dif, abs(C[N] - 2 * C[i]));
  cout << min_dif << endl;
}

Measured memory_bytes: 256
def main():

    N, M = map(int, input().split())
    A = []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append([a, b-1])

    A.sort()

    a, b = A[0]
    cnt = 1
    for i in range(1, M):
        if A[i][0] <= b:
            a = A[i][0]
            b = min(b, A[i][1])
        else:
            a, b = A[i]
            cnt += 1
    return cnt

if __name__ == '__main__':
    print(main())


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N, A, B; cin >> N >> A >> B;
    ll cnt = N / (A + B);
    ll mod = N % (A + B);
    ll ans = A * cnt + min(mod, A);
    cout << ans << "\n";
}

Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val (N, L) = readLine()!!.split(" ").map { it.toInt() }

    val tastes = (1..N).map { L + it - 1 }
    val sum = tastes.sum()
    if (tastes.first() < 0 && tastes.last() < 0) {
        println(sum - tastes.last())
    } else if (tastes.first() > 0 && tastes.last() > 0) {
        println(sum - tastes.first())
    } else {
        println(sum)
    }
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<int>> v(1002, vector<int>(1002, -1));
    array<bitset<1002>, 1002> use;
    map<pair<int,int>, pair<int,int>> p;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            int x = i + j, y = i - j + 500;
            use[x].set(y);
        }

    if(d & 1){
        for(int i = 0; i < 1002; ++i)
            for(int j = 0; j < 1002; ++j)
                v[i][j] = i % 2;
    }else{
        for(int i = 0; i < 1002; ++i)
            for(int j = 0; j < 1002; ++j){
                int f1 = i % (2 * d) >= d;
                int f2 = j % (2 * d) >= d;
                v[i][j] = f1 + 2 * f2;
            }
    }

    auto print = [&]{
        string s = "RYGB";
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                int x = i + j, y = i - j + 500;
                cout << s[v[x][y]];
            }
            cout << endl;
        }
    };

    print();
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using pint = pair<int, int>;
using pll = pair<ll,ll>;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,h;
    cin >> n >> h;
    vector<int>b(n+1,0);
    int cut_max=0,a;
    REP(i,n){
        cin >> a >> b[i];
        cut_max = max(a,cut_max);
    }
    sort(b.begin(),b.end(),greater<>());
    int count=0;
    for(int i=0;i<n+1;i++){
        if(cut_max<b[i])h-=b[i];
        else{
            count += (h+cut_max-1)/cut_max + i;
            break;
        }
        if(h<=0){
            count += i+1;
            break;
        }
    }
    COUT(count);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int A[100][100];
    int B[100][100];
    int n, m, l;
    long long c;
    int i, j, k;
    scanf("%d %d %d", &n, &m, &l);
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    for(i = 0; i < m; i++) {
        for(j = 0; j < l; j++) {
            scanf("%d", &B[i][j]);
        }
    }
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            c = 0;
            for(k = 0; k < m; k++) {
                c += A[i][k] * B[k][j];
            }
            if(j == (l-1)) {
                printf("%lld\n", c);
            } else {
                printf("%lld ", c);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
char s[200005];
int f[200005];
int dp1[200005], dp2[2][200005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cin >> s+1;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(s[i] == '1') cnt++;
    }
    for(int i=1;i<=200000;i++){
        int b = __builtin_popcount(i);
        f[i] = f[i%b] + 1;
    }

    int mod = cnt-1;
    if(mod >= 1){
        int sum = 0, mul = 1;
        for(int i=n;i>=1;i--){
            if(s[i] == '1') sum = (sum + mul)%mod;
            mul = mul*2%mod;
        }
        dp1[0] = sum;

        sum = 0, mul = 1;
        for(int i=n;i>=1;i--){
            dp2[0][i] = mul;
            mul = mul*2%mod;
        }
    }
    mod = cnt+1;
    int sum = 0, mul = 1;
    for(int i=n;i>=1;i--){
        if(s[i] == '1') sum = (sum + mul)%mod;
        mul = mul*2%mod;
    }
    dp1[1] = sum;

    sum = 0, mul = 1;
    for(int i=n;i>=1;i--){
        dp2[1][i] = mul;
        mul = mul*2%mod;
    }

    for(int i=1;i<=n;i++){
        if(s[i] == '1'){
            int mod = cnt-1;
            if(mod == 0) printf("0\n");
            else{
                int val = (dp1[0] - dp2[0][i] + mod)%mod;
                printf("%d\n", f[val]+1);
            }
        }
        else{
            int mod = cnt+1;
            int val = (dp1[1] + dp2[1][i])%mod;
            printf("%d\n", f[val]+1);
        }
    }
}

Measured memory_bytes: 6252
#include <cstdio>

int arr[201] = {0};

int main()
{
  for (int i = 1; i < 201; i += 2)
  {
    for (int j = 1; j <= i; j += 2)
    {
      if (i % j == 0)
        ++arr[i];
    }
  }

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

  int count = 0;
  for (int i = 1; i <= n; i += 2)
  {
    if (arr[i] == 8)
      ++count;
  }

  printf("%d", count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int main(){
	int N,K;
	string s;
	cin>>N;
	cin>>s;
	cin>>K;
	char a = s[K-1];
	for(int i=0;i<N;i++){
		if(s[i] != a) s[i] = '*';
	}
cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
// # get a integer
// fscanf(STDIN, "%d", $a);
// # get two integers separated with half-width break
// fscanf(STDIN, "%d %d", $b, $c);
// # get a string
// fscanf(STDIN, "%s", $s);
// # output
// echo ($a+$b+$c)." ".$s."\n";

// sort
fscanf(STDIN, "%d %d %d", $a, $b, $c);

$arr = array($a, $b, $c);

sort($arr);

if($arr[1]-$arr[0] === $arr[2]-$arr[1])
	print_r("YES");
else
	print_r("NO");

//  

Measured memory_bytes: 4728
import java.util.*;
import java.math.*;
public class Main {
	static int[] color;
	static int[] component;
	static int component_count;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String t = in.next();
		if(s.equals(t.substring(0, t.length() - 1))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} 


Measured memory_bytes: 35744
from itertools import accumulate
from bisect import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

A_cs = list(accumulate(A))

def can_survive(i): #ソート済みAのi番目(0-index)の生き物が生き残る
  can_absorb = i
  while True:
    cur_volume = A_cs[can_absorb]
    can_absorb_v = A_cs[can_absorb]*2
    if can_absorb_v >= max_a:
      return True
    next_can_absorb = bisect(A,can_absorb_v)-1
    if can_absorb == next_can_absorb:
      return False
    else:
      can_absorb = next_can_absorb

#print([can_survive(i) for i in range(N)])

def search(l,r): #surviveする最小のi
  if r==l+1:
    if can_survive(l):
      return l
    else:
      return r
  c = (l+r)//2
  if can_survive(c):
    return search(l,c)
  else:
    return search(c,r)

x = search(0,N)
print(N-x)

Measured memory_bytes: 14524
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    int mx = 0;
    ll ans = 0;
    rep(i,n){
        if(!chmax(mx, a[i])){
            ans += mx-a[i];
        }
    }
    cout << ans << '\n';
    
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	ll x;
	cin>>x;
	for (ll i=-1000; i<=1000; i++){
		for (ll j=-1000; j<=1000; j++){
			if (i*i*i*i*i-j*j*j*j*j==x){
				cout<<i<<' '<<j;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3640
# ABC145 - Virtual
# A
if False: print(int(input())**2)

# B
if True:
    N=int(input())
    S=input()
    print('Yes' if N%2==0 and S[:N//2]*2==S else 'No')
# C
if False:
    import itertools

    def fact(n,mod):
        ret=1
        for i in range(2,n+1):
            ret=(ret*i)%mod
        return ret

    N=int(input())
    X=[tuple(map(int,input().split())) for _ in range(N)]
    ans=0
    for p in itertools.permutations(X):
        # print(p)
        sx,sy=p[0]
        for x,y in p:
            ans+=((sx-x)**2+(sy-y)**2)**0.5
            sx,sy=x,y
        # print(ans)
    ans/=fact(N,10**9+7)
    print(ans)

# D
# E

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

#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	
	int n, k;	
	cin >> n >> k;

	double prefix[n];
	double a[n] ;

	double x;

	cout << fixed << setprecision(6);
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		x =  x + 1;

		x = x / 2;
		if (i == 0)
		{
			a[i] = x;
		}
		else
		{
			a[i] = x + a[i-1];
		}	

	}

	double sum = a[k-1];


	double temp = 0;

	for (int i = k; i < n; i++ )
	{
		temp = a[i] - a[i - k];

		if(temp > sum )
			sum = temp;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = (int)b/a;
      if(c*a == b) System.out.println(a+b);
      else System.out.println(b-a);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,l,MIN=1e9,all=0,sabun;
  cin >> n >> l;
  for(int i=0;i<n;i++){
    all+=l+i;
    if(MIN>abs(l+i)){
      MIN=min(MIN,abs(l+i));
      sabun=l+i;
    }
  }
  cout << all-sabun << endl;
  return 0;
}

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

int i,n,q,A[N],m;

int plus(i,m){
  int x;

  if(m==0) return 1;
  else if(i>=n) return 0;

  x = plus(i+1,m) || plus(i+1,m-A[i]);
  return x;
}

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

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);

    if(plus(0,m)==1){
      printf("yes\n");
    }
		else{
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2004
import math
def prime(n):
    k = 2
    while k<=math.sqrt(n):
        if n % k == 0:
            # print(k,"の倍数です")
            return False
        k += 1
    return True
l = [0]*(10**5+1)
for i in range(2,10**5+1):
    if prime(i) and prime(int((i+1)/2)):
        l[i] += 1
l[2] = 0
# print(l[:10])
for i in range(10**5):
    l[i+1] = l[i] + l[i+1]

# print(l[:10])
# print(prime(35))    
q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    print(l[b] - l[a-1])


Measured memory_bytes: 54108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t,n,i,j,a,sum=0;
    cin>>n>>a;
    int s[n];
    for(i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);
    for(i=0;i<a;i++)
    {
        sum+=s[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String os = "CODEFESTIVAL2016";
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != os.charAt(i))
				count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 10064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define umap unordered_map
#define double long double
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef complex<double> point;
template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}
const int maxn = 1e5 + 100;
int a[maxn];
int main(){
	iOS;
	int n;
	cin >> n;
	For(i,0,n){
		cin >> a[i];
		-- a[i];
	}
	int ans = 0;
	For(i,0,n)
		if(i < a[i] && a[a[i]] == i)
			++ ans;
	cout << ans << endl;
	return 0;
}

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

int data[10];

bool bt(int b, int c, int no) {
    if (no >= 10) return true;
    else if (data[no] < b && data[no] < c) return false;//どっちにも入れれない＞＜

    if (data[no] > b) return bt(data[no], c, no+1);
    else if (data[no] > c) return bt(b, data[no], no+1);
}

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> data[j];
        }
        if (bt(0, 0, 0)) cout << "YES";
        else cout << "NO";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
deque<char> deq;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for(auto tmp : S) {
        deq.push_back(tmp);
    }
    bool on = false;
    int Q;
    cin >> Q;
    while(Q--) {
        int T;
        cin >> T;
        if(T == 1) on ^= true;
        else {
            int F;
            cin >> F;
            char c;
            cin >> c;
            if(on ^ (F == 1)) deq.push_front(c);
            else deq.push_back(c);
        }
    }
    string ans;
    for(auto tmp : deq) ans.push_back(tmp);
    if(on) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1368
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define MAXN 2000
struct Edge{
    int v,u;
}E[MAXN+5];
int N,K;
vector<int> G[MAXN+5];

int dfs(int u,int f,int MaxD,int D){
    int ret=0;
    if(D>MaxD)
        ret++;
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i];
        if(v!=f)
            ret+=dfs(v,u,MaxD,D+1);
    }
    return ret;
}

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<N;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
        E[i]=(Edge){u,v};
    }
    int Ans=N;
    if(K&1)
        for(int i=1;i<N;i++)
            Ans=min(Ans,dfs(E[i].u,E[i].v,K/2,0)+dfs(E[i].v,E[i].u,K/2,0));
    else
        for(int i=1;i<=N;i++)
            Ans=min(Ans,dfs(i,-1,K/2,0));
    printf("%d",Ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int a,b,i,c,d;
    map<long long int,long long int>m;
    vector<long long int>v;
    string s;
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
  if(a+b+c+d==7) {cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7\n";}
    else if(a+b+c-d==7)
   {cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7\n";}
    else if(a+b-c+d==7)
  {cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7\n";}
      else if(a-b+c+d==7)
  {cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7\n";}
      else if(a-b-c-d==7)
   {cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7\n";}
    else if(a-b-c+d==7)
   {cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7\n";}
    else if(a-b+c-d==7)
  {cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7\n";}
        else if(a+b-c-d==7)
  {cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7\n";}
 
     }

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

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    bool water[31];
    for(int i=1;i<=30;i++) water[i]=false;
    queue<int> Q;
    Q.push(A);
    Q.push(B);
    while(!Q.empty()){
        int t=Q.front();
        Q.pop();
        if(t<=F/100) water[t]=true;
        if(t+A<=F/100 && !water[t+A]){
            Q.push(t+A);
        }
        if(t+B<=F/100 && !water[t+B]){
            Q.push(t+B);
        }
    }
    double max=0.0;
    int answ,anss;
    for(int i=1;i<=30;i++){
        if(!water[i]) continue;
        for(int b=0;b<=E*i/D;b++){
            int s=D*b+C*((i*E-D*b)/C);
            if(100*i+s>F) s=F-100*i;
            if(s<0) continue;
            if(max<=100.0*s/(100.0*i+s)){
                max=100.0*s/(100.0*i+s);
                answ=100*i;
                anss=s;
            }
        }
    }

    cout << (answ+anss) << ' ' << anss << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    int temp;
    vector<int> p;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        p.push_back(temp);
    }
    sort(p.begin(), p.end());

    vector<int> q;
    for (int i = -105; i < 105; i++) {
        auto itr = std::find(p.begin(), p.end(), i);    //  最初の要素5へのイテレータを返す
        if (itr != p.end()) {     // 発見した場合
            
        } else {
            q.push_back(i);
        }
    }


    int sa;
    int ans_num;

    for (int i = 0; i < q.size(); i++) {
        if (i == 0) {
            sa = abs(x - q[i]);
            ans_num = 0;
        } else {
            if (sa > abs(x - q[i])) {
                sa = abs(x - q[i]);
                ans_num = i;
            }
        }
    }

    cout << q[ans_num];

    

    return 0;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
#define all(v) v.begin(), v.end()

int main(){
  int n;
  cin >> n;
  string ans = "";
  REP(i,0,n){
    ans += "ACL";
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n,k;
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int rt;
int col[N],fa[N];
int lef[N],rig[N];
int val[N];
bool ans;
int id[N];

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

void dfs1(int x){
	for(int p=h[x];p;p=e[p].nxt)
	if (col[e[p].x]==-1){
		fa[e[p].x]=x;
		col[e[p].x]=col[x]^1;
		dfs1(e[p].x);
	}
}

void dfs2(int x){
	lef[x]=-1e+9,rig[x]=1e+9;
	if (col[x]){
		for(int p=h[x];p;p=e[p].nxt)
		if (fa[e[p].x]==x){
			dfs2(e[p].x);
			lef[x]=max(lef[x],lef[e[p].x]-1);
			rig[x]=min(rig[x],rig[e[p].x]);
		}
	}
	else{
		for(int p=h[x];p;p=e[p].nxt)
		if (fa[e[p].x]==x){
			dfs2(e[p].x);
			lef[x]=max(lef[x],lef[e[p].x]);
			rig[x]=min(rig[x],rig[e[p].x]+1);
		}
	}
	if (lef[x]>rig[x])ans=0;
	if (val[x]>-1){
		if (val[x]/2<lef[x]||val[x]/2>rig[x])ans=0;
		lef[x]=rig[x]=val[x]/2;
	}
}

void getid(int x){
	id[x]=lef[x]*2+col[x];
	for(int p=h[x];p;p=e[p].nxt)
	if (fa[e[p].x]==x){
		if (!col[x]){
			lef[e[p].x]=max(lef[e[p].x],lef[x]-1);
			rig[e[p].x]=min(rig[e[p].x],lef[x]);
		}
		else{
			lef[e[p].x]=max(lef[e[p].x],lef[x]);
			rig[e[p].x]=min(rig[e[p].x],lef[x]+1);
		}
		getid(e[p].x);
	}
}

int main(){
	n=get();
	fo(i,1,n)col[i]=val[i]=-1;
	fo(i,2,n){
		int x=get(),y=get();
		inse(x,y),inse(y,x);
	}
	k=get();
	fo(i,1,k){
		int x=get(),v=get();
		val[x]=v;
		if (i==1)rt=x;
	}
	col[rt]=val[rt]&1;
	dfs1(rt);
	fo(i,1,n)
	if (val[i]>-1&&(val[i]&1)!=col[i])return printf("No\n"),0;
	ans=1;
	dfs2(rt);
	if (!ans)return printf("No\n"),0;
	printf("Yes\n");
	getid(rt);
	fo(i,1,n)printf("%d\n",id[i]);
	return 0;
}

Measured memory_bytes: 8320
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int>a(n);
  for (int & x: a) {
    char c; std::cin >> c;
    x = c == 'E';
  }
  std::partial_sum(all(a),a.begin());
  a.insert(a.begin(),0);
  debug(a);

  int ans = n;
  rep(i,0,n) {
    int x = i - a.at(i);
    int y = a.at(n) - a.at(i+1);
    assert(0<=x&&0<=y);
    int now = x + y;
    debug(i,x,y,now);
    cmn(ans,now);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3584
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(1 << n);
    let mut top2 = a
        .into_iter()
        .enumerate()
        .map(|(i, a)| ((a, i), (0, 0)))
        .collect::<Vec<_>>();
    let mut masks = (0..(1usize << n))
        .map(|mask| (mask.count_ones(), mask))
        .collect::<Vec<_>>();
    masks.sort();
    for (_, mask) in masks.into_iter() {
        for i in 0..n {
            if mask & (1 << i) != 0 {
                continue;
            }
            let next_mask = mask | (1 << i);
            top2[next_mask] = add(top2[next_mask], top2[mask].0);
            top2[next_mask] = add(top2[next_mask], top2[mask].1);
        }
    }

    let mut max = 0;
    for i in 1..(1 << n) {
        let ((a, _), (b, _)) = top2[i];
        max = cmp::max(max, a + b);
        sc.write(format!("{}\n", max));
    }
}

fn add<T: PartialOrd>((a, b): (T, T), v: T) -> (T, T) {
    if a == v || b == v {
        (a, b)
    } else if v > a {
        (v, a)
    } else if v > b {
        (a, v)
    } else {
        (a, b)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

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

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

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

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};


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

    vector<vector<int>> rival(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        rival[a].push_back(b);
        rival[b].push_back(a);
    }

    UnionFind uf(n);

    int bridge = 0;
    rep(i, n - 1) {
        int a = i;
        int b = i + 1;

        bool ok = [&] {
            for (int c : rival[b]) {
                if (uf.is_union(a, c)) {
                    return false;
                }
            }
            return true;
        }();

        if (ok) {
            bridge++;
            uf.connect(a, b);
        }
    }

    cout << n - 1 - bridge << endl;

}





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

const int BLACK = 0, WHITE = 1, NOT_VISITED = -1;

int flip(const int color) {
  return WHITE ^ color;
}

void dfs(int v, const Tree& tree, vector<int>& node, int color) {
  node[v] = color;

  for (auto e : tree[v]) {
    int nv = e.first;
    int w = e.second;

    if (node[nv] != NOT_VISITED)
      continue;

    int nc = (w % 2 == 0) ? color : flip(color);
    dfs(nv, tree, node, nc);
  }
}

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

  vector<int> node(n, NOT_VISITED);
  Tree t(n);

  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    t[u].emplace_back(v, w);
    t[v].emplace_back(u, w);
  }

  dfs(0, t, node, BLACK);

  rep(i, n) cout << node[i] << endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	long double x[1010],y[1010];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	double ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	ans*=2.0/n;
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}


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

struct card{
  int card;
  int number;
  string mark;
};

bool check_stability(vector<card>& b, vector<card>& s){
  for(int i = 0; i < b.size(); i++){
    if(b[i].card != s[i].card) return false;
  }
  return true;
}

int find_min(vector<card>& v, int sorted_end){
  int min_id;
  int min = 100;
  for(int i = sorted_end; i < v.size(); i++){
    if(v[i].number < min){
      min_id = i;
      min = v[i].number;
    }
  }
  return min_id;
}

void SelectionSort(vector<card>& data, vector<card>& s_sort){
  int id;
  for(int i = 0; i < s_sort.size(); i++){
    id = find_min(s_sort, i); 
    swap(s_sort[i],s_sort[id]);
  }
}

void BubbleSort(vector<card>& data, vector<card>& b_sort){
  for(int i = 0; i < b_sort.size()-1; i++){ 
    for(int j = 0; j < b_sort.size() - i; j++){
      if(b_sort[b_sort.size()-2 - j].number > b_sort[b_sort.size()-1 - j].number){
        swap(b_sort[b_sort.size()-2 - j], b_sort[b_sort.size()-1 - j]);
      }
    }
  }
}



card input_to_struct(string input){
  card data={*(input.substr(0,1)).c_str()-'A', atoi(input.substr(1).c_str()),input.substr(0,1)};
  return data;
}

int main(int argc,char* argv[]){
  int n = 0;
  string input;
  vector<card> data, b_sort, s_sort;
  cin >> n;
  for(int i = 0; i < n;i++) {
    cin >> input;
    data.push_back(input_to_struct(input));
  }
  
  for(int i = 0; i<data.size();i++){
    s_sort.push_back(data[i]);
    b_sort.push_back(data[i]);
  }

  SelectionSort(data, s_sort);
  BubbleSort(data, b_sort);
  for(int i = 0; i < data.size(); i++){
    cout << b_sort[i].mark <<  b_sort[i].number;
    if(i < data.size()-1) cout << " ";
    else cout << endl;
  }
  if(true){
    cout << "Stable" << endl;
  }else{
    cout << "Not Stable" << endl;
  }
  for(int i = 0; i < data.size(); i++){
    cout << s_sort[i].mark <<  s_sort[i].number;
    if(i < data.size()-1) cout << " ";
    else cout << endl;
  }
  if(check_stability(b_sort, s_sort)){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
} 

Measured memory_bytes: 3124
#include <iostream>

using namespace std;
static const int MAX = 2000000;

int H, A[MAX + 1];

void maxHeapify(int i){
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	largest = i;
	if (l <= H && A[l] > A[i]){
		largest = l;
	}
	if (r <= H && A[r] > A[largest]){
		largest = r;
	}
	if (largest != i){
		int temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(largest);
	}
}

void solve(){
	cin >> H;
	for (int i = 1; i <= H; ++i)
	{
		cin >> A[i];
	}
	for (int i = H / 2; i >= 1; --i)
	{
		maxHeapify(i);
	}
	for (int i = 1; i <= H; ++i)
	{
		cout << " " << A[i];
	}
	cout << endl;
}

int main(){
	cin >> H;
	for (int i = 1; i <= H; ++i){
		cin >> A[i];
	}
	for (int i = H / 2; i >= 1; --i){
		maxHeapify(i);
	}
	for (int i = 1; i <= H; ++i){
		cout << " " << A[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 5004
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;

int n, m,l;
string s;


int main() {
	cin >> n >> m;
	int sta = 1;
	int en = n;
	int a, b;
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		sta = max(sta,a);
		en = min(en,b);
	}
	int ans = en-sta + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}





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

int main()
{
    int n, i, j;
    cin >> n;
    int a[n][3];
    for(i = 0; i < n; ++i) {
        for(j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    int dp[3];
    dp[0] = a[0][0];
    dp[1] = a[0][1];
    dp[2] = a[0][2];

    for(i = 1; i < n; ++i) {
        for(j = 0; j < 3; ++j) {
            if(j == 0)
                dp[j] = max(a[i][j] + dp[1], a[i][j] + dp[2]);
            else if(j == 1)
                dp[j] = max(a[i][j] + dp[0], a[i][j] + dp[2]);
            else
                dp[j] = max(a[i][j] + dp[0], a[i][j] + dp[1]);
        }
        //wrong as if dp[0] is changed then for j=1, dp[1] will work with changed dp[0] val, hence we need new
        //cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    }
    cout << max({ dp[0], dp[1], dp[2] }) << "\n";

    return 0;
}*/

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, i, j;
    cin >> n;
    int a[n][3];
    for(i = 0; i < n; ++i) {
        for(j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    int dp[3];
    dp[0] = a[0][0];
    dp[1] = a[0][1];
    dp[2] = a[0][2];

    for(i = 1; i < n; ++i) {
        int newdp[3];
        for(j = 0; j < 3; ++j) {
            if(j == 0)
                newdp[j] = a[i][j] + max(dp[1], dp[2]);
            else if(j == 1)
                newdp[j] = a[i][j] + max(dp[0], dp[2]);
            else
                newdp[j] = a[i][j] + max(dp[0], dp[1]);
        }
        dp[0] = newdp[0];
        dp[1] = newdp[1];
        dp[2] = newdp[2];
        // wrong as if dp[0] is changed then for j=1, dp[1] will work with changed dp[0] val, hence we need new
        // cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    }
    cout << max({ dp[0], dp[1], dp[2] }) << "\n";

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define sort(v)	sort(v.begin(),v.end());
#define rsort(v) sort(v.rbegin(),v.rend());
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1,temp;a=a%m;while(b){if(b&1){res=(res*a)%m;}temp=(a%m);a=(temp*temp)%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}











int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char ch1,ch2,ch3,ch;
	string s1,s2,s3,str;
    lli i,j,k,a,t,b,c,n,m,sum=0,ans=0,temp;
    cin >> a >> b;
    if(a==b){
    	rep(i,0,a)	cout << a;
	}
	else{
		if(a<b){
			rep(i,0,b)	cout << a;
		}
		else{
			rep(i,0,a)	cout << b;
		}
	}
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

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

Measured memory_bytes: 256
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

const int MN = 100111;

vector<int> ke[MN];
bool good;
int cnt;
int color[MN];

void dfs(int u) {
    ++cnt;
    for(int v : ke[u]) {
        if (color[v] < 0) {
            color[v] = 1 - color[u];
            dfs(v);
        }
        else {
            if (color[v] == color[u]) good = true;
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9);
    int n, m;
    while (cin >> n >> m) {
        FOR(i,1,n) ke[i].clear();
        FOR(i,1,m) {
            int u, v; cin >> u >> v;
            ke[u].push_back(v);
            ke[v].push_back(u);
        }

        memset(color, -1, sizeof color);

        int single = 0;
        int hasOddCycle = 0;
        int normal = 0;

        FOR(i,1,n) if (color[i] < 0) {
            cnt = 0;
            good = false;
            color[i] = 0;
            dfs(i);

            if (cnt == 1) single++;
            else if (good) hasOddCycle++;
            else normal++;
        }

        int res = 0;
        // single, x
        while (single > 0) {
            res += 2 * n - 1;
            --n;
            --single;
        }

        // normal, normal
        res += normal * normal * 2;

        // odd, odd
        res += hasOddCycle * hasOddCycle;

        // normal, odd
        res += normal * hasOddCycle * 2;

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


Measured memory_bytes: 12416
#include <iostream>
using namespace std;
const int mod = 1e9+7;

const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
  }
}

// 二項係数計算
// mainの中でCOMinit()を呼んで初期化してあげる
long long COM(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;
}

int main() {
  COMinit();
  int N, M; cin >> N >> M;
  int ans = COM(N, 2) + COM(M, 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12160
using System;
using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int N = int.Parse(Console.ReadLine());
      string ss = Console.ReadLine();

      BubbleSort(ss.Split(), ss.Split(), N);

      SelectionSort(ss.Split(), ss.Split(), N);
    }

    static void BubbleSort(string[] C0, string[] C, int N)
    {
      for (int i = 0; i < N - 1; i++)
      {
        for (int j = N - 1; j >= i + 1; j--)
        {
          if ((int)C[j][1] < (int)C[j - 1][1])
          {
            string temp = C[j];
            C[j] = C[j - 1];
            C[j - 1] = temp;
          }
        }
      }
      if (StableCheck(C0, C) == true) Console.WriteLine("Stable");
      else Console.WriteLine("Not stable");
    }

    static void SelectionSort(string[] C0, string[] C, int N)
    {
      for (int i = 0; i < N - 1; i++)
      {
        int minj = i;
        for (int j = i; j <= N - 1; j++)
        {
          if (C[j][1] < C[minj][1]) minj = j;
        }
        string temp = C[minj];
        C[minj] = C[i];
        C[i] = temp;
      }

      if (StableCheck(C0, C) == true) Console.WriteLine("Stable");
      else Console.WriteLine("Not stable");
    }

    static bool StableCheck(string[] C0, string[] C)
    {
      string st = "";
      foreach (var x in C)
      {
        st += x[0].ToString() + x[1].ToString() + " ";
      }
      Console.Write(st.Trim() + "\n");

      List<int> list = new List<int>();

      foreach (var x in C)
      {
        int count = 0;
        for (int i = 0; i < C.Length; i++)
        {
          if (C[i][1] == x[1]) count++;
        }
        if (count == 1)
        {
          count = 0;
          continue;
        }
        list.Add(x[1]);
      }

      foreach (var d in list)
      {
        List<char> s0 = new List<char>();
        List<char> s1 = new List<char>();

        for (int j = 0; j < C0.Length; j++)
        {
          if (C0[j][1] == d) s0.Add(C0[j][0]);
        }

        for (int j = 0; j < C.Length; j++)
        {
          if (C[j][1] == d) s1.Add(C[j][0]);
        }
        if (new String(s0.ToArray()) != new String(s1.ToArray())) return false;
      }
      return true;
    }

  }
}









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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll A,P,ans;
  cin >> A>> P;
  ans = (A*3+P)/2;
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256