akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int M = in.nextInt();
            int K = in.nextInt();
            int A[] = CPUtils.readIntArray(N, in);
            int B[] = CPUtils.readIntArray(M, in);
            long[] prefix_sum_A = getPrefixSum(A);
            long[] prefix_sum_B = getPrefixSum(B);

            long max = 0;
            max = getMax(K, A, prefix_sum_A, prefix_sum_B, max);
            max = getMax(K, B, prefix_sum_B, prefix_sum_A, max);

            max = getMax(M, K, prefix_sum_B, max);
            max = getMax(N, K, prefix_sum_A, max);

            out.println(max);
        }

        private long getMax(int m, int k, long[] prefix_sum_B, long max)
        {
            if (k >= prefix_sum_B[m - 1])
            {
                max = Math.max(max, m);
            }
            return max;
        }

        private long getMax(int k, int[] a, long[] prefix_sum_A, long[] prefix_sum_B, long max)
        {
            for (int i = 0; i < a.length; i++)
            {
                if (prefix_sum_A[i] <= k)
                {
                    int books = i + 1;
                    int low = lowerBound(prefix_sum_B, k - prefix_sum_A[i] + 1);
                    if (low - 1 >= 0)
                        books += low;
                    max = Math.max(max, books);
                }
            }
            return max;
        }

        private long[] getPrefixSum(int A[])
        {
            long[] prefix_sum = new long[A.length];
            prefix_sum[0] = A[0];
            for (int i = 1; i < A.length; i++)
            {
                prefix_sum[i] = prefix_sum[i - 1] + A[i];
            }
            return prefix_sum;
        }

        public static int lowerBound(long[] array, long value)
        {
            int low = 0;
            int high = array.length;
            while (low < high)
            {
                int mid = (low + high) / 2;
                if (value <= array[mid])
                {
                    high = mid;
                } else
                {
                    low = mid + 1;
                }
            }
            return low;
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



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

namespace AtCoder_Project_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int k = int.Parse(Console.ReadLine());

            for (int i = 0; i < k; i++)
            {
                int max_index = 0, max = ab[0];

                for (int j = 0; j < ab.Length; j++)
                {
                    if (max < ab[j])
                    {
                        max = ab[j];
                        max_index = j;
                    }
                }
                ab[max_index] *= 2;
            }
            Console.WriteLine(ab.Sum());
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef vector<DT> vec;
typedef list<DT> li;

int main() {
	ifstream fin("Text.txt");
	int i, j , q;
	DT x1,x2,y1,y2,lx,ly;
	cin >> x1 >> y1 >> x2 >> y2;
	lx = x2 - x1;
	ly = y2 - y1;
	forn(i, ly) {
		cout << "U";
	}
	forn(i, lx+1) {
		cout << "R";
	}
	forn(i, ly + 1) {
		cout << "D";
	}
	forn(i, lx + 1) {
		cout << "L";
	}
	cout << "UL";
	forn(i, ly + 1) {
		cout << "U";
	}
	forn(i, lx + 1) {
		cout << "R";
	}
	forn(i, ly + 1) {
		cout << "D";
	}
	forn(i, lx) {
		cout << "L";
	}
	return 0;

}

Measured memory_bytes: 256
var
  n,m,i,j,sum:longint;
  a:array[0..200,0..200] of char;
  p:boolean;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      p:=true;
      if a[i,j]='#' then begin write('#');p:=false; end;
      if p then
      begin
        sum:=0;
        if a[i-1,j]='#' then sum:=sum+1;
        if a[i+1,j]='#' then sum:=sum+1;
        if a[i-1,j-1]='#' then sum:=sum+1;
        if a[i-1,j+1]='#' then sum:=sum+1;
        if a[i,j+1]='#' then sum:=sum+1;
        if a[i,j-1]='#' then sum:=sum+1;
        if a[i+1,j-1]='#' then sum:=sum+1;
        if a[i+1,j+1]='#' then sum:=sum+1;
        write(sum);
      end;
    end;
    writeln;
  end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

const double PI = acos(-1);
int32_t main(){
	boost;
	cout << setprecision(20) << fixed;
	double a, b, v;
	cin >> a >> b >> v;
	double l = 0, r = PI / 2 , ans = PI / 2;

	for(int i = 0; i < 500; i++) {
		double m = (l + r) / 2;
		double x = a * tan(m);
		double y = b - x;
		double tot ;
		if(a * tan(m) <= b)
       	tot = a * a * b - a * a * a * tan(m) / 2.0;
    	 else
      	tot = b * b / tan(m) * a / 2.0;	
		if(tot >= v) {
			ans = m;
			l = m;
		}
		else
			r = m;
	}
	ans = (ans * 180) / PI;
	cout << ans << endl;
}


Measured memory_bytes: 4288
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True


c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

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


Measured memory_bytes: 3064
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int n; cin >> n;
    vector<pair<int,int>> a(n), b(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    rep(i, n) cin >> b[i].first >> b[i].second;

    sort(b.begin(), b.end());
    int ans = 0;
    int y, pos;
    rep(i, n){
        y = -1;
        rep(j, n){
            if(b[i].first > a[j].first){
                if(a[j].second > y and b[i].second > a[j].second){
                    y = a[j].second;
                    pos = j;
                }
            }
        }
        if(y != -1){
            a[pos].first = 1000, a[pos].second = 1000;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	long long x, y;
	cin >> x >> y;
	long long ans;
	
    if(x <= y){//--x--y-->
        if(x * y < 0){//--x--0--y-->
            ans = abs(abs(y) - abs(x)) + 1;
        }else{//--x--y--0> || --0--x--y-->
            ans = min(abs(y - x), abs(abs(y) - abs(x)) + 1);
        }
    }else{//--y--x-->
        ans = abs(abs(x) - abs(y)) + 1;
        if(x * y > 0){//--y--x--0--> || --0--y--x-->
            ans = abs(abs(x) - abs(y)) + 2;
        }
    }
    cout << abs(ans) << endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let mut aa = i::i();
    let mut pri1:i64=100;
    let mut cou=0;
    loop {
        cou+=1;
        pri1=((pri1 as f64)*1.01).floor() as i64;
        if (pri1>=aa){
            println!("{}",cou );
            return;
        }
    }

}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;

int n, q;
vector<int> adj[200005];
int a[200005];

void dfs(int u, int p) {
    for (int i : adj[u]) {
        if (i^p) {
            a[i] += a[u];
            dfs(i, u);
        }
    }
}


int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        a[p] += x;
    }
    
    dfs(1, 0);
    
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
}

Measured memory_bytes: 23552
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
#include <random>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr long INF = 1L << 60;
constexpr int MOD = 1e9 + 7;

int n;
string a,b,c;

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

  cin >> n >> a >> b >> c;
  int ans = 0;
  for(int i = 0;i < n; ++i) {
    if(a[i]==b[i]&&b[i]==c[i]) continue;
    if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]) ++ans;
    else ans += 2;
  }
  cout << ans;
  return 0;
}

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

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

	sort(a, a + N, greater<int>());
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}
	}
	cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>

using namespace std;

int main(void){
	char str[5] = "\0";
	bool frag = false;
	scanf("%s", str);
	
	for (int i = 0; i < 4; i++){
		if (str[i] == 'A' && str[i + 1] == 'C')
			frag = true;
	}

	if (frag)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;

    ll ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans = (ans * i) % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 3664
a = list(map(int,input().split()))
a_1,a_2 = [],[]
a_1.append(a[0])
a_1.append(a[1])
a_2.append(a[2])
a_2.append(a[3])

#print(a_1,a_2)
max_a = -(10**30)
for i in a_1:
    for l in a_2:
        if(i*l > max_a):
            max_a = i*l

print(max_a)



Measured memory_bytes: 9180
#include <stdio.h>

void swa(int sakagutidaisuke[]) {
	int nakamurayuuichi = sakagutidaisuke[0];
	sakagutidaisuke[0] = sakagutidaisuke[1];
	sakagutidaisuke[1] = nakamurayuuichi;
}

int N;
int p[114514];

int main(void) {
	int i;
	int count = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	if (p[1] == 1) {
		swa(p + 1);
		count++;
	}
	for (i = 2; i < N; i++) {
		if (p[i] == i) {
			swa(p + i);
			count++;
		}
	}
	if (p[N] == N) {
		swa(p + N - 1);
		count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws Exception {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
        line = line.trim();
        //半角スペースを区切り文字として扱う
        String[] readLineArray = line.split("[\\s+]");
        //変数に配列を代入
        int a = Integer.parseInt(readLineArray[0]);
        int b = Integer.parseInt(readLineArray[1]);

        if(a>b){
            System.out.println("a > b");
        }
        else if(a<b){
            System.out.println("a < b");
        }
        else {
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 16960
#include<cstdio>
	#include<cstring>
	int main()
	{
		char a[100000];
		int b[100000];
		long long sum;
		int q;
		scanf("%d",&q);
		scanf("%s",a);
		scanf("%s",a);
		char w=a[0];
		int z=0,t=1;
		b[0]=1;
		for(int i=1;i<q;i++)
		{
			if(w==a[i])
			{
				t++;
			}
			else
			{
				b[z++]=t;
				t=1;
				w=a[i];
				
			}
			
		}
		if(w==a[q-1])
		b[z++]=t;
		
	//	for(int i=0;i<strlen(a);i++)
	//	printf("%d ",b[i]);
		
		for(int i=0;i<z;i++)
		{
			if(i==0)
				if(b[i]==1)
					sum=3;
				else
					sum=6;
			if(i>=1)
				if(b[i-1]==1&&b[i]==2)
					sum=sum*2%1000000007;
				else
					if(b[i-1]==2&&b[i]==2)
						sum=sum*3%1000000007;
					else
						if(b[i-1]==2&&b[i]==1)
							sum=sum*1%1000000007;
						else
							if(b[i-1]==1&&b[i]==1)
								sum=sum*2%1000000007;		
			
		}	
		printf("%lld\n",sum%1000000007);
		
		
		

	
		return 0;
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  ll a,b,n=0;cin>>a>>b;
  if(a%2==1){
    n^=a;
    a++;
  }
  if(b%2==0){
    n^=b;
    b--;
  }
  if((b-a+1)%4==2)n^=1;
  cout<<n<<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.range;
import std.string;
import std.math;

void main() {
	long n = readln.chomp.to!int;
	long[] as = readln.chomp.split(' ').map!(s => s.to!long).array;
	long[] dp = new long[n*2];
	dp[0] =  as[0];
	dp[1] = -as[0];
	for (size_t i = 1; i < n-1; ++i) {
		dp[i*2]   = max(dp[i*2-2] + as[i], dp[i*2-1] - as[i]);
		dp[i*2+1] = max(dp[i*2-2] - as[i], dp[i*2-1] + as[i]);
	}
	dp[n*2-1] = dp[n*2-3] - as[n-1];
	dp[n*2-2] = dp[n*2-4] + as[n-1];
	write(max(dp[2*n-1], dp[2*n-2]));
}


Measured memory_bytes: 7548
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    long N;
    cin >> N;
    string S[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> S[i];
    }

    long AC_count = 0;
    long WA_count = 0;
    long TLE_count = 0;
    long RE_count = 0;

    for (int i = 0; i < N; ++i)
    {
        if (S[i] == "AC")
        {
            AC_count++;
        }
        else if (S[i] == "WA")
        {
            WA_count++;
        }
        else if (S[i] == "TLE")
        {
            TLE_count++;
        }
        else
        {
            RE_count++;
        }
    }
    cout << "AC x " << AC_count << "\n";
    cout << "WA x " << WA_count << "\n";
    cout << "TLE x " << TLE_count << "\n";
    cout << "RE x " << RE_count << "\n";
}


Measured memory_bytes: 5464
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int W, H, w, h, x, y;
  
  scanf("%d%d%d%d%d%d", &W, &H, &w, &h, &x, &y);

  int l = max(x - w/2, -W/2);
  int r = min(x + w/2, W/2);
  int u = max(y - h/2, -H/2);
  int d = min(y + h/2, H/2);
  
  printf("%.10lf\n",((double)(u+d)/2)/((double)(l+r)/2));
  
  return 0;
}



Measured memory_bytes: 3232
antenna = [0] * 5

for i in range(5):
    antenna[i] = int(input())

k = int(input())
judge = 0
for i in range(5):
    for j in range(i + 1, 5):
        if abs(antenna[i] - antenna[j]) > k:
            judge = 1
            break

print(":(" if judge == 1 else "Yay!")

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

void quick(int a[],int left,int right);

int main(){
  int N,M;
  long ans=0;
  scanf("%d%d",&N,&M);
  int X[M],diff[M-1];
  for (int i = 0; i < M; i++)
  {
    scanf("%d",&X[i]);
  }

  quick(X,0,M-1);

  for (int i = 0; i < M-1; i++)
  {
    diff[i]=abs(X[i+1]-X[i]);
  }

  quick(diff,0,M-2);

  for (int i = 0; i < M-(N-1)-1; i++)
  {
    ans+=diff[i];
  }
  
  printf("%ld",ans);

  return 0;
}

void quick(int a[],int left,int right)
{
    int s,t,i,j;

    if (left<right){
        s=a[left];            
        i=left; j=right+1;      
        while (1){              
            while (a[++i]<s);
            while (a[--j]>s);
            if (i>=j) break;
            t=a[i]; a[i]=a[j]; a[j]=t;
        }
        a[left]=a[j]; a[j]=s;

        quick(a,left,j-1);
        quick(a,j+1,right);
    }
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,a,b,c,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	    for(int j=0;j<=b;j++)
	        for(int z=0;z<=c;z++){
	        	int k=i*500+j*100+z*50;
	        	if(k==x)
	        	   ans++;
	        	if(k>x)
	        	   break;
	        }
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $N, $C);
$list = [];
$start = [];
$end = [];
for($i=0;$i<$N;$i++){
    fscanf(STDIN, "%d%d%d", $s, $t, $c);

    if(isset($end[$c][$s])){
        $news = $list[$end[$c][$s]][0];
        unset($list[$end[$c][$s]]);
        unset($array_column[$end[$c][$s]]);
        $s = $news;
    }
    if(isset($start[$c][$t])){
        $newt = $list[$start[$c][$t]][1];
        unset($list[$start[$c][$t]]);
        unset($array_column[$start[$c][$t]]);
        $t=$newt;
    }
    $end[$c][$t] = $i;
    $start[$c][$s] = $i;

    $list[$i] = [$s, $t, $c];
    $array_column[$i] = $s;
}
//$array_column = array_column($list, 0);
array_multisort($array_column, SORT_ASC, $list);
$ans=0;
$anslist = [];
foreach($list as $value){
    $ok = 0;
    if(!isset($anslist[0]) || min($anslist) >= $value[0]){

        $anslist[$ans] = $value[1];
        $ans++;
    }else {
        for ($i = 0; $i < $ans; $i++) {
            if ($anslist[$i] < $value[0]) {
                $anslist[$i] = $value[1];
                $ok = 1;
                break;
            }
        }
    }
//    if(isset($anslist[0]) && $anslist[0] < $value[0]){
//        $anslist[0] = $value[1];
//    }else{
//        $anslist[$ans] = $value[1];
//        $ans++;
//    }
//    if($ok === 0){
//    }
//    sort($anslist);

}

echo $ans;

Measured memory_bytes: 71540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)
int ban[1020][1020];
int xy[1000020][2];
#define BAN_MAX (2000050)
#define KABE (-1)
#define IDOU (5)

int main() {
	int h,w;
	int ch,cw;
	int dh,dw;
	string S;
	int warp;
	int warp_old_s;
	int warp_new_s;
	int warp_old_e;
	int warp_new_e;
	int p;
	int x,y;
	int xk1[4]={1,0,-1,0};
	int yk1[4]={0,1,0,-1};
	int xk2[20]={2,2,2, 2, 2,1,1, 1, 1,0, 0,-1,-1,-1,-1,-2,-2,-2,-2,-2};
	int yk2[20]={2,1,0,-1,-2,2,1,-1,-2,2,-2, 2, 1,-1,-2, 2, 1, 0,-1,-2};

	cin >> h >> w;
	cin >> ch >> cw;
	cin >> dh >> dw;

	rep(i, h+IDOU+IDOU)rep(j, w+IDOU+IDOU){
		ban[i][j]=KABE;
	}

	rep(i, h){
		cin >> S;
		rep(j, w){
			if (S.at(j)=='.') ban[i+IDOU+1][j+IDOU+1]=BAN_MAX;
		}
	}
	warp=0;
	warp_old_s=0;
	warp_new_s=0;
	warp_old_e=1;
	warp_new_e=1;
	ch+=IDOU;
	cw+=IDOU;
	dh+=IDOU;
	dw+=IDOU;
    ban[ch][cw]=warp;
    xy[warp_old_s][0]=ch;
    xy[warp_old_s][1]=cw;
	p=warp_new_e;

	while (1) {
		while (1) {
			rep2(i, warp_new_s, warp_new_e){
				rep(k, 4) {
					x=xy[i][0]+xk1[k];
					y=xy[i][1]+yk1[k];
					if(ban[x][y]>warp){
						ban[x][y]=warp;
						xy[p][0]=x;
						xy[p][1]=y;
						p++;
					}
				}
			}
			if(p==warp_new_e) break;
			warp_new_s=warp_new_e;
			warp_new_e=p;
		}
		warp++;
		warp_old_e=warp_new_e;
		p=warp_old_e;
		rep2(i, warp_old_s, warp_old_e){
			rep(k, 20) {
				x=xy[i][0]+xk2[k];
				y=xy[i][1]+yk2[k];
				if(ban[x][y]>warp){
					ban[x][y]=warp;
					xy[p][0]=x;
					xy[p][1]=y;
					p++;
				}
			}
		}
		if(p== warp_old_e) break;
		warp_old_s=warp_old_e;
		warp_old_e=p;
		warp_new_s=warp_old_s;
		warp_new_e=warp_old_e;
	}
	if(ban[dh][dw]==BAN_MAX){
		cout << -1 << endl;
		return 0;
	}
	cout << ban[dh][dw] << endl;
	return 0;
}


Measured memory_bytes: 11560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 1;
    rep(i, N) ans = lcm(ans, A[i]);
    output(ans);
    
    
    return 0;
}

Measured memory_bytes: 256
a,b,c,d,e=[int(input()) for i in range(5)]
a1=a%10
b1=b%10
c1=c%10
d1=d%10
e1=e%10
A=[a1,b1,c1,d1,e1]
for i in range(5):
  if 0 in A:
    A.remove(0)
if A==[]:
  cnt=(a//10 + b//10+c//10+d//10+e//10)*10
  A.append(0)
else:
  cnt=(a//10 + b//10+c//10+d//10+e//10)*10+10*(len(A)-1)
cnt1=cnt+min(A)
print(cnt1)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
int Stack[SIZE];
int Top = 0;

void push(int number){
  Stack[Top] = number;
  Top++;
}
int pop(void){
  Top--;
  return Stack[Top];
}

int main(){

  int num, cal1, cal2;
  int i = 0;
  char moji[SIZE];
  
  while(scanf("%s",moji) != EOF){
    if(moji[0]== '+'){
      //スタックからのデータ取り出し
      cal1 = pop();
      cal2 = pop();
      //データ挿入
      push(cal1+=cal2);
    }
    else if(moji[0] == '-'){
      cal1 = pop();
      cal2 = pop();
      push(cal2-=cal1);
    }
    else if(moji[0] == '*'){
      cal1 = pop();
      cal2 = pop();
      push(cal1*=cal2);
    }
    else{
      //数字に変換 スタックに格納(push)
      num = atoi(moji);
      push(num);
    }
  }
  printf("%d\n",pop());
  
  return 0;
}


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

using namespace std;

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

	string s;
	cin >> s;

	int n = s.size();

	vector<int> dp;
	dp.assign(n + 1, 0);

	vector<string> S = {"dream", "dreamer", "erase", "eraser"};
	
	dp[0] = 1;

	for(int i = 0; i < n; ++i) {
		for(auto& t : S) {
			int len = t.size();
			if(s.substr(i, len) == t) {
				dp[i + len] |= dp[i];
			}
		}
	}

	if(dp[n]) {
		cout << "YES" << '\n';
	} else {
		cout << "NO" << '\n';
	}
	return 0;
}


Measured memory_bytes: 848
import sys

N = int(sys.stdin.readline().rstrip())  # 節点数

parents = [None] * N

CHs = [[None, None] for _ in range(N)]
_Pre = []
_In = []
_Post = []

# ## DFS ## #


def dfs(u, r=-1):

    # u を訪れたときの処理
    _Pre.append(u)

    if CHs[u][0] != -1:
        dfs(CHs[u][0], u)
    
    _In.append(u)

    if CHs[u][1] != -1:
        dfs(CHs[u][1], u)

    _Post.append(u)

    # u を離れる前の処理


def main():
    for i in range(N):
        id, lf, rg = map(int, sys.stdin.readline().rstrip().split())
        CHs[id][0] = lf
        CHs[id][1] = rg

        if lf != -1:
            parents[lf] = id
        if rg != -1:
            parents[rg] = id

    # 根を見つける
    u = 0
    root = None
    while True:
        if parents[u] is None:
            root = u
            parents[u] = -1
            break
        u = parents[u]

    dfs(root, 0)
    print("Preorder")
    print("", *_Pre)
    print("Inorder")
    print("", *_In)
    print("Postorder")
    print("", *_Post)


main()



Measured memory_bytes: 5620
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int n = sc.nextInt();

        double[] v = new double[n];
        for(int i=0;i<n;i++){
            v[i] = sc.nextInt();
        }

        Arrays.sort(v);

        for(int i=0;i<n-1;i++){
            v[i+1]=(double) ((v[i]+v[i+1])/2);
        }

        System.out.println(v[n-1]);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<stdlib.h>

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

Node root;

Node treeMinimum(Node );
Node treeSearch(Node , int );
Node treeSuccessor(Node );
void insert(int );
void inorder(Node );
void preorder(Node );

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

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

    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}


Node treeMinimum(Node x){

  while(x->left != NIL)
    x = x->left;

  return x;
  
}

Node treeSearch(Node u, int k){
  //ノードの中身が空の場合、
  if(u == NIL || k == u->key)
    return u;
  
  if(k < u->key)
    return treeSearch(u->left, k);
  
  else
    return treeSearch(u->right, k);
  
}

Node treeSuccessor(Node x){
  
  Node y;

  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;

}

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

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

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;

    else
      x = x->right;
  }
  
  z->parent = y;

  if(y == NIL)
    root = z;

  else if(z->key < y->key)
    y->left = z;

  else
    y->right = z;
}

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

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

Measured memory_bytes: 19364
N = int(input())
S = list()
T = list()
for _ in range(N):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
X = input()
ans = 0
flag = False
for i in range(N):
    if flag:
        ans += T[i]
    if S[i] == X:
        flag = True
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

vector<p32> dir = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
bool check(int i, int j, int n, int m)
{
	return (i >= 0 && i < n && j >= 0 && j < m);
}
int getDir(int i, int j, int x, int y)
{
	if (y == j && i > x)
		return 0;
	if (i == x && y > j)
		return 1;
	if (y == j && i < x)
		return 2;
	if (i == x && y < j)
		return 3;
	return -1;
}

void solve(int tc)
{
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--;
	y1--;
	x2--;
	y2--;
	vector<string> arr(h);
	for (int i = 0; i < h; i++)
		cin >> arr[i];
	queue<p32> Q;
	vector<v32> dist(h, v32(w, 1e9));
	dist[x1][y1] = 0;
	Q.push({x1, y1});
	while (!Q.empty())
	{
		auto p = Q.front();
		Q.pop();
		int x = p.fi, y = p.se;
		for (auto itr : dir)
		{
			for (int j = 1; j < k + 1; j++)
			{
				int nx = x + itr.fi * j;
				int ny = y + itr.se * j;
				if (!check(nx, ny, h, w))
					continue;
				if (arr[nx][ny] == '@')
					break;
				if (dist[nx][ny] <= dist[x][y])
					break;
				if (dist[nx][ny] == 1e9)
				{
					dist[nx][ny] = dist[x][y] + 1;
					Q.push({nx, ny});
				}
			}
		}
	}
	cout << (dist[x2][y2] == 1e9 ? -1 : dist[x2][y2]) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 12156
n = int(input())

c = []
s = []
f = []

for _ in range(n-1):
    ce,se,fe = map(int, input().split())
    c.append(ce)
    s.append(se)
    f.append(fe)

for i in range(n-1):
    min = 0
    for j in range(i,n-1):
        if min <= s[j]:
            min = s[j] + c[j]
        else:
            md = min % f[j]
            if md != 0: md = f[j] - md
            min += md + c[j]
    print(min)
print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9+7;
const int N = 1e5+10;
typedef long long ll;
int n;
ll fact[N];
ll a[N],b[N];
ll mod_pow(ll x, ll n){
    ll res = 1;
    for (; n > 0; n >>= 1) {
        if (n & 1) res = res * x % Mod;
        x = x * x % Mod;
    }
    return res;
}
void init() {
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i-1] * i % Mod;
}
ll get(ll x){
    return fact[n]*mod_pow(x, Mod - 2)%Mod;
}
void add(ll &a, ll b){
    a = (a + b) % Mod;
}
int main() {
    init();
    
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) add(b[0], get(i));
    for (int i = 1; i < n; i++) {
        add(b[i], b[i-1]);
        add(b[i], get(i+1));
        add(b[i], Mod-get(n-i+1));
    } 
    ll ans = 0;
    for (int i = 0; i < n; i++) add(ans, a[i] * b[i]);
    cout << ans << endl;
}

Measured memory_bytes: 2560
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
p=C.index(max(C))
for i in range(26):
  if C[i]!=0:
    k+=C[i]
for i in range(26):
    A[i]=int(C[i]/k*D)

for i in range(26):
  for j in range(A[i]):
    m=max([l if B[l]==0 and l<(D+1)//(A[i]+1)*j else 0 for l in range(D)])
    B[m]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=p+1

for i in range(D):
  print(B[i])


Measured memory_bytes: 9028
n = int(input())
high = list(map(int,input().split()))

a = []
count = 0

for x in range(n-1):
  if high[x]-high[x+1] >= 0 :
    count += 1
  else:
    a.append(count)
    count = 0
a.append(count)

print(max(a))
    

Measured memory_bytes: 20300
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
int main(){
  
  int a,b;
  cin >> a >> b;
  cout<<(a-1)*(b-1) << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[2][111]={};
	cin>>n;
	FOR(i,0,2){
		FOR(j,0,n){
			cin>>a[i][j];
		}
	}
	int ans=0,v=0;
	FOR(i,0,n){
		v=0;
		FORQ(j,0,i){
			v+=a[0][j];
		}
		FORQ(j,i,n-1){
			v+=a[1][j];
		}
		ans=max(ans,v);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
lst = 0
if l>=0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - l
elif l < 0 and l+n-1 >=0:
        for i in range(1,n+1):
            lst+=l+(i-1)
        a = lst
elif l+n-1 <0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - (l+n-1)
print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans=min(a, b)+min(c, d);
	cout << ans << endl;


  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
    int M;
    cin>>M;

    int ans=0;

    int sum=0;
    rep(i,M){
        int d,c;
        cin>>d>>c;
        sum+=d*c;
        ans+=c;
    }

    while(sum>=10){
        ans+=sum/10;
        sum=sum/10+(sum%10);
    }
    ans--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

string N;

int main() {
	rd(N);
	wr("ABC");
	wrln(N);
	return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    int i,j,k,l;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < m;++i){
        cin >> b.at(i);
    }
    bool flag = false;
    for(i = 0;i <= n-m;++i){
        for(j = 0;j <= n-m;++j){
            for(k = 0;k < m;++k){
                for(l = 0;l < m;++l){
                    if(a.at(i+k).at(j+l) != b.at(k).at(l)){
                        flag = true;
                        break;
                    }
                }
                if(flag){
                    flag = false;
                    break;
                }
            }
            if(k == m){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

    if(a>b)
        swap(a,b);

    b-(a+w)<0?cout<<0:cout<<b-(a+w);
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int h1, m1, h2, m2, k;
    std::cin >> h1 >> m1 >> h2 >> m2 >> k;
    std::cout << (h2 - h1) * 60 + m2 - m1 - k << std::endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#define int long long
using namespace std;
const int mod=1e9+7;
const int N=2e5+2;
int fact[N];
int binpow(int x,int y){
	int tich=1;
	while(y){
		if((y&1)){
			tich*=x;
			tich%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return tich;
}
int C(int x,int y){
	return ((fact[y]*binpow(fact[x],mod-2))%mod*binpow(fact[y-x],mod-2))%mod;
}
signed main(){
	int n,m,a,b,i,j,k;
	int ans=0;
	cin>>n>>m>>a>>b;
	fact[0]=1;
	for(i=1;i<=m+n;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	for(i=1;i<=n-a;i++){
		ans+=C(i-1,i+b-2)*C(n-i,m-b-1+n-i);
		ans%=mod;
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pq priority_queue<int> 
#define pqs priority_queue<int,vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)  // no of ones in setbit
#define zrobits(x) __builtin_ctzll(x)       //101000 here 3..no of 0 aftrer 1sr right one 
#define mod 1000000007
#define inf 1e18
#define prDouble(x)  cout<<fixed<<setprecision(10)<<x     // ans upto 5 decimal place 
#define mk(ar,n,type) type *arr=new type[n];
#define w(x) int x;cin>>x;while(x--)
int dp[3001][3001] ;  



int fn(int arr[], int i , int j )
{

	if(i==j)
	{
		return arr[i] ; 
	}
	if(i>j)
	{
		return 0 ; 
	}

	if(dp[i][j] !=-1 )
	{
		return dp[i][j] ; 
	}

	int a=min(arr[i]+fn(arr,i+1,j-1) , arr[i]+fn(arr,i+2,j) ) ; 
	int b=min(arr[j]+fn(arr,i+1,j-1), arr[j]+fn(arr,i,j-2) ) ; 

	return dp[i][j]= max(a, b) ; 

}


int32_t main()
{
	int n; 
	cin>>n; 
	int arr[n+1];
	int s=0 ; 
	for(int i=0 ; i<n; i++)
	{
		cin>>arr[i] ; 
		s=s+arr[i] ; 
	}
	memset(dp, -1, sizeof(dp)) ; 
	int x=fn(arr, 0, n-1);
	int y=(s-x) ; 
	cout<<(x-y) ; 

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=2500,INF=1e18;
ll N,M,pe;
typedef pair<ll,ll> P;
vector<P> G[MAX_N],rG[MAX_N];
ll dst[MAX_N],rdst[MAX_N];
vector<ll> negcyc,rnegcyc;
void bell(ll s,vector<P> *gra,ll *d,vector<ll> &ncyc){
	fill(d,d+N,INF);
	d[s]=0;
	REP(i,N){
		REP(v,N){
			if(d[v]==INF)continue;
			for(auto e:gra[v]){
				if(d[e.first]>d[v]+e.second){
					d[e.first]=d[v]+e.second;
					if(i==N-1)ncyc.push_back(v);
				}
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>pe;
	REP(i,M){
		ll a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		G[a].push_back(P(b,pe-c));
		rG[b].push_back(P(a,pe-c));
	}
	bell(0,G,dst,negcyc);
	bell(N-1,rG,rdst,rnegcyc);
	bool flg=false;
	for(auto v:negcyc){
		if(rdst[v]!=INF){
//			cout<<v<<endl;
			flg=true;
		}
	}
	if(flg){
		cout<<-1<<endl;
	}else{
		cout<<max(-dst[N-1],0ll)<<endl;
	}
}

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

int main()
{
    string s;
    cin >> s;
    int max = 0;
    for (int i=0; i<s.length(); i++) {
        if (s.at(i) == 'A') {
            for (int j=i+1; j<s.length(); j++) {
                if (s.at(j) == 'Z' && max < j-i+1) max = j-i+1;
            }
            break; 
        }
    }
    cout << max << endl;
}


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

int main() {
  int A,B,C,D,L,R;
    cin >> A >> B >> C >> D;
    L = A + B;
    R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  
  else if (L == R) {
    cout << "Balanced" << endl;
  } 
  
  else{
    cout << "Right" << endl;
  }
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll V[55];
bool U[55];

ll cmb(ll n, ll r) {
    ll ret = 1;
    memset(U, 0, sizeof(U));
    REP(i, r) {
        ret *= (n - i);
        REP(j, r) {
            if (U[j + 1])
                continue;
            if (ret % (j + 1) == 0) {
                U[j + 1] = true;
                ret /= (j + 1);
            }
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    REP(i, N) {
        cin >> V[i];
    }
    sort(V, V + N, greater<ll>());
    ll s = 0;
    REP(i, A) {
        s += V[i];
    }

    pll mx(s, A);
    FOR(i, B, A) {
        s += V[i];
        if (mx.first * (A + 1 + i) < s * mx.second)
            mx = pll(s, A + 1 + i);
    }

    cout << OF64 << (double) (mx.first) / (double) (mx.second) << endl;
    ll cnt = 0;
    ll num = 0;
    REP(i, N) {
        if (V[i] == V[mx.second - 1]) {
            cnt++;
            if (i < mx.second)
                num++;
        }
    }

    ll ans = 0;
    s = mx.first;
    FOR(i, B + 1, mx.second) {
        if (mx.first * i == s * mx.second) {
            ans += cmb(cnt, num);
        }
        num++;
        s += V[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l[500],count=0;
	cin>>n;
	for(int i=0;i<2*n;i++)cin>>l[i];
	sort(l,l+n*2);
	for(int i=0;i<n*2;i+=2){
		count+=min(l[i],l[i+1]);
	}
	cout<<count<<endl;
}


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

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

    if(n == 1) {
        cout << "1" << endl;
        return 0;
    }

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

    int ans = 1;
    bool inc = (a[1] > a[0]), equal = (a[1] == a[0]);
    for (auto i = 2; i < n; i++) {
        if(equal) {
            if(a[i] == a[i - 1]) continue;
            inc = (a[i] > a[i - 1]);
            equal = false;
        } else if(inc and a[i] < a[i - 1]){
            ans++;
            equal = true;
        } else if (not(inc) and a[i] > a[i - 1]) {
            ans++;
            equal = true;
        }
    }

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

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

using namespace std;
typedef long long ll;

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

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

  if (k < n) {
    int cur = 0;
    for (int i = 0; i < k; ++i) {
      cur = a[cur];
    }
    cout << cur + 1<< '\n';
    return 0;
  }

  vector<int> used(n, -1);
  used[0] = 0;
  int next = a[0];
  int start = -1;
  int cnt = 0;
  while (true) {
    cnt++;
    if (used[next] >= 0) {
      start = next;
      break;
    }
    used[next] = cnt;
    next = a[next];
  }
  k -= used[start];
  cnt -= used[start];

  ll r = k % cnt;
  next = start;
  while (r > 0) {
    next = a[next];
    r--;
  }
  cout << next + 1 << '\n';
  return 0;
}



Measured memory_bytes: 4844
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,l,a[100005];
int main(){
	cin >> n >> l;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n-1;i++)
		if(a[i]+a[i+1]>=l){
			cout << "Possible\n";
			for(int j=0;j<i;j++)
				cout << j+1 << endl;
			for(int j=n-1;j>i+1;j--)
				cout << j << endl;
			cout << i+1 << endl;
			return 0;
		}
	cout << "Impossible";
	return 0;
}

Measured memory_bytes: 1152