akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

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

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

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

int dp[100100];

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

	int N=in(),K=in();
	vector<int> h(N);
	REP(i,N) h[i] = in();
	for(auto& x:dp) x = 1e9;
	dp[0] = 0;

	for(int i=0;i<N;i++){
		for(int j=0;j<K;j++){
			if(i<N-j-1) chmin(dp[i+1+j],dp[i]+abs(h[i+1+j]-h[i]));
		}
	}
	
	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vecint vector<int>
#define vecll vector<ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int from, to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int dp1[2010][2010];
int dp2[2010][2010];
int dp3[2010][2010];
int dp4[2010][2010];


int main(void){
	int h, w; cin >> h >> w;
	vector<string> s(h);

	rep(i, h){
		cin >> s[i];
	}
	
	rep(i, h){
		int count = 0;
		rep(j, w){
			if(s[i][j] == '#') count = 0;
			else{
				if(j == 0) dp1[i][j] = max(dp1[i][j], ++count);
				else dp1[i][j] = max(dp1[i][j], ++count);
			}
		}
	}

	rep(i, h){
		int count = 0;
		for(int j=w-1; 0<=j; j--){
			if(s[i][j] == '#') count = 0;
			else{
				if(j == w-1) dp2[i][j] = max(dp2[i][j], ++count);
				else dp2[i][j] = max(dp2[i][j], (++count));
			}
		}
	}

	rep(j, w){
		int count = 0;
		rep(i, h){
			if(s[i][j] == '#') count = 0;
			else{
				if(i == 0) dp3[i][j] = max(dp3[i][j], ++count);
				else dp3[i][j] = max(dp3[i][j], (++count));
			}
		}
	}

	rep(j, w){
		int count = 0;
		for(int i=h-1; 0<=i; i--){
			if(s[i][j] == '#') count = 0;
			else{
				if(i == 0) dp4[i][j] = max(dp4[i][j], ++count);
				else dp4[i][j] = max(dp4[i][j], (++count));
			}
		}
	}

	int ans = 0;
	rep(i, h) rep(j, w){
		ans = max(ans, dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j]);
	}
	cout << ans-3 << endl;

	return 0;
}

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

bool solve(int i, int m, int n, int A[]) {
	if (m == 0) return true;
	if (i >= n) return false;
	if (solve(i+1, m, n, A)) return true;
	if (solve(i+1, m - A[i], n, A)) return true;
	return false;
}

int main() {
	int n; cin >> n;
	int A[n]; for (int i=0; i<n; i++) cin >> A[i];
	int q; cin >> q;
	int m;
	for (int i=0; i<q; i++) {
		cin >> m;
		if (solve(0, m, n, A)) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3088
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b;
	cin >> a >> b;
	if (a*b == 15) {
		cout << "*" << endl;
	}
	else if (a + b == 15) {
		cout << "+" << endl;
	}
	else cout << "x" << endl;
}

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vector<int> als(n + 1);
	for (int i = 1; i <= n; ++i)cin >> als[i];

	vector<int> ballNum(n + 1, 0);
	int cnt = 2, ballCnt = 0;
	vector<int> referNum(1, 1);
	for (int rep = n;;) {
		int turnPoint = n / cnt + 1;

		for (int i = rep; i >= turnPoint; --i) {
			int ballTotal = 0;
			for (auto r : referNum)ballTotal += ballNum[i * r];
			if (ballTotal % 2 != als[i]) {
				++ballNum[i];
				++ballCnt;
			}
		}

		referNum.push_back(cnt);
		if (rep == 1 && turnPoint == 1)break;
		rep = turnPoint - 1;
		++cnt;
	}
	
	cout << ballCnt << endl;
	bool toSpaceDraw = false;
	for (int i = 1; i <= n; ++i) {
		if (ballNum[i] == 1) {
			if (toSpaceDraw) cout << " ";
			cout << i;
			toSpaceDraw = true;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3316
#include <stdio.h>
int main(void)
{
	int a;
	int b;
	int max = -1000000;
	int low = 1000000;
	long int sum=0;
	int i;
	scanf("%d", &a);

	for (i = 0; i < a; i++) {

		scanf("%d", &b);

		if (b > max) {
			max = b;
		}

		if (b < low) {
			low = b;
		}

		sum += b;
	}

	printf("%d %d %ld\n", low, max, sum);
	return 0;
}


Measured memory_bytes: 2104
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{s:String};
    println!("{}", if s.contains("AC") {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
def count_prime(num)
  res = 0
  return res if num.odd?

  while num % 2 == 0
    res += 1
    num /= 2
  end

  res
end

n = gets.to_i
as = gets.split.map(&:to_i)

puts as.inject(0) { |r, a| r + count_prime(a) }


Measured memory_bytes: 2300
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();

        if(A<=B*2){
            System.out.println("0");
        }else{
            int C=A-B*2;
            System.out.println(C);
        }

        //END
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cassert>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

string s;
int K;

int main()
{
  cin >> s >> K;
  int N = s.length();           // |s|

  // sの長さKまでの部分文字列
  vector<string> vec;

  REP(j,1,K+1) {
    REP(i,0,N) {
      // cout << "i = " << i << ' ';
      // cout << "j = " << j << ' ';
      // cout << "N = " << N << endl;

      if (i + j > N) break;     // ??
      // 長さ j の部分文字列
      vec.push_back(s.substr(i,j));
      // cout << s.substr(i,j) << endl;
    }
  }

  sort(vec.begin(), vec.end());
  unique(vec.begin(), vec.end());

  assert(vec.size() >= K);
  cout << vec[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    int a;
    string s;
    cin>>a>>s;
    
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n,k;
    cin>>n>>k;
    int a[k+1]={0};
    int ans=0;
    for(int i=k;i>0;i--){
        a[i]=power(k/i,n);
        for(int j=2*i;j<=k;j+=i){
            a[i]-=a[j];
            a[i]+=mod;
            a[i]%=mod;
        }
        ans+=(a[i]*(i))%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4360
h,w,k=map(int,input().split())
c = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if (i>>x) & 1 and (j>>y) & 1 and c[x][y] == "#":
                    cnt+=1
        if cnt ==k:
            ans += 1
print(ans)

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



int main() {
  int l, r, d;
  cin >> l >> r >> d;
  
  int ans=0;
  for(int i=l; i<=r; i++){
    if(i%d==0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    vector<ll> a(n), f(n);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> f[i];

    sort(ALL(a));
    sort(ALL(f), greater<ll>());

    ll left = 0;
    ll right = a.back()*f.front();
    while(left < right){
        ll mid = left + (right - left) / 2;

        ll cnt = 0;
        rep(i, n){
            ll x = mid / f[i];

            cnt += max(0LL, a[i]-x);
        }

        if(cnt <= k)right = mid;
        else left = mid+1;
    }

    cout << right << endl;
}

Measured memory_bytes: 6428
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll start = a;
    if(a%x != 0) start = a + (x - a%x);
    ll ans = 0;
    if(b >= start) ans = 1 + (b-start)/x;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int k;
	cin >> k;
	
	string data;
	cin >> data;
	
	int l = 0;
	
	int i = 0;
	while(data[i] == '1') i++;
	
	queue<int> l_q;
	
	char last = '0';
	int max_length = 0;
	
	for(int i=0; i < n; i++) {
		if(last == '0' && data[i] == '1') {
			l_q.push(i);
		}
		
		if(last == '1' && data[i] == '0') {
			if(l_q.size() >= k) {
				l = l_q.front();
				l_q.pop();
			}
		}
		
		max_length = max(max_length, i - l + 1);
		last = data[i];
	}
	
	max_length = max(max_length, n-l);
	cout << max_length;
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int k, n;
	cin >> k >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	sort(a, a+n);
	int Max = 0;
	for(int i = 0; i < n-1; i++){
		Max=max(Max,a[i+1]-a[i]);
	}
	Max=max(Max,a[0]-a[n-1]+k);
	cout << k-Max << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main extends PrintWriter {
    Main()
    {
        super(System.out);
    }
    public static void main(String args[]) {
      Main o=new Main();
      o.main();
      o.flush();
      o.close();
    }
    void main()
    {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
            if(str.charAt(0)=='R' && str.charAt(1)=='R' && str.charAt(2)=='R')
            println(3);    
            else if((str.charAt(0)=='R' && str.charAt(1)=='R') || (str.charAt(1)=='R' && str.charAt(2)=='R'))
            println(2);
            else if(str.indexOf('R')>=0)
            println(1);
            else
            println(0);
        
        sc.close();
    }
}

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

using namespace std;

int main() {

	int n = 1000000;

	vector<int> a(200);
	vector<int> b(200);

	int nn, nnb;
	int ii = 1;
	int jj = 1;
	while (1) {
		a[ii] = ii * (ii + 1) * (ii + 2) / 6;
		if (a[ii] % 2 == 1) {
			b[jj] = a[ii];
			jj++;
		}
		if (a[ii] > n) {
			nn = ii;
			nnb = jj;
			break;
		}
		ii++;
	}

	//ｎを作る時の最小数
	vector<int> dp(1000010, 1000010);
	vector<int> dpb(1000010, 1000010);

	dp[0] = 0;
	dp[1] = 1;
	dpb[0] = 0;
	dpb[1] = 1;

	for (int j = 1; j <= nn; j++) {
		for (int i = a[j]; i <= n; i++) {
			dp[i] = min(dp[i], dp[i - a[j]] + 1);
		}
	}

	for (int j = 1; j <= nnb; j++) {
		for (int i = b[j]; i <= n; i++) {
			dpb[i] = min(dpb[i], dpb[i - b[j]] + 1);
		}
	}


	while (1) {

		cin >> n;
		if (n == 0) { return 0; }
		cout << dp[n] << " " << dpb[n] << endl;
	}

	return 0;
}


Measured memory_bytes: 10504
import sys

# sys.stdin = open('b1.in')


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


a, b, c = map(int, input().split())

d = gcd(a, b)
if c % d == 0:
    print('YES')
else:
    print('NO')


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

row, col = [0] * H, [0] * W
for h, w in hw:
    row[h - 1] += 1
    col[w - 1] += 1

rowmax, colmax = max(row), max(col)
cnt = row.count(rowmax) * col.count(colmax)
for h, w in hw:
    if row[h - 1] == rowmax and col[w - 1] == colmax:
        cnt -= 1
print(rowmax + colmax - (cnt == 0))


Measured memory_bytes: 68412
M,D=map(int,input().split())
N=0
if M<4 or D<21:
    print(0)
else: 
    for i in range(1,M+1,1):
        for j in range(1,D+1,1):
            if (j//10)*(j%10)== i and j//10>=2 and j%10>=2:
                N+=1

    print(N)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fr(i,n) for(ll i=0;i<n;i++)
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
using namespace std;
int main()
{
	int n,m;
	ll s=0;
	cin>>n>>m;
	int a[m];
	fr(i,m)
	cin>>a[i];
	fr(i,m)
	s+=a[i];
	if(s>n)
	cout<<"-1"<<endl;
	else
	cout<<(n-s)<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int a, b, x;

double solve(){
    if(x > a*a*b/2.0){
        return atan((2.0*(a*a*b-x))/(a*a*a));
    }else{
        return atan(a*b*b/(2.0*x));
    }
}

signed main(){
    cin >> a >> b >> x;
    printf("%.10f\n",solve()*180/M_PI);
}

Measured memory_bytes: 384
using System;
class Program
    {
    	static void Main(string[] args)
    	{
    		// 整数の入力
    		int a = int.Parse(Console.ReadLine());
    		// 数列の入力
            int[] arr = new int[a];
    		for (int i = 0; i < a; i++)
            {
                arr[i] = int.Parse(Console.ReadLine());
            }
    		//出力
            int[] ans = new int[a];
            //colorIndex[i]---最後にその色iを見た位置
            int[] colorIndex = new int[200001];
            for (int i = 0; i <= 200000; i++)
            {
                colorIndex[i] = -1;
            }

            ans[a - 1] = 1;
            colorIndex[arr[a - 1]] = a - 1;
            for (int i = a - 2; i >= 0; i--)
            {
                if (colorIndex[arr[i]] == -1)
                {
                    colorIndex[arr[i]] = i;
                    ans[i] = ans[i + 1];
                    //Console.Error.WriteLine("+0");
                }
                else if (colorIndex[arr[i]] == i + 1)
                {
                    colorIndex[arr[i]] = i;
                    ans[i] = ans[i + 1];
                    //Console.Error.WriteLine("+0");
                }
                else
                {
                    ans[i] = (ans[i + 1] + ans[colorIndex[arr[i]]]) % 1000000007;
                    colorIndex[arr[i]] = i;
                    //Console.Error.WriteLine("+ans[]");
                }
                //Console.Error.WriteLine(colorIndex[2] + " " + colorIndex[4] + " " + colorIndex[5]);
                //Console.Error.WriteLine(ans[0] + " " + ans[1] + " " + ans[2] + " " + ans[3] + " " + ans[4] + " " + ans[5]);
                
                
            }
            Console.WriteLine(ans[0] % 1000000007);
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 17372
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        x:usize,y:usize,a:usize,b:usize,c:usize,
       mut  p:[i64;a],
        mut q:[i64;b],
        mut r:[i64;c],
    }
    let mut all = vec![];
    for &p in p.iter() {
        all.push((p, 0));
    }
    for &q in q.iter() {
        all.push((q, 1));
    }
    for &r in r.iter() {
        all.push((r, 2));
    }
    all.sort();
    all.reverse();

    let mut xcount = 0;
    let mut ycount = 0;
    let mut zcount = 0;
    let mut ans = 0;
    for &(c, s) in all.iter() {
        if s == 2 {
            zcount += 1;
            ans += c;
        }
        if s == 0 && xcount < x {
            ans += c;
            xcount += 1;
        }
        if s == 1 && ycount < y {
            ans += c;
            ycount += 1;
        }
        if xcount + ycount + zcount == x + y {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 14196
import Data.List (foldl')

isSameSign :: Int -> Int -> Bool
isSameSign x y = x * y > 0

solve :: [Int] -> Int
solve = min <$> negativeFirst <*> positiveFirst

diff :: (Num a) => a -> a -> a
diff a b = abs $ a - b

generateFirst :: [Int] -> [Int] -> (Int, Int)
generateFirst = (foldl' fn (0, 0) .) . zip 
    where
        fn (acc, cost) (sign, x) = if (isSameSign (acc + x) sign)
                                   then (acc + x, cost)
                                   else (sign, cost + (diff (acc + x) sign))

negativeFirst :: [Int] -> Int
negativeFirst = snd . generateFirst (cycle [-1, 1])

positiveFirst :: [Int] -> Int
positiveFirst = snd . generateFirst (cycle [1, -1])

main :: IO ()
main = do
    _ <- readLn :: IO Int
    xs <- map read . words <$> getLine
    print $ solve xs

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

// 最小値を求める関数 (arrayは配列名,nはデータ数)
int min_d(int array[], int n){
	int min_data;
	min_data = array[0];
	for(int i = 1; i < n; i++){
		if(min_data > array[i]){
			min_data = array[i];
		}
	}
	return min_data;
}

// 最大値を求める関数 (arrayは配列名,nはデータ数)
int max_d(int array[], int n){
	int max_data;
	max_data = array[0];
	for(int i = 1; i < n; i++){
		if(max_data < array[i]){
			max_data = array[i];
		}
	}
	return max_data;
}

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

	int min_cost = 9999999;	//最小のコスト
	int cost = 0;		//計算中のコスト
	int min_data, max_data;		//最小の整数と最大の整数
	int det;
	int cost_over_flag;

	min_data = min_d(a, n);
	max_data = max_d(a, n);

	for (int i = min_data; i <= max_data; i++){
		cost = 0;
		cost_over_flag = 0;
		for (int j = 0; j < n ; j++){
			det = i - a[j];
			cost += det * det;
			if (cost > min_cost){
				cost_over_flag = 1;
				break;
			}
		}
		if (cost_over_flag == 0){
			min_cost = cost;
		}
	}

	printf("%d\n", min_cost);

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Map<String, Boolean> hash = new HashMap<String, Boolean>();
		
		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n; i++){
			String[] str = br.readLine().split(" ");
			
			if(str[0].equals("insert")){
				hash.put(str[1], true);
			} else if(str[0].equals("find")){
				if(hash.get(str[1]) == null){
					System.out.println("no");
				} else {
					System.out.println("yes");
				}
			}
		}
	}
}


Measured memory_bytes: 190016
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let c: String = input();
    let c: Vec<char> = c.chars().collect();
    println!("{}", (c[0] as u8 + 1) as char);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	if (s[1] == 'B') cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define int long long
using namespace std;
class event{
public:
  int wt,val;  
};
int32_t main(){
    int n,w;
    cin>>n>>w;
    event arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i].wt;
        cin>>arr[i].val;
    }
    int dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(int j=0;j<=w;j++){
        dp[1][j]=0;
    }
    dp[1][arr[1].wt]=arr[1].val;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=w;j++){
            dp[i][j]=dp[i-1][j];
            if(arr[i].wt<=j){
                dp[i][j]=max(dp[i][j],arr[i].val+dp[i-1][j-arr[i].wt]);
            }
        }
    }
    cout<<*max_element(dp[n],dp[n]+w+1)<<endl;
    //cout<<dp[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int cnt=0;
    int a, b, k; cin>>a>>b>>k;
    vector<int> ans;
    for(int i=1; i <= min(a, b); i++){
        if(a % i == 0 && b % i == 0){
            ans.push_back(i);
            cnt++;
        }
    }
    cout<<ans[cnt-k]<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    if(s[si][sj]=='#') continue;
    vector<vector<int>>dist(h,vector<int>(w,INF));
    dist[si][sj] = 0;
    queue<P> q;
    q.push(P(si,sj));
    while(!q.empty()){
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir,4){
        int ni = i+di[dir], nj = j+dj[dir];
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        if(dist[ni][nj]!=INF) continue;
        dist[ni][nj] = dist[i][j]+1;
        q.push(P(ni,nj));
      }
    }
    rep(i,h)rep(j,w){
      if(dist[i][j]==INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll L, R, d;

int main()
{
  std::cin >> L >> R >> d;

  std::cout << R/d-(L-1)/d << std::endl;

  return 0;
}

Measured memory_bytes: 3616
import re

tokens = list(input().split())
stack = []

for token in tokens:
   if  re.match('\d', token):
       stack.append(int(token))
   else:
        rval = stack.pop(-1)
        lval = stack.pop(-1)
        if token == '+':
            result = lval + rval
        elif token == '-':
            result = lval - rval
        elif token == '*':
            result = lval * rval
        stack.append(result)

print(stack.pop(-1))



Measured memory_bytes: 6540
#include <iostream>
using namespace std;
const int N=1e5+10;
int a[N],ord[N];
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ord[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<ord[i]<<" ";
	}
	return 0;
} 

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int ans1,ans2;
  ans1=n>=2?(n*(n-1))/2:0;
  ans2=m>=2?(m*(m-1))/2:0;
  cout<<ans1+ans2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MOD = 1e9 + 7;
const int MAXN = 1e5;

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

	int N;
	LL A[MAXN], B[MAXN];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	LL cnt = 0;
	for (int i = N-1; i >= 0;) {
//		if ((A[i]+cnt) == 0 || (A[i]+cnt)%B[i] > 0) {
		if ((A[i]+cnt)%B[i] > 0) {
			cnt += B[i] - ((A[i]+cnt)%B[i]);
		} else {
			i--;
		}
	}
	cout << cnt << endl;

	return 0;
}

	

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

int main() {
  int n, p;
  string s;
  cin >> n >> p >> s;
  long long int cnt = 0;
  
  if ((p == 2) || (p == 5)) {
    for (int i = 0; i < n; i++) {
      if((int)(s[i] - '0') % p == 0) {
        cnt += i+1; //左端の選び方
      }
    }
  }
  
  else {
    vector<int> u(n+1, 0), count_mod(p, 0);
	int pow10 = 1, md = 0;
	for (int i = n-1; i >= 0; i--) {
   	 count_mod[md]++;
 	 md = (md + (int)(s[i] - '0') * pow10) % p;
     pow10 = (pow10 * 10) % p;
     cnt += count_mod[md];
    }
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 1284
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll vis[N],dp[N],n;
ll f(ll x){
	if(x<=0)return 1;
	if(dp[x]!=-1)return dp[x];
	ll ans=0;
	if(x-1>=0&&vis[x-1]==0)ans+=f(x-1);
	if(x-2>=0&&vis[x-2]==0)ans+=f(x-2);
	ans%=hell;
	return dp[x]=ans;
}
int main()
{
	ios
	ll i,j,m;
	cin>>n>>m;
	ll a[m+1];
	for(i=0;i<m;i++){
		cin>>a[i];
		vis[a[i]]=1;
	}
	memset(dp,-1,sizeof dp);
	dp[0]=1;
	f(n);
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra()
{
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while (1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;

        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 3108
N=int(input())
A=[int(i)for i in input().split()]

def insertionSort(A,N):
    for i in range(N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        print(*A)

insertionSort(A,N)


Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  vector<int> a = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  x--; y--;
  cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int x;
  cin>>x;
  if(x==0){cout<<1<<endl;}
  else{cout<<0<<endl;}
}

Measured memory_bytes: 3628
//
// Created by tac on 2016/10/12.
//

#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>

double circle_area(double r) {
    return M_PI * r * r;
}

double circle_length(double r) {
    return 2.0 * M_PI * r;
}

int main() {
    double r;
    std::cin >> r;
    std::cout << std::fixed << std::setprecision(6) << circle_area(r) << " " << circle_length(r) << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3256
#include <iostream>
using namespace std;
int main(void){
#define MAX 10100
    int n, p[MAX]; //患者数、患者番号
    int d1[MAX], d2[MAX]; //1回目に歩いた距離、2回目に歩いた距離

    while(true){
        cin >> n;
        if(n == 0) break;

        for(int i = 0; i < n; i++){
            cin >> p[i] >> d1[i] >> d2[i];
        }

        int d_sum[MAX]; //１日に歩いた距離
        int d_max = 0, p_max; //１日に歩いた距離の最大値、歩いた距離が一番長い患者の患者番号
        
        for(int i = 0; i < n; i++){
            d_sum[i] = d1[i] + d2[i];
            if(d_sum[i] > d_max){
                d_max = d_sum[i];
                p_max = p[i];
            }
        }
        cout << p_max << " " << d_max << endl;
    }
}



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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int H,R;

int main() {
	cin>>H>>R;
	if(H>=0)cout<<1<<endl;
	if(H<0){
		if(abs(H)==R)cout<<0<<endl;
		else cout<<-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
#define SWAP(a,b) (a += b,b = a - b,a -= b)
int main (){
  int a,A[100]={},flag,count=0;
  scanf("%d",&a);
  for(int i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  flag=1;
  while(flag==1){
    flag=0;
    for(int i=a-1;i>0;i--){
      if(A[i-1]>A[i]){
	SWAP(A[i-1],A[i]);
	flag=1;
	count++;
      }
    }
  }
    for(int i=0;i<a-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d",A[a-1]);
    printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <queue>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
int main(){
	int a,b,t,n,p,s,m;
	for(;scanf("%d",&n),n;printf("%d\n",s*2-m)){
		vector<vpii> isl(n+1);
		for(;--n;){
			scanf("%d%d%d",&a,&b,&t);
			isl[a].push_back(pii(b,t));
			isl[b].push_back(pii(a,t));
		}
		queue<pii> q;
		q.push(pii(1,0));
		for(s=m=0;!q.empty();){
			pii p=q.front();
			q.pop();
			for(
				vpii::iterator it=isl[p.first].begin();
				it!=isl[p.first].end();
				++it
			){
				if(isl[it->first].size()>1){
					q.push(pii(it->first,it->second + p.second));
					m=max(m,it->second + p.second);
					s += it->second;
				}
			}
			isl[p.first].clear();
		}
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

struct Segment {
  int l, r;
};

class Solution {
 public:
  void solve() {
    int n;
    cin >> n;
    vector<Segment> s;
    for (int i = 0; i < n; ++i) {
      int x, l;
      cin >> x >> l;
      s.push_back({x - l, x + l});
    }

    sort(s.begin(), s.end(), [](Segment a, Segment b) {
      return a.l < b.l || (a.l == b.l && a.r < b.r);
    });

    int ans = 0, l = s[0].l, r = s[0].r;
    for (int i = 1; i < n; ++i) {
      if (s[i].l >= r) {
        ans++;
        l = s[i].l;
        r = s[i].r;
      } else if (s[i].r <= r) {
        l = s[i].l;
        r = s[i].r;
      }
    }
    ans++;
    cout << ans;
  }
};

int main() {
  Solution solution = Solution();
  solution.solve();
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int main(){
    int n,k;scn(n),scn(k);
    int h[n+1],dp[n+1];
    for(int i=1;i<=n;i++) scn(h[i]);
    dp[n]=0;
    dp[n-1]=abs(h[n-1]-h[n]);
    for(int i=n-2;i>0;i--){
        dp[i]=1e9;
        for(int j=i+1;j<=i+k&&j<=n;j++)
        dp[i]=min(dp[j]+abs(h[j]-h[i]),dp[i]);
    }
    printf("%d\n",dp[1]);
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e6+11;

void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        ll h1,m1,h2,m2;
        cin>>h1>>m1>>h2>>m2>>n;
        
        ll ans=(h2-h1)*60+m2-m1;
        ans-=n;
        cout<<ans<<endl;
        
                
        
}
int main(){
        FS;
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

int main()
{
	int N;
	cin >> N;
	int count = 0;
	for (int n = 0; n < N; n++)
	{
		int next;
		cin >> next;
		while (next % 2 == 0)
		{
			count += 1;
			next /= 2;
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 3608
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def sqrt_case_manager(N):
    # x ∈ [1, N] に対して、N//x の取りうる値と、その値を取るときの x の範囲（半開区間）を列挙
    # O(sqrt(N))
    l = 1
    while l <= N:
        r = N//(N//l) + 1
        yield N//l, l, r
        l = r

def solve(N, K, cases):
    # dp[k][n] := k 個目まで見て、k 個目に n を置く場合の数
    #           = sum( dp[k-1][N/n以下] )
    # dp[k][l,r] := k 個目まで見て、k 個目に [l, r) を置く場合の数
    #              ただし n' ∈ [l, r) について N/n' は同じ値を取る
    #             = sum( dp[k-1][N/l以下] )
    mod = 10**9+7
    dp = np.zeros((K+1, len(cases)), dtype=np.int64)
    dp[0, 0] = 1
    for k in range(1, K+1):
        cum = 0
        for n in range(len(cases)):
            cum = (cum + dp[k-1, n]) % mod
            _, l, r = cases[-n-1]
            dp[k, -n-1] = cum * (r-l) % mod
    print(dp[-1].sum() % mod)


numba_compile([
    [solve, "(i8,i8,i8[:,:])"],
])


def main():
    N, K = map(int, input().split())
    cases = np.array(list(sqrt_case_manager(N)), dtype=np.int64)
    solve(N, K, cases)

main()


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

int main(){
    ll i,j,n,q,l,r,ans;
    string s;
    cin >> n >> q;
    cin >> s;
    //n = s.length();
    ll hoge[n];
    hoge[0] = 0;
    for(i = 1; i < n; i++){
        if(s[i] == 'C' && s[i-1] == 'A'){
            hoge[i] = hoge[i-1] + 1;
        }
        else{
            hoge[i] = hoge[i-1];
        }
    } 

    for(i = 0;i < q; i++){
        cin >> l >> r;
    ans = hoge[r-1] - hoge[l-1];
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(){
    int n, x; 
    while(std::cin >> n >> x){
      	if(0 == n && 0 == x){
          return 0;
        }
      
        int count = 0;
        for(int i = 1; i <= n; ++i){
            for(int j = i + 1; j <= n; ++j){
                for(int k = j + 1; k <= n; ++k){
                    if(x == i + j + k){
                        ++count;
                    }
                }
            }
        }

        std::cout << count << std::endl;
    }
  
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void){

int N, M, a, b, i;

cin >> N >> M;

int c[N];

for(i = 0; i < N + 1; i++){
    c[i] = 0;
}

for(i = 0; i < M; i++){
    
    cin >> a >> b;
    
    c[a] = c[a] + 1;
    
    c[b] = c[b] + 1;
    
}

for(i = 1; i <= N; i++){
    cout << c[i] << endl;
}
    
}


Measured memory_bytes: 3204
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int64_t gcd(int64_t a, int64_t b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
int64_t lcm(vector<int64_t> A)
{
    int64_t ans = A[0];
    for (int i = 1; i < A.size(); i++)
    {
        ans = ans / gcd(ans, A[i]) * A[i];
    }
    return ans;
}

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

    vector<int64_t> A(N);
    rep(i, N) cin >> A[i];
    cout << lcm(A) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, pair<int, int> > PP;
const int MAX=1e5+10;
const ll MOD=1e9+7;

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_inv(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

int main(){
	int N;
	cin >> N;
	ll A[MAX];
	rep1(i,N) cin>>A[i];
	ll ism[MAX];
	ism[0] = 0;
	rep1(i,N){
		ism[i] = ism[i-1] + mod_inv(i , MOD);
	}
	ll ans = 0;
	rep1(i,N){
		ll tmp = (ism[i] + ism[N+1-i] - 1 + MOD) % MOD;
		tmp = (tmp * A[i]) % MOD;
		ans = (ans + tmp) % MOD;
	}
  	rep1(i,N) ans = (ans * i) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int n;cin>>n;
  cout<<((n%2==0) ? (n*n/4):(n/2)*(n/2+1))<<endl;
  return 0;
}


Measured memory_bytes: 256