akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m>>a>>b;
	double da,db;
	double pi=acos(-1);
	da=abs(b/60.-(a*60+b)/720.);
	db=n*n+m*m-2.*n*m*cos(2*da*pi);
	cout<<fixed<<setprecision(10)<<sqrt(db)<<endl;
}

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

typedef pair<int,int> P;

int main(){
    int num,solve;
    vector<P> v;
    
    while(true){
        scanf("%d,%d" ,&num, &solve);
        if(!num&&!solve) break;
        v.push_back(P(-solve,num));
    }
    sort(v.begin(),v.end());
    
    int select;
    while(cin >> select){
        int cnt = 1;
        for(int i = 0 ; i < v.size() ; i++){
            if(i&&v[i].first != v[i-1].first) cnt++;
            if(v[i].second == select) break;
        }
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <string.h>
int main(){
    int i,j,n,moji[50][26]={},D[26]={};
    char S[51];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",S);
        for(j=0;j<strlen(S);j++) moji[i][S[j]-97]++;
    }
    for(i=0;i<26;i++) D[i]=moji[0][i];
    for(i=1;i<n;i++) for(j=0;j<26;j++) if(D[j]>moji[i][j]) D[j]=moji[i][j];
    for(i=0;i<26;i++) for(j=0;j<D[i];j++) printf("%c",97+i);
    puts("");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A, B;
//int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int N;
int x[10], y[10];

double dist(int i, int j)
{
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}
void solve()
{
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> x[i] >> y[i];
	double sum = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++)
	{
		v[i] = i + 1;
	}
	do
	{
		for (int i = 0; i < N - 1; i++)
			sum += dist(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));
	int Factorial = 1;
	for (int i = 2; i <= N; i++)
	{
		Factorial *= i;
	}
	cout << fixed << setprecision(10) << sum / Factorial << endl;
	return;
}

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

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;


int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans=0;
    if(a>b)ans=a-b;
    printf("%d\n",ans);
    return 0;
}
























Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
using namespace std;

int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 2000;
//int d[maxn];
//string str;
//bool vis[20];
//int main() {
//    while(cin >> k >> str) {
//        memset(vis,0,sizeof(vis));
//        for(int i = 1; i <= k; i++) cin >> d[i],vis[d[i]] = 1;
//        int ans = 0;
//        int len = str.size();
//        string ans = "9999999999999999";
//        int flag = 0;
//        for(int i = len - 1; i >= 0; i--) {
//            int x = str[i] - '0';
//            if(!vis[x]) continue;
//            else {
//                if(!flag) {
//                    for(int i = x; i <= 9; i++) {
//                        if(!vis[i]) {
//                            flag = 1;
//                            vis[]
//                        }
//                    }
//                }
//
//            }
//        }
//    }
//    return 0;
//}




#include <bits/stdc++.h>

using namespace std;

const int maxn = 2000;
int d[maxn];
string str;
bool vis[20];
int k;
long long num;
int main() {
    while(cin >> num >> k) {
        memset(vis,0,sizeof(vis));
        for(int i = 1; i <= k; i++) cin >> d[i],vis[d[i]] = 1;
        int ans = 0;
        for(long long i = num; i <= (long long)1e7; i++) {
            stringstream ss;
            ss << i;
//            cout << ss << endl;
            str = "";
            ss >> str;
            int len = str.size();
            int flag = 0;
//            cout << str << endl;
            for(int j = 0; j < len; j++) {
                int x = str[j] - '0';
                if(vis[x]) {
                    flag = 1;
                    break;
                }
            }
            if(!flag) {
                num = i;
                break;
            }
        }
        cout << num << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#D
from heapq import heappush,heappop
from collections import deque
import sys
n,k=map(int,input().split())
v=deque(list(map(int,input().split())))
w=[[] for i in range(n)]
answer=-100000000
for i in range(min(n+1,k+1)):
    for j in range(min(n-i+1,k-i+1)):
        h=[]
        
        for a in range(i):
            heappush(h,v[a])
        for a in range(j):
            heappush(h,v[n-1-a])
        for a in range(k-i-j):
            if h and h[0]<0:
                heappop(h)
            else:
                break
        answer=max(answer,sum(h))
print(answer)

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

const int MAX_N = 1e5+2;
int n, m;
vector<int> G[MAX_N];
bool vis[MAX_N];
int pre[MAX_N];

void add_edge(int from, int to)
{
	G[from].push_back(to);
	G[to].push_back(from);
}

void solve()
{
	queue<int> que;
	que.push(1);
	vis[1]=true;
	while(!que.empty()){
		int x = que.front(); que.pop();
		for(int i=0;i<(int)G[x].size();++i){
			int y = G[x][i];
			if(!vis[y]){
			    vis[y]=true;
				pre[y]=x;
				que.push(y);
			}
		}
	}
	for(int i=2;i<=n;++i)if(!vis[i]){
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
	for(int i=2;i<=n;++i)cout << pre[i] << '\n';
}

int main()
{
	int a, b;
	cin >> n >> m;
	for(int i=0;i<m;++i){
		cin >> a >> b;
		add_edge(a, b);
	}
	solve();
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


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

    if(K==1) cout << 0 << endl;
    else{
        int mi, ma;
        mi = 1;
        ma = N-(K-1)*mi;
        cout << ma - mi << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let (h, w): (usize, usize) = input_two();
    let mut b = vec![vec![false; w + 2]; h + 2];
    for i in 1..h + 1 {
        for (j, c) in input::<String>().unwrap().chars().enumerate() {
            if c == '#' {
                b[i][j + 1] = true;
            }
        }
    }

    let n4: [(i32, i32); 4] = [(0, 1), (1, 0), (-1, 0), (0, -1)];

    let mut ans = "Yes";
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            if b[i][j] {
                if !n4
                    .iter()
                    .map(|&(x, y)| b[(i as i32 + x) as usize][(j as i32 + y) as usize])
                    .any(|x| x)
                {
                    ans = "No";
                    break;
                }
            }
        }
    }

    println!("{}", ans);
}

pub fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

pub fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int dp[312][313][312];
    
string s;
int n;
int compute(int i,int j,int left){
	
	if(j<i)
		return 0;
	if(i==j)
		return 1;
	if(dp[i][j][left])
		return dp[i][j][left];
	dp[i][j][left]=max(compute(i+1,j,left),compute(i,j-1,left));
	if(s[i]==s[j]){
		dp[i][j][left]=max(dp[i][j][left],2+compute(i+1,j-1,left));
	}
	else if(left){
		dp[i][j][left]=max(dp[i][j][left],2+compute(i+1,j-1,left-1));
	}
	return dp[i][j][left];

}
int main(){
    std::ios::sync_with_stdio(false);
    
    cin>>s;
    int k;
    n=s.length();
    cin>>k;
    cout<<compute(0,n-1,k)<<endl;
    return 0;  
    
}



Measured memory_bytes: 114816
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var remainBricks = 0;
            for (int i = 0; i < N; i++) if (a[i] == remainBricks + 1) remainBricks++;
            Console.WriteLine(remainBricks == 0 ? -1 : N - remainBricks);
        }
    }
}


Measured memory_bytes: 34012
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


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


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int main() {

	
	int q;
	cin >> q;
	set<int> st;
	for (int i = 0; i < q; i++)
	{
		int c, d;
		cin >> c >> d;
		if (c == 0) {
			st.insert(d);
			cout << st.size() << endl;
		}
		else if (c == 1) {
			cout << st.count(d) << endl;
		}
		else
		{
			st.erase(d);
		}
	}
	

	
	return 0;
}


Measured memory_bytes: 12448
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int n,a[110];
	cin>>n;
	lol(i,n)cin>>a[i];
	sort(a,a+n);
	int ans=1;
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static ArrayList<Integer>a = new ArrayList<Integer>();
	static ArrayList<Integer>b = new ArrayList<Integer>();
	static ArrayList<Integer>c = new ArrayList<Integer>();
	
	public static void main(String[] args) {
		while(read()){
			
		}

	}
	
	static boolean read(){
		if(!sc.hasNext())return false;
		
		N = sc.nextInt();
		//System.out.println("N = " + N);
		for(int j = 0; j < N; j++){
			for(int i = 0; i < 10; i++){
				a.add(sc.nextInt());
				//System.out.println("a = " + a.get(i));
			}
			
			b.add(0);
			c.add(0);
			
			solve();
			
			a.clear();
			b.clear();
			c.clear();
		}	
		
		return true;
	}
	
	static void solve(){
		boolean f = true;
		
		for(int i = 0; i < 10; i++){
			
			int ball = a.get(i);
			//System.out.println(ball);
			int last_b = b.get(b.size()-1);
			int last_c = c.get(c.size()-1);
			
			if(ball < last_b && ball < last_c){
				f = false;
				//System.out.println(ball);
				break;
			}
			
			int abs_b = ball - last_b;
			int abs_c = ball - last_c;
			
			if( abs_b < 0 && abs_c < 0){
				f = false;
				//System.out.println(ball);
				break;
			}else if( abs_b < 0 && abs_c > 0 ){
				c.add(ball);
			}else if( abs_c < 0 && abs_b > 0){
				b.add(ball);
			}else if( abs_b > abs_c){
				c.add(ball);
			}else{
				b.add(ball);
			}
			
		}
		
		if(f){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
	

}

Measured memory_bytes: 12000
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        if i % 2 == 0:
            ans[0] += a[i]
        else:
            ans[0] -= a[i]
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(' '.join(map(str, ans)))
main()

Measured memory_bytes: 19132
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int lb(int l,int r,int n,int *d){
  if(n>(1<<29))return r;
  while(l-r){
    int m=(l+r)/2;
    n<=d[m]?(r=m):(l=m+1);
  }
  return l;
}

int n,i,j,k,s=0,c,a[200010],b[200010],d[200010];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  for(i=0;i<n;i++)scanf("%d",&b[i]);
  for(i=0;i<29;i++){
    R=C=1;
    k=(1<<i);//printf("%d\n",k);
    for(j=0;j<n;j++)hin((int)(b[j]&((2LL<<i)-1)));
    for(j=0;j<n;j++)d[j]=N[hout()];
    //for(j=0;j<n;j++)printf("%d ",d[j]);printf("\n");
    for(j=c=0;j<n;j++)c+=((lb(0,n,2*k-(a[j]&((2<<i)-1)),d)-
			   lb(0,n,1*k-(a[j]&((2<<i)-1)),d))%2+
			  (n-
			   lb(0,n,3*k-(a[j]&((2<<i)-1)),d))%2);
    s+=c%2*k;
    /*or(j=0;j<n;j++)printf("%d %d %d %d\n",s,
			   lb(0,n,2*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,1*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,3*k-(a[j]&((2<<i)-1)),d));//*/
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define int long long int
#define ss second
#define ff first
#define pb push_back
using namespace std;
const int MAX_N = 2 * 1e5 + 10, inf = 1e13 + 10, mod = 1000ll * 1000 * 1000 + 7ll;
vector <int> adj[MAX_N];
int dp[MAX_N][3];
int a[MAX_N], b[MAX_N], c[MAX_N];

int32_t main()
{
    ios :: sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];

    for(int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 13568
import numpy as np

N, M, C = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ary = [[int(i) for i in input().split()] for j in range(N)]
npb = np.array(b).T
npa = np.zeros((M, N))
npa = np.array(ary)
ans = np.array(np.dot(npa, npb))
count = 0
for res in ans+C:
    if res > 0:
        count += 1

print(count)


Measured memory_bytes: 14488
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
vector<pair<int,int> >A;
int L[1<<17],R[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int L,R;cin>>L>>R;
		A.push_back(make_pair(L,R));
	}
	sort(A.begin(),A.end());
	long ans=0;
	R[N-1]=A[N-1].second;
	L[0]=A[0].second;
	for(int i=1;i<N;i++)L[i]=min(L[i-1],A[i].second);
	for(int i=N-2;i>=0;i--)R[i]=min(R[i+1],A[i].second);
	for(int i=1;i<N;i++)
	{
		long Z=i==1?(long)1e9:L[i-2];
		long X=A[i-1].second;
		long Y=R[i];
		ans=max(ans,max(0L,min(X,Z)-A[i-1].first+1)+max(0L,Y-A[N-1].first+1));
		ans=max(ans,max(0L,X-A[i-1].first+1)+max(0L,min(Y,Z)-A[N-1].first+1));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  char s;
  in(s);
  if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o')
    out("vowel");
  else
    out("consonant");
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

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

  vector<string> a(n);
  vector<string> b(m);

  rep (i, n) {
    cin >> a[i];
  }

  rep (i, m) {
    cin >> b[i];
  }

  bool res = false;
  rep (i, n-m) rep (j, n-m) {
    bool isOk = true;
    rep (k, m) {
      rep (l, m) {
        if (b[k][l] != a[i+k][j+l]) isOk = false;
      }
    }
    if (isOk) res = true;
  }

  if (m == n) {
    bool isOk = true;
    rep (i, m) rep (j, n) {
      if (b[i][j] != a[i][j]) isOk = false;
    }
    if (isOk) res = true;
  }

  cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

intl pow(intl a,intl n){
  intl ans=1;
  Rep(i,n) ans *=a;
  return ans;
}

int main(){
  int C;
  int A;
  cin >>A;
  C = A%10;
  if(C==2 || C==4||C==5||C==7||C==9)cout <<"hon";
  else if(C==3) cout<<"bon";
  else {cout <<"pon";}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<int,int>;
int main() {
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    rep(i,N){cin>>p[i];}
    sort(p.begin(),p.end());
    //reverse(p.begin(),p.end());
    ll answer=0;
    rep(i,K){answer+=p[i];}
    cout<<answer<<endl;
    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int W,a,b;
int main(){
	cin>>W>>a>>b;

	ll R=0;

	if((a+W)<b)R=b-(a+W);
	else if((b+W)<a)R=a-(b+W);

	cout<<R<<endl;


	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A;
    cin >> A;
    N -= A;
  }
  if (N < 0){
    cout << -1 << endl;
  } else {
    cout << N << endl;
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int x = scan.nextInt();

        if (k == 1) {
            System.out.print(x);
            return;
        }

        int start = x - k + 1;
        int end =  x + k - 1;

        for(; start <= end; start++) {
            if(start > x - k + 1)System.out.print(" ");
            System.out.print(start) ;
        }

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int n;cin >> n;
    cout << 1-n  << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int M, N, a;
    cin >> M >> N;
    int best = 0;
    for (int i = 0; i < M; ++i) {
        int score = 0;
        for (int j = 0; j < N; ++j) {
            cin >> a;
            score += a;
        }
        if (score > best) {
            best = score;
        }
    }
    cout << best << endl;
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

long long ans, DP[10005][105][2];
string k;
int d,n;

long long dp(int pos, int remain, bool full){
//	printf(">> %d %d\n",pos,remain);
	if(pos>=n){
		if(remain == 0) return 1;
		return 0;
	}
	long long res = 0;
	if(DP[pos][remain][full]!=-1) return DP[pos][remain][full];
	if(full){
		for(int i=0;i<k[pos]-'0';i++){
			res += dp(pos+1,(remain+i)%d,0);
			res %=MOD;
		}
		res += dp(pos+1,(remain+k[pos]-'0')%d,1);
		res%=MOD;
	} else {
		for(int i=0;i<=9;i++){
			res += dp(pos+1,(remain+i)%d,0);
			res %=MOD;
		}
	}
	res %=MOD;
//	printf("%d %d = %lld\n",pos,remain,res);
	return DP[pos][remain][full] = res;
}

int main(){
	memset(DP,-1,sizeof DP);
	cin>>k;
	n = k.length();
	scanf("%d",&d);	
	ans = dp(0,0,1);
	printf("%lld\n",(ans-1+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;

int a[N];
int Min[N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    Min[1] = a[1];
    int ans = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i] < Min[i-1]) {
            ans++;
        }
        Min[i] = min(Min[i-1], a[i]);
    }
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 1792
from operator import itemgetter


def solve():
    t = 0
    for a, b in ab:
        t += a
        if t > b:
            return False
    return True


n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=itemgetter(1))

print('Yes' if solve() else 'No')


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;

	vector <int> A(N, 0);
	int sum = 0;
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
		sum += A[ii];
	}

	int cnt = 0;
	for (int ii = 0; ii < N; ++ii){
		if (4 * M * A[ii] >= sum){
			cnt++;
		}
	}

	if (cnt >= M){
		cout << "Yes" << endl;
	} else {	
		cout << "No" << endl;
	}




	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int com_count = 0;

void merge(int A[], int left, int mid, int right)
{
  int i ,j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[500000],R[500000];

  for(i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = 1000000000;
  i = j = 0;

  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    com_count++;
  }
}

void mergeSort(int A[], int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}


int main(void)
{
  int i,n, A[500000];

  cin >> n;

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

  mergeSort(A, 0, n);

  for(i = 0;i < n - 1;i++){
    cout << A[i] << ' ';
  }
  
  cout << A[i] << endl << com_count << endl;
  
  return 0;
}



Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int n,m,ans=0;
bool p[50][50]={};
bool used[50]={};
int a[50],b[50];


void dfs(int x){
  used[x]=true;
  for(int i=0;i<n;i++){
    if (p[x][i] && !used[i]){
      dfs(i);
    }
  }
}

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    p[a[i]][b[i]]=p[b[i]][a[i]]=true;
  }
  for(int i=0;i<m;i++){
    p[a[i]][b[i]]=p[b[i]][a[i]]=false;
    dfs(0);
    p[a[i]][b[i]]=p[b[i]][a[i]]=true;
    int count=0;
    for(int i=0;i<n;i++){
      if(used[i]){
        count++;
      }
      used[i]=false;
    }
    if (count!=n) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

 int count =0;
 for( int i=a; i<=b; i++ ){
  if( c%i==0 ){
   count++;
  }
 }

 cout << count << endl;

 return 0;
}


Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        // 入力情報（個数）
        int N = scan.nextInt();

        int ansAC = 0;
        int ansWA = 0;
        int ansTLE = 0;
        int ansRE = 0;

        List<String> results = new ArrayList<String>();

        // 入力情報（内容）
        for(int i = 0; i < N; i++){
            String input = scan.next();
            results.add(input);
        }

        // カウント
        ansAC = Collections.frequency(results, "AC");
        ansWA = Collections.frequency(results, "WA");
        ansTLE = Collections.frequency(results, "TLE");
        ansRE = Collections.frequency(results, "RE");

        // 結果出力
        System.out.println("AC x "+ ansAC);
        System.out.println("WA x "+ ansWA);
        System.out.println("TLE x "+ ansTLE);
        System.out.println("RE x "+ ansRE);
        scan.close();

    }
}

Measured memory_bytes: 65140
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    string A,B;cin>>A>>B;
    if(A.size()==B.size()){
        if(A>B)cout<<"GREATER";
        else if(A==B)cout<<"EQUAL";
        else cout<<"LESS";
    }else if(A.size()>B.size()){
        cout<<"GREATER";
    }else{
        cout<<"LESS";
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
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;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    vint a(5); rep(i,5) cin >> a[i];
    vector<int> surplus(5);
    int ans = 0;
    rep(i,5){
        ans += ((a[i]+9)/10)*10;
        surplus[i] = a[i]%10;
    }

    sort(all(surplus));

    if(*max_element(all(surplus)) != 0){
        ans -= 10 - *upper_bound(all(surplus),0);
    }    

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


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int m, n;
	int a[100][100], b[100];
	//long c[100] = {0};
	int c[100] = {0};
	//int sum=0
	
	scanf(" %d %d", &m, &n);
	
	for(int i=0; i<m; ++i){
		for(int j=0; j<n; ++j){
			scanf(" %d", &a[i][j]);	
		}
	}
	
	for(int i=0; i<n; ++i){
		scanf(" %d", &b[i]);
	}
	
	for(int i=0; i<m; ++i){
		for(int j=0; j<n; ++j){
			c[i] += a[i][j]*b[j];
		}
		printf("%d\n", c[i]);
	}
	
	//for(int i=0; i<m; ++i)
		//printf("%ld\n", c[i]);
	
	return 0;
}



Measured memory_bytes: 2760
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

ll dp[3100][3100];
ll a[3100];
int N;

ll dfs(int r,int l){
    if(dp[r][l]!=INF) return dp[r][l]; 
    ll temp=0;
    if( (N-(l-r+1))%2==0 ){
        if(r==l) temp=a[r];
        else temp=max(dfs(r+1,l)+a[r],dfs(r,l-1)+a[l]);
    }else{
        if(r==l) temp=0;
        else temp=min(dfs(r+1,l),dfs(r,l-1));
    }
    return dp[r][l]=temp;
}

int main(){
    for(int i=0;i<3100;i++){
        for(int j=0;j<3100;j++) dp[i][j]=INF;
    }
    cin>>N;
    ll sum=0;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        sum+=a[i];
    } 

    cout<<-sum+2*dfs(1,N)<<endl;

}

Measured memory_bytes: 75520
import sys
from collections import deque

n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i:[] for i in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = deque([0])
res = {0:-1}
while len(que) > 0:
    cur = que.popleft()
    for _next in graph[cur]:
        if _next in res:
            continue
        res[_next] = cur
        que.append(_next)

if len(res) < n:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(res[i]+1)

Measured memory_bytes: 104720
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    vll v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end(), greater<ll>());
    cout << v[0]*10+v[1]+v[2] << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n;
struct EDGE { int v,w,nx; }lb[N<<1]; int tot=1,top[N];
void add (int u,int v,int w) { lb[++tot]=(EDGE){v,w,top[u]},top[u]=tot; }
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
int dis[N]; bool vis[N];
int dij ()
{
	for (int i=0; i<=n; i++)
		dis[i]=oo;
	priority_queue <pii,vector<pii>,greater<pii>> q;
	dis[1]=1,q.push (mp(dis[1],1));
	while (q.size ())
	{
		int u=q.top ().se; q.pop ();
		if (vis[u]) continue; vis[u]=1;
		for (int kb=top[u]; kb; kb=lb[kb].nx)
		{
			int v=lb[kb].v,w=lb[kb].w;
			if (dis[v]> dis[u]+w) dis[v]=dis[u]+w,q.push (mp(dis[v],v));
		}
	}
	return dis[0];
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n);
	for (int i=0; i< n; i++)
		add (i,i==n-1?0:(i+1),1),add (i,(i*10)%n,0);
	pr(dij ());

    return 0;
}


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

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

	int ans = 0;
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    vector< int > ps(n);
    cin >> ps;

    whole(sort, ps);
    ps.back() /= 2;

    cout << whole(accumulate, ps, 0ll) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int max = s.Max();
            Console.WriteLine(max < s.Sum() - max ? "Yes" : "No");
        }
    }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int n;
    cin>>n;
    vi a(n),ans(n+1,0);
    f(i,1,n){
        cin>>a[i];
        ans[a[i]]++;
    }
    f(i,1,n+1)cout<<ans[i]<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

void solve(map<string, int> &m, string tmpl, string tmpr) {
  m[tmpl+tmpr]++;
  m[tmpr+tmpl]++;
  reverse(ALL(tmpr));
  m[tmpl+tmpr]++;
  m[tmpr+tmpl]++;
  reverse(ALL(tmpl));
  m[tmpl+tmpr]++;
  m[tmpr+tmpl]++;
  reverse(ALL(tmpr));
  m[tmpl+tmpr]++;
  m[tmpr+tmpl]++;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int m; cin >> m;
  REP(i, m) {
    string s; cin >> s;
    map<string, int> mp;
    FOR(i, 1, SZ(s)) {
      solve(mp, s.substr(0, i), s.substr(i, SZ(s)-i));
    }
    cout << mp.size() << endl;
  }
}



Measured memory_bytes: 3124
s=input()
for _ in range(int(input())):
 a=input().split()
 o=a[0];i=int(a[1]);j=int(a[2])+1
 if'p'==o[0]:print(s[i:j])
 else:
  t=a[3]if'p'==o[2]else s[i:j][::-1]
  s=s[0:i]+t+s[j:]

Measured memory_bytes: 5608
#include<cstdio>
#define ll long long
using namespace std;
const int N=3010;
int n,mo;
ll C[N][N],g[N][N];
ll mi(ll x,ll y,ll mo)
{
	ll ans=1;
	while (y)
	{
		if (y&1) ans=ans*x%mo;
		x=x*x%mo;
		y>>=1;
	}
	return ans;
}
void pre()
{
	C[0][0]=g[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		C[i][0]=g[i][0]=1;
		for (int j=1;j<=i;j++)
		{
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mo)%mo;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&mo);
	pre();
	ll ans=0,now=1;
	for (int i=0;i<=n;i++)
	{
		ll x=0,y=1,X=mi(2,n-i,mo);
		for (int j=0;j<=i;j++)
		{
			x=(x+g[i][j]*y%mo)%mo;
			y=y*X%mo;
		}
		ans=(ans+x*C[n][i]*now%mo*mi(2,mi(2,n-i,mo-1),mo)%mo)%mo;
		now=-now;
	}
	printf("%lld\n",(ans+mo)%mo);
	return 0;
}


Measured memory_bytes: 139904
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
g = []
for i in range (n):
  g.append(v[i] - c[i])
m = 0
for i in range(n):
  if g[i] > 0:
    m += g[i]
print(m)



Measured memory_bytes: 3064