akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+2;
const ll mod=1e9+7;
int f[2010];
ll mul(ll a,ll b,ll mod)
{
    ll ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main()
{
   int n;
   ll k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
       cin>>f[i];
   int num1=0;
   for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
           if(f[i]>f[j]) num1++;
   int num=0;
   for(int i=1;i+1<=n;i++)
       for(int j=i+1;j<=n;j++)
       if(f[j]<f[i]) num++;
   cout<<(mul((ll)num,k,mod)+mul(k*(k-1)/2,(ll)num1,mod))%mod;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }


// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

string s, t;
string F(int k) {
	string ret(s);
	string ss = s.substr(k, t.size());
	REP(i, 0, ss.size()) {
		if (ss[i] != '?' && ss[i] != t[i]) return INFSTR;
	}

	copy(t.begin(), t.end(), ret.begin() + k);
	for (auto& c : ret) {
		if(c == '?') c = 'a';
	}
	return ret;
}

int main() {
	cin >> s >> t;
	string mn = INFSTR;
	REP(i, 0, s.size() - t.size() + 1) {
		mn = min(mn, F(i));
	}
	cout << (mn == INFSTR ? "UNRESTORABLE" : mn) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
lst = [int(x) for x in input().split()]
a = 0
b = 0
for n in lst:
    if n % 4 == 0:
        a += 1
    elif n % 2 == 0:
        b += 1

if b >= 2:
    N = N - (b - 1)

if a >= N // 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

ll cal(ll n){
  return n*(n+1)/2;
}

int main()
{
  string s;
  cin>>s;
  int n=s.size();
  vector<ll> v;
  ll cnt=0;
  REP(i,n){
    if(s[i]=='<'){
      if(cnt>=0) cnt++;
      else{
        v.emplace_back(cnt);
        cnt=1;
      }
    }else{
      if(cnt<=0) cnt--;
      else{
        v.emplace_back(cnt);
        cnt=-1;
      }
    }
    if(i==n-1) v.emplace_back(cnt);
  }
  // REP(i,v.size()) cout<<v[i]<<endl;
  v.emplace_back(0);

  ll ans=0;
  if(v[0]<0){
    ans+=cal(-v[0]);
    v.erase(v.begin());
  }
  for(int i=0;i<v.size()-1;i+=2){
    ans+=cal(max(v[i],-v[i+1]))+cal(min(v[i],-v[i+1])-1);
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3068
N, T = gets.split.map(&:to_i)
c = []
t = []
N.times do |i|
	c[i], t[i] = gets.split.map(&:to_i)
end

ans = "TLE"
until c.empty? do
  if t[c.index(c.min)] > T
    t.delete_at(c.index(c.min))
    c.delete_at(c.index(c.min))
  else
    ans = c.min
    break
  end
end
puts ans


Measured memory_bytes: 1788
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

int ok(int x, int n)
{
  return 0 <= x && x < n;
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  mf_graph<int> g(n * m + 2);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (i % 2 == j % 2) g.add_edge(0, i * m + j + 1, 1);
      else g.add_edge(i * m + j + 1, n * m + 1, 1);
    }
  }
  vector<int> a;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (i % 2 == j % 2)
      {
        for (int k = 0; k < 4; k++)
        {
          int nx = cx[k] + i, ny = cy[k] + j;
          if (ok(nx, n) && ok(ny, m) && s[i][j] == '.' && s[nx][ny] == '.')
          {
            a.push_back(g.add_edge(i * m + j + 1, nx * m + ny + 1, 1));
          }
        }
      }
    }
  }
  cout << g.flow(0, n * m + 1) << "\n";
  for (auto id : a)
  {
    auto e = g.get_edge(id);
    if (e.flow == 1)
    {
      int i1 = (e.from - 1) / m, j1 = (e.from - 1) % m;
      int i2 = (e.to - 1) / m, j2 = (e.to - 1) % m;
      if (i1 - 1 == i2) s[i1][j1] = '^', s[i2][j2] = 'v';
      if (j1 - 1 == j2) s[i1][j1] = '<', s[i2][j2] = '>';
      if (i1 + 1 == i2) s[i1][j1] = 'v', s[i2][j2] = '^';
      if (j1 + 1 == j2) s[i1][j1] = '>', s[i2][j2] = '<';
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << s[i] << "\n";
  }
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
double coin[3010];
double dp[3010][3010];

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

	cin>>n;
	for(int i=1;i<=n;i++)
        cin>>coin[i];

    //for(int i=0;i<=n;i++)
    //    dp[i][0]=1;
    dp[0][0]=1;

    for(int i=1;i<=n;i++)
        dp[0][i]=dp[0][i-1]*(1-coin[i]);

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j]=dp[i][j-1]*(1-coin[j])+dp[i-1][j-1]*coin[j];

    /*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/

    cout << fixed;
    cout<<setprecision(10);

    double sol=0;
    for(int i=n/2+1;i<=n;i++)
        sol+=dp[i][n];
    cout<<sol;

	return 0;
}


Measured memory_bytes: 70912
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;


#[fastout]
fn main() {
    input!{
        n: usize,
        a_vec: [usize; n],
    }
    let flag0 = if a_vec.iter().filter(|x| **x == 0).collect::<Vec<&usize>>().len() >= 1 { true } else { false } ;
    let mut flag = false;
    let mut ans = bigint::BigInt::from_u64(1).unwrap();
    for a in a_vec.iter() {
        ans *= bigint::BigInt::from_u64(*a as u64).unwrap();
        if ans > bigint::BigInt::from_u64(1e18 as u64).unwrap() {
            flag = true;
            break;
        } 
    }

    if flag0 {
        println!("0");
    } else if flag {
        println!("-1")
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4992
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
//    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
void solve(){
    int n;
    cin>>n;
    int t;
    int count=0;
    for (int i = 0; i < n; ++i) {
        cin>>t;
        if (t&1 and (i+1)&1)
            count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3596
<?php
// Your code here!
$input = fgets(STDIN);
$number_array = explode(' ', $input);

$left_right_number = $number_array[0] - 1;

$array = array($number_array[1]);
for($i = 1; $i <= $left_right_number; $i++) {
    array_push($array, $number_array[1] + $i);
    array_unshift($array, $number_array[1] - $i);
}

echo(implode(' ', $array));

?>


Measured memory_bytes: 3828
import numpy as np

U = 3000
R,G,B,N = map(int,input().split())

a = np.zeros(U+1,dtype = np.int64)

for r in range(0,U+1):
  x = R*r
  if x > U:
    break
  a[x::G] += 1


ans = a[N::-B].sum()
print(ans)

Measured memory_bytes: 21520
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (auto &hi: h) cin >> hi;
    sort(begin(h), end(h));
    int mi = INF;
    for (int i = 0; i + k - 1 < n; i++) {
        mi = min(mi, h[i + k - 1] - h[i]);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	char A, B;
	
	scanf("%c\n %c", &A, &B);
	
	if (A== '1'&&B=='2'){
		printf("3");
	}else if (A=='1'&&B=='3'){
		printf("2");
	}else if(A=='3'&&B=='1'){
		printf("2");
	}else if (A=='3'&&B=='2'){
		printf("1");
	}else if (A=='2'&&B=='1'){
		printf("3");
	}else if (A=='2'&&B=='3'){
		printf("1");
	}
	
	
	
	
	return 0;
}

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

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


const int INF = 1 << 30;
vector<int> h;
vector<int> dp;


int main() {
    int n, k;
    cin >> n >>  k;
    h.assign(n+100, 0);
    for (int i=0; i<n; i++) cin >> h.at(i);

    dp.assign(n+100, INF);
    dp.at(0) = 0;

    for(int i=0; i<n; i++){
        for(int j=1; j<=k; j++){
            chmin(dp.at(i+j), dp.at(i)+abs(h.at(i)-h.at(i+j)));
        }
    }

    cout << dp.at(n-1) << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
//#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)

int main(){
    ll n;cin>>n;
    ll a[n];
    fr(i,n)cin>>a[i];
    ll l = 0,r = 0,ans = 0;
    ll Xor = a[0], Add = a[0];
    while(r-l>=0 && r < n){
        if(Xor == Add){
            ans += r-l+1;
            r ++;
            if(r<n){
                Xor ^=a[r];
                Add +=a[r];
            }
        }else{
            if(l<n){
                Xor ^=a[l];
                Add -=a[l];
            l++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
n,k = map(int,input().split())
t = [[] for _ in range(n)]
flag = [False for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    t[a-1].append(b-1)
    t[b-1].append(a-1)
res = 1
mod = 10**9+7

def dfs(s):
    global t
    global k
    global res
    global mod
    global flag
    if s == 0:
        res *= k
        tk = k-1
        for _ in range(len(t[s])):
            res *= tk
            res %= mod
            tk -= 1
    else:
        tk = k-2
        for _ in range(len(t[s])-1):
            res *= tk
            res %= mod
            tk -= 1
    flag[s] = True
    for g in t[s]:
        if not flag[g]:
            dfs(g)

if k ==1:
    if n>1:
        print(0)
    else:
        print(1)
elif k ==2:
    if n>2:
        print(0)
    else:
        print(2)
else:
    dfs(0)
    print(res % mod)

Measured memory_bytes: 88112
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int coin[21];
    coin[0] = 0; 
    for (int i = 1; i < M+1; ++i){
        int c;
        cin >> c;
        coin[i] = c;
    }
    int c[21][50001];
    for(int i = 0; i < N+1; i++){
        c[0][i] = 500000;
    }
    for(int j = 0; j < M+1; j++){
        c[j][0] = 0;
    }
    for(int i = 1; i < M+1; ++i){
        for(int j = 1; j < N+1; ++j){
            if(j < coin[i]){
                c[i][j] = c[i-1][j];
            }else{
                c[i][j] = min(c[i-1][j], c[i][j-coin[i]] + 1);
            }
        }
    }
    cout << c[M][N] << endl; 
}

Measured memory_bytes: 7200
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<cstdio>

using namespace std;

void Solution()
{
    string w;
    string t;
    
    int count = 0;
    
    cin>>w;
    
    for(int i = 0; i < (int)w.size(); i++)
    {
        w[i] = toupper(w[i]);
    }
    
    while(cin>>t)  //compute by each space
    {
        if(t == "END_OF_TEXT") break;
        
        for (int i = 0; i < (int)t.size(); i++)
        {
            t[i] = toupper(t[i]);
        }
        
        if(t == w) count++; // or if(t.find(w) != string::npos)
    }
    
    cout<<count<<endl;
    
}

int main()
{
    Solution();
    return 0;
}

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

public class Main{
	public static void main(String args[]) throws Exception {

		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		Map<Integer, Integer> mp = new HashMap<>();
		while (n-- > 0) {
			int k = sc.nextInt();
			if (mp.containsKey(k))
				mp.put(k, mp.get(k) + 1);
			else
				mp.put(k, 1);

		}
		int ans = 0;
		for (Map.Entry<Integer, Integer> i : mp.entrySet()) {
			if (i.getKey() < i.getValue())
				ans += Math.abs(i.getValue()-i.getKey());
			else if (i.getKey() > i.getValue()) {
				ans +=  i.getValue();
			}
		}
		System.out.println(ans);
		out.close();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 45956
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
  using namespace std;
using namespace __gnu_pbds;
  #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const double PI = acos(-1);
  const int N = 1e6 + 7;
  int mod = 1e9 + 7;
 
int32_t main()
{


    int n;
    cin >> n;

    int a[n+1];

    rep(i,1,n)
    {
      cin >> a[i];
    }

    int dp[n+1];

    dp[1] = 0;
    dp[2] = dp[1] + abs(a[1] - a[2]);

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


    cout << dp[n];

   return 0;
}       


Measured memory_bytes: 1792
X = int(input())
if X >= 400 and X <= 599:
    print(8)
elif X >= 600 and X <= 799:
    print(7)
elif X >= 800 and X <= 999:
    print(6)
elif X >= 1000 and X <= 1199:
    print(5)
elif X >= 1200 and X <= 1399:
    print(4)
elif X >= 1400 and X <= 1599:
    print(3)
elif X >= 1600 and X <= 1799:
    print(2)
elif X >= 1800 and X <= 1999:
    print(1)

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

int main(){
	double input;
	while(cin >> input){
		double ans = input;
		double s = input;
		for(int i = 2; i <= 10; i++){
			if(i % 2 == 0){
				ans += s * 2;
				s *= 2;
			}
			else {
				ans += s / 3;
				s /= 3;			}
		}
		printf("%.8f\n", ans);
	}
}

Measured memory_bytes: 1236
n = int(input())
array = [int(x) for x in input().split(' ')]
s = 0
sums = []
for i in range(n-1, -1, -1):
    if i == n-1:
        sums.append(array[i])
    else:
        sums.append(sums[-1] + array[i])

sums.pop()
for i in range(n-1):
    s += array[i] * sums.pop()

print(s % (10 ** 9 + 7))

Measured memory_bytes: 31604
#include <iostream>

using namespace std;

const long MOD = 1000000007;

long dp[301][301][301];

int main(){
    int N, M;
    cin >> N >> M;
    dp[0][1][1] = 1;
    for(int i = 1; i <= M; i++){
        for(int j = 1; j <= N; j++){
            for(int k = 1; k <= j; k++){
                //cout << i << ' ' << j << ' ' <<  k << endl;
                if(j == k){
                    for(int l = 1; l <= j; l++){
                        dp[i][j][k] += dp[i-1][j][l]*l;
                        dp[i][j][k] %= MOD;
                    }
                }else{
                    dp[i][j][k] = (dp[i-1][j][k]*(j-k))%MOD;
                    dp[i][j][k] += (dp[i-1][j-1][k]*(N-j+1))%MOD;
                    dp[i][j][k] %= MOD;
                }
            }
        }
    }
    cout << dp[M][N][N] << endl;
}

Measured memory_bytes: 212608
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5 3 2
)");
#define cin input
#endif

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

	if (a<=x && x<=a+b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int a, b;
    cin >> a >> b;
    if(a == b) {
        int l = min(a, b);

        REP(i, l) {
            cout << a;
        }
    } else {
        if(a < b) {
            REP(i, b) {
                cout << a;
            }
        } else {
            REP(i, a) {
                cout << b;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define ll long long
#define maxn 40
#define maxa 10
#define maxx 500000000

int d[maxn + 1][maxa * maxn + maxa + 2][maxa * maxn + maxa + 2];
int a[maxn + 1], b[maxn + 1], c[maxn + 1];

int main() {
    int n, aa, bb, rez = maxx;
    scanf("%d%d%d", &n, &aa, &bb);

    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= maxn * maxa; j++) {
            for (int k = 0; k <= maxn * maxa; k++) {
                d[i][j][k] = maxx;
            }
        }
    }

    d[0][0][0] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= maxn * maxa; j++) {
            for (int k = 0; k <= maxn * maxa; k++) {
                if (d[i - 1][j][k] != maxx) {
                    d[i][j][k] = std::min(d[i - 1][j][k], d[i][j][k]);
                    d[i][j + a[i]][k + b[i]] = std::min(d[i][j + a[i]][k + b[i]], d[i - 1][j][k] + c[i]);
                }
            }
        }
    }
    for (int i = 1; i <= maxn * maxa; i++) {
        for (int j = 1; j <= maxn * maxa; j++) {
            if (aa * j == bb * i)
                rez = std::min(rez, d[n][i][j]);
        }
    }
    if(rez != maxx)
        printf("%d", rez);
    else
        printf("-1");
    return 0;
}


Measured memory_bytes: 27392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int lef[2010][2010],righ[2010][2010],up[2010][2010],down[2010][2010];
char s[2010][2010];
int h,w;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    // left
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='.'){
                if(s[i][j-1]!='.'){lef[i][j]=1;}
                else{lef[i][j]=lef[i][j-1]+1;}
            }
        }
    }
    // right
    for(int i=1;i<=h;i++){
        for(int j=w;j>=1;j--){
            if(s[i][j]=='.'){
                if(s[i][j+1]!='.'){righ[i][j]=1;}
                else{righ[i][j]=righ[i][j+1]+1;}
            }
        }
    }
    // up
    for(int j=1;j<=w;j++){
        for(int i=1;i<=h;i++){
            if(s[i][j]=='.'){
                if(s[i-1][j]!='.'){up[i][j]=1;}
                else{up[i][j]=up[i-1][j]+1;}
            }
        }
    }
    //down
    for(int j=1;j<=w;j++){
        for(int i=h;i>=1;i--){
            if(s[i][j]=='.'){
                if(s[i+1][j]!='.'){down[i][j]=1;}
                else{down[i][j]=down[i+1][j]+1;}
            }
        }
    }

    int ans = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='.'){
                int res = 1 + lef[i][j-1] + righ[i][j+1] + up[i-1][j] + down[i+1][j];
                ans = max(ans,res);
            }
        }
    }
    cout<<ans<<newl;
}


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

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

    if((a + b) % 2 == 0){
        cout << (a + b) / 2 << '\n';
    }  
    else{
        cout << (a + b) / 2 + 1 << '\n';
    }

    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    vector<vector<int>> A(K, vector<int>(N));

    for (int i = 0; i < K; i++)
    {
        cin >> d.at(i);
        for (int j = 0; j < d.at(i); j++)
        {
            cin >> A.at(i).at(j);
        }
    }
    int count = 0;
    for (int k = 0; k < N; k++)
    {
        bool ans = 0;
        for (int i = 0; i < K; i++)
        {
            for (int j = 0; j < d.at(i); j++)
            {
                if (A.at(i).at(j) == k + 1)
                {
                    ans = 1;
                    break;
                }
            }
        }
        if (!ans)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for (i = 0; i <= VMAX; i++) C[i] = 0;

    for (i = 0; i < n; i++){
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];

    for (j = n; j >= 1; j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for (i = 1; i <= n; i++){
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 9548
#include <stdio.h>

int main(){

  int N = 0, res = 0;

  scanf("%d", &N);

  int i = 0;

  if( N < 10 ){
    for( i = 0; i < 10; i++ ){
      if( i < N){
      res++;
      }
    }
  }

  else{
  for( i = 1; i < 10; i++ ){
    if( i < N ){
      res++;
    }
  }
  for( i = 99; i < 999; i++  ){
    if( i < N ){
      res++;
    }
  }
  for( i = 9999; i < 99999; i++ ){
    if( i < N ){
      res++;
    }
  }
  }

  printf("%d", res);

  return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
 string s; cin >> s;
 for(int i=0;i<s.size();i++)for(int j=0;j<i;j++){
  if (s[i]==s[j]) {cout << "no" << endl; return 0;} 
 }
 cout << "yes" << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;

int main()
{
	IOS
    int n,k;
    cin>>n>>k;
    int num[55];
    for(int i=0;i<n;i++)
    	cin>>num[i];
    int maxe = 0;
    for(int a = 0 ; a <= k ; a++)
    {
    	for(int b = 0 ; b <= k ; b++)
    	{
    		for(int c = 0 ; c <= k ; c++)
    		{
    			if(a + c + b <= k && a + b >= c && a + b <= n)
    			{
    				priority_queue<int>q;
    				for(int i=0;i<a;i++)
    					q.push(num[i]);
    					
					for(int i=0;i<b;i++)
						q.push(num[n-i-1]);
					
					int sum = 0;
					for(int i=0;i<a+b-c;i++)
					{
						sum = sum + q.top();
						q.pop();
					}
					maxe = max(maxe,sum);
				}
			}
		}
	}
	cout<<maxe<<endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

int n;
int g[13];

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

	cin >> n;

	for (int k = 0;k < n;k++){
		int tmp;
		fill(g,g+13,2);
		g[6] = 3;
		for (int i = 0;i < 6;i++){
			cin >> tmp;
			g[tmp-1] = 1; 
		}	
		if(g[0] == 1 && g[12] == 1) cout << "no" << endl;
		else if(g[0] == 2 && g[12] == 2) cout << "yes" << endl;
		else if(g[0] == 1){
			int t = 0;
			int a = 6, b = 6;
			while(true){
				if(t%2 == 0){
					if(g[a-1] == 1){
						g[a-1] = 3; a--;
					}else if(g[b+1] == 1){
						g[b+1] = 3; b++;
					}
				}else{
					if(g[b+1] == 2){
						g[b+1] = 3; b++;
					}else if(g[a-1] == 2){
						g[a-1] = 3; a--;
					}
				}
				if(a == 0){cout << "yes" << endl; break;}
				if(b == 12){cout << "no" << endl; break;}
				t++;
			}
		}else if(g[0] == 2){
			int t = 0;
			int a = 6, b = 6;
			while(true){
				if(t%2 == 0){
					if(g[b+1] == 1){
						g[b+1] = 3; b++;
					}else if(g[a-1] == 1){
						g[a-1] = 3; a--;
					}
				}else{
					if(g[a-1] == 2){
						g[a-1] = 3; a--;
					}else if(g[b+1] == 2){
						g[b+1] = 3; b++;
					}
				}
				if(a == 0){cout << "no" << endl; break;}
				if(b == 12){cout << "yes" << endl; break;}
				t++;
			}
		}
	}

	return 0;

}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.1415926535
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int has[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool ispalin(string s)
{
	string k = s;
	reverse(k.begin(),k.end());
	if(k == s)
	{
		return true;
	}

	return false;
}


signed main()
{
    
	speedrap
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		int x,y,a,b,c;
		cin>>x>>y>>a>>b>>c;
		vector<int> vta,vtb,vtc;
		for(int i = 0 ; i < a ; i++)
		{
			int k ;
			cin>>k;
			vta.push_back(k);
		}

		for(int i = 0 ; i < b; i++)
		{
			int k ; 
			cin>>k;
			vtb.push_back(k);
		}

		for(int i = 0 ; i < c ; i++)
		{
			int k ; 
			cin>>k;
			vtc.push_back(k);
		}

		multiset<int> sta,stb;
		sort(vtc.begin(),vtc.end());
		sort(vta.begin(),vta.end());
		sort(vtb.begin(),vtb.end());
		reverse(vtc.begin(),vtc.end());
		reverse(vta.begin(),vta.end());
		reverse(vtb.begin(),vtb.end());
		for(int i = 0 ; i < x ; i++)
		{
			sta.insert(vta[i]);
		}

		for(int i = 0 ; i < y ; i++)
		{
			stb.insert(vtb[i]);
		}

		for(int i = 0 ; i < vtc.size() ; i++)
		{
			auto it1 = sta.begin();
			auto it2 = stb.begin();
			int val = vtc[i];
			int go = min(*it1,*it2);
			if(go < val)
			{
				if(*it1 < *it2)
				{
					sta.erase(it1);
					sta.insert(val);
				}
				else
				{
					stb.erase(it2);
					stb.insert(val);
				}
			}
			else
			{
				break;
			}
		}

		int sum = 0;

		auto it = sta.begin();

		for(it = sta.begin() ; it!= sta.end() ; it++)
		{
			sum += *it;
		}	
		auto it1 = stb.begin();
		for(it1 = stb.begin() ; it1 != stb.end() ; it1++)
		{
			sum += *it1;
		}

		cout<<sum;
	}
}

Measured memory_bytes: 10996
#[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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n:i32,
    }


    println!("{}", n * n);

}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int ans = 0;
        for(int i = 0; i < S.length / 2; i++) if(S[i] != S[S.length - i - 1]) ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	auto result = 0;
	for (auto i = 1; i <= N; ++i)
	{
		auto temp = i;
		auto sum = 0;
		while (temp > 0)
		{
			sum += temp % 10;
			temp /= 10;
		}

		if (sum >= A && sum <= B)
		{
			result += i;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
a1, a2, a3, a4 = 0, w, 0, h
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        a1 = max(a1, x)
    elif a == 2:
        a2 = min(a2, x)
    elif a == 3:
        a3 = max(a3, y)
    elif a == 4:
        a4 = min(a4, y)
print(max(0, a2 - a1) * max(0, a4 - a3))

Measured memory_bytes: 3064
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0]
X = line[1]
line = lines.shift().split(' ')
ans = 1
sum = 0
for (i = 0; i<N; i++) {
    sum += line[i] * 1
    if (sum <= X) {
        ans++
    }
}
console.log(ans)

Measured memory_bytes: 11596
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N;

int main() {

	scanf("%d", &N);

	int ans = 1123456;

	rep(i, N - 1) {
		int count = 0;
		int j = N - i - 1;
		int t = i + 1;
		rep(k, 7) {
			count += t % 10;
			t /= 10;
			count += j % 10;
			j /= 10;
		}
		ans = min(ans, count);
	}

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

	return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(input() for i in range(n))
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    if a[i] == 'AC':
        ac += 1
    elif a[i] == 'WA':
        wa += 1
    elif a[i] == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 16172
#include<iostream>
#include<string.h>
using namespace std;
long  a[200001];
int main(){
	int n;
	int i,j;
	int max;
	int small;
	memset(a,0,sizeof(a));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	max=a[1]-a[0];
	small=a[0];
	for(i=1;i<n;i++){
		if(max<a[i]-small){
			max=a[i]-small;
		}
		if(small>a[i]){
			small=a[i];
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 1000) {
		vector<int> res = { i / 100,(i / 10) % 10,i % 10 };
		int sol = 0;
		rep(j, n) {
			if (int(s[j] - '0') == res[sol]) sol++;
			if (sol == 3) break;
		}
		if (sol == 3) ans++;
	}
	
	dunk(ans);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int c,d,e,f,g,h,i,j,a,b;
	cin>>c>>d>>e>>f>>g>>h>>i>>j;
	a=c+d+e+f;
	b=g+h+i+j;
	if(a<b)cout<<b<<endl;
	else cout<<a<<endl;
	return 0;
	}



Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<climits>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<utility>
#include<iomanip>
//#include<ext/pb/ds/assoc_container.hpp>

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef long long int lld;
typedef long double real;

lld mod = 1e9+7;

template<typename T>
void input_vector(vector<T>& v, lld n, lld start=0) {
	for(lld i=start; i<n; ++i) 
		cin>>v[i];
}

template<typename T>
void display_vector(vector<T> v, lld start=0, string sep=" ") {
	for(lld i=start; i<v.size(); ++i)
		cout<<v[i]<<sep;
	cout<<"\n";
}

void fillPrimes(vector<lld>& sieve, vector<lld>& primes) {
	lld i, j;
	
	for(i=2*2; i<sieve.size(); i+=2) 
		sieve[i]=0;
	
	j=3;
	while(j<sieve.size()) {
		for(i=j*j; i<sieve.size(); i+=(2*j)) {
			sieve[i]=0;
		}
		
		// get next prime
		for(i=j+1; i<sieve.size(); ++i)
			if(sieve[i]) {
				j=i;
				break;
			}
		if(i==sieve.size())
			break;
	}
	
	for(i=2; i<sieve.size(); ++i) {
		if(sieve[i])
			primes.push_back(i);
	}
}

vector<pair<lld, lld>> factorize(lld n, vector<lld> primes) {
	vector<pair<lld, lld>> factors;
	lld tmp=n;
	for(lld i=0; primes[i]*primes[i]<=n; ++i) {
		if(tmp%primes[i]==0){
			pair<lld, lld> pr = {primes[i], 0};
			while(tmp%primes[i]==0) {
				pr.second++;
				tmp /= primes[i];
			}
			factors.push_back(pr);
		}
	}
	if(tmp>1)
		factors.push_back({tmp, 1});
	return factors;
}

void solve(lld h1, lld m1, lld h2, lld m2, lld k) {
	lld h, m, req;
	if(m2>=m1) {
		req = (h2-h1)*60 + (m2-m1);
		cout<<req-k<<"\n";
		return;
	}
	
	req = (h2-h1-1)*60 + (m2+60-m1);
	cout<<req-k<<"\n";
	
}

int main() {
	lld t=1;
	//cin>>t;
	
	for (lld cs=1; cs<=t; ++cs) {
		lld h1,m1,h2,m2,k;
		cin>>h1>>m1>>h2>>m2>>k;
		solve(h1, m1, h2, m2, k);
	}
	
	return 0;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a1, b1 = inputMap()
    a2, b2 = inputMap()
    a3, b3 = inputMap()
    
    maps = {}
    maps[a1] = 1
    maps[b1] = 1
    
    if a2 in maps:
        maps[a2] += 1
    else:
        maps[a2] = 1
        
    if b2 in maps:
        maps[b2] += 1
    else:
        maps[b2] = 1
        
    if a3 in maps:
        maps[a3] += 1
    else:
        maps[a3] = 1
        
    if b3 in maps:
        maps[b3] += 1
    else:
        maps[b3] = 1
        
    for k,v in maps.items():
        if v > 2:
            print("NO")
            sys.exit()
            
    print("YES")
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38640
#include<stdio.h>
int main(void) {
	int width[30];
	int w, n, a, b, tmp, i;
	scanf("%d", &w);
	scanf("%d", &n);
	for(i = 0; i < w; i++) width[i] = i + 1;
	for(i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		tmp = width[b-1];
		width[b-1] = width[a-1];
		width[a-1] = tmp;
	}
	for(i = 0; i < w; i++) printf("%d\n", width[i]);
	return 0;
}

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

int main() {
	char x;
  	cin>> x;
  	
  	if(isupper(x)){
     	cout<<"A"<<endl; 
    }else{
     	cout<<"a"<<endl; 
    }
}

Measured memory_bytes: 3620
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int N=100005;

int n,ans,a[N],p1[N],p2[N];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n; 
    for (int i=1;i<=n;++i) cin>>a[i];
    p1[0]=a[1];
    p2[n+1]=a[n];
    for (int i=1;i<=n;++i)
        p1[i]=__gcd(a[i],p1[i-1]),
        p2[n-i+1]=__gcd(a[n-i+1],p2[n-i+2]);
    ans=max(p2[2],p1[n-1]);
    for (int i=2;i<n;++i) ans=max(ans,__gcd(p1[i-1],p2[i+1]));
    cout<<ans<<'\n';
}

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

int main() {
  int N,T,A;
  cin >> N;
  cin >> T >> A;
  
  vector<double> H(N);
  for(int i=0; i<N; i++) {
    cin >> H[i];
  }
  double best = INT_MAX;
  int ans = 0;
  for(int i=0; i<N; i++) {
    double temp = T - H[i]*0.006;
    if(abs(best - A) > abs(temp - A)){
      best = temp;
      ans = i+1;
    }
  }
  cout << ans << endl;
}
  
  
 

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}


Measured memory_bytes: 3632
def resolve():
    H, W = [int(i) for i in input().split()]
    aa = [input() for _ in range(H)]
    print("".join(["#" for _ in range(W + 2)]))
    for r in range(H):
        print("#" + aa[r] + "#")
    print("".join(["#" for _ in range(W + 2)]))


resolve()


Measured memory_bytes: 9124
S = input()

result = 0

op_cnt = len(S) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    #print(op)
    
    formula = ""
    for p_n, p_o in zip(S, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    result += eval(formula.replace("-",""))
    
print(result)

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

typedef long long ll;

#define F for(int i = 0; i < N; i++)

int main() {

    int x;
    cin >> x;

    if(x == 1){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }

}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
	int k;
	string s;
	cin>>s>>k;
	int i;
	for(i=0;i<k;i++){
		if(s[i]=='1') continue;
		else{
			cout<<s[i];
			break;
		}
	}
	if(i==k) cout<<1;
}

Measured memory_bytes: 256
import sys

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    
    ans = 0
    for i, a in enumerate(A):
        if i%2==0 and a % 2 == 1:
            ans += 1
        
    print(ans)

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

dp = [n+1]*(n+1)
dp[0] = 0

for i in range(1, n+1):
    j = 1
    while j <= n:
        dp[i] = min(dp[i], dp[i-j]+1)
        j *= 6

    k = 1
    while k <= n:
        dp[i] = min(dp[i], dp[i-k]+1)
        k *= 9

print(dp[n])


Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 200005;
const ll M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        rep(i, n){
            cin >> a[i];
            if(a[i] % 2){
                print(1LL << (n - 1));
                return 0;
            }
        }
        print(m ? 0 : 1LL << n);
    }
}


Measured memory_bytes: 1792
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		output();
	}
 
	private static void output ()
	{
		for (int i = 1; i <= 9; i++){
			for (int j = 1; j <= 9; j++){
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

Measured memory_bytes: 24200