akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;

    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;

    } else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

struct Robot {
	int position, arm;
};
int main() {
	int n; std::cin >> n;
	std::vector<Robot> robots(n);
	for (auto& r : robots) std::cin >> r.position >> r.arm;
	std::sort(robots.begin(), robots.end(), [](Robot a, Robot b) {return a.position + a.arm < b.position + b.arm; });
	int count = 0;
	int right = INT_MIN;
	for (const auto robot : robots) {
		if (right <= robot.position - robot.arm) {
			++count;
			right = robot.position + robot.arm;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 1656
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int main(){
   int t;
   while(scanf("%d",&t) != EOF, t ){
      int n;
      scanf("%d",&n);
      int tot = 0;
      int data[n][2];
      rep(i,n){
         scanf("%d %d",&data[i][0],&data[i][1]);
      }
      rep(i,n){
         tot += data[i][1] - data[i][0];
      }
      if( tot < t){
         printf("%d\n",t-tot);
      }else{
         printf("OK\n");
      }
   }
   return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX


int main()
{
    
    int n,k;
    cin>>n>>k;
    vector<int > dp(n+1);
    vector<int > h(n+1);
    int i,cost;
    for(i=0;i<n;i++){
        cin>>h[i+1];
    }
    
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(i=3;i<=n;i++)
  {
      cost=inf;
  for(int j=1;j<=k;j++)
  {
      if(i-j==0)
      break;
      int x=dp[i-j]+abs(h[i]-h[i-j]);
      cost=min(x,cost);
     
     
   
  }
  dp[i]=cost;
  }
  cout<<dp[n]<<endl;
  
    
    return 0;
    
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int a, b, x;
    readf("%d %d %d\n", &a, &b, &x);

    bool f = false;
    if (a > x) f = false;
    else if (a + b >= x) f = true;
    else f = false;

    writeln(f ? "YES" : "NO");

    auto _ = readln(); // dbg
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 1000
using namespace std;  
#define PI 3.141592653589793238462643383279502884197169
int main()
{
   
 double a,b,h,m;
cin>>a>>b>>h>>m;
double theta1=M_PI*h/6+M_PI*m/360;

theta1=M_PI_2-theta1;
 double theta2=M_PI*m/30;
theta2=M_PI_2-theta2;
double theta=abs(theta1-theta2);
double ans=sqrtl(a*a+b*b-2*a*b*cos(theta));
printf("%.10f",ans);
    return 0;
}

Measured memory_bytes: 4228
#include <iostream>
        #include <string>
        #include <unordered_map>
        #include <algorithm>
         
        using namespace std;
         
        int main() {
          int n;
          cin >> n;
          unordered_map<string, int> mp;
         
          for (int i=0; i<n; ++i) {
            string s;
            cin >> s;
            sort(s.begin(), s.end());
            mp[s]++;
          }
         
          long long result = 0;
          for (auto &e : mp) {
            long long v = (long long)e.second;
            result += v * (v - 1) / 2;
          }
         
          cout << result << "\n";
         
          return 0;
        }


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

int main() {

	int k,a,b;
	cin>>k>>a>>b;

	for(int i=a;i<=b;i++) 
		if(i%k==0) {
			cout<<"OK"<<endl;
			return 0;
		}
	cout<<"NG"<<endl;
}



Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (B - A <= 0) {
		cout << "delicious" << endl;
	}
	else if (B - A > X) {
		cout << "dangerous" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

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

typedef long long ll;
const int N = 1000 + 10;
int v[N*2], u[N*2], cost[N*2];
ll dis[N];
bool vis[N];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d%d%d", &v[i], &u[i], &cost[i]);
        cost[i] = -cost[i];
    }
    memset(dis, 0x3f, sizeof dis);
    memset(vis, 0, sizeof vis);
    dis[1] = 0;
    for(int i = 1; i <= n-1; i++)
        for(int j = 1; j <= m; j++)
            dis[u[j]] = min(dis[u[j]], dis[v[j]] + cost[j]);
    ll ans = -dis[n];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(dis[u[j]] > dis[v[j]] + cost[j])
            {
                dis[u[j]] = dis[v[j]] + cost[j];
                vis[u[j]] = true;
            }
        }
    if(vis[n]) puts("inf");
    else printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.buffer.readline

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to = map(lambda a: int(a) - 1, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

def calcDist(fr):
    minDist = [10**18] * N
    que = deque([(fr, 0)])

    while que:
        now, dist = que.pop()

        if minDist[now] < dist:
            continue
        minDist[now] = dist

        for to in edges[now]:
            if minDist[to] > dist + 1:
                minDist[to] = dist + 1
                que.append((to, dist + 1))

    return minDist

D0 = calcDist(0)
R = max(calcDist(D0.index(max(D0)))) + 1

if R == 1:
    print('First')
    exit()

canFirstWin = [False] * (R + 1)
canFirstWin[1] = True
canFirstWin[2] = False

for i in range(3, R + 1):
    canFirstWin[i] = not(canFirstWin[i - 1] and canFirstWin[i - 2])

print('First' if canFirstWin[R] else 'Second')


Measured memory_bytes: 58604
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= flip replicateM readInts >>= print . solve . sort . (:) ( 0, 2000000000 ) . map mp

solve [ ( a, b ) ] = b
solve ( ( a, b ) : rest@( ( c, d ) : _ ) ) = min ( c - a ) ( b - d ) + solve rest

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   int x = a + b;
   int y = c + d;
   if (x > y) {
      puts("Left");
   } else if (x < y) {
      puts("Right");
   } else {
      puts("Balanced");
   }

   return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint x, k, d;
    cin >> x >> k >> d;
    if(x<0) x *= -1;

    llint ans = 1e15, a, b;
    a = x % d;
    b = abs(a - d);
    llint c = x / d;

    if(c>k) {
        ans = x - k * d;
    }
    else {
        k -= c;
        if(k%2==0) ans = a;
        else ans = b;
    }
    cout << ans << endl;
    
    return 0;
}




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

using namespace std;


bool calc(string st, int a, int b)
{
    int num = 0;
    if (b - a < 1) {
        return false;
    }
    if (b - a == 1 && st[a] == '0') {
        return true;
    } else if (st[a] == '0') {
        return false;
    }
    for (int i = a; i < b; i++) {
        num *= 10; num += st[i] - '0';
    }
    return (num <= 255);
}

int main()
{
    string st;
    cin >> st;

    int ans = 0;
    for (int i = 1; i < st.size(); i++) {
        for (int j = i + 1; j < st.size(); j++) {
            for (int k = j + 1; k < st.size(); k++) {
                if (calc(st, 0, i) && 
                        calc(st, i, j) &&
                        calc(st, j, k) &&
                        calc(st, k, st.size())) {
                    ans++;
                }
            }
        }
    }

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




Measured memory_bytes: 3240
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		if(S.equals("a") || S.equals("i") || S.equals("u") || S.equals("e") || S.equals("o")) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 23764
n,q = map(int,input().split())
s = list(input())
l = [0]*(n)
for i in range(n-1):
        if s[i] == "A" and s[i+1] == "C":
                l[i+1] = l[i] + 1
        else:
                l[i+1] = l[i]  
for j in range(q):
        k,t = map(int,input().split())
        print(l[t-1] - l[k-1])

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

const int nm = 1e5;
int n, a[nm + 1];
long long ans = 0;
long long cap[nm + 1]; //leaf以外のキャパ;
long long node[nm + 2];

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

	cap[0] = 1 - a[0];
	for (int i = 1; i <= n; i++)
		cap[i] = min(cap[i - 1] * 2 - a[i], (long long) 4e18);

	for (int i = 0; i <= n; i++)
		if (cap[i] < 0) {
			cout << -1 << endl;
			return 0;
		}

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


Measured memory_bytes: 5628
use std::io;
fn get_parms() -> Vec<i32> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("stdin error");
    return buf
        .split_whitespace()
        .map(|x| x.parse().expect("Parse failed"))
        .collect();
}

fn main() {
    let parms = get_parms();
    let (W, H, x, y, r) = (parms[0], parms[1], parms[2], parms[3], parms[4]);
    if x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H {
        println!("Yes");
    } else {
        println!("No");
    }
}



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

int main() {
  int ans = 0, a = 0, b = 0;
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == '0'){
      if(b >= 1) {
        ans += 2;
        b--;
      }else{
        a++;
      }
    }else{
     if(a >= 1) {
        ans += 2;
        a--;
      }else{
        b++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 512
s = gets.chomp

# 65 <= c <= 90: upper
# 97 <= c <= 122: lower

p1 = s[0] == "A"
p2 = s[2..(-2)].include?("C")
p3 = s.bytes.map{|c| c <= 90}.count(true) == 2

if p1 && p2 && p3 then
  puts "AC"
else
  puts "WA"
end


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
string s;


int main() {
    cin >> s;
    if(s.size() == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    REP(i, 0, s.size() - 2) {
        int l = i;
        int m = i + 1;
        int r = i + 2;
//        vector<int> v(26, 0);
//        for (int j = l; j <= r; j++) {
//            v[s[j] - 'a']++;
//        }
//        if (*max_element(v.begin(), v.end()) > 1) {
//            cout << l + 1 << " " << r + 1 << endl;
//            return 0;
//        }
        if(s[l] == s[m]){
            cout << l + 1 << " " << m + 1 << endl;
            return 0;
        }else if(s[l] == s[r]){
            cout << l + 1 << " " << r + 1 << endl;
            return 0;
        }else if(s[m] == s[r]){
            cout << m + 1 << " " << r + 1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        int dig = 0,rem = 7;
        while(dig < 1e7){
            dig++;
            if(rem%n == 0){
                cout << dig ;
                return 0;
            }
            rem = (rem*10 + 7) % n;
        }
        cout << -1 ;
    }    
}

Measured memory_bytes: 3612
//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){
    ll N;cin>>N;
    ll a[N];
    REP(i,N)cin>>a[i];
    ll sum=0;

    ll ave;
    REP(i,N)sum+=a[i];
    if(sum*1.0/N>=0)ave=(sum*1.0/N)+0.5;
    else ave=(sum*1.0/N)-0.5;
    //cout<<"ave:"<<ave<<"\n";
    ll ans=0;
    REP(i,N){
        ans+=(ave-a[i])*(ave-a[i]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<string> s(3);
  REP(i,3){
    cin >> s[i];
    transform(s[i].begin(), s[i].end(), s[i].begin(), ::toupper);
  }
  REP(i,3) cout << s[i][0];
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
	Scanner sc = new Scanner(System.in);
	int x;
	int y;
	
	void rp3(){
	
		x = sc.nextInt();
		y = sc.nextInt();
		
	
		for(int i=1; (x>0 || y>0); i++){
			if(x>y){
				System.out.println(y+" "+x);
			}else{
				System.out.println(x+" "+y);
			}
			x = sc.nextInt();
			y = sc.nextInt();
			
		}
	}
	
	public static void main(String[]agrs){
			new Main().rp3();
	}
}
	

Measured memory_bytes: 27188
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        m: usize,
        d: usize,
    }
    let mut cnt = 0;
    for j in 1..m+1 {
        for i in 2..d + 1 {
            let k0 = i % 10;
            let k1 = i / 10;
            if k0 >= 2 && k1 >= 2 && k0 * k1 == j {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
  int N;
  int V[21];
  int C[21];
  int i;
  int max=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&V[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d",&C[i]);
  }
  for(i=0;i<N;i++){
    if(V[i]-C[i]>0){
      max=max+V[i]-C[i];
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 1716
def train_ticket(s)
  chars = s.chars
  plus = Array.new(s.size - 1) { false }
  f = ->(i) {
    if i == plus.size
      formula = ''
      chars.each_with_index do |c, i|
        if i < plus.size
          sign = plus[i] ? '+' : '-'
          formula += c + sign
        else
          formula += c
        end
      end
      if eval(formula) == 7
        puts "#{formula}=7"
        exit
      end
      return
    end

    plus[i] = false
    f.call(i + 1)
    plus[i] = true
    f.call(i + 1)
  }
  f.call(0)
end

puts train_ticket(gets.chomp)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int vx = y1 - y2;
  int vy = x2 - x1;
  int x3 = x2 + vx;
  int y3 = y2 + vy;
  int x4 = x3 + y2 - y3;
  int y4 = y3 + x3 - x2;
  cout << x3 << " " << y3 << " " << x4 << " " << y4;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,n = LI()
    g = LIR(n)
    dp = [float("inf")]*(h+1)
    dp[h] = 0
    for a,b in g:
        for i in range(h+1)[::-1]:
            ni = max(0,i-a)
            nd = dp[i]+b
            if nd < dp[ni]:
                dp[ni] = nd
    print(dp[0])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 44636
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
long long mod = 1e9+7;

char s[304][304];
int ans[304][304];
int main(){
  int H, W, K;
  scanf("%d", &H);
  scanf("%d", &W);
  scanf("%d", &K);
  std::vector<int > strcount(H, 0);
  std::queue<std::pair<int, int> > queue;
  for (int i=0; i<H; i++){
    std::string input;
    std::cin >> input;
    for (int j=0; j<W; j++){
      s[i][j]=input[j];
      if (s[i][j]=='#'){
        strcount[i]++;
        queue.push(std::make_pair(i, j));
      }
    }
  }
  bool find = false;
  int counter = 1;
  while(queue.size()>0){
    int i = queue.front().first;
    int j = queue.front().second;
    queue.pop();
    ans[i][j]=counter;
    counter++;
  }
  for (int i=0; i<H; i++){
    if (strcount[i]==0) continue;
    for (int j=1; j<W; j++){
      if (ans[i][j-1]!=0 && ans[i][j]==0){
        ans[i][j] = ans[i][j-1];
      }
    }
    for (int j=W-2; j>=0; j--){
      if (ans[i][j+1]!=0 && ans[i][j]==0){
        ans[i][j]=ans[i][j+1];
      }
    }
  }  
  for (int i=0; i<H-1; i++){
    if (strcount[i]!=0 && strcount[i+1]==0){
      for (int j=0; j<W; j++){
        ans[i+1][j]=ans[i][j];
      }
      strcount[i+1]++;
    }
  }
  for (int i=H-2; i>=0; i--){
    if (strcount[i]==0 && strcount[i+1]!=0){
      for (int j=0; j<W; j++){
        ans[i][j]=ans[i+1][j];
        //printf("ans[%d][%d]=ans[%d][%d]\n", i, j, i+1, j);
      }
      strcount[i]++;
    }
  }
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      printf("%d%c", ans[i][j],(j==W-1)?'\n':' ');
    }
  }
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

long nCr(long n, long k) {
    long r = 1;
    for (long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main(){
	int n;
	cin >> n;
	vector<ll> a;
	rep(i,0,n){
		int ta;
		cin >> ta;
		a.push_back(ta);
	}
	vsort(a);
	ll M = a[a.size()-1];
	
	if( M%2 ){
		int l_idx = lb(a,M/2)-a.begin();
		int u_idx = ub(a,M/2)-a.begin();
		//cout << l_idx << " " << u_idx << endl;
		if(u_idx == n-1 ) u_idx--;
		if( a[l_idx] == M/2 ) cout << M << " " << a[l_idx] << endl;
		else if( a[l_idx+1] == M/2+1 ) cout << M << " " << a[l_idx+1] << endl;
		else{
			if( M/2 - a[l_idx-1] < a[u_idx] - M/2 ) cout << M << " " << a[l_idx-1] << endl;
			else cout << M << " " << a[u_idx] << endl;
		}
		
	}
	else{
		int l_idx = lb(a,M/2)-a.begin();
		int u_idx = ub(a,M/2)-a.begin();
		if(u_idx == n-1 ) u_idx--;
		//cout << l_idx << " " << u_idx << endl;
		if( a[l_idx] == M/2 ) cout << M << " " << a[l_idx] << endl;
		else{
			if( M/2 - a[l_idx-1] < a[u_idx] - M/2 ) cout << M << " " << a[l_idx-1] << endl;
			else cout << M << " " << a[u_idx] << endl;
		}
	}
		
	ret 0;
}

Measured memory_bytes: 1400
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

int main() {
    int H,W,h,w;
    cin>>H>>W;
    cin>>h>>w;
    
    cout<<(H-h)*(W-w)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,x,t; cin >> n >> x >> t;
  int p = 0;
  int ti = 0;

  while(p<n){
    p+=x;
    ti+=t;
  }


  cout << ti << '\n';


  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll sum;

bool c(ll a){
    return a * n <= sum;
}

int main(){
    while(cin >> n && n){
        sum = 0;
        vector<ll> v(n);
        rep(i,n){
            cin >> v[i];
            sum += v[i];
        }
        ll ans = 0;
        rep(i,n){
            if(c(v[i]))ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3124
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k, s; cin >> n >> k >> s;
  vector<int> ans(n);
  REP(i, k) ans[i] = s;
  if (s == 1000000000) {
    FOR(i, k, n) ans[i] = 1;
  } else {
    FOR(i, k, n) ans[i] = 1000000000;
  }
  REP(i, n) cout << ans[i] << " \n"[i + 1 == n];
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
 
using namespace std;
 
int main(int argc, char const *argv[])
{
	string s;
	int ok = 0, asd;
	cin >> s;
	for(auto i : s)
		if(i == 'C') ok = 1;
		else if(i == 'F' && ok) return cout << "Yes\n", 0;
 
	cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
    int x;
    cin >> x;
 
    int s;
    int x0 = x;
    while (x > 0) {
        s += x % 10;
        x /= 10;
    }
 
    if (x0 % s == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read(){
	int f=1,x=0; char c=getchar();
	while (c>'9' || c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0'; c=getchar();}
	return f*x;
}
int maxans=0,sum=0;
int main(){
	int n,m;
	char s[110][11],t[110][11];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	cin>>m;
	for(int i=1;i<=m;i++)cin>>t[i];
	for(int i=1;i<=n;i++){
		sum=0;
		for(int j=1;j<=n;j++)
			if(strcmp(s[i],s[j])==0)sum++;
		for(int j=1;j<=m;j++)
			if(strcmp(s[i],t[j])==0)sum--;
		if(sum>maxans)maxans=sum;
	}
	cout<<maxans;
	return 0;
}

Measured memory_bytes: 256
n, m = [int(_) for _ in input().split()]
b = [[int(_) for _ in input().split()] for __ in range(m)]
p = [int(_) for _ in input().split()]
ans = 0
for i in range(2**n):
    s = format(i, '0'+str(n)+'b')
    for j in range(m):
        on = 0
        for k in range(b[j][0]) : on += int(s[b[j][k+1]-1])
        on %= 2
        if p[j] != on : break
    else : ans += 1
print(ans)

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


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

  rep(i, 25){
    int r = n-(i*4);
    if (r>=0 and r%7==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
S = int(input())
A = [int(x) for x in input().split()]

Sum = 0
Asum = sum(A) % 1000000007
for i in range(len(A) -1 ):
    b = A[i]
    Asum = Asum - b
    if Asum < 0:
        Asum = Asum + 1000000007
    Sum = (Sum + Asum * b) % 1000000007

print(Sum)


Measured memory_bytes: 94260
from collections import defaultdict
import sys
sys.setrecursionlimit(20000000)
connection = defaultdict(lambda: [])

n = int(input())

ab = []
for i in range(n-1):
    a, b = map(int, input().split())
    connection[a].append(b)
    connection[b].append(a)
    ab.append((a, b))

c = list(map(int, input().split()))
c.sort()

ans = [0] * (n+1)

checked_list = []
def dfs(num):
    checked_list.append(num)
    ans[num] = c.pop()
    for next_num in connection[num]:
        if next_num not in checked_list:
            dfs(next_num)


l = []
for i in range(1, n+1):
    l.append([i, len(connection[i])])
l.sort(key=lambda x: x[1], reverse=True)
dfs(l[0][0])

score = 0

for a, b in ab:
    score += min(ans[a], ans[b])

print(score)
print(" ".join(map(str, ans[1:])))


Measured memory_bytes: 13084
using System;
using System.Linq;
class Program
{
  static void Main(string[] args)
  {
    string[] NX = Console.ReadLine().Split(' ');
    int N = int.Parse(NX[0]);
    int X = int.Parse(NX[1]);
    int[] m = new int[N];
    for(int i = 0; i < N; i++)
    {
      m[i] = int.Parse(Console.ReadLine());
    }
    int ans = N;
    X -= m.Sum();
    ans += X / m.Min();
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
double abs_Double(double x){
	if(x>=0) return x;
      else return -x;
}
int main(void) {
	int N,T,A,position;
	cin >> N >> T >> A;
  	double H[N+20],min=1000000.0;
	for(int i=0;i<N;++i){
		cin >> H[i];
      	if(min > abs_Double(A-(T-0.006*H[i])) ){
        	min = 	abs_Double(A-(T-0.006*H[i])) ;
          position = i+1;
        }
	}
  cout << position;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 50
int a[N+1],b[N+1];
int main(){
	int n,mn,i;scanf("%d",&n);mn=n;
	for(i=1;i<=n;i++)scanf("%d%d",a+i,b+i);
	for(i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		int x=a[i]-a[j],y=b[i]-b[j],ans=n;
		for(int k=1;k<=n;k++)for(int o=1;o<=n;o++)
			if(a[k]-a[o]==x&&b[k]-b[o]==y)ans--;
		mn=min(mn,ans);
	}
	printf("%d\n",mn);
	return 0;
}
/*1
2
1 1
2 2
*/
/*2
3
1 4
4 6
7 8
*/
/*3
4
1 1
1 2
2 1
2 2
*/

Measured memory_bytes: 256
/*ex3_4
    takafumi_ueki*/
#include <stdio.h>
int main(void){
    int x;
    scanf("%d",&x);
    /*例えば,xを2で割った余りが０（２で割り切れる）かつ
    ２で割った商が10未満だったら一桁の整数同士の掛け算で表せるということなので、それを3,4,5,,,,と調べる。*/
    if(((x%1 == 0)&&((x/1)<10))||((x%2 == 0)&&((x/2)<10))||((x%3 == 0)&&((x/3)<10))||((x%4 == 0)&&((x/4)<10))||((x%5 == 0)&&((x/5)<10))||((x%6 == 0)&&((x/6)<10))||((x%7 == 0)&&((x/7)<10))||((x%8 == 0)&&((x/8)<10))||((x%9 == 0)&&((x/9)<10))){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int square(long long int & n)
{
	long long tmp = sqrt(n), ans = 0;
	for(int i = tmp; i >= 1; i--)
    	if( n % i == 0 )
    	{
    		tmp = n/i;
    		while( tmp > 0 )
        	{
        		ans++;
        		tmp /= 10;
        	}
        	return ans;
      	}
}
int main()
{
	long long int n;
  	cin >> n;
  	cout << square(n);
}

Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,t;
    cin >> x >> t;
    if (x >= t) PRINT(x-t);
    else PRINT(0);
}



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


int main() 
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans(n);
    vector<int> aa(n);
    rep(i, n)
    {
        ans[i] = 0;
        aa[i] = k;
    }
    rep(i, q)
    {
        int a;
        cin >> a;
        ans[a-1] += 1;
    }
    int max=0;
    rep(i,n)
    {
        max += ans[i];
    }
    rep(i, n)
    {
        if(max-ans[i]>=k)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
        
    }

    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,s=0,ans,j;
	cin>>n;
	for(int i=1;i<=n;i++){
		j=i;
		ans=0;
		while(j!=0){
			ans++;
			j=j/10;
		} 
		if(ans%2==1)
		s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5;

char s[8];

int main(){
    int n;
    scanf("%d", &n);
    int ans = (n / 500) * 1000;
    printf("%d\n", ans + 5 * ((n % 500) / 5));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

size_t f(size_t x) {
    size_t a = 100;
    size_t c = 0;
    while (a < x) {
        a = static_cast<size_t>(a * 1.01);
        ++c;
    }
    return c;
}

int main() {
    size_t n = input();
    size_t k = input();
    vector<size_t> t(n, 0);
    for (size_t i = 0; i < k; ++i) {
        size_t d = input();
        vector<size_t> a = input(d);
        for (auto ai : a) {
            ++t[ai - 1];
        }
    }
    size_t c = 0;
    for (auto e : t) {
        if (e == 0)
            ++c;
    }
    cout << c << endl;
    return 0;
}


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

int main(){
    string a,b;cin >> a >> b;
    a+=b;
    int x = stoi(a);
    int i=1;
    while(x>=i*i){
        if(x == i*i){
            cout << "Yes" << endl;
            return 0;
        }
        i++;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = 0
if n % 3 != 0:
    for i in range(0, n - 1):
        if a[i] == a[i + 1]:
            flag += 1
        else:
            break
    if flag == n - 1:
        print("Yes")
    else:
        print("No")
else:
    n3 = n // 3

    if a[0] ^ a[n3 * 2] != a[n3]:
        print("No")
    else:
        for i in range(0, n - 1):
            if i == n3 - 1 or i == n3 * 2 - 1:
                continue
            if a[i] == a[i + 1]:
                flag += 1
            else:
                break
        if flag == n - 3:
            print("Yes")
        else:
            print("No")



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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {
    string s;
    cin>>s;

    map<char,int>S;
    rep(i,s.size())S[s[i]]++;

    if((S['N']!=0)&&(S['S']!=0)||(S['N']==0)&&(S['S']==0)){
        if((S['W']!=0)&&(S['E']!=0)||(S['W']==0)&&(S['E']==0)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ cout << "["; for (T item: v) { cout << item << ", "; } cout << "]" << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi, k = gi;
    print(k*pow(k-1, n-1));
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,m,a[100010],ans=0;
	cin>>n>>m;
	REP(i,n){
		cin>>a[i];
	}
	REP(i,n){
		ans+=min(abs(a[i])*2,abs(a[i]-m)*2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256