akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}
/*
Node treeMaximum(Node x){


}
*/
Node treeSearch(Node u, int k){
 while(u!=NIL && k != u->key){ 
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right==NIL)y=z;
    else y=treeSuccessor(z);
    if(y->left != NIL){
      x=y->left;
    }
    else {
      x=y->right;
    }
    if(x!=NIL){
      x->parent=y->parent;
    }

    if(y->parent ==NIL){
      root=x;
    }
    else {
      if(y==y->parent->left){
	y->parent->left=x;
      }
      else{
	y->parent->right=x;
      }
    }
    if(y!=z){
      z->key=y->key;
    }
    free(y);
  }



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 while(x!=NIL){
   y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }


}

void inorder(Node u){
if(u==NIL)return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
 if(u==NIL)return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

 for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 


  return 0;
}

Measured memory_bytes: 19364
import math

a, b, h, m = map(int, input().split())

h %= 12
short = m*6

long = (h*60+m)/2.0
dif = abs(short-long)
cs=math.radians(dif)
c=math.sqrt(a**2+b**2-2*a*b*math.cos(cs))
print(c)


Measured memory_bytes: 9444
N, Y = map(int, input().split())

count_max = Y / 1000  # all 1000

ans = '-1 -1 -1'
for i in range(N+1):  # 10000
    for j in range(N+1 - i):  # 5000
        k = N - i - j
        if k < 0:
            continue
        total = 10000 * i + 5000 * j + 1000 * k
        if total == Y:
            ans = '{} {} {}'.format(i, j, k)
            break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n;
    vector<int> time(n);
    for (int i = 0; i < n; i++){
        cin >> time.at(i);
    }

    cin >> m;
    for (int i = 0; i < m; i++){
        int p, x;
        cin >> p >> x;
        int count = 0;
        for (int j = 0; j < n; j++){
            if ( j == (p - 1)){
                count += x;
            }
            else{
                count += time.at(j);
            }
        }

        cout << count << endl;
    }

}

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N,K; vi d; int A[100][100];
void input()
{
    cin>>N>>K;
    for(int i=0;i<K;++i){
        int a; cin>>a; d.emplace_back(a);
        for(int j=0;j<d[i];++j){
            cin>>A[i][j];
        }
    }
}

void solve()
{
    vi sunuke(N+1,0);
    for(int i=0;i<K;++i){
        for(int j=0;j<d[i];++j){
            sunuke[A[i][j]]=1;
        }
    }
    int ans=0;
    for(int i=1;i<N+1;++i){
        if(sunuke[i]==0) ++ans;
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (K % 2 == 0)
  {
    cout << "-1" << endl;
    return 0;
  }

  int count = 1;
  int mod = 7;
  int now = 7;
  std::unordered_set<int> s;
  while (true)
  {
    mod %= K;
    if (s.count(mod) > 0)
    {
      cout << "-1" << endl;
      break;
    }
    s.insert(mod);
    if (mod == 0)
    {
      cout << count << endl;
      break;
    }
    now = (now * 10) % K;
    mod += now;
    if (now == 0)
    {
      cout << "-1" << endl;
      break;
    }
    count++;
  }

  return 0;
}


Measured memory_bytes: 42612
#coding: utf-8
N = int(input())
A = list(map(int,input().split()))
Q = int(input())

T = [0] * (10**5+1)
for a in A:
    T[a] += 1
S = sum(A)
for i in range(Q):
    b, c = map(int,input().split())
    cnt = T[b]
    T[c] += T[b]
    S -= cnt*b
    S += cnt*c
    T[b] = 0
    print(S)

Measured memory_bytes: 20888
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = Integer.MAX_VALUE;

        while(true){
            int T = sc.nextInt();
            if(T==0) break;
            int[] t = new int[T];
            for(int i=0; i<T; i++) t[i] = sc.nextInt();

            int n = sc.nextInt();
            int[] time = new int[103];
            Arrays.fill(time, INF);

            int max = 0;
            for(int i=0; i<n; i++){
                int d = sc.nextInt()-1, m = sc.nextInt();
                max = Math.max(max, d);
                time[d] = Math.min(time[d], m);
            }

            int[][] dp = new int[max+2][T];
            for(int i=0; i<=max; i++) Arrays.fill(dp[i], INF);
            dp[0][0] = 0;

            for(int i=0; i<max; i++){
                for(int j=0; j<T; j++){
                    if(dp[i][j]==INF) continue;
                    if(time[i+1]>=t[(j+1)%t.length]) dp[i+1][(j+1)%t.length] = dp[i][j];
                    dp[i+1][0] = Math.min(dp[i+1][0], dp[i][j] + 1);
                }
            }

            int min = Integer.MAX_VALUE;
            for(int i=0; i<T; i++) min = Math.min(min, dp[max][i]);
            System.out.println(min);
        }
    }

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

Measured memory_bytes: 23624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	map<int, int> c1, c2;
	rep(i, n){
		int x; cin >> x;
		if(i % 2) c1[x]++;
		else c2[x]++;
	}
	vector<pi> p1, p2;
	for(auto i : c1) p1.emplace_back(-i.second, i.first);
	for(auto i : c2) p2.emplace_back(-i.second, i.first);
	sort(all(p1)); sort(all(p2));
	
	int ans = n;
	rep(i, min(10, (int)p1.size())) rep(j, min(10, (int)p2.size())){
		if(p1[i].second == p2[j].second)
			ans = min(ans, n + min(p1[i].first, p2[j].first));
		else
			ans = min(ans, n + p1[i].first + p2[j].first);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6140
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define rep(i, n) for (u32 i = 0; i < (n); ++i)
#define repr(i, n) for (u32 i = ((n)-1); i >= 0; --i)

i32 gcd(i32 a, i32 b) {
	if (a < b) return gcd(b, a);
	i32 r;
	while (true) {
		r = a % b;
		if (r == 0) break;
		a = b;
		b = r;
	}
	return b;
}

i64 lcm(i32 a, i32 b) {
	i64 gcd_value = gcd(a, b);
	i64 ab = (i64)a * b;
	return ab / gcd_value;
}

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

	i64 A, B;
	i32 C, D;
	cin >> A >> B >> C >> D;

	i64 mC = B / C - (A - 1) / C;
	i64 mD = B / D - (A - 1) / D;
	i64 lcm_value = lcm(C, D);
	auto mCD =  B / lcm_value - (A - 1) / lcm_value;
	const auto num_numbers = (B - A + 1) - (mC + mD - mCD);
	printf("%llu\n", num_numbers);

	return 0;
}


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

int main()
{
	int n = 0, a[100] = { 0 }, minj = 0, temp = 0, k = 0;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n - 1; i++){

		minj = i;

		for (int j = i + 1; j < n; j++) {
			if (a[j] < a[minj])
				minj = j;
		}

		if (minj > i) {
			temp = a[i];
			a[i] = a[minj];
			a[minj] = temp;
			k++;
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << a[i] << " ";
	cout << a[n - 1] << endl;

	cout << k << endl;
		
	return 0;
}

Measured memory_bytes: 3084
n, k = map(int, input().split())
R, S, P = map(int, input().split())
t = input()

dp = [0] * n
dic = {"r": P, "s": R, "p": S}


for i in range(n):
    if i >= k and (t[i - k] == t[i]) and dp[i - k] != 0:
        continue
    dp[i] = dic[t[i]]


print(sum(dp))


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int a[1000001];
    cin>>N;
    a[0]=0;
    for(int i=1;i<=N;i++){
        cin>>a[i];
    }
    int light[1000001]={0};
    light[1]=1;
    int i=1;
    int count=0;
    while(true){
        if(light[2]==1){
            break;
        }
        light[i]=0;
        light[a[i]]=1;
        i=a[i];
        count++;
        if(count>=1000000){
            count=-1;
            break;
        }
    }
    cout<<count<<endl;
    return 0;
}

        

Measured memory_bytes: 8064
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	dump(N);
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	dump(A.size());
	auto f = [&](int n) {
		dump(n);
		map<int, int>mp;
		rep(i, 1, N) {
			if (A[i - 1] < A[i]) {
				//mp[A[i]] = 0;
			}
			else {
				if (n == 1)return false;
				dump(mp);
				mp.erase(mp.upper_bound(A[i]), mp.end());
				dump(mp);
				int x = A[i];
				while (mp[x] == n-1) {
					mp[x] = 0;
					x--;
				}
				if (x == 0)return false;
				mp[x]++;
			}
		}
		return true;
	};
	int l = 0, r = N;
	while (r - l > 1) {
		int m = (l + r) / 2;
		dump(l, m, r);
		if (f(m)) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main( void )
{
	int l[10];
	l[0] = 1;
	for ( int i = 1; i < 10; i++ )
		l[i] = l[i-1] * 2;

	int n;
	while ( cin >> n )
	{
		bool f = false;
		for ( int i = 0; i < 10; i++ )
		{
			if ( n & 1 << i )
			{
				cout << (f?" ":"") << l[i];
				f = true;
			}
		}
		cout << endl;
	}

	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;




int main(){
  ll m, k;
  cin >> m >> k;

  ll t = pow(2, m);

  if(m == 0){
    if(k == 0) cout << "0 0" << endl;
    else       cout << -1 << endl;
    return 0;
  }

  if(m == 1){
    if(k == 0) cout << "0 0 1 1" << endl;
    else       cout << -1 << endl;
    return 0;
  }

  if(t <= k){
    cout << -1 << endl;
    return 0;
  }

  rep(i, t){
    if(i != k) cout << i << " ";
  }

  cout << k << " ";

  rep(j, t){
    ll i = t-j-1;
    if(i != k) cout << i << " ";
  }

  cout << k << endl;



  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int n;
int ans = 0;

void dfs(ll x) {
    if (x > n) return;
    ll tmp = x;
    bool flag[3] = {false};
    while (tmp > 0) {
        if (tmp % 10 == 3) flag[0] = true;
        else if (tmp % 10 == 5) flag[1] = true;
        else flag[2] = true;
        tmp /= 10;
    }
    if (flag[0] && flag[1] && flag[2]) ans ++;
    dfs(10 * x + 3);
    dfs(10 * x + 5);
    dfs(10 * x + 7);
    return;
}

int main()
{
    cin >> n;
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;

namespace AtCoderPractice
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var W = cin.ReadInt;
            var H = cin.ReadInt;
            var x = cin.ReadInt;
            var y = cin.ReadInt;
            var fc = 0;

            if (x * 2 == W && y * 2 == H)
            {
                fc = 1;
            }
            
            Console.WriteLine($"{(Double)W * (Double)H / 2} {fc}");
        }
    }

    public class ConsoleInput
    {
        private readonly TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine
        {
            get { return _stream.ReadLine(); }
        }

        public int ReadInt
        {
            get { return int.Parse(Read); }
        }

        public long ReadLong
        {
            get { return long.Parse(Read); }
        }

        public double ReadDouble
        {
            get { return double.Parse(Read); }
        }

        public string[] ReadStrArray(long N)
        {
            var ret = new string[N];
            for (long i = 0; i < N; ++i) ret[i] = Read;
            return ret;
        }

        public int[] ReadIntArray(long N)
        {
            var ret = new int[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadInt;
            return ret;
        }

        public long[] ReadLongArray(long N)
        {
            var ret = new long[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadLong;
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 220000;
typedef long long ll;
int n,m,k;
unordered_map<string,int> mp;
vector<string> v;
int mx=0;
int main(){
    cin>>n;
    string s;
    fo(i,1,n) {
        cin>>s;
        mp[s]++;
        int t=mp[s];
        if(t==mx) v.push_back(s);
        if(t>mx){
            mx=t;
            v.clear();
            v.push_back(s);
        }
    }
    sort(v.begin(),v.end());
    for(auto ss:v)
        cout<<ss<<endl;
    return 0;
}

Measured memory_bytes: 26040
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int sum = 0;

		while (k > 0) {
			if (a != 0) {
				a--;
				k--;
				sum += 1;
			} else if (b != 0) {
				b--;
				k--;
				sum += 0;
			} else if (c != 0) {
				c--;
				k--;
				sum += -1;
			}
		}

		System.out.println(sum);
		sc.close();

	}
}

Measured memory_bytes: 35664
from math import log2, ceil

n, k = [int(a) for a in input().split()]

result = 0
for i in range(1, n+1):
    if i >= k:
        result += 1 / n
    else:
        m = ceil(log2(k / i))
        result += (1 / 2**m) / n

print(result)

Measured memory_bytes: 3060
n,m,x,y = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
ans = "War"
for i in range(x + 1,y - x + x + 1):
  if max(X) < i and min(Y) >= i:
    ans = "No War"
print(ans)

Measured memory_bytes: 3060
A, B, M = map(int, input().split())
ref = list(map(int, input().split()))
mic = list(map(int, input().split()))
coupons = [ list(map(int, input().split())) for i in range(M)]
ans = min(ref) + min(mic)

for i in coupons:
  price = ref[i[0]-1] + mic[i[1]-1] - i[2]
  if price < ans:
    ans = price

print(ans)


Measured memory_bytes: 38488
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k1,i,p[1000],price=0;
	cin>>n>>k1;
	for(i=0;i<n;i++){
		cin>>p[i];
	}
	sort(p,p+n);
	for(i=0;i<k1;i++){
		price += p[i];
	}
	cout<<price<<endl;
	return 0;
}


Measured memory_bytes: 3144
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

# 二分探索 #
def nibutan(list,n):
	left = 0
	right = len(list)
	while left+1 != right:
		middle = (left+right)//2
		if list[middle] <= n:
			left = middle
		else:
			right = middle
	return right

N = I()
l = IL()
tmp = l[0]

suml = [tmp]
for i in range(1,N):
	tmp += l[i]
	suml.append(tmp)

num = suml[0]
ans = abs(suml[-1]-num*2)
for i in range(1,N-1):
	num = suml[i]
	ans = min(ans, abs( suml[-1] - num*2 ))

print(ans)

Measured memory_bytes: 24620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

// B Burger(L-1) P Burger(L-1) B
ll solve(vector<ll> sizeOfBurger, vector<ll> numberOfPutties, ll level, ll x) {
  if (x == 0) return 0;
  if (level == 0) return 1;

  ll length = sizeOfBurger[level - 1];
  ll putties = numberOfPutties[level - 1];

  if (x == 1) {
    return 0;
  }
  else if (x <= length + 1 ) {
    return solve(sizeOfBurger, numberOfPutties, level - 1, x -1);
  }
  else if (x <= length + 2) {
    return putties + 1;
  }
  else if (x < 2 * length + 2) {
    return putties + 1 + solve(sizeOfBurger, numberOfPutties, level - 1, x - 2 - length);
  }
  else {
    return 2 * putties + 1;
  }
}

int main() {
  ll N, X;
  cin >> N >> X;

  vector<ll> sizeOfBurger(N+1, 0);
  vector<ll> numberOfPutties(N+1, 0);

  sizeOfBurger[0] = 1;
  numberOfPutties[0] = 1;

  for (ll i = 1; i <= N; i++) {
    sizeOfBurger[i] = 2 * sizeOfBurger[i-1] + 3;
    numberOfPutties[i] = 2 * numberOfPutties[i-1] + 1;
  }

  ll ans = solve(sizeOfBurger, numberOfPutties, N, X);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;
 
int h,w,sx,sy,gx,gy,tx,ty;
char house[505][505];   
bool isvisited[505][505]={false};
 
void search(int x,int y){
    if(isvisited[x][y]){
        return;
    }
    isvisited[x][y]=true;
 
    if(x<=0 || x>h || y<=0 || y>w){
        return;
    }
 
    if(house[x][y]=='#'){
        return;
    }
 
    search(x-1,y-1);
    search(x-1,y);
    search(x-1,y+1);
    search(x,y-1);
    search(x,y);
    search(x,y+1);
    search(x+1,y-1);
    search(x+1,y);
    search(x+1,y+1);
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,a[200005];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a +n);
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cout<<"NO"<<'\n';
      return 0;
    }
  }
  cout<<"YES"<<'\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

	
int main(void){
    int X[5];
    REP(i,5){
        cin >> X[i];
    }
    
    REP(i,5){
        if(X[i]==0){
            cout << i+1 << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3620
N=gets.chomp.to_i
d=[]
d=gets.chomp.split(" ").map{|i| i.to_i}
sum=0

for i in 0..(N-2) do
  for j in (i+1)..(N-1) do
    sum+=d[i]*d[j]
  end
end

print("#{sum}")


Measured memory_bytes: 3836
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var ways []map[int]struct{}

func main() {
	sc.Split(bufio.ScanWords)

	ways = make([]map[int]struct{}, 4)
	for i := 0; i < 4; i++ {
		ways[i] = make(map[int]struct{})
	}
	for i := 0; i < 3; i++ {
		a := nextInt() - 1
		b := nextInt() - 1
		ways[a][b] = struct{}{}
		ways[b][a] = struct{}{}
	}

	var t [4]bool
	for i := 0; i < 4; i++ {
		t[i] = true
		if search(i, t) {
			fmt.Println("YES")
			return
		}
		t[i] = false
	}
	fmt.Println("NO")
}

func search(prev int, way [4]bool) bool {
	all := true
	for i := 0; i < 4; i++ {
		all = all && way[i]
	}
	if all {
		return true
	}
	for i := 0; i < 4; i++ {
		if _, ok := ways[prev][i]; ok && !way[i] {
			way[i] = true
			if search(i, way) {
				return true
			}
			way[i] = false
		}
	}
	return false
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from collections import defaultdict, deque

edges = defaultdict(lambda: [])
used = set()
d = defaultdict(lambda: 0)


def dfs(i):
    if i in used:
        return d[i]
    used.add(i)
    ret = -1
    for v in edges[i]:
        tmp = dfs(v)
        ret = max(ret, tmp)
    d[i] = ret + 1
    return ret+1

def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    h = {}
    for i, al in enumerate(a):
        for pa, ta in zip(al, al[1:]):
            pa, ta = pa-1, ta-1
            edges[1000*min(i, pa)+max(i, pa)].append(1000*min(i, ta)+max(i, ta))
            if 1000*min(i, pa)+max(i, pa) not in h:
                h[1000*min(i, pa)+max(i, pa)] = 0
            if 1000*min(i, ta)+max(i, ta) not in h:
                h[1000*min(i, ta)+max(i, ta)] = 1
            else:
                h[1000*min(i, ta)+max(i, ta)] += 1
    
    deq = deque([])
    for k, v in h.items():
        if v == 0:
            deq.append(k)
    
    ans = 0
    while deq:
        u = deq.popleft()
        for v in edges[u]:
            h[v] -= 1
            if h[v] == 0:
                deq.append(v)
        ans += 1
    
    if ans != n*(n-1) // 2:
        print(-1)
    else:
        length = 0
        for k, _ in edges.items():
            tmp = dfs(k)
            length = max(length, tmp)
        print(length + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 251760
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP(i, 1, n+1)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}
template<class T>
void printp(vector<pair<T,T>> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << (*it).first << "," << (*it).second << endl;
    }
    cout << endl;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() {
    ull N;
    cin>>N;
    ll res = 0;
    auto divs = prime_factorize(N);
    for (auto p : divs) {
        for(int i = 1; true; i++) { 
            if (p.second - i < 0) break;
            p.second -= i;
            res++;
        }
    }
    //printp(divs);
    cout << res;
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"charmap.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin>>s;
	bool f=1;
	rep(i,s.size()){
		if((i+1)%2==1){
			if(s[i]=='L')f=0;
		}
		else{
			if(s[i]=='R')f=0;
		}
	}
	if(f){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
    return 0;
}

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

const long long mod = 1e9+7;
long long dp[1100][1100];

int main()
{
	long long h, w;
	cin >> h >> w;
	string s[h];
	for(long long i = 0; i < h; i++)
		cin >> s[i];
	for(long long i = 0; i < h; i++) {
		for(long long j = 0; j < w; j++)
			dp[i][j] = 0;
	}
	dp[0][0] = 1;
	for(long long i = 0; i < h; i++) {
		for(long long j = 0; j < w; j++) {
			if(s[i][j] == '.')
			{
				if(i == 0 && j != 0)
					dp[i][j] = dp[i][j - 1];
				else if(j == 0 && i != 0)
					dp[i][j] = dp[i - 1][j];
				else if(i == 0 && j == 0)
					dp[i][j] = 1;
				else
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= mod;
			}
		}
	}
	cout<<dp[h - 1][w - 1] << endl;
	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

template<typename T>
class BIT {
public:
    BIT(int n = 0) :n(n), d(n + 1) {}
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) d[i] += x;
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) x += d[i];
        return x;
    }
private:
    int n;
    vector<T> d;
};


int n;
int k;
ll a[200005], b[200005];
int c[200005];
void solve() {
    cin >> n >> k;

    rep(i, n) cin >> a[i];
    rep(i, n) b[i + 1] = b[i] + a[i] - k;

    {
        vector<pair<ll, int>> vec(n + 1);
        rep(i, n + 1) { vec[i].first = b[i]; vec[i].second = i; }
        all(sort, vec);
        rep(i, n + 1) c[i] = vec[i].second;
    }

    BIT<ll> bit(n + 1);
    ll ans = 0;
    rep(i, n + 1) {
        ans += bit.sum(c[i]);
        bit.add(c[i]);
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int a, b; cin >> a >> b;
	if (a + b < 24)cout << a + b << "\n";
	else cout << a + b - 24 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < n.size(); i++) {
        if (n[i] == '1') {
            n[i] = '9';
        } else {
            n[i] = '1';
        }
    }
    cout << n << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vi a(n);
  while(true){
    rep(i,n) cout << char('a'+a[i]);
    cout << "\n";
    bool change=false;
    for(int i=n-1;i>0;i--){
      int biggest=0;
      rep(j,i){
        biggest=max(biggest,a[j]);
      }
      if(a[i]<=biggest){
        a[i]++;
        for(int j=i+1;j<n;j++){
          a[j]=0;
        }
        change=true;
        break;
      }
    }
  if(!change) break;
  }
  
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int min_mai = min(x, y);
	long long ans = 0;
	if (a + b > 2 * c) {
		ans += c * 2 * min_mai;
		if (x >= y) {
			if (a < 2 * c) {
				ans += a*(x - y);
			}
			else {
				ans += 2 * c*(x - y);
			}
		}
		else {
			if (b < 2 * c) {
				ans += b*(y - x);
			}
			else {
				ans += 2 * c*(y - x);
			}
		}
	}
	else {
		cout << a*x + b*y << endl;
		return 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, L = map(int,input().split())

all_taste = 0
taste_list = []
minimum = L + N - 1

for i in range(1, N+1, 1):
  all_taste += L + i - 1
  taste_list.append(L + i - 1)
else:
  for i in range(N):
    if abs(taste_list[i]) < abs(minimum):
      minimum = taste_list[i]
  else:
    print(all_taste - minimum)
    
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//

//-------------------関数----------------------//
ll h, w, grid[200][200], dp[500][200][200];
ll p[] = {1, 0, 0, 1, 1, 1, 0, 0};
int main() {
  cin >> h >> w;
  REP(i, h) {
    REP(j, w) { cin >> grid[i][j]; }
  }
  REP(i, h + w - 2) {
    REP(X, min(w, i + 1)) {
      REP(x, min(w, i + 1)) {
        if (h <= i - X || h <= i - x)
          continue;
        ll y = i - x, Y = i - X, cost = grid[Y][X] + grid[y][x];
        // cost -= (X == x && grid[y][x]);
        cost -= (X == x ? grid[y][x] : 0);
        REP(k, 4) {
          dp[i + 1][X + p[k * 2]][x + p[k * 2 + 1]] = max(
              dp[i + 1][X + p[k * 2]][x + p[k * 2 + 1]], cost + dp[i][X][x]);
        }
      }
    }
  }
  cout << dp[h + w - 2][w - 1][w - 1] + grid[h - 1][w - 1] << endl;
}


Measured memory_bytes: 123520
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	for (int i = 0;i < n;i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) {
			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;
	return 0;
}

//AAAAAAAAAAAAAAAA
//int main() {
//	int a, b, c;
//	cin >> a >> b >> c;
//
//	if (a != b && b != c && c != a) {
//		cout << "No" << endl;
//	}
//	else if (a == b && b == c) {
//		cout << "No" << endl;
//	}
//	else cout << "Yes" << endl;
//
//	return 0;
//}

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

using namespace std;
#define ll long long

int main()
{
    ll n;
    cin>>n;
    ll arr[n+5]={0};
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];

    }
    ll ans=INT_MAX;
    for(int i=1;i<=100;i++)
    {
        ll cost=0;
        for(int j=0;j<n;j++)
        {
            ll x=(arr[j]-i)*(arr[j]-i);
            cost+=x;
        }
        ans=min(ans,cost);
    }
    cout<<ans<<endl;

}


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

using namespace std;

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


int main(){
  int s, w;
  cin >> s >> w;
  if(w >= s){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}



signed main(){
  int q,h,s,d;
  cin>>q>>h>>s>>d;
  int n;
  cin>>n;
  int A[3] ={q*4,h*2,s};
  sort(A,A+3);
  int ans = 0;
  if(d < A[0] * 2) ans += (n / 2) * d, n%=2;
  ans += A[0] * n;
  cout<<ans<<endl;
    

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ll long long
#define me(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e2+5;
int n, m;
char mp[maxn][maxn];
int dir[8][2]={0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,1,-1,-1};
int slove(int i, int j)
{
    int cnt = 0;
    for(int k=0; k<8; k++)
    {
        int ti = i + dir[k][0];
        int tj = j + dir[k][1];
        if(ti<0||ti>=n||tj<0||tj>=m||mp[ti][tj]=='.')
            continue;
        cnt ++;
    }
    return cnt;
}

int main()
{
    cin >> n>> m;
    for(int i=0; i<n; i++)
        scanf("%s", mp[i]);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]=='#')
                printf("#");
            else
                printf("%d", slove(i, j));
        }
        puts("");
    }
    return 0;
}

/**

**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
	cin >> S;
	int n;
	n=0;
	for (int i=0; i<4; i++){
		if (S.at(i)=='+'){
			n += 1;
		}
	}
	cout << -4+2*n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
//my approch
int solve1(int n,int a[],int b[],int c[]){
	vector<int> dp(n+1);
	dp[0] = 0;
	dp[1] = max(a[1],max(b[1],c[1]));
	for(int i=2;i<=n;i++){
		if(dp[i-1]-dp[i-2]==a[i-1])
			dp[i] = dp[i-1]+max(b[i],c[i]);
		else if(dp[i-1]-dp[i-2]==b[i-1])
			dp[i] = dp[i-1]+max(a[i],c[i]);
		else
			dp[i] =dp[i-1]+max(a[i],b[i]);
	}

	return dp[n];

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

}

int main(){

/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
int n;
cin>>n;
int a[n+1],b[n+1],c[n+1];
a[0] = b[0] = c[0] =0;
for(int i=1;i<=n;i++){
	cin>>a[i]>>b[i]>>c[i];
}
cout<<solve(n,a,b,c);

}
		

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] v = new int[25025];
		for(int i = 0;i < 25025;i++){
			v[i] = 1;
		}
		int p = 3;
		while(true){
			if(p*p > 50050){
				break;
			}else{
				if(v[(p-1)/2] == 0){
					p += 2;
				}else{
					int t = p*p;
					while(t < 50050){
						v[(t-1)/2] = 0;
						t += 2*p;
					}
					p += 2;
				}
			}
		}
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 3){
				System.out.println(2 + " " + 5);
				continue;
			}
			int prev = 0;
			boolean sw = false;
			for(int i = 1;i < 25025;i++){
				if(v[i] != 1){
					continue;
				}
				if((2*i + 1) == n && !sw){
					sw = true;
					continue;
				}
				if(sw || (2*i + 1) > n){
					System.out.println(2*prev+1 + " " + (2*i+1));
					break;
				}
				prev = i;
			}
		}
	}
}

Measured memory_bytes: 20044
#include<bits/stdc++.h>
using namespace std;
#define inf 1e15
int main(){
  int size;
  cin>>size;
  vector<int>height(size+2,0);
  for(int i=0;i<size;i++){
	//int x;
    //cin>>x;
    cin>>height[i];
  }
  vector<int>dp(size+2,inf);
  dp[0]=0;
  for(int i=0;i<size;i++){
  	dp[i+2]=min(dp[i+2],dp[i]+abs(height[i]-height[i+2]));
  	dp[i+1]=min(dp[i+1],dp[i]+abs(height[i]-height[i+1]));
  }
  cout<<dp[size-1];
  return 0;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 305
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db long double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
LL f[N][N];
struct node{
    int u, v, w;
    node(){}
    node(int _u, int _v, int _w){
        u = _u; v = _v; w = _w;
    }
    bool operator < (const node &rhs)const {
        return w < rhs.w;
    }
}e[100005];
int en, n, x;
int main(){
    //IN;
    memset(f, 0x3f, sizeof(f));
    SC(n);
    FF(i, 1, n)
    FF(j, 1, n){
        SC(x);
        if(i < j) e[++en] = node(i, j, x);
    }
    FF(i, 1, n) f[i][i] = 0;
    sort(e + 1, e + 1 + en);
       
    LL ans = 0;
    for(int i = 1; i <= en; ++i){
        int w = e[i].w, u = e[i].u, v = e[i].v;
        if(w > f[u][v]){
            ans = -1;
            break;
        }
        if(f[u][v] > w){
            f[u][v] = f[v][u] = w;
            FF(p, 1, n) FF(q, 1, n)
                if(f[p][u] + w + f[v][q] < f[p][q]) f[p][q] = f[q][p] = f[p][u] + w + f[v][q];
            ans += w;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

int a[105];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, x;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (x - a[i] < 0)
			return cout << i << "\n", 0;
		x -= a[i];
	}
	cout << n - ((x == 0) ? 0 : 1) << "\n";
}


Measured memory_bytes: 256
h = [-1, -1, -1]

10.times{
  it = gets.to_i
  if h[0] < it
    h = [it, h[0], h[1]]
  elsif h[1] < it
    h =  [h[0], it, h[1]]
  elsif h[2] < it
    h = [h[0], h[1], it]
  end
}

3.times{|i|
  puts h[i]
}

Measured memory_bytes: 8560