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

int n;

int main() {
  cin >> n;
  vector<int> g[n];
  pair<int, int> p[n];
  for (int i = 0; i < n; i ++) p[i].first = 0;

  for (int i = 0; i < n - 1; i ++) {
    int a, b;
    cin >> a >> b;
    a --, b --;
    g[a].push_back(b);
    g[b].push_back(a);
    p[a].first ++, p[b].first ++;
    p[a].second = a, p[b].second = b;
  }

  vector<int> c(n);
  int sum = 0;
  for (int i = 0; i < n; i ++) {
    cin >> c[i];
    sum += c[i];
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  sum -= c[0];

  sort(p, p + n);
  reverse(p, p + n);

  vector<int> ans(n);
  vector<int> check(n, 0);
  queue<int> q;
  q.push(p[0].second);
  ans[p[0].second] = c[0];
  int u, i = 1;
  while (!q.empty()) {
    u = q.front(); q.pop();
    check[u] = 2;
    priority_queue<pair<int, int>> pq;
    for (int i = 0; i < g[u].size(); i ++) {
      if (check[g[u][i]] == 2) continue;
      q.push(g[u][i]);
      pq.push(make_pair((int)g[g[u][i]].size(), g[u][i]));
    }

    while (!pq.empty()) {
      pair<int, int> v;
      v = pq.top(); pq.pop();
      if (check[v.second] == 0) {
        ans[v.second] = c[i];
        i ++;
        check[v.second] = 1;
      }
    }
  }

  cout << sum << endl;
  for (int i = 0; i < n; i ++) {
    if (i) cout << " ";
    cout << ans[i] ;
  }
  cout << endl;
}

Measured memory_bytes: 1280
def main():
    from collections import deque

    h, w = map(int, input().split())

    s = [input() for _ in range(h)]

    drdc = (1, 0), (-1, 0), (0, 1), (0, -1)

    ret = -1
    for r in range(h):
        for c in range(w):
            if s[r][c] == '.':
                dist = [[-1] * w for _ in range(h)]
                dist[r][c] = 0

                q = deque()
                q.append((r, c, 0))

                md = -1
                while q:
                    qr, qc, d = q.popleft()
                    for dr, dc in drdc:
                        nr = qr + dr
                        if nr < 0 or h <= nr:
                            continue
                        nc = qc + dc
                        if nc < 0 or w <= nc:
                            continue
                        if s[nr][nc] == '#':
                            continue
                        if dist[nr][nc] != -1:
                            continue
                        nd = d + 1
                        dist[nr][nc] = nd
                        if md < nd:
                            md = nd

                        q.append((nr, nc, nd))

                ret = max(ret, md)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);

int main() {
	double a, b, h, m;
    cin >> a >> b >> h >> m;

    double hh = (double)h / 12.0 + (m / (60 * 12));
    double mm = (double)m / 60.0;
    double r = 2 * pi * (mm - hh);

    double ans = (a * a) + (b * b) - (2 * a * b * cos(r));
    if (ans < 0.00) ans = -ans;
    cout << fixed << setprecision(20) << sqrt(ans) << '\n';

    return 0;
}

Measured memory_bytes: 4168
import sys

N, M = map(int, input().split())
AB = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N)]

AB.sort()

res = 0
for a, b in AB:
    if M > b:
        M -= b
        res += a * b
    else:
        res += a * M
        break
print(res)


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	VI abc(3);
	cin >> abc[0] >> abc[1] >> abc[2];
	sort(all(abc));
	cout << (abc[2] == abc[1] + abc[0]? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
cnt=0
for i in range(1, n+1, 2):
    ans = 1
    for j in list(set(prime_factorize(i))):
        ans *= (1+prime_factorize(i).count(j))
    if ans == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(0, input[0] - 2 * input[1]));
        }
    }
}


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

vector<pair<uint64_t, int>> factors(uint64_t n) {
  vector<pair<uint64_t, int>> f;
  int count = 0;
  while (n % 2 == 0) {
    count++;
    n /= 2;
  }
  if (count)
    f.push_back({2, count});
  for (uint64_t k = 3; k <= sqrt(n); k += 2) {
    count = 0;
    while (n % k == 0) {
      count++;
      n /= k;
    }
    if (count)
      f.push_back({k, count});
  }

  if (n > 2)
    f.push_back({n, 1});
  return f;
}
uint64_t ipow(uint64_t n, int k) {
  uint64_t r = 1ULL;
  for (int i = 0; i < k; i++)
    r *= n;
  return r;
}
int main() {
  uint64_t n; cin >> n;
  int total = 0;
  unordered_set<uint64_t> zs;

  for (auto [p, c] : factors(n)) {
    for (int k = 1; k <= c; k++) {
      uint64_t z = ipow(p, k);
      if (!zs.count(z) && n % z == 0) {
        n /= z;
        total++;
        zs.insert(z);
      }
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll wt[101],pft[101];
ll n;
ll dp[110][100001];
ll solve(ll st_index,ll wt_left){
    
    if(st_index == n ) return 0;
    
    if(dp[st_index][wt_left]!=-1) return dp[st_index][wt_left];
    
    ll ans = solve(st_index+1,wt_left);
    
    if(wt[st_index]<=wt_left){
        ans = max(ans,pft[st_index]+solve(st_index+1,wt_left-wt[st_index]));
    }
    
    return dp[st_index][wt_left] = ans;
    
}


int main() {
	
	ll w;
	cin>>n>>w;
	memset(wt,0,sizeof wt);
	memset(pft,0,sizeof pft);
	memset(dp,-1,sizeof dp);
	
	for(ll i=0;i<n;i++){
	    cin>>wt[i]>>pft[i];
	}
	
	ll ans = solve(0,w);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 86144
/*
power code taken from geeks for geeks
*/
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;


const ll INF = 1e18 + 5;
const ll MAX_N = 1e5 + 5;
const ll MODD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
ld modd(ld a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return (a + MODD) % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str {
    ll a, b;
};



void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll ans = 0LL;
    ll c = a[0];
    for(ll i = 1; i < n; i++) {
        ans = modulo(ans + a[i] * c);

        c = modulo(c + a[i]);
    }

    cout << ans << endl;
}

int main(){


  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    


    ll t=1;

    // cin >> t;

    


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

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

int a,b,c,ans;
string s;


int  main()
{
    cin>>a>>b;
    if(a>=13){
        cout<<b<<endl;
    }else if(a<=5){
        cout<<0<<endl;
    }else{
        cout<<b/2<<endl;
    }

}


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

using namespace std;

#define MOD 1000000007
#define PB push_back
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef pair<int, int> PII;
typedef pair<int, string> PIS;
typedef pair<string, int> PSI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef set<double> SETD;
typedef multiset<int> MSETI;
typedef deque<int> DQI;
typedef deque<double> DQD;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    char s[n];
    cin >> s;
    char prev = s[0];
    int slimes = 1;
    for(int i = 1; i < n; i++) {
        if(s[i] != prev) {
            slimes++;
            prev = s[i];
        }
    }
    cout << slimes << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
n = N-1
for i in range(N//2):
  if A[2*i]!=n or A[2*i+1]!=n:
    print(0)
    exit()
  n -= 2
  
if N&1 and A[-1]!=0:
  print(0)
  exit()

print((1<<N//2)%(10**9+7))


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int H, W; cin >> H >> W;
    vector<string> s( H );
    REP( i, H ) cin >> s[i];

    REP( i, W + 2 ) cout << "#";
    cout << endl;
    REP( i, H ){
        cout << "#" << s[i] << "#" << endl;
    }
    REP( i, W + 2 ) cout << "#";
    cout << endl;
}


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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;
    ans += n / x;
    ans += (n % x != 0);
    cout << ans * t << endl;
    return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int m = n / 2;
  cout << a[m] - a[m - 1] << '\n';
  return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)

Measured memory_bytes: 32136
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	long long temp;
	int n;
	scanf("%d", &n);
	map<long long, int>p;
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", &temp);
		p[temp] += 1;
	}
	int count = 0;
	for (auto it = p.begin(); it != p.end(); ++it)
	{
		if (it->second % 2 == 1)
			count++;
	}
	printf("%d\n", count);
	system("pause");
	return 0;
}

Measured memory_bytes: 6776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long dp[100010][3];
int main(){
    int n; cin>>n;
    cin>>dp[1][0]>>dp[1][1]>>dp[1][2];
    for(int i=2;i<=n;i++){
        int a[3]; rep(j,3) cin>>a[j];
        for(int j=0;j<3;j++){
            dp[i][j]=max(dp[i-1][(j+1)%3]+a[j],dp[i-1][(j+2)%3]+a[j]);
        }
    }
    long long ans=0;
    rep(i,3) ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
use std::io::*;
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut ans: u64 = itr.next().unwrap().parse().unwrap();
    for _ in 0..n - 1 {
        let a: u64 = itr.next().unwrap().parse().unwrap();
        ans = lcm(ans, a);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
      ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
      ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}

void solve(istream& cin, ostream& cout) {
  int a, b, x;
  cin >> a >> b >> x;
  long double ok = PI / 2.0;
  long double ng = 0.0;
  REP(i, 100000) {
    long double mid = (ok + ng) / 2.0;
    if (f(a, b, mid) < x) ok = mid;
    else
      ng = mid;
  }
  cout << ok / PI * 180 << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    a=inp()
    b=inp()
    c=inp()
    print(((a+b)*c)//2)



for _ in range(1):
    solve()
    


Measured memory_bytes: 9328
a, b = list(map(int, input().split()))
d = b - a
if d == 0:
    ans = a
elif d == 1:
    ans = a ^ b


if a % 2 == 1:
    if d == 2:
        ans = a ^ 1
    elif d == 3:
        ans = a ^ b ^ 1
    elif d>3:
        ans=a
        r=d%4
        if r==0:
            ans^=0
        elif r==1:
            ans^=0^b
        elif r==2:
            ans^=0^1
        else:
            ans^=0^1^b

elif a % 2 == 0:
    if d == 2:
        ans = b ^ 1
    elif d == 3:
        ans = 0
    elif d>3:
        ans=b
        r=d%4
        if r==0:
            ans^=0
        elif r==1:
            ans^=b-1
        elif r==2:
            ans^=1
        else:
            ans=0
print(ans)



Measured memory_bytes: 3064
N, X = map(int, input().split())
LIST = list(map(int,input().split()))

RES = []
ichi = 0
RES.append(ichi)
for i in LIST:
    ichi = ichi + i
    RES.append(ichi)

cnt = 0
for i in RES:
    if i <= X:
        cnt = cnt + 1

print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void) {
	
	int count = 0;//???????????°
	int n;//??°????????°
	int i,j;//????????????
	int a[100]={0};
	int temp;
	
	scanf("%d\n",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(j=0;j<n;j++){
		for(i=n-1;i>j;i--){
			if(a[i-1]>a[i]){
				temp = a[i-1];
				a[i-1] = a[i];
				a[i] = temp;
				
				count++;
			}
			else{}
		}
	}
	for(i=0;i<n;i++){
		printf("%d",a[i]);
		if (i != n-1) printf(" ");
		else{}
	}
	
	printf("\n%d\n",count);
	
	return 0;
}

Measured memory_bytes: 604
N = int(input())


def lyuca(a, b, count):
    count = count - 1
    if count == 0:
        return a + b
    else:
        return lyuca(b, a + b, count)


if N == 0:
    print(2)
elif N == 1:
    print(1)
elif N > 1:
    print(lyuca(2, 1, N - 1))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n;
  cin>>n;
  map<int,int> m;
  const int mod=1000000007;
  for(signed i=2;i<=n;++i){
    int a=i,r=2;
    while(true){
      if(a<=1)break;
      if(a%r==0){
        m[r]++;
        a/=r;
      }
      else r++;
    }
  }
  int res=1;
  for(auto itr=m.begin();itr!=m.end();++itr){
    pint p=*itr;
    int a=p.second;
    res*=(a+1);
    res%=mod;
  }
  out(res);


  return 0;
}



Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>
#include <list>
using ll = long long;
using namespace std;
static ll imin = std::numeric_limits<ll>::min() / 2;
static ll imax = std::numeric_limits<ll>::max() / 2;
#define rep(i, n) for(ll i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(ll i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(ll i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(ll i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}
constexpr ll mod = 1e9+7;

ll modfact(ll n){
  ll res=1;
  while(n>0){
    res %=mod;
    res*=n;
    n--;
  }
  return res%mod;
}
   

int main(int argc, char const* argv[])
{
  readl(N);
  double res=0;
  rep(i,N){
    double x;
    cin>>x;
    string u;
    cin>>u;
    if(u=="JPY"){
      res+=x;
    }else{
      res+=380000.0*x;
    }
  }

  cout<<res<<endl;

}



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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define reunique(a) (a).resize(unique(all(a)) - (a).begin())
#define ld long double
#define int long long

void SOLVE(){
    int n;
    cin >> n;
    n = (n + 1) / 2;
    cout << n << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;

public class Main {

    private void solve() throws IOException {
        new Main().solve();
    }

    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        Random r = new Random();
        int n = Integer.parseInt(f.readLine());
        long[] nums = new long[n];

        for (int i = 0; i < n; i++) {
            char[] seq = f.readLine().toCharArray();
            long firstMultiply = 1000000000;
            boolean passedDot = false;
            for (int j = 0; j < seq.length; j++) {
                if (passedDot) firstMultiply /= 10;
                if (seq[j] == '.') passedDot = true;
            }

            long value = 0;
            for (int j = seq.length - 1; j >= 0; j--) {
                if (seq[j] == '.') continue;
                value += (seq[j] - '0') * firstMultiply;
                firstMultiply *= 10;
            }
            nums[i] = value;
        }

        int[][] atLeast = new int[50][50];
        long pairs = 0;
        for (int i = 0; i < n; i++) {
            int diviedByTwo = 0;
            int dividedByFive = 0;
            while (nums[i] % 2 == 0) {
                diviedByTwo++;
                nums[i] /= 2;
            }
            while (nums[i] % 5 == 0) {
                dividedByFive++;
                nums[i] /= 5;
            }

            pairs += atLeast[Math.max(18 - diviedByTwo, 0)][Math.max(18 - dividedByFive, 0)];

            for (int j = 0; j <= Math.min(18, diviedByTwo); j++) {
                for (int k = 0; k <= Math.min(18, dividedByFive); k++) {
                    atLeast[j][k]++;
                }
            }
        }

        out.println(pairs);
        out.close();
    }
}

Measured memory_bytes: 54092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M;
ll dp[2222][2222], sum[2222][2222];

int main()
{
    cin >> N >> M;
    vector<int> S(N), T(M);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    for (int i = 0; i < M; i++)
    {
        cin >> T[i];
    }
    dp[0][0] = 1;
    for (int j = 0; j <= M; j++)
    {
        sum[0][j] = 1;
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (S[i] == T[j])
                dp[i + 1][j + 1] += sum[i][j];
        }
        ll now = 0;
        for (int j = 0; j <= M; j++)
        {
            now += dp[i + 1][j] % mod;
            now %= mod;
            sum[i + 1][j] = (sum[i][j] + now) % mod;
        }
    }
    cout << sum[N][M] << endl;
}

Measured memory_bytes: 72064
N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
  if h <= top
    top = h
  else
    if h-1 == top
      next
    else
      result = "No"
      break
    end
  end
end
puts result

Measured memory_bytes: 9348
n = int(input())
h = list(map(int, input().split()))
ans = [0]*n
for i in range(1,n):
    if i==1:
        ans[i]=abs(h[i]-h[i-1])
    else:
        a = abs(h[i]-h[i-1])
        b = abs(h[i]-h[i-2])
        ans[i]= min(ans[i-1]+a,ans[i-2]+b)
print(ans[-1])

Measured memory_bytes: 13908
#include <iostream>
#define MAX 110

using namespace std;

int n,ans,s1[MAX],s2[MAX];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s1[i],s1[i]+=s1[i-1];
    for(int i=1;i<=n;i++)cin>>s2[i],s2[i]+=s2[i-1];
    for(int i=1;i<=n;i++){
      ans=max(ans,s1[i]+s2[n]-s2[i-1]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int bit[19] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};

void update_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		if (k > BIT[i]) BIT[i] = k;
		i += (i & -i);
	}
}

int max_BIT(int BIT[], int r)
{
	int max = 0;
	while (r > 0) {
		if (BIT[r] > max) max = BIT[r];
		r -= (r & -r);
	}
	return max;
}

int main()
{
	int i, N, A[262145];
	scanf("%d", &N);
	for (i = 0; i < bit[N]; i++) scanf("%d", &(A[i]));
	A[bit[N]] = -1;
	
	int j, k, dp[262144][2] = {}, BIT[262144] = {};
	for (i = 1, dp[0][0] = 0, dp[0][1] = bit[N]; i < bit[N]; i++) {
		dp[i][0] = i;
		for (j = i, k = 0; j > 0; j >>= 1, k++) {
			if ((j & 1) == 0) continue;
			if (A[dp[i^bit[k]][0]] > A[dp[i][0]]) {
				if (A[dp[i^bit[k]][1]] > A[dp[i][0]]) dp[i][1] = dp[i^bit[k]][1];
				else dp[i][1] = dp[i][0];
				dp[i][0] = dp[i^bit[k]][0];
			} else if (A[dp[i^bit[k]][0]] > A[dp[i][1]] && dp[i^bit[k]][0] != dp[i][0]) dp[i][1] = dp[i^bit[k]][0];
		}
		update_BIT(bit[N] - 1, BIT, i, A[dp[i][0]] + A[dp[i][1]]);
	}
	for (i = 1; i < bit[N]; i++) printf("%d\n", max_BIT(BIT, i));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7308
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)


int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,j,n,x,k;
    lli l=0;
        cin>>n;
        lli a[n];
        map<lli,lli> mp;
        for(j=0;j<n;j++){
            cin>>a[j];
            l=l+mp[j+1-a[j]];
            mp[j+1+a[j]]++;
        }
        cout<<l;
}

Measured memory_bytes: 27768
import sys
input = sys.stdin.readline
li_A = list(map(int, input().split()))
li_abs = [0]*3
for i in range(3):
    li_abs[i] = abs(li_A[i] - li_A[(i+1)%3])
li_abs.sort()
print(li_abs[0]+li_abs[1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;

int main(void) {
	int n, m, i, j, k;
	cin >> n >> m;
	vector<LL> a(m);
	vector<LL> b(m);
	vector<LL> ans(n, 0);
	for (i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		ans[a[i]-1]++; ans[b[i]-1]++;
	}
	for (i = 0; i < n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
readInt :: String -> Int
readInt = read

main = do
    a <- readInt <$> getLine
    putStrLn $ solve a

solve a =if elem a list then "Yes" else "No"

list = [4*a + 7*b | a <- [0..25], b <- [0..14], (4*a + 7*b) <= 100]

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n)
	{
		cin>>a[i];
	}
	ll req=1;
	for(ll i=0;i<n;i++)
	{
		if(a[i]==req)
		{
			req++;
		}
	}
	if(req==1)
	cout<<"-1";
	else
	cout<<n-req+1;
}
int main()
{
	IOS
	ll t;
	t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int res=-10000;
int main()
{
	int x;
	int y[10000];
	cin>>x;
	for(int i=0;i<x;i++)cin>>y[i];
	for(int j=0;j<x;j++)
	{
		for(int k=j+1;k<x;k++)res=max(res,abs(max(y[j],y[k])-min(y[j],y[k])));
	}
	cout<<res<<endl;
	return 0;
}

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

int main()
{
    int n,x,y;
    cin >> n >> x >> y;

    vector<vector<int>> g(n);
    rep(i,n-1) {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x-1].push_back(y-1);
    g[y-1].push_back(x-1);

    vector<int> cnt(n, 0);

    rep(i,n) {
        vector<int> d(n, -1);
        queue<pair<int,int>> que;

        que.push({i,0});
        d[i] = 0;        
        
        while(!que.empty()) {
            int cv = que.front().first;
            int cd = que.front().second;
            que.pop();
            
            for(auto nv:g[cv]) {
                if(d[nv] >= 0) continue;
                que.push({nv, cd+1});
                d[nv] = cd+1;
                cnt[cd+1]++;
            }
        }
    }

    rep2(i,1,n) cout << cnt[i]/2 << endl;
    return 0;
}

Measured memory_bytes: 384
//Volume2-0219
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		final int    END  =  0,
		             KIND = 10;
		      int    n;
		      int[]  cnt;
		      String ret;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
    		if(n==END){break;}

    		//calculate
    		cnt = new int[KIND];
    		while(n-- > 0){
    			cnt[sc.nextInt()]++;
    		}
    		//output
    		for(int i=0;i<KIND;i++){
    			ret = "";
    			if(cnt[i] == 0){
    				ret = "-";
    			} else {
    				for(int j=0;j<cnt[i];j++){
    					ret += "*";
    				}
    			}
    			System.out.println(ret);
    		}
    	}
	}
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


#define int long long
typedef int Weight;

#define REP(i, n) for(int i=0;i<(int)n;++i)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
const int INF = 1e15;

void shortestPath(const Graph &g, int s,
                  vector<Weight> &dist, vector<int> &prev) {
    int n = g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    for (Q.push(Edge(-2, s, 0)); !Q.empty();) {
        Edge e = Q.top();
        Q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        FOR(f, g[e.dst]) {
            if (dist[f->dst] > e.weight + f->weight) {
                dist[f->dst] = e.weight + f->weight;
                Q.push(Edge(f->src, f->dst, e.weight + f->weight));
            }
        }
    }
}

void solve(ll n, ll m, ll s, ll t, vector<ll> u, vector<ll> v, vector<ll> a, vector<ll> b) {
    Graph g(n), g2(n);
    for (int i = 0; i < m; i++) {
        u[i]--;
        v[i]--;
        g[u[i]].push_back(Edge(u[i], v[i], a[i]));
        g[v[i]].push_back(Edge(v[i], u[i], a[i]));
        g2[u[i]].push_back(Edge(u[i], v[i], b[i]));
        g2[v[i]].push_back(Edge(v[i], u[i], b[i]));
    }
    vector<Weight> w(n), w2(n);
    vector<int> prev(n);
    shortestPath(g, s - 1, w, prev);
    shortestPath(g2, t - 1, w2, prev);
    vector<int> res(n, 1e15);
    for (int i = n - 1; i >= 0; i--) {
        if (i + 1 != n) res[i] = min(res[i], res[i + 1]);
        res[i] = min(w[i] + w2[i], res[i]);
    }
    for (int i = 0; i < n; i++) cout << 1000000000000000 - res[i] << endl;
}


void main_(istream &cin) {
    ll m;
    ll n;
    ll t;
    ll s;
    cin >> n;
    cin >> m;
    vector<ll> u(m - 1 + 1);
    vector<ll> a(m - 1 + 1);
    vector<ll> v(m - 1 + 1);
    vector<ll> b(m - 1 + 1);
    cin >> s;
    cin >> t;
    for (int i = 0; i <= m - 1; i++) {
        cin >> u[i];
        cin >> v[i];
        cin >> a[i];
        cin >> b[i];
    }
    solve(n, m, s, t, u, v, a, b);
}

signed main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 28928
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

const int MOD = 1000000007;

struct Edge {
    int to;
    int weight;

    Edge(int t, int w) : to(t), weight(w) {}
};

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    if (mp[0] == N) {
        cout << "Yes" << endl;
        return 0;
    }
    if (N % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> all;
    for (auto& p : mp) {
        for (int i = 0; i < p.second / (N / 3); ++i) {
            all.emplace_back(p.first);
        }
    }
    if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef unsigned long long ulint;
typedef long double ldouble;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
constexpr lint mod1 = 1e9+7;

int main() {
  string s; int l;
  cin >> s >> l;
  vector<int> n(s.size());
  rep(i, s.size()) n[i] = s[i] - '0';
  vector<vector<vector<ulint>>> dp(s.size()+1, vector<vector<ulint>>(2, vector<ulint>(s.size()+1, 0)));
  dp[0][1][0] = 1;
  rep(i, s.size()){
    rep(j, 10){
      if(j == 0) rep(k, s.size()+1) dp[i+1][0][k] += dp[i][0][k];
      else rep(k, s.size()+1) dp[i+1][0][min(k+1, (int)s.size())] += dp[i][0][k];      
    }
    rep(j, 10){
      if(j < n[i]){
        if(j == 0) rep(k, s.size()+1) dp[i+1][0][k] += dp[i][1][k];
        else rep(k, s.size()+1) dp[i+1][0][min(k+1, (int)s.size())] += dp[i][1][k];
      }
      else if(j == n[i]){
        if(j == 0) rep(k, s.size()+1) dp[i+1][1][k] += dp[i][1][k];
        else rep(k, s.size()+1) dp[i+1][1][min(k+1, (int)s.size())] += dp[i][1][k];
        break;
      }
    }
  }
  cout << dp[s.size()][0][l] + dp[s.size()][1][l] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    queue <ll> Queue;
    for (int i = 1; i <= 9; ++i) {
        ll a = i;
        Queue.push(a);
    }
    
    ll ans;
    int k; cin >> k;
    rep(i, k) {
        ll a = Queue.front();
        if (i == k - 1) ans = a;
        Queue.pop();
        if (a % 10 != 0) {
            Queue.push(a * 10 + a % 10 - 1);
        }
        Queue.push(a * 10 + a % 10);
        if (a % 10 != 9) {
            Queue.push(a * 10 + a % 10 + 1);
        }
    }

    out(ans);

    return 0;
}






Measured memory_bytes: 1792
N = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...
B = list( map(int, input().split()) )	# 1 2 3 4 5 ...


def F(N,A,B):
	dp=[0]*(N+1)
	for n in range(N+1):
		v=n
		for i in range(3):
			if n>=A[i]:
				x = dp[n-A[i]]+B[i]
				if x>v:
					v = x
		dp[n]=v

		#for a,b in zip(A,B):
		#	if n>=a:
		#		v = max(v, dp[n-a]+b)
		#dp[n]=v

		#dp[n] = max(n, max(dp[n-a]+b for a,b in zip(A,B) if n>=a))
	
	return dp[N]

ans = F(F(N,A,B),B,A)
print( ans )


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

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

typedef long long ll;

signed main()
{
    bool NG = true;
    int n,m,x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int> > a (n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    ll pattern = 1 << n;
    
    ll ans = 1L << 62;
    for (ll i = 0; i < pattern; ++i){
        vector<int>point(m,0);
        ll cost = 0;
        for (ll j = 0; j < n; ++j){
            if (i & (1 << j)){
                cost += c[j];
                rep(k,m){
                    point[k] += a[j][k];
                }
            }
        }
        bool OK = true;
        rep(k,m) if (point[k] < x) OK = false;
        if (OK){
            NG = false;
            ans = min(ans,cost);
        }
    }

    if (NG) puts("-1");
    else cout << ans << endl;

    return 0;
}


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

#define REP(i, n) for(int i=0; i<n; i++)
#define REPA(i, a, n) for(int i=a; i<n; i++)
#define REPE(i, a, n) for(int i=a; i<=n; i++)
#define SetArray(a, n) for(int array_i=0; array_i<n; array_i++) cin >> a[array_i]
#define print(x) cout << x
#define printw(x) cout << x << " "
#define println(x) cout << x << endl
#define printl() cout << endl
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vi;

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

    string a;
    REP(i, n){
        cin >> a;
        s.insert(a);
    }

    int items = 0;
    for(auto x:s){
        items++;
    }

    println(items);

    return 0;
}




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

using namespace std;

int main() {
	vector<int> v1;
	vector<int> v2;
	int h;
	int w;
	bool IsInput = true;

	while (IsInput) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		v1.push_back(h);
		v2.push_back(w);
	}
	
	for(int i = 0; i < v1.size();i++){
		for (int j = 0; j < v1[i];j++) {
			for (int k = 0; k < v2[i]; k++) {
				if (j == 0 || j == v1[i] - 1 || k == 0 || k == v2[i] - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		
		HashMap<Integer,Integer> h = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			a[i] = s.nextInt();
			if(h.containsKey(a[i]))
			h.put(a[i],h.get(a[i])+1);
			else
			h.put(a[i],1);
		}
		
		int ctr = 0;
		for(int i=0;i<n;i++) {
			int k = a[i];
			if(k==1) {
				if(h.get(1)>1) {
					ctr++;
				}
			}
			else if(h.get(a[i])>1 || h.containsKey(1)) {
				ctr++;
			}
			else {
				for(int j=2;j*j<=k;j++) {
					if(k%j==0) {
						if(h.containsKey(j) || h.containsKey(k/j)) {
							ctr++;
							break;
						}
					}
				}
			}
			
		}
		System.out.println(n-ctr);
		
	}
}

Measured memory_bytes: 73356
#include<cstdio>
#include<stdlib.h>
#include<iostream>

using namespace std;

const int maxn = 105;

int M[maxn][maxn];
int visit[maxn];
int d[maxn];
int p[maxn];
int n;


int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		visit[i] = false;
		d[i] = 0x3f3f3f;
		for(int j = 0;j < n;j++){
			cin >> M[i][j];
		}
	}
	int result = 0;
	d[0] = 0;
	while(true){
		int min_distance = 0x3f3f3f;
		int u;
		for(int j = 0;j < n;j++){ 
			if(d[j] < min_distance && (!visit[j])){
				min_distance = d[j];
				u = j;
			}
		}
//		cout << u << endl;
		if(min_distance == 0x3f3f3f)break;
		result += min_distance;
		visit[u] = true;
		d[u] = min_distance;
		for(int s = 0;s < n;s++){
			if(M[u][s] == -1)continue;
			if(M[u][s] < d[s]){
				d[s] = M[u][s];
				p[s] = u;
			}
		}
//		for(int s = 0;s < n;s++)cout << d[s] <<" ";
//		cout << endl;
	}
	cout << result << endl;
	
	
}


Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		int a = Integer.parseInt(list[0]);
		int b = Integer.parseInt(list[1]);
		int c = Integer.parseInt(list[2]);

		if( (a+b) == c){
			System.out.print("Yes");
		}else if( (b+c) == a){
			System.out.print("Yes");
		}else if( (c+a) == b){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}

	}

}


Measured memory_bytes: 8148
# -*- coding: utf-8 -*-
N = int(input())

ans = 2 ** 30
for i in range(1, N//2 + 1):
    a = sum([int(c) for c in str(i)])
    b = sum([int(c) for c in str(N - i)])
    # print(a, b)
    ans = min(ans, a+b)

print(ans)

Measured memory_bytes: 42600
#include <bits/stdc++.h> 
using namespace std; 
#define INF 1001000100010001000 
#define MOD 1000000007 
#define EPS 1e-10 
#define int long long 
#define rep(i, N) for (int i = 0; i < N; i++) 
#define Rep(i, N) for (int i = 1; i < N; i++) 
#define For(i, a, b) for (int i = (a); i < (b); i++)
 #define pb push_back 
#define eb emplace_back 
#define mp make_pair 
#define pii pair<int, int> 
#define vi vector<int> 
#define vvi vector<vi > 
#define vb vector<bool> 
#define vvb vector<vb > 
#define vp vector< pii > 
#define all(a) (a).begin(), (a).end() 
#define Int(x) int x; cin >> x; 
#define int2(x, y) Int(x); Int(y); 
#define int3(x, y, z) Int(x); int2(y, z); 
#define in(x, a, b) ((a) <= (x) && (x) < (b))
 #define fir first 
#define sec second 
#define ffir first.first
 #define fsec first.second
 #define sfir second.first 
#define ssec second.second
 #define Decimal fixed << setprecision(10) 
//int dxy[5] = {0, 1, 0, -1, 0};
 // cmd${0:#:TARGET} 
signed main() 
{ 
std::ios::sync_with_stdio(false);
 std::cin.tie(0); 

Int(n);
vi a(n);
rep(i, n) cin >> a[i];

map<int,int> mp;
rep(i, n) mp[a[i]]++;

int oe[2] = {0};
for(auto i : mp) oe[(i.second %2)]++;

cout << oe[0] + oe[1] - (oe[0]%2) << endl;

return 0;
 }

Measured memory_bytes: 7296
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int n;

struct node{
	int l,r;
	int key;
	void init(int a){
		l=r=-1;
		key=a;
	}
};
struct bst{
	int size;
	node t[600001];
	void init(){
		size=0;
	}
	void insert(int v){
		int i=0;
		while(i<size){
			int& child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		t[size++].init(v);
	}
	bool find(int v){
		int i=0;
		while(i<size){
			if(t[i].key==v)return true;
			int child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		return false;
	}

	void preorder(int pos){
		if(pos==-1|| pos==size)return;
		printf(" %d",t[pos].key);
		preorder(t[pos].l);
		preorder(t[pos].r);
	}

	void inorder(int pos){
		if(pos==-1|| pos==size)return;
		inorder(t[pos].l);
		printf(" %d",t[pos].key);
		inorder(t[pos].r);
	}

	void postorder(int pos){
		if(pos==-1|| pos==size)return;
		postorder(t[pos].l);
		postorder(t[pos].r);
		printf(" %d",t[pos].key);
	}
};

bst T;

int main(void){
	scanf("%d",&n);
	char str[100];
	for(int i=0;i<n;i++){
		scanf("%s",str);
		if(str[0]=='i'){
			int a;
			scanf("%d",&a);
			T.insert(a);
		}else if(str[0]=='f'){
			int a;
			scanf("%d",&a);
			printf("%s\n",T.find(a)?"yes":"no");
		}else{
			T.inorder(0);
			printf("\n");
			T.preorder(0);
			printf("\n");
		}
	}
	return 0;
}



Measured memory_bytes: 7424