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

const double PI = 3.14159265358979323846L;

void solve(){
  int r; cin >> r;
  cout << (2.0L*PI*r) << endl;
}

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


Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#define pi 3.1415926535
#define rep(i,n)  for(int i = 0; i < n;i++);
using namespace std;
vector<int> v;
int main() {
	int a, b; double c;
	cin >> a >> b >> c;
	double d = pow(a * a + b * b - 2 * a * b * cos((c * pi) / 180), 0.5);
	double e = a * b * sin((c * pi) / 180) * 0.5;
	cout << fixed << setprecision(10) << e << " "  << d + a + b  << " " << 2 * e / a<< endl;
}


Measured memory_bytes: 3544
#include <iostream>
#include <cstring>

using namespace std;

int main(){

  int n;

  cin >> n;

  string card,card2;
  int a=0,b=0;

  for(int i=0;i<n;i++){
    cin >> card >> card2;
    if(card.compare(card2)>0){
      a+=3;
      //      cout << a << ' ' <<  b << endl;
    }
    else  if(card.compare(card2)<0){
      b+=3;
      // cout << a << ' ' <<  b << endl;
    }
    else  if(card.compare(card2)==0){
      
      a++;
      b++;
      // cout << a << ' ' <<  b << endl;
    }
  }

  cout << a << ' ' <<  b << endl;
}

Measured memory_bytes: 1204
#include"bits/stdc++.h"
#define REP(i,n)  for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n) for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n) for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)for(ll i=(n);i>0;--i)
#define ALL(obj)  (obj).begin(),(obj).end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline vector<vector<T>>vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

vector<vector<ll>>neighbor;
vector<ll>ans;
void cnt(ll node,ll parent,ll par_val)
{
    ans[node]+=par_val;
    for(auto c:neighbor[node]){
        if(c!=parent){
            cnt(c,node,ans[node]);
        }
    }
}
int main()
{
    ll n=in(),q=in();

    neighbor.resize(n);
    REP(i,n-1){
        ll a=in()-1,b=in()-1;
        neighbor[a].push_back(b);
        neighbor[b].push_back(a);
    }

    ans.resize(n,0);
    REP(i,q){
        ll p=in()-1,x=in();
        ans[p]+=x;
    }

    cnt(0,-1,0);
    REP(i,n){
        if(i!=0)cout<<' ';
        cout<<ans[i];
    }
    cout<<endl;
}

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

int main() {
    int N;
    bool verif = false;
    int dir = 0, esq = 0;
    string S;
    cin >> N;
    cin >> S;



    //Numero de parenteses abrindo
    for(int i=0; i<N; i++) {

        if(S[i] == ')') {


            if(!dir)
                esq++;
            else
                dir--;

        }else{


            for(int i=0; i<esq; i++)
                cout << '(';

            esq = 0;
            dir++;
        }
    }


    for(int i=0; i<esq; i++) {
        cout << '(';
    }



    cout << S;
    dir = esq = 0;
    verif = false;


    //Numero de parenteses fechando
    for(int i=N-1; i>=0; i--) {

        if(S[i] == '(') {

           

            if(!dir)
                esq++;
            else
                dir--;

        }else{


            for(int i=0; i<esq; i++)
                cout << ')';

            esq = 0;
            dir++;
        }
    }


    for(int i=0; i<esq; i++) {
        cout << ')';
    }

    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    a = int(input())
    ansdict= {}
    count = 1000
    mcount =1000 *(-1)

    for i in range(0,1000):
        c = i **5
        ansdict[i]=c
        ansdict[i*(-1)]=c*(-1)
    flag = 0

    for i in range(mcount+1,count):
        for j in range(mcount+1,count):
            ans = ansdict[j]-ansdict[i]
            if ans ==a:
                print(str(j) + " " +str(i))
                flag+=1
                break
        if flag == 1:
            break


Measured memory_bytes: 9400
fun main(args: Array<String>) {
    // Your code here!
    var n = readLine()!!.toInt()
    var juns = readLine()!!.split(" ").map{it.toInt()}
    var min = juns[0]
    var cnt = 0.until(n).count{ 
      i -> val pi = juns[i]
      if(pi <= min){
          min = pi
          true
      }else{
          false
      }
    }
    
    print(cnt)
}   

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

int main(void){
    std::string s;
    cin >> s;
    int n = s.size();
    int N=0,E=0,W=0,S=0;
    
    for(int i=0;i<n;i++){
        if     ("N" == s.substr(i,1)) N += 1;
        else if("E" == s.substr(i,1)) E += 1;
        else if("W" == s.substr(i,1)) W += 1;
        else if("S" == s.substr(i,1)) S += 1;
    }
    N > 0 && S == 0 ? cout << "No"  <<  endl :
    N == 0 && S > 0 ? cout << "No"  <<  endl :
    E > 0 && W == 0 ? cout << "No"  <<  endl :
    E == 0 && W > 0 ? cout << "No"  <<  endl :
                      cout << "Yes" <<  endl ;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

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

	cout << 1110 - n << endl;
	
}

Measured memory_bytes: 764
module Main where

import Control.Applicative
import Numeric
import Data.Char
import Data.List
import Data.Ord

main :: IO ()
main = do
  { cs <- getContents
  ; putStr $ unlines
           $ map showCharCount
           $ mergeCharCounts
           $ charCounts
           $ alphas cs
  }

alphas :: String -> String
alphas = map toLower . filter isAlpha

charCounts :: String -> [(Char, Int)]
charCounts = map count . group . sort

count :: String -> (Char, Int)
count s = (head s, length s)

initCharCounts :: [(Char, Int)]
initCharCounts = zip ['a' .. 'z'] (repeat 0)

mergeCharCounts :: [(Char, Int)] -> [(Char, Int)]
mergeCharCounts = merge initCharCounts

merge :: [(Char, Int)] -> [(Char, Int)] -> [(Char, Int)]
merge [] [] = []
merge xs [] = xs
merge (x:xs) (y:ys) = case (comparing fst) x y of
  LT -> x : merge xs (y:ys)
  EQ -> y : merge xs ys
  _  -> error "Henn!"

showCharCount :: (Char, Int) -> String
showCharCount (c, n) = [c] ++ " : " ++ show n 
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDoubles

showDoubles :: Double -> String
showDoubles d = showFFloat Nothing d ""



Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int n, len, car;
	string a, b, ans;
	cin >> n;
	for(int i = 0;i < n;++i){
		car = 0;
		ans = "";
		cin >> a >> b;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		len = max(a.length(), b.length());
		for(int i = 0;i < len;++i){
			int x, y, s;
			x = i < a.length() ? a[i] - '0' : 0;
			y = i < b.length() ? b[i] - '0' : 0;
			s = x + y + car;
			car = s / 10;
			ans += (s % 10 + '0');
		}
		if(car != 0) ans += (car + '0');
		if(ans.length() <= 80){
			reverse(ans.begin(), ans.end());
			cout << ans << endl;
		}
		else{
			cout << "overflow" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
S = input()
a = 0
b = 0
for i, s in enumerate(S):
  if i % 2:
    if s == "1":
      a += 1
    else:
      b += 1
  else:
    if s == "1":
      b += 1
    else:
      a += 1
print(min(a, b))

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

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

	string s;
	cin>>s;
	int cnt = 0;
	for(auto i : s){
		if( i == 'o' ){ cnt++; }
	}
	cout<<700 + cnt * 100 <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,t;
    while(1){
        cin>>a>>b;
        if(a==0){
            if(b==0){
                break;
            }
        }
        if(a>b){
            t=a;
            a=b;
            b=t;
        }
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <set>
using namespace std;

const int needleX[4] = {-1, 0, 1, 0};
const int needleY[4] = {0, -1, 0, 1};

pair<int, int> newPoint(pair<int, int>& nowPoint, int i, vector<vector<bool> >& depart, bool takayuki){
  pair<int, int> result;
  result.first = nowPoint.first + (needleX[i] * (takayuki ? 1 : -1));
  result.second = nowPoint.second + (needleY[i] * (takayuki ? 1 : -1));
  if(!depart[result.first][result.second]){ result = nowPoint; }
  return result;
}

int main(void){
  while(true){
    int w, h;
    cin >> w >> h;
    if(w == 0 && h == 0){ break; }
    pair<int, int> takayuki, kazuyuki;
    cin >> takayuki.second >> takayuki.first;
    cin >> kazuyuki.second >> kazuyuki.first;

    int input;
    vector<vector<bool> > depart(h + 2, vector<bool>(w + 2, false));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        cin >> input;
        if(input == 0){ depart[i][j] = true; }
      }
    }

    int ans = -1;
    set<pair<pair<int, int>, pair<int, int> > > used;
    queue<pair<int, pair<pair<int, int>, pair<int, int> > > > wait;
    used.insert(make_pair(takayuki, kazuyuki));
    wait.push(make_pair(0, make_pair(takayuki, kazuyuki)));
    while(!wait.empty()){
      int cost = wait.front().first;
      pair<int, int> t = wait.front().second.first;
      pair<int, int> k = wait.front().second.second;
      wait.pop();
      
      if(t == k){
        ans = cost;
        break;
      }

      for(int i = 0; i < 4; i++){
        pair<int, int> newt = newPoint(t, i, depart, true);
        pair<int, int> newk = newPoint(k, i, depart, false);
        if(used.count(make_pair(newt, newk)) == 0){
          used.insert(make_pair(newt, newk));
          wait.push(make_pair(cost + 1, make_pair(newt, newk)));
        }
      }
    }
    
    if(ans == -1){ cout << "NA" << endl; }
    else{ cout << ans << endl; }
  }
  
  return 0;
}

Measured memory_bytes: 13864
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
#define N (int)1e6+10
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
void fast() {

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

#ifdef ONLINE_JUDGE
	//	freopen("palindrome.in", "r", stdin);

	//freopen("palindrome.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("9000000.txt", "r", stdin);

	//freopen("ConsoleApplication1.zip", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int d;
	cin >> d;
	switch (d)
	{
	case 22:
		ex("Christmas Eve Eve Eve"); break;
	case 23:
		ex("Christmas Eve Eve"); break;
	case 24:
		ex("Christmas Eve"); break;
	case 25:
		ex("Christmas"); break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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


void solve(){
	int n;
	cin >> n;
	ll a[n];
	forn(i,0,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);
	long long int ans = 0;
	ans+=a[0];
	for(int i=0;i<((n-1)/2 - 1);i++){
		ans+=(2*a[i+1]);
		// cout << ans << endl;
	}
	if(n==2){
		cout << a[0] << endl;return;
	}
	
	if(n%2){
		ans+=a[(n-1)/2];
	}
	else{
		ans+=2*a[(n-1)/2];
	}
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() <= k) cout << s << endl;
	else cout << s.substr(0, k) << "..." << endl;
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

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


void solve(long long Q, long long H, long long S, long long D, long long N){
    vector<pair<LL, int>> memo;
    memo.PB(MP(Q*8, 1));
    memo.PB(MP(H*4, 2));
    memo.PB(MP(S*2, 3));
    memo.PB(MP(D, 4));

    sort(ALL(memo));

    LL ans = 0;
    int idx = 0;
    if(memo[0].second == 4) {
        ans += N / 2 * memo[0].first;
        N = N % 2;
        idx++;
    }

    ans += memo[idx].first / 2 * N;
    cout << ans << endl;
}

int main(){
    long long Q;
    scanf("%lld",&Q);
    long long H;
    scanf("%lld",&H);
    long long S;
    scanf("%lld",&S);
    long long D;
    scanf("%lld",&D);
    long long N;
    scanf("%lld",&N);
    solve(Q, H, S, D, N);
    return 0;
}


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

int main(){
  char c;
  cin >> c;
  ++c;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
xy=[]
for i in range(n):
    xt,yt=map(int, input().split())
    xy.append((xt,yt))

from itertools import permutations

perms=permutations(xy)
dis=[]
for p in perms:
    d_tmp=[]
    for i in range(1,len(p)):
        d=((p[i][0]-p[i-1][0])**2+(p[i][1]-p[i-1][1])**2)**0.5
        d_tmp.append(d)
    dis.append(sum(d_tmp))
        
print(sum(dis)/len(dis))

Measured memory_bytes: 4376
#include<stdio.h>
int main(){
int a,b,c,d;
while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0)
break;
for(c=0;c<a;c++){
for(d=0;d<b;d++){
	if(c==0||c==a-1||d==0||d==b-1)
printf("#");
else
printf(".");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <functional>

template<typename T>
struct segment_tree {
	long long N;				// the size of V
	long long M;				// the number of leaves
	std::vector<T> V;			// 1-indexed
	std::function<T(T, T)> OP;	// binary operation
	T ID;						// identity element of OP

	segment_tree(std::vector<T>& a, std::function<T(T, T)> f, T t) : OP(f), ID(t) {
		M = 1;
		while (M < a.size()) M *= 2;
		N = 2 * M;
		V.resize(N, ID);
		for (long long i = 0; i < a.size(); i++) V[M + i] = a[i];
		for (long long i = a.size(); i < M; i++) V[M + i] = ID;
		for (long long i = M - 1; i > 0; i--) {
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	segment_tree() {}
	void init(std::vector<T>& a, std::function<T(T, T)> f, T t) {
		OP = f; ID = t;
		M = 1;
		while (M < a.size()) M *= 2;
		N = 2 * M;
		V.resize(N, ID);
		for (long long i = 0; i < a.size(); i++) V[M + i] = a[i];
		for (long long i = a.size(); i < M; i++) V[M + i] = ID;
		for (long long i = M - 1; i > 0; i--) {
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	void point_update(long long i, T x) {
		i += M;
		V[i] = x;
		while (i / 2 < i) {
			i /= 2;
			V[i] = OP(V[2 * i], V[2 * i + 1]);
		}
	}

	T range_subfunc(
		long long cur_node, long long cur_left, long long cur_right,
		long long l, long long r
	) {
		if (cur_right <= l || r <= cur_left) return ID;
		if (l <= cur_left && cur_right <= r) return V[cur_node];
		long long mid = (cur_left + cur_right) / 2;
		return OP(
			range_subfunc(cur_node * 2, cur_left, mid, l, r),
			range_subfunc(cur_node * 2 + 1, mid, cur_right, l, r)
		);
	}

	T range_fold(long long l, long long r) {
		return range_subfunc(1, 0, M, l, r);
	}
};

int main() {
	long long n, q;
	std::cin >> n >> q;
	std::vector<long long> a(n, (1ll << 31) - 1);
	auto f = [] (long long i, long long j) {return std::min(i, j);};
	segment_tree<long long> sg(a, f, (1ll << 31) - 1);
	while (q--) {
		long long com, x, y;
		std::cin >> com >> x >> y;
		if (com == 0) sg.point_update(x, y);
		else std::cout << sg.range_fold(x, y + 1) << '\n';
	}
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl h1,m1,h2,m2,k;

void input_var(){
    cin >> h1 >> m1 >> h2 >> m2 >> k;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl time = 0;
    h1 = h1 * 60;
    h2 = h2 * 60;
    time = (h2 + m2) - (h1 + m1);
    time -= k;
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 3640
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

cnt = 0
X = []
for i in range(H):
    for j in range(W):
        if a[i][j] % 2:
            cnt += 1
            a[i][j] -= 1
            if j == W-1:
                if i == H-1:
                    cnt -= 1
                    break
                a[i+1][j] += 1
                X.append([i+1, j+1, i+2, j+1])
            else:
                a[i][j+1] += 1
                X.append([i+1, j+1, i+1, j+2])

print(cnt)    
for i in range(cnt):
    print(*X[i])

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int a, b;
  cin >> a >> b;
  if (a <= 5) cout << 0;
  else if (a <= 12) cout << b / 2;
  else cout << b;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3688
word = input()
tmp = []
num = 0
for looop in range(0,100000):
    tmp = input().split()
    if tmp[0] == 'END_OF_TEXT':
        break
    else:
        for x in range(len(tmp)):
            if word.lower() == tmp[x].lower():
                num += 1
print(num)


Measured memory_bytes: 7420
#include<stdio.h>
#include<stdlib.h>
int A[100001],n;

int Partition(int A[], int p, int r);


int main(){
  int i,m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    
  }
  m= Partition(A,0,n-1);

  for(i=0;i<m;i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[m]);
  
  for(i=m+1;i<n-1;i++){
    printf("%d ",A[i]);
  }
  
  printf("%d\n",A[n-1]);


  return 0;
}


int Partition(int A[], int p,int r){
  int x,i,j,temp,temp2;

  x = A[r];
  i = p-1;

  // printf("x = %d\n",x);

  for(j=p;j<=r-1;j++){
    if(A[j] <= x){
      
      i += 1;
      temp = A[i];
      A[i]=A[j];
      A[j]= temp;
    }
  }

  temp2 = A[i+1];
  A[i+1] = A[r]; 
  A[r]= temp2;  

  return i+1;
}

Measured memory_bytes: 988
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using pdd = pair<double, double>;

template <typename T, typename F = std::plus<T>>
class fenwick_tree {
public:
	using value_type = T;
private:
	std::vector<T> m_data;
	F m_func;
public:
	fenwick_tree()
		: m_data(1)
		, m_func()
	{ }
	explicit fenwick_tree(
		size_t n,
		const value_type& x = value_type(),
		const F& f = F())
		: m_data(n + 1)
		, m_func(f)
	{
		m_data[0] = value_type();
		for(size_t i = 1; i <= n; ++i){
			m_data[i] = x;
			for(size_t j = i; (j & 1) == 0u; j >>= 1){
				m_data[i] = m_func(m_data[j], m_data[i]);
			}
		}
	}
	size_t size() const {
		return m_data.size() - 1;
	}
	value_type query(size_t i) const {
		value_type s = m_data[i];
		for(i -= i & -i; i > 0; i -= i & -i){
			s = m_func(m_data[i], s);
		}
		return s;
	}
	void modify(size_t i, const value_type& x){
		const auto n = m_data.size();
		for(++i; i < n; i += i & -i){
			m_data[i] = m_func(m_data[i], x);
		}
	}
};

int count_inversion(const std::vector<double>& a){
	const int n = a.size();
	vector<double> b(a);
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	fenwick_tree<int> ft(b.size());
	int answer = 0;
	for(int i = 0; i < n; ++i){
		const int k = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		answer += i - ft.query(k);
		ft.modify(k, 1);
	}
	return answer;
}

double solve(
	const vector<double>& a,
	const vector<double>& b,
	const vector<double>& c)
{
	const int n = a.size();
	const int nc = n * (n - 1) / 2;
	double ly = -1e9, ry = 1e9;
	for(int iter = 0; iter < 100; ++iter){
		const double y = (ly + ry) * 0.5;
		vector<pdd> v(n);
		for(int i = 0; i < n; ++i){
			const double x = (c[i] - b[i] * y) / a[i];
			const double t = -b[i] / a[i];
			v[i] = pdd(x, t);
		}
		sort(v.begin(), v.end());
		vector<double> w(n);
		for(int i = 0; i < n; ++i){ w[i] = v[i].second; }
		const int inv = count_inversion(w);
		if(inv <= nc / 2){
			ry = y;
		}else{
			ly = y;
		}
	}
	return ly;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	int n;
	cin >> n;
	vector<double> a(n), b(n), c(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	const double y = solve(a, b, c);
	const double x = solve(b, a, c);
	cout << x << " " << y << endl;
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


struct pp{
    ll a,b,c,d;
};

void solve()
{ 
    ll a,b,n;
    cin>>a>>b>>n;
    ll i;
    // for(i=1;i<=n;i++)
    // {
    //     cout<<floor((a*i)/b)-a*floor(i/b)<<" ";
    // }
    // cout<<"\n";
    if(n<b)
    {
        cout<<floor((a*n)/b)-a*floor(n/b)<<"\n";
    }
    else
    {
          cout<<floor((a*(b-1))/b)-a*floor((b-1)/b)<<"\n";
    } 
   


  
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


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


return 0;
}

Measured memory_bytes: 3824
# coding: utf-8

if __name__ == '__main__':
    n = int(input())
    p = 1
    for i in range(n):  #range(10) は [0,1,2,3,4,5,6,7,8,9] を表す
        p *= (i+1)
        p %= int(1e9 + 7)
    print(p)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;

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

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

	int cnt = 1;

	int maxi = h[0];

	for (int i = 1; i < n; i++) {
		if (h[i] >= maxi) {
			cnt++;
			maxi = h[i];
		}
	}
	
	cout << cnt << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll a, b;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> a >> b;
	print(max(a-2*b, 0LL))
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ans = b
done = 0
for i in range(a, b+1):
    if i % 4 != 0:
        ans ^= i
    else:
        done = i
        break

for i in range(b-1, a, -1):
    if i % 4 != 3 and i >= done:
        ans ^= i
    else:
        break

print(ans)

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007ll
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main(){ cin.tie(0); ios::sync_with_stdio(0); solve(); }

ll power(ll a, ll n) {
  ll ret = 1;
  for (; n > 0; n >>= 1, a = a * a % MOD) {
    if (n % 2 == 1) ret = ret * a % MOD;
  }
  return ret;
}

ll comb(ll n, ll r) {
  ll x = 1, y = 1;
  rep(i, r) {
    x = x * (n - i) % MOD;
    y = y * (i + 1) % MOD;
  }
  return x * power(y, MOD - 2) % MOD;
}

void solve()
{
  ll n, a, b;
  in(n, a, b);
  ll ans = power(2, n) - 1;
  ans = (ans - comb(n, a) + MOD) % MOD;
  ans = (ans - comb(n, b) + MOD) % MOD;
  print(ans);
}


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

int n, m;
vector<vector<int>> switches;
vector<int> p;

bool all_lights_on(int bit) {
  for(int i = 0; i < m; ++i) {
    int count = 0;
    for(int s : switches[i]) {
      if (bit & (1<<s)) count++;
    }
    if (count%2 != p[i]) return false;
  }
  return true;
}

int main() {
  cin >> n >> m;
  switches.resize(m);
  p.resize(m);
  for(int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++) {
      int s;
      cin >> s;
      --s;
      switches[i].push_back(s);
    }
  }
  for(int i = 0; i < m; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for(int bit = 0; bit < (1<<n); ++bit) {
    if(all_lights_on(bit)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * The Number of Island
 */
public class Main {

	final static int SEA = 0;
	final static int LAND = 1;
	final static int VISITED = -1;

	final static int[] V = { 1, -1, 0, 0 };
	final static int[] H = { 0, 0, 1, -1 };

	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (true) {
			// load map
			int[][] map = new int[12][12];
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();
			for (int i = 0; i < 12; i++) {
				line = br.readLine();
				for (int j = 0; j < 12; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}

			// solve
			count = 0;
			for (int i = 0; i < 12; i++) {
				for (int j = 0; j < 12; j++) {
					if (map[i][j] == LAND) {
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							visit(map);
						}
						count++;
					}
				}
			}

			// output.
			System.out.println(count);

			// next
			line = br.readLine();
			if (line == null) {
				break;
			} else {
				continue;
			}
		}
		//
	}

	public static void visit(int[][] map) {

		int x, y;
		x = xs.remove();
		y = ys.remove();

		map[x][y] = VISITED;

		// next choices
		for (int i = 0; i < 4; i++) {
			int xv, yh;
			xv = x + V[i];
			yh = y + H[i];
			if (xv >= 0 && xv < 12 && yh >= 0 && yh < 12
					&& map[xv][yh] != VISITED && map[xv][yh] != SEA) {
				xs.add(xv);
				ys.add(yh);
			}
		}
	}
}

Measured memory_bytes: 37708
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
using namespace std;

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

void explode(int x, int y, vector<string> &ground);

bool isOver(int x, int y){
	return (x < 0 || x >= 8 || y < 0 || y >= 8);
}

void clear(int x, int y, vector<string> &ground){
	if(!isOver(x, y)){
		if(ground[y][x] == '1'){
			explode(x, y, ground);
		}
	}
}

void explode(int x, int y, vector<string> &ground){
	ground[y][x] = '0';
	for(int i = 0; i < 4; i++){
		for(int j = 1; j <= 3; j++){
			clear(x+dx[i]*j, y+dy[i]*j, ground);
		}
	}
}

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

	for(int k = 0; k < n; k++){
		vector<string> ground(8);
		getline(cin, ground[0]);
		int x, y;
		for(int i = 0; i < 8; i++){
			cin >> ground[i];
		}
		cin >> x >> y;
		x--;
		y--;
		explode(x, y, ground);

		cout << "Data " << k+1 << ':' << endl;
		for(int i = 0; i < 8; i++){
			cout << ground[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1212
N = int(input())
A = [int(i) for i in input().split()]
a = {}
for i in A:
	if i in a:
		a[i] += 1
	else:
		a[i] = 1
b = 0
for i in a.values():
	if i % 2 == 0:
		b += 1
if b % 2:
	print(len(a) - 1)
else:
	print(len(a))

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h1,h2,m1,m2,t;
	cin>>h1>>m1>>h2>>m2>>t;
	int val=0;
	val+=(h2-h1)*60;
	val+=m2-m1;
	cout<<val-t<<"\n";
	return 0;
}

Measured memory_bytes: 3652
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 300;
    InputStream in = System.in;
    PrintStream out = System.out;
    static int x[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        for (int i=0;i<N;i++) {
            for (int j=0;j<D;j++) {
                x[i][j] = sc.nextInt();
            }
        }
        int res=0;
        for (int i=0;i<N;i++) {
            for (int j=i+1;j<N;j++) {
                long sum=0;
                for (int d=0;d<D;d++) {
                    long p = x[i][d] - x[j][d];
                    sum += p*p;
                }
                double p = Math.sqrt(sum);
                if (p==(int)p) res++;
            }
        }
        out.println(res);
    }

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


Measured memory_bytes: 23764
n,a,b = map(int,input().split())
t = True
if a > b:
    t = False
if a != b and n == 1:
    t = False
if t:
    if n == 1 or n == 2:
        print(1)
    else:
        print((b*(n-1)+a)-(a*(n-1)+b)+1)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll A(N);
  ll max = 0;
  ll max2 = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
    if (i == 0) {
      max = a;
      continue;
    }

    if (max <= a) {
      max2 = max;
      max = a;
      continue;
    }
    if (max2 < a) {
      max2 = a;
    }
  }

  rep(i, N) {
    ll a = A[i];
    if (a == max) {
      COUT(max2);
    } else {
      COUT(max);
    }
  }
  return 0;
}

Measured memory_bytes: 3200
/*
Author:Jenil Mehta
Not yet serious but trying to be serious :)
Coding is lub
*/
 
#include <iostream>
#include <sstream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
ll dp[100000+2][3];
int main()
{
    ll n;
    cin>>n;
    
    ll a[n+1];
    ll b[n+1];
    ll c[n+1];
    ll i,j;
    ll ans=0;
    ll index=0;
    vector <ll> res;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    for(i=1;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][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][2],dp[n][1]))<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n ;
  cin >> n ;
  ll A[90] ;
  A[0] = 2 ;
  A[1] = 1 ;
  rep(i,n) A[i+2] = A[i+1] + A[i] ;
  cout << A[n] << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K, Q = map(int, input().split())
A = [int(input()) for _  in range(Q)]
ans = [0]*N
for i, value in enumerate(A):
    ans[value - 1] += 1

for element in ans:
    if K - (Q - element) > 0 :
        print('Yes')
    else:
        print('No')

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

int main() {
	int N;
    long long W;
	cin >> N >> W;
	long long w[N];
	int v[N];
	vector<int>v1, v2, v3, v4;
	cin >> w[0]>> v[0];
	v1.push_back(v[0]);
	for (int i=1; i<N; i++){
		cin >> w[i] >> v[i];
		if (w[i]==w[0]) v1.push_back(v[i]);
		else if (w[i]==w[0]+1) v2.push_back(v[i]);
		else if (w[i]==w[0]+2) v3.push_back(v[i]);
		else v4.push_back(v[i]);
	}
	sort(v1.begin(), v1.end()); reverse(v1.begin(), v1.end());
	sort(v2.begin(), v2.end()); reverse(v2.begin(), v2.end());
	sort(v3.begin(), v3.end()); reverse(v3.begin(), v3.end());
	sort(v4.begin(), v4.end()); reverse(v4.begin(), v4.end());
	//for (int i=0; i<v1.size(); i++) cout << v1[i] << " ";
	//for (int i=0; i<v2.size(); i++) cout << v2[i] << " ";
	//for (int i=0; i<v3.size(); i++) cout << v3[i] << " ";
	//for (int i=0; i<v4.size(); i++) cout << v4[i] << " ";
	long long z = 0;
	for (int i=0; i<=v1.size(); i++){
		for (int j=0; j<=v2.size(); j++){
			for (int k=0; k<=v3.size(); k++){
				for (int l=0; l<=v4.size(); l++){
					if (w[0]*i+(w[0]+1)*j+(w[0]+2)*k+(w[0]+3)*l<=W){
						long long sum = 0;
						for (int x=0; x<i; x++) sum+= v1[x];
						for (int x=0; x<j; x++) sum+= v2[x];
						for (int x=0; x<k; x++) sum+= v3[x];
						for (int x=0; x<l; x++) sum+= v4[x];
						z = max (z, sum);
					}
			
				}
			}
		}
	}
	cout << z << endl;
}


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

double x[3],y[3];

double distance(int a,int b){
	return sqrt(pow(x[a]-x[b],2.0)+pow(y[a]-y[b],2.0));
}

int main(){
	int n,i,j;
	double xp,yp,R,S,s,s2,r,a,b,c,d,e,f;
	double len[3];

	scanf("%d",&n);

	for(i = 0;i < n;i++){
		for(j = 0;j < 3;j++){
			scanf("%lf %lf",&x[j],&y[j]);
		}

		s = 0.0;
		for(j = 0;j < 3;j++){
			len[j] = distance((j+2)%3,(j+1)%3);
			s += len[j];
		}
		s /= 2.0;
		s2 = s;
		r = 1.0;
		for(j = 0;j < 3;j++){
			s2 *= (s-len[j]);
			r *= len[j];
		}
		S = sqrt(s2);
		R = r/(4.0*S);

		a = 2*(x[1] - x[0]);
		b = 2*(y[1] - y[0]);
		c = x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
		d = 2*(x[2] - x[0]);
		e = 2*(y[2] - y[0]);
		f = x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];

		xp = (b*f-e*c)/(a*e-d*b);
		yp = (c*d-f*a)/(a*e-d*b);

		printf("%.3f %.3f %.3f\n",xp,yp,R);
	}

	return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    // Least significant bit.
    ll lsb(ll x) { return x & (-x); }

    template <class T> const T inf() { return 0; }
    template <> const ll inf<ll>() { return 0x3f3f3f3f3f3f3f3fll; }
    template <> const int inf<int>() { return 0x3f3f3f3f; }

    template <class T> T gcd(T a, T b) { return abs(__gcd(a, b)); }
    template <class T> T clamp(T n, T l, T r) { return n < l ? l : n > r ? r : n; }
    template <class T> T lcm(T a, T b) { return abs(a / gcd(a, b) * b); }
    template <class T> T sgn(T n) { return n == 0 ? 0 : n > 0 ? 1 : -1; }

    // Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

    int n; cin >> n;
    cout << ((n / 2) + (n % 2)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string query(vector<pair<int,int> >& vpp)
{
    for(int i=0;i+2<vpp.size();i++)
    {
       // cout<<i<<endl;
        int flag=0;
        for(int j=0;j<3;j++)
            if(vpp[i+j].first!=vpp[i+j].second)
            {
                flag=1;
                break;
            }
        if(flag==0)
            return "Yes";
    }
    return "No";
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    vector<pair<int,int> >vpp;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        vpp.push_back(make_pair(a,b));
    }

    cout<<query(vpp)<<endl;
    return 0;
}

Measured memory_bytes: 3628
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, a + b - n) << '\n';
}


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

public class Cake
{
    public int w { get; set; }
    public int d { get; set; }
    public int s { get; set; }

    public Cake(int d, int w)
    {
        this.d = d;
        this.w = w;
        s = w * d;
    }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var cakes = new List<Cake>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var d = int.Parse(line[2]);
            if (n == 0 && w == 0 && d == 0) break;
            cakes.Add(new Cake(d, w));
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line2[0]);
                var s = int.Parse(line2[1]);
                cutCake(cakes, p, s);
            }
            var ret = cakes.OrderBy(x => x.s).Select(x => x.s).ToArray();
            for (int i = 0; i < ret.Length; i++)
                if (i == ret.Length - 1) Console.WriteLine(ret[i]);
                else Console.Write("{0} ", ret[i]);
        }
    }
    public static void cutCake(List<Cake> c, int p, int s)
    {
        var nw = c[p - 1].w;
        var nd = c[p - 1].d;
        while (true)
        {
            if (s < nw)
            {
                c.RemoveAt(p - 1);
                if (s < nw - s)
                {
                    c.Add(new Cake(nd, s));
                    c.Add(new Cake(nd, nw - s));
                }
                else
                {
                    c.Add(new Cake(nd, nw - s));
                    c.Add(new Cake(nd, s));
                }
                return;
            }
            else if (s - nw < nd)
            {
                c.RemoveAt(p - 1);
                if (s - nw < nd - s + nw)
                {
                    c.Add(new Cake(s - nw, nw));
                    c.Add(new Cake(nd - s + nw, nw));
                }
                else
                {
                    c.Add(new Cake(nd - s + nw, nw));
                    c.Add(new Cake(s - nw, nw));
                }
                return;
            }
            else s -= (nd + nw);
        }
    }
}

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

typedef long long ll;
const int N = 2e5;
int a[N+100],ind[N+100],vis[N+100];

int main()
{
	int n;
	ll k;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	int cur = 1;
	for(ll i=0;i<=k;i++){
		ind[i] = cur;
		if(i==k){
			printf("%d\n",cur);
			return 0;
		}
		if(vis[cur]){
			int sz = i-vis[cur];
			ll ext = k-vis[cur];
			//printf("%d %lld\n",sz,ext);
			printf("%d\n",ind[ext%sz+vis[cur]]);
			return 0;
		}
		vis[cur] = i;
		cur = a[cur];
	}
}


Measured memory_bytes: 5892