akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		@SuppressWarnings("unchecked")
		PriorityQueue<Integer>[] queue = new PriorityQueue[n];
		for(int i = 0; i < n; i++){
			//降順に設定
			queue[i] = new PriorityQueue<Integer>(new Comparator<Integer	>() {
				@Override
				public int compare(Integer a, Integer b) {
					return b - a;
				}
			});
		}

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");

			//insert
			if(tmpArray[0].equals("0")){
				int t = Integer.parseInt(tmpArray[1]);
				int x = Integer.parseInt(tmpArray[2]);

				queue[t].add(x);
			}
			//getMax
			else if(tmpArray[0].equals("1")){
				int t = Integer.parseInt(tmpArray[1]);

				if(!queue[t].isEmpty()){
					System.out.println(queue[t].peek());
				}
			}
			//deleteMax
			else {
				int t = Integer.parseInt(tmpArray[1]);

				if(!queue[t].isEmpty()){
					queue[t].poll();
				}
			}
		}

	}
}


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

int main(void) {
    int N;
    char a;
    bool four = false;
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> a;
        if(a == 'Y')four = true;
    }

    if(four) cout << "Four\n";
    else cout << "Three\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> tostr(ll n){
    vector<ll> num;
    while(n){
        num.push_back(n%10);
        n/=10;
    }
    return num;
}
double f(ll n, ll sum){
    return (double)n/(double)sum;
}
ll nextSnuke(vector<ll> num, ll n){
    ll sum=0;
    for(ll a=0;a<num.size();a++){
        sum+=num[a];
    }
    double mini=f(n,sum);
    ll sepuluh=1;
    ll ans=n;//printf("%d %d %lf\n",n,sum,mini);
    for(ll a=0;a<num.size();a++){
        n=n-num[a]*sepuluh+9*sepuluh;
        sum=sum-num[a]+9;
        double tmp=f(n,sum);//printf("%d %d %d %lf\n",num[a],n,sum,tmp);
        if(tmp<mini){
            mini=tmp;
            ans=n;
        }
        sepuluh*=10;
    }
    return ans;
}
int main(){
    ll k;
    scanf("%lld",&k);
    ll snuke=1;
    printf("%d\n",snuke);
    k--;
    while(k--){
        vector<ll> num = tostr(snuke+1);
        snuke = nextSnuke(num,snuke+1);
        printf("%lld\n",snuke);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll inv(ll x) {return power(x, MOD - 2);}
const int MAXN = 1e5 + 5;
//const bool is_in = container.find(element) != container.end();
int main()
{
	zapp;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	int cnt = 1;
	while(1) 
	{
		if(cnt & 1) 
		{
			c -= b;
			if(c <= 0) 
			{
				cout << "Yes";
				return 0;
			}
		}
		else 
		{
			a -= d;
			if(a <= 0) 
			{
				cout << "No";
				return 0;
			}
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int a, b, c, d, n, k, ans;
int ar[234567];
string s;
bool b1, b2;
bool f(int p) {
	int k1 = k;
	int n1 = n;
	while (p && n1) {
		k1 -= p;
		p = p / 2;
		n1--;
	}
	if (k1 < 0)return 0;
	return 1;
}
signed main() {
	cin >> n >> k;
	int p1 = 0, p2 = k + 1;
	while (p2 - p1 > 1) {
		int mid = (p1 + p2) / 2;
		if (f(mid))p1 = mid;
		else p2 = mid;
	}
	cout << p1 << endl;
}


Measured memory_bytes: 3168
#include <iostream>

using namespace std;

int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == t[i])
      continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int n,a[100009],dp[100009];
int main() {
    cin>>n;
    for(int i=1;i<=n;i++)
    {	cin>>a[i];
}
    dp[1]=a[1];
	dp[2]=abs(a[1]-a[2]);
	dp[3]=min(abs(a[3]-a[1]),abs(a[3]-a[2])+dp[2]);
	for(int i=4;i<=n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n];
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
    int a, b, c, n, i;

n = 0;

scanf("%d %d %d",&a, &b, &c);

for(i = a; i <= b; i++){
if(c % i == 0)
n++;
}
printf("%d\n", n);
   return 0;
}


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

char shift(char c, int n)
{
  int order = c - 'A';
  order = (order + n) % 26;
  return (char)(order + 'A');
}

int main()
{
  int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;
  for (int i=0; i<S.length(); i++) S[i] = shift(S[i], N);
  std::cout << S << std::endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
    }
    ll ans = ceil((double)(n-1) / (k - 1));
    cout << ans << endl;
}

Measured memory_bytes: 640
#![allow(non_snake_case)]

#[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" ) } ; }

fn main() {
    input! {
        n: usize, T: u64,
        ct: [(u64, u64);n]
    }

    let mut ctm = ct .into_iter()
        .filter(|&(_,t)| t <= T)
        .collect::<Vec<_>>();
    ctm.sort();
    if ctm.len() == 0 {
        println!("TLE");
    } else {
        println!("{}", ctm[0].0);
    }
}

Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
int s(int k){
	string s=to_string(k);
	int ans=0;
	for(int i=0;i!=s.size();++i)
		ans+=stoi(s.substr(i,1));
	return ans;
}
int main(){
	int n;
	cin>>n;
	if((n%s(n))==0)
		cout<<"Yes";
	else
		cout<<"No";
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a = 0;
	int c[1000];
	int e[1000];
	int aw[2] = { 0, 0 };
	for (int i = 0; i < 1000; i++)
	{
		e[i] = 0;
	}
	int d[1000];
	int b = 0;
	cin >> a;
	cin >> b;
	for (int i = 0; i < a; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < b; i++)
	{
		cin >> d[i];
	}
	for (int i = 0; i < b; i++)
	{
		for (int j = 0; j < a; j++)
		{
			if (d[i] >= c[j])
			{
				e[j]++;

				break;
			}
		}
	}
	for (int i = 0; i < a; i++)
	{
		if (e[i] > aw[0])
		{
			aw[0] = e[i];
			aw[1] = i + 1;
		}
	}
	cout << aw[1] << endl;
		return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s1, s2;
    cin >> s1 >> s2;
    if (s1.size() < s2.size())
        swap(s1, s2);
    if (s1.size() == s2.size())
        cout << "No\n";
    else if (s2.compare(s1.substr(0, s2.length())) == 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
  int r,d,x0;
  int prex;
  cin >> r >> d >> x0;
  prex=x0;
  for (int i=0; i < 10; i++){
    cout << prex*r-d << endl;
    prex=prex*r-d;
  }
    
  return 0;

}


Measured memory_bytes: 256
N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = i = j = 0

import bisect

for b in B:
    i = bisect.bisect_left(A,b)
    j = N - bisect.bisect_right(C,b)
    ans += i * j
print(ans)

Measured memory_bytes: 29300
N = int(input())
s = [int(i) for i in input().split()]
ans = 0
for i in range(1, N-2):
    p = 0
    a = N-1
    k = 0
    while True:
        k += 1
        a -= i
        b = a-i
        if b>0 and a!= N-1-a and a!=N-1-a-i:
            p += (s[a] + s[N-1-a])
            ans = max(ans, p)
        else:
            break
print(ans)

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

typedef long long ll;

ll N, M;
vector<ll> I;
ll R;

int main() {
  cin >> N >> M;
  I.resize(N + 1);
  for (ll i = 0; i < M; ++i) {
    ll l, r;
    cin >> l >> r;
    --l;
    --r;
    ++I[l];
    --I[r + 1];
  }
  for (ll i = 0; i < N; ++i) {
    if (I[i] == M) ++R;
    I[i + 1] += I[i];
  }
  assert(I[N] == 0);
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 1024
<?php
$inputs = explode(" ",trim(fgets(STDIN)));
$no = false;
$i = 0;
while($i < 2){
    $count = strlen($inputs[$i]);
    $text = substr($inputs[$i],$count-1,1);
    $text2 = substr($inputs[$i+1],0,1);
    if($text != $text2){
        echo "NO";
        $no = true;
        break;
    }
    ++$i;
}

if($no == false){
    echo "YES";
}

Measured memory_bytes: 3956
nums = []
5.times do |_i|
  nums << gets.chop.to_i
end

mod = nums.map{ |num| num % 10 }
mods = []
mod.each_with_index do |m, i|
    if m == 0
        mods[i] = 10
    else
        mods[i] = m
    end
end

min_i = mods.index(mods.min)

res = 0
nums.each_with_index do |n, i|
    if i == min_i
        res += n
    else
        res += n + (10 - mods[i])
    end
end

p res



Measured memory_bytes: 3836
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e8 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)1e6 + 7)
#define N ((int)1e5 + 7)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < pair < ll, pair < ll, ll > >,  null_type,  less < pair < ll, pair < ll, ll > > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

ll arr[N];

void ses()
{
    cout<<"NO\n";
    exit(0);
}

int main()
{
    fastio;
    int n;
    cin>>n;
    ll sum = 0;
    for(int i = 1 ; i<=n ; i++){
        cin>>arr[i];
        sum += arr[i];
    }
    ll con = 1ll*n*(n+1)/2;
    if(sum % con != 0) ses();
    int tot = sum/con;
    for(int i = 1 ; i<=n ; i++){
        arr[i] -= 1ll*i*tot;
    }
    ll cnt = 0;
    for(int i = 1 ; i < n ; i++){
        ll tmp = arr[i] - arr[i+1];
        if(tmp < 0 || tmp%n != 0) ses();
        cnt += tmp/n;
    }
    if(cnt<=tot) cout<<"YES\n";
    else ses();
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python

def main():
    N = int(input())

    memo = {}
    for _ in range(N):
        num = int(input())
        if not num in memo:
            memo[num] = 1
        else:
            memo[num] ^= 1

    result = 0
    for value in memo.values():
        result += value
    print(result)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 15076
from scipy.sparse.csgraph import dijkstra
INF = float('inf')
N,M = map(int,input().split())
g = [[INF]*N for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    g[a-1][b-1] = c
    g[b-1][a-1] = c
d = dijkstra(g)
ans = 0
for i in range(N):
    for j in range(N):
        if g[i][j] != INF and g[i][j] > d[i][j]:
            ans += 1
ans //= 2
print(ans)

Measured memory_bytes: 23412
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define all(c) (c).begin(),(c).end()
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  bool on(Point c){return abs(ccw(a,b,c))!=1;}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  vector<Point> intersectionPoints(Line l){
    Real a=l.b.y-l.a.y,b=l.a.x-l.b.x;
    Real c=-(a*l.a.x+b*l.a.y);

    Real L=l.a.dist(l.b);
    Point e=(l.b-l.a)/L;
    Point v(-e.y,e.x);
    Real k=-(a*p.x+b*p.y+c)/(a*v.x+b*v.y);

    if(r<k)vector<Point>();
    Point q=p+v*k;
    Real S=sqr(r*r-k*k);
    vector<Point>res;
    res.push_back(q+e*S);
    res.push_back(q-e*S);
    return res;
  }
  
};

int main(void){

  Circle c;
  cin >> c.p.x >> c.p.y >> c.r;
  int q;
  cin >> q;
  while(q--){
    Line l;
    cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
    vector<Point>res=c.intersectionPoints(l);
    sort(all(res));
    printf("%.8f %.8f ",res[0].x,res[0].y);
    printf("%.8f %.8f ",res[1].x,res[1].y);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define fl long double
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define np next_permutation
#define pi 3.141592653589793238
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define vll vector<ll>
#define vp vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define revpq priority_queue <int, vector<int>, greater<int>>
const ll mod=1000000007;
const ll INF=10000000000;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}

int main()
{
    fastio
    ll i,j,k,n,m;
    string s,t;
    cin>>s;
    cin>>t;
    ll ans=0;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r, n;
    cin >> l >> r;
    
    n = r - l;
    sum += n + 1;
    
  }
  
  cout << sum << endl;
  
}


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

// #define  part ..
#define listi vector<int > 
#define listll vector<long long >
#define pii pair<int ,int > 
#define pll pair<long long ,long long >
#define heap priority_queue<long long >

#define pb(a) push_back(a)
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick  	ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...









//write function from here ...









int Main(){

int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
int temp = d-b;
if(temp<0){
	c--;
	temp+=60;

}

temp =  max((c-a),0)*60+temp;

temp = temp-e;
cout<<temp;








return 0;



}
























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

    Main();
    
    
}


Measured memory_bytes: 3656
nums = "1234567890"
a, b = map(int, input().split())
s = input()
ok_flg = True
for i in range(a):
    if s[i] not in nums:
        ok_flg = False
        break
if s[a] != "-":
    ok_flg = False
for j in range(b):
    if s[a + 1 + j] not in nums:
        ok_flg = False
        break
if ok_flg == True:
    print("Yes")
else:
    print("No")


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  string s,b,a;

  cin>>s;
  s.erase(s.end()-2);


  //cout<<a<<" "<<b<<endl;
  while(s.size()!=0){
    a=s.substr(0,s.size()/2);
    b=s.substr(s.size()/2,s.size());
    //cout<<a<<" "<<b<<endl;
      if(a==b){cout<<a.size()*2<<endl;break;}
      s.erase(s.end()-1);
  }





return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define vi vector<ll>
#define all(_x) _x.begin(), _x.end()
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define lb(_x, _a) (lower_bound(all(_x), _a) - _x.begin())
#define ub(_x, _a) (upper_bound(all(_x), _a) - _x.begin())

int main()
{
  	// ll is int now
    ll k,n;
    cin>>k>>n;
    vi arr(n); for(auto &x : arr) cin>>x;

    ll res = LONG_MAX;
    ll a,b;
    rep(i,0,n)
    {
        if(i==0){
            a = k - arr[n-1] + arr[0];
            b = arr[1]-arr[0];
        }
        else if(i==n-1)
        {
            b = k - arr[n-1] + arr[0];
            a = arr[n-1] - arr[n-2];
        }
        else
        {
            a = arr[i] - arr[i-1];
            b = arr[i+1] - arr[i];
        }
        
        res = min(res, min(k-a, k-b));
    }
    cout<<res<<endl;
    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    ll x;
    cin>>x;

    bool rev=false;
    for(int i=0;i<x;i++) {
        int t;
        cin>>t;

        if(t==2) {
            if(rev) {
                reverse(s.begin(),s.end());
                rev=!rev;
            }
            int pos;
            cin>>pos;

            string y;
            cin>>y;
            if(pos==1) {
                s.insert(0,y);
            }
            else {
                s.append(y);
            }
        }
        else {
            rev=!rev;
        }
    }
    if(rev) {
        reverse(s.begin(),s.end());
    }
    cout<<s<<endl;
}




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

int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int dp[3][3][16];
int main() {
	int n;
	while (cin >> n, n) {
		char s, t, b; cin >> s >> t >> b;
		memset(dp, 0, sizeof(dp));
		dp[(s - 'A') / 3][(s - 'A') % 3][0] = 1;
		rep(k, n) {
			rep(i, 3) {
				rep(j, 3) {
					if (!dp[i][j][k])continue;
					rep(l, 4) {
						int nx = i + dx[l], ny = j + dy[l];
						if (nx < 0 || ny < 0 || nx >= 3 || ny >= 3 || 'A' + nx * 3 + ny == b)
							dp[i][j][k + 1] += dp[i][j][k];
						else dp[nx][ny][k + 1] += dp[i][j][k];
					}
				}
			}
		}
		int sum = 0;
		rep(i, 3)rep(j, 3)sum += dp[i][j][n];
		printf("%.7lf\n", (double)dp[(t - 'A') / 3][(t - 'A') % 3][n] / (double)sum);
	};
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const ll inf = 10000000010000000;
ll dp[410][410];
ll arr[410];
ll cumi[410];

ll go(ll i, ll j){
    if(i >= j)   return 0;
    ll &ret = dp[i][j];

    if(ret != -1)   return ret;
    ll ans = inf;
    for(int k = i; k < j; k++){
        ans = min(ans,go(i,k)+go(k+1,j));
    }
    return ret = ans + cumi[j]-cumi[i-1];
}
int main(){
    memset(dp,-1,sizeof dp);
    ll n;
    scanf("%llu",&n);

    for(ll i = 1; i <= n; i++)  scanf("%llu",arr+i);
    for(ll i = 1; i <= n; i++)  cumi[i] = cumi[i-1] + arr[i];
    ll ans = go(1,n);
    printf("%llu\n",ans);
}


Measured memory_bytes: 1536
#include <cmath>
#include <iostream>

using namespace std;

typedef unsigned int uint32;

namespace {
bool IsPrime(uint32 x) {
  if (x == 2) {
    return true;
  }
  if (x % 2 == 0) {
    return false;
  }

  const uint32 m = static_cast<uint32>(sqrt(x));
  for (size_t i = 3; i <= m; ++i) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
} // namespace

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

  uint32 c = 0;
  uint32 x;
  for (uint32 i = 0; i < n; ++i) {
    cin >> x;
    if (IsPrime(x)) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}

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


int main(){
	int A, B;
	cin >> A >> B;
	char S[A+B+1];
	cin >> S;
	for(int i=0; i<A; i++){
		if(S[i]=='-'){
			cout << "No";
			return 0;
		}
	}
	if(S[A]!='-'){
		cout << "No";
		return 0;
	}
	for(int i=A+1; i<A+B+1; i++){
		if(S[i]=='-'){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int a,b;
	double c;
	cin >> a >> b;
	if(1<=b&&b<=10){
		c=10*a+b;
		if(sqrt(c)==floor(sqrt(c))){
			cout <<"Yes";
		}
		else{
			cout <<"No";
		}
	}
	else if(10<=b&&b<=99){
		c=100*a+b;
		if(sqrt(c)==floor(sqrt(c))){
			cout <<"Yes";
		}
		else{
			cout <<"No";
		}
	}
	else{
		c=1000*a+b;
		if(sqrt(c)==floor(sqrt(c))){
			cout <<"Yes";
		}
		else{
			cout <<"No";
		}
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 
ll LLMAX = 9223372036854775807;
int main() {
    int n;
    cin >> n;
    vi a(n);
    for (auto& i : a)   cin >> i;
    vector<vi> cost(n, vi(n, 0)), size(n, vi(n, 0));
    for (int i = 0; i < n; ++i) {
        size[i][i] = a[i];
        for (int j = i + 1; j < n; ++j) {
            size[i][j] = size[i][j - 1] + a[j];
        }
    }
    for (int l = 2; l <= n; ++l) {
        for (int i = 0; i + l - 1 < n; ++i) {
            int j = i + l - 1;
            cost[i][j] = LLMAX;
            for (int k = i + 1; k <= j; ++k) {
                cost[i][j] = min(cost[i][j], 
                            cost[i][k - 1] + cost[k][j] + size[i][k - 1] + size[k][j]);
            }
        }
    }
    cout << cost[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int x, y;
	cin>>x>>y;
	int ans=0;
	if(x==3) ans+=100000;
	else if(x==2) ans+=200000;
	else if(x==1) ans+=300000;
	if(y==3) ans+=100000;
	else if(y==2) ans+=200000;
	else if(y==1) ans+=300000;
	if(x==1 && y==1) ans+=400000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
let m = 950527

let to_key s =
  let char_to_x c =
    if c = 'A' then 1
    else if c = 'C' then 2
    else if c = 'G' then 3
    else if c = 'T' then 4
    else 0 in
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(char_to_x s.[i])) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match Str.split (Str.regexp " ") (read_line ()) with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 20180
// Problem Link: https://atcoder.jp/contests/aising2020/tasks/aising2020_f
// Tutorial Link: https://img.atcoder.jp/aising2020/editorial.pdf

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL poww(LL a,LL n)
{
    if(n==0) return 1;
    LL val=poww(a,n/2);
    if(n%2==0) return (val*val)%mod;
    else return (((val*val)%mod)*a)%mod;
}

LL fact[30], inv[30];

LL c1(LL k) {
    return (((fact[11] * inv[11-k])%mod) * inv[k]) % mod;
}

LL c2(LL k) {
    LL ans = 1;
    for(int i = 1; i <= 15; i++) ans = (ans * (k+i)) % mod;
    return (ans*inv[15]) % mod;
}

LL n, t;

int main() {
    fact[0] = 1;
    inv[0] = 1;
	for(int i=1; i<=25; i++) {
        fact[i]=(fact[i-1]*i)%mod;
        inv[i] = poww(fact[i], mod-2);
    }
    cin >> t;
    while(t--) {
        cin >> n;
        if(n < 5) {
            cout << "0\n";
            continue;
        }
        LL ans = 0;
        for(int k = 0; k <= min(11LL, n-5); k++) {
            LL rem = n-k-5;
            if(rem % 2) continue;
            rem /= 2;
            ans = (ans + (c1(k) * c2(rem))%mod) % mod;
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll  long long int
#define mod 1000000007
using namespace std;
int main() {
    ll n;
    cin>>n;
    ll a[n];ll ct=2;ll p[2]={-1,-1};
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++){
        if(a[i]!=i+1){
            ct--;
            p[ct]=i;
        }
        if(ct==0)break;
    }
    if(p[0]!=-1)
    swap(a[p[0]],a[p[1]]);bool f=true;
    for(ll i=0;i<n-1;i++){
        if(a[i+1]-a[i]!=1)f=false;
    }
    if(!f)cout<<"NO"<<"\n";
 else
     cout<<"YES"<<"\n";
    }




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<string> s(n);
  rep(i,n) {
    string t; cin >> t;
    sort(t.begin(), t.end());
    s[i] = t;
  }
  sort(s.begin(), s.end());
  ll cnt = 1;
  rep(i,n-1) {
    if (s[i] == s[i+1]) cnt++;
    else {
      ans += (cnt*(cnt-1)/2);
      cnt = 1;
    } 
  }
  ans += cnt*(cnt-1)/2;
  cout << ans << endl;

  return 0;
}

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

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

  int k=1;
  int mx=a[0];
  for(auto i=1;i<n;i++){
       if(a[i]<=mx){k++;}
       mx=min(mx,a[i]);
  }
  cout<<k<<endl;
}


Measured memory_bytes: 1024
import math

n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

middle = math.ceil(max(a) / 2)
oldMiddle = 0
h = middle // 2
rightMin = max(a)

while h > 0:
    cut = 0
    if middle == 0:
        middle = 1
        break
    for i in range(n):
        cut += math.ceil(a[i] / middle) - 1
    h = math.ceil(abs(middle - oldMiddle) / 2)
    oldMiddle = middle
    if cut <= k:
        if (middle - h == rightMin):
            break
        middle -= h
    else:
        rightMin = middle
        middle += h

print(middle)

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll h, w;
    cin >> h >> w;
    vector<string> mat(h+1, string(w, '#'));
    REP(i, 0, h) {
        cin >> mat[i];
        mat[i].pb('#');
    }
    mat[h].pb('#');
    vvi dp(h+1, vi(w+1, 0));
    auto cp = dp;
    ll p;
    REP(i, 0, h+1) {
        p = -1;
        REP(j, 0, w+1) {
            if (mat[i][j] == '#') {
                dp[i][p+1] = j-p-1;
                dp[i][j] = p+1-j;
                p = j;
            }
        }
    }
    REP(i, 0, h+1)
        REP(j, 1, w+1)
            dp[i][j] += dp[i][j-1];
    REP(i, 0, w+1) {
        p = -1;
        REP(j, 0, h+1) {
            if (mat[j][i] == '#') {
                cp[p+1][i] = j-p-1;
                cp[j][i] = p+1-j;
                p = j;
            }
        }
    }
    REP(i, 0, w+1)
        REP(j, 1, h+1)
            cp[j][i] += cp[j-1][i];
    ll m = 0;
    REP(i, 0, h)
        REP(j, 0, w)
            m = max(dp[i][j] + cp[i][j] - 1, m);
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 70656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	vector<bool> b(n, false);
	b[0] = true;
	rep(i,n){
		cin >> a[i];
		--a[i];
	}
	int cur = 0, cnt = 0;
	while(true){
		if(cur == 1){
			cout << cnt << endl;
			return 0;
		}
		cur = a[cur];
		if(b[cur]){
			cout << -1 << endl;
			return 0;
		}
		b[cur] = true;
		++cnt;
	}
	return 0;
}

Measured memory_bytes: 3728
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

vector<int> ans;

void dfs(int v, int p, int now, vector<vector<int>> &G){
	ans[v] += now;
	for(auto nv : G[v]){
		if(nv == p) continue;
		dfs(nv, v, ans[v], G);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	vector<vector<int>> to(n);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n, 0);
	rep(i,q){
		int p, x;
		cin >> p >> x;
		ans[p-1] += x;
	}
	dfs(0, -1, 0, to);
	rep(i,n){
		cout << ans[i];
		if(i < n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100010];
ll finv[100010];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return 0;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(100005);
    while(t--){
        int s;
        cin>>s;
        ll dp[s+1]={0};
        for(int i=3;i<=s;i++){
            dp[i]++;
            dp[i]%=MOD;
            for(int j=i+3;j<=s;j++)
                dp[j]+=dp[i],dp[j]%=MOD;
        }
        cout<<dp[s];
    }
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

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

    int N;
    cin >> N;
    vector<int> A(1 << N);
    REP(i, A.size()) {
        cin >> A[i];
    }

    vector<int> dp(1 << N);
    vector<int> B(1 << N);
    B[0] = A[0];
    vector<vector<int>> C(1 << N, vector<int>(N, -1));
    FOR(i, 1, 1 << N) {
        B[i] = A[i];
        dp[i] = dp[i - 1];
        REP(j, N) {
            if (i & (1 << j)) {
                amax(B[i], B[i ^ (1 << j)]);
                C[i][j] = A[i];
                REP(k, N) {
                    if (k == j) continue;
                    if (i & (1 << k)) {
                        amax(C[i][j], C[i ^ (1 << k)][j]);
                    }
                }
                amax(dp[i], B[i ^ (1 << j)] + C[i][j]);
            }
        }
        cout << dp[i] << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 33116
#include <stdio.h>

typedef struct _node {
    int val;
    struct _node *left;
    struct _node *right;
    struct _node *parent;
} NODE;

NODE *root = NULL;

void insert(int val) {
    NODE *x = new NODE;
    x->val = val;
    x->left = NULL;
    x->right = NULL;
    x->parent = NULL;
    NODE *y = NULL; // parent
    NODE *z = root; // interator
    while (z != NULL) {
        y = z;
        if (x->val <= z->val) {
            z = z->left;
        } else {
            z = z->right;
        }
    }
    x->parent = y;
    if (y == NULL) {
        root = x;
    } else if (x->val <= y->val) {
        y->left = x;
    } else {
        y->right = x;
    }
}

NODE* find(int val) {
    NODE *p = root;
    while (p!=NULL&&p->val!=val){
        if (val<=p->val){
            p=p->left;
        }else{
            p=p->right;
        }
    }
    return p;
}

void preorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    printf(" %d", p->val);
    preorder(p->left);
    preorder(p->right);
}

void inorder(NODE *p) {
    if (p == NULL) {
        return;
    }
    inorder(p->left);
    printf(" %d", p->val);
    inorder(p->right);
}

int main() {
    int n, val;
    scanf("%d", &n);
    char cmd[100];
    for (int i = 0; i < n; i++) {
        scanf("%s %d", cmd, &val);
        if (cmd[0] == 'i') {
            insert(val);
        } else if (cmd[0]=='f'){
            if(find(val)==NULL){
                printf("no\n");
            }else{
                printf("yes\n");
            }
        } else {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 21428
def gcd(a,b):
    if(b==0):
        return a
    return gcd(b,a%b)
a,b=map(int,input().split())
maxi=max(a,b)
mini=min(a,b)
gg=gcd(mini,maxi)
maxii=maxi//gg
minii=mini//gg
print(maxii*mini)


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  unsigned long long x;
  cin >> x;
  int res = 0;
  unsigned long long cur = 100;
  while (cur < x) {
    cur = (unsigned long long) (cur * 1.01);
    res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, k, m;
  cin>>n>>k;
  vector<int> a;
  vector<int> b;
  REP(i, n-1){
    a.push_back(1);
    b.push_back(i+2);
  }
  int kk=(n-1)*(n-2)/2;
  m=n-1;
  if(kk<k){
    cout<<-1<<endl;
    return 0;
  }
  if(kk==k) goto loopend;
  for(int i=2; i<n; ++i){
    for(int j=i+1; j<=n; ++j){
      a.push_back(i);
      b.push_back(j);
      ++m;
      --kk;
      if(kk==k) goto loopend;
    }
  }
  loopend:
  cout<<m<<endl;
  REP(i, a.size()){
    cout<<a[i]<<" "<<b[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
import itertools

N = int(input())
A = []
x_y = []

for i in range(N):
    x = int(input())
    A.append(x)
    x = [list(map(int,input().split()))
        for _ in range(A[i])]
    x_y.append(x)


zerone = [0,1]

# 0,1の組み合わせを作る
HOU_all = list(itertools.product(zerone,
repeat = N))



Honer_Count = 0

for HOU_state in HOU_all:

    count_N = 0

    for i in range(N):
        count_A = 0
        if HOU_state[i] == 1:
            for j in range(A[i]): 
                if HOU_state[x_y[i][j][0]-1] != x_y[i][j][1]:
                    break
                else:
                    count_A += 1
                    continue
            
            if count_A == A[i]:
                count_N += 1

    if count_N == sum(HOU_state):
        Honer_Count = max([sum(HOU_state),Honer_Count])
        

print(Honer_Count)

Measured memory_bytes: 8948
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

dp = [[-float('inf')]*3 for _ in range(N+1)]
for j in range(3):
  dp[0][j] = 0

for i in range(N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i+1][k] = max(dp[i+1][k], dp[i][j]+A[i][k])

print(max(dp[N]))

Measured memory_bytes: 84596
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
ll ans=0;// = 10^n-9^n+8^n
ll a=1,b=2,c=1;
for(int i=0;i<n;i++)
{
a=(a*10)%mod;
b=(b*9)%mod;
c=(c*8)%mod;
}
ans=(a-b+mod)%mod;
ans=(ans+c)%mod;
cout<<ans;
}

Measured memory_bytes: 3600
def main24():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(3):
        buf.append(int(strbufs[i]));
    if (buf[0]%2==1)and(buf[1]%2==1)and(buf[2]%2==1):
        buf.sort();
        are = buf[0] * buf[1];
        print(are);
    else:
        print(0);

if __name__ == '__main__':
    main24()

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	long long h,m,k,x;
	long long sum=0;
	scanf("%lld %lld",&h,&m);
	if(h==1||m==1)
		sum=1;
	else if(h%2==0)
	{
		sum=(h/2)*m;
	}
	else if(m%2==0)
	{
		sum=(m/2)*h;
	}
	else 
	{
		sum=(h*m)/2+1;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define Max 15
#define mem(a,b) memset(a,(int)b,sizeof(a));
#define pb push_back
#define mp make_pair
const LL mod=1e9+7;
const ULL base=131;
const LL LL_MAX=9223372036854775807;
using namespace std;
int n,m;
int p[Max],c[Max],on[Max];
map<pair<int,int>,int>mm;
bool check(){
    mem(on,0);
    for(int i=n;i>=1;i--){
        if(c[i]){
            for(int j=1;j<=m;j++)
                if(mm[mp(j,i)]==1)
                    on[j]++;
        }
    }
    for(int i=1;i<=m;i++){
         if((on[i]%2)!=p[i])
            return 0;
    }

    return 1;
}
int fun(){
    int len=pow(2,n)-1,now,op,ans=0;
    for(int i=0;i<=len;i++){
        now=i;
        for(int j=n;j>=1;j--){
            op=now%2;
            now/=2;
            c[j]=op;
        }
        if(check())
            ans++;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&m);
    int t,sw;
    for(int i=1;i<=m;i++){
        scanf("%d",&t);
        for(int j=0;j<t;j++){
            scanf("%d",&sw);
            mm[mp(i,sw)]=1;
        }
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&p[i]);
    printf("%d\n",fun());
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;


string s[55];

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

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m;

	vector<bool> aka(n, false);
	vector<int> cnt(n, 1);
	aka[0] = true;
	rep(i, 0, m) {
		int x, y; cin >> x >> y;
		--x, --y;
		if (aka[x]) {
			if (cnt[x] == 1) aka[x] = false;
			aka[y] = true;
		}
		cnt[x] -= 1;
		cnt[y] += 1;
	}

	int ans = 0;
	rep(i, 0, n) if (aka[i]) ++ans;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      t=t+'0';
    }
    else if(s[i]=='1'){
      t=t+'1';
    }
    else{
      if(t.size()!=0){
        t=t.substr(0,t.size()-1);
      }
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
n = int(input())
t_lst = list(map(int, input().split()))
m = int(input())

for i in range(m):
    p, x = map(int, input().split())
    count = 0
    for j in range(n):
        if j == p-1:
            count += x
        else:
            count += t_lst[j]
    print(count)



Measured memory_bytes: 9116
n,k=map(int,input().split())

a=list(map(int,input().split()))

l=[1]
di={}
di[1]=1

for i in a:
    b=a[l[-1]-1]
    if b in di:
        x=b
        break
    l.append(b)
    di[b]=1
t1=0
for j in l:
    if j==x:
        break
    else:
        t1+=1

t2=len(l)-t1
if k<=t1:
    print(l[k])

else:
    aa=(k-t1)%t2
    print(l[t1+aa])

Measured memory_bytes: 35584
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

int main()
{
    ll N, M, C;
    cin >> N >> M >> C;
    ll B[100];

    for (ll i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++)
    {
        ll sum = 0;
        for (ll j = 0; j < M; j++)
        {
            ll a;
            cin >> a;
            sum += a * B[j];
        }
        if (sum + C > 0) ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256