akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#define DIR_LEFT 1
#define DIR_DOWN 2
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char a[500][500];
    char move[500][500] = {};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    int count = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j] % 2 == 1){
                // odd num case
                if(j!=w-1){
                    a[i][j]--;
                    a[i][j+1]++;
                    move[i][j] = DIR_LEFT;
                }
                else if(i!=h-1){
                    // end of row
                    a[i][j]--;
                    a[i+1][j]++;
                    move[i][j] = DIR_DOWN;
                }
            }
        }
    }

    // count moves
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(move[i][j]==DIR_LEFT || move[i][j]==DIR_DOWN){
                count++;
            }
        }
    }
    cout << count << endl;

    // output moves
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(move[i][j]==DIR_LEFT){
                int x1 = j+1;
                int x2 = j+2;
                int y1 = i+1;
                int y2 = i+1;
                cout << y1 << ' ' << x1 << ' ' << y2 << ' ' <<  x2 << endl;
            }
            else if(move[i][j]==DIR_DOWN){
                int x1 = j+1;
                int x2 = j+1;
                int y1 = i+1;
                int y2 = i+2;
                cout << y1 << ' ' << x1 << ' ' << y2 << ' ' <<  x2 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2560
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def ciasteczka(): 
    N, K = wczytaj_liste()
    max_cukierkow = wczytaj_liste()
    przed = [1]
    for dziecko in max_cukierkow:
        po = [None]* min(len(przed)+ dziecko, K+1)
        suma_kroczaca = 0
        for i in range(len(po)):
            if len(przed) > i: #trzeba dodać
                suma_kroczaca += przed[i]
            if i-dziecko-1 > -1:
                suma_kroczaca -= przed[i-dziecko-1]
            suma_kroczaca %= 10**9+7
            po[i] = suma_kroczaca
        przed = po
    if K < len(przed):
        print(przed[K])
    else:
        print(0)
    
ciasteczka()  

Measured memory_bytes: 122188
import java.util.Scanner;

public class Main {
    int n, w;
    Item[] is;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        w = sc.nextInt();
        is = new Item[n];
        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            int w = sc.nextInt();
            is[i] = new Item(w, v);
        }
    }

    void solve() {
        int[][] dp = new int[n+1][w+1];
        for (int i = 1; i < n+1; i++) {
            int w = is[i-1].w;
            int v = is[i-1].c;
            for (int j = 0; j < this.w+1; j++) {
                if (j - w < 0)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = Math.max(dp[i][j-w]+v,
                            Math.max(dp[i-1][j], dp[i-1][j-w]+v));
            }
        }
        int ans = Integer.MIN_VALUE;
        for (int i = 0; i < w + 1; i++) {
            ans = ans > dp[n][i] ? ans : dp[n][i];
        }
        System.out.println(ans);
    }

    private class Item {
        int w, c;
        Item(int w, int c) {
            this.w = w;
            this.c = c;
        }
    }
}

Measured memory_bytes: 31284
// ------------------
// author: MatsuTaku
// date  : 19/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int H, A; cin>>H>>A;
  cout << H/A+(H%A>0) << endl;

  return 0;
}


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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  int k;
  cin >> k;
  k--;
  char c = s[k];

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != c) {
      cout << "*";
    } else {
      cout << c;
    }
  }

  cout << endl;
  return 0;
}


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

using namespace std;

int main() {
    int N = 0, cnt = 0;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int dp[10010];

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n){
		cin >> a[i] >> b[i];
	}
	rep(i, 0, h + 1) dp[i] = INF;
	dp[0] = 0;
	rep(i, 0, n){
		rep(j, 0, h + 1){
			dp[min(h, j + a[i])] = min(dp[min(h, j + a[i])], dp[j] + b[i]);
		}
	}
	cout << dp[h] << endl;
}

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

#define fst first
#define snd second

int n, x[20], y[20];

using pii = pair<int, int>;
vector<pii> ary;

inline int det(pii a, pii b) {
	int ax = x[a.snd] - x[a.fst];
	int ay = y[a.snd] - y[a.fst];
	int bx = x[b.snd] - x[b.fst];
	int by = y[b.snd] - y[b.fst];
	return ax * by - ay * bx;
}


int ans = 0;

void dfs(int mask) {
	if (mask == (1 << n) - 1) {
		const int m = ary.size();
		int cur = 0;
		rep(j, m)rep(i, j) if (det(ary[i], ary[j]) == 0) cur++;
		ans = max(ans, cur);
	}

	int low = -1;
	rep(i, n) if (((mask >> i) & 1) == 0) low = i;
	mask |= (1 << low);

	rep(i, n) {
		if (((mask >> i) & 1) == 0) {
			ary.push_back(pii(low, i));
			dfs(mask | (1 << i));
			ary.pop_back();
		}
	}
}

int main(void) {
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;

int main() {
	scanf("%lld %lld", &N, &K);
	if(ceil(N / (2 * 1.0)) >= K) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  long n;
  cin >> n;
  long long a[n], s[n+1];
  s[0] = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }
  
  long long result = 0;
  for (long long i = 0; i < n; i++) {
    result += a[i]*((s[n] - s[i+1]) % 1000000007);
    if (result >= 1000000007) result %= 1000000007;
  }
  
  cout << result;
  
  return 0;
}

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

cum = 0
d = 1
for i in range(1, 100):
  if cum + 26**i>=n:
    #print(cum, d)
    break
  cum += 26**i
  d += 1

rest = n - cum - 1
ans = [0]*d
for i in range(d-1, -1, -1):
  ans[i] = rest//(26**i)
  rest = rest%(26**i)
  
ans = ans[::-1]
#print(ans)

alp = 'abcdefghijklmnopqrstuvwxyz'
mapp = {i:alp[i] for i in range(26)}
for i in range(d):
  ans[i] = mapp[ans[i]]
  
print(''.join(ans))



Measured memory_bytes: 61784
let rec iter a b f = if a >= b then [] else let v = f a in v :: iter (a+1) b f
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.concat [
    [|0|]; Array.init n (fun _ -> Scanf.scanf " %d" (fun v -> v)); [|0|];
  ] in
  let s =
    iter 0 (n+1) (fun i -> abs (a.(i) - a.(i+1)))
    |> List.fold_left (+) 0 in
  iter 1 (n+1) (fun i ->
    s - abs (a.(i-1)-a.(i)) - abs (a.(i)-a.(i+1)) + abs (a.(i-1)-a.(i+1)))
  |> List.iter (Printf.printf "%d\n")

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int m = n / 15;
  cout << n * 800 - m * 200 << endl;
}

Measured memory_bytes: 3584
H, W = map(int, input().split())
grid = []

for _ in range(H):
  x = input()
  if x != "."*W:
    grid.append(x)

h = len(grid)
Flag = [True]*W

for j in range(W):
  if all(grid[i][j] == "." for i in range(h)):
    Flag[j] = False

for i in range(h):
  print("".join([grid[i][j] for j in range(W) if Flag[j]]))

Measured memory_bytes: 66776
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll N,p,res;


    cin >> N;

    ll iMax = 0;

    res = 0;

    REP(i,N)
    {
        cin >> p;
        res += p;
        iMax = max(iMax,p);
    }

    res -= iMax / 2;

    cout << res << endl;

    return 0;
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)A+=x+y;
		else if(x<y)B+=x+y;
		else A+=x,B+=y;
		}
		cout<<A<<" "<<B<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1160
Narray = [n for n in str(input())]

counter = 0
if len(Narray) > 1:
    for n in range(1,len(Narray)):
        if Narray[n] == Narray[n-1]:
            counter+=1
            if  Narray[n] == '1':
                Narray[n] = '0'
            else:
                Narray[n] = '1'

print(counter)

Measured memory_bytes: 3956
/*ID:PROG:LANG:*/
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 998244353
#define MAXN 300005
using namespace std;
int n;
bool fg=0;
char s[MAXN];
int rd(){
	int x=0,tp=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("1.out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(i&1)fg|=(s[i]!='h');
		else fg|=(s[i]!='i');
	}
	if(fg || n%2==1)printf("No\n");
	else printf("Yes\n");
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    for(int i=0;i<=n-1-i;i++){
        if(s[i]!=s[n-1-i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
const v: [char; 10] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
fn main() {
    let n: usize = read();
    let mut cand: Vec<Vec<char>> = vec![vec!['a']];
    for i in 1..n {
        let mut newcand: Vec<Vec<char>> = vec![];
        for c in &mut cand {
            for j in 0..i + 1 {
                let mut next_c = c.clone();
                next_c.push(v[j]);
                newcand.push(next_c);
            }
        }
        cand = newcand;
    }
    let mut homoid: HashSet<Vec<(usize, usize)>> = HashSet::new();
    for c in cand {
        let mut candid = vec![];
        for i in 0..n {
            for j in i + 1..n {
                if c[i] == c[j] {
                    candid.push((i, j));
                }
            }
        }
        if homoid.contains(&candid) {
            continue;
        } else {
            homoid.insert(candid);
            println!("{}", c.into_iter().collect::<String>());
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 413924
def gcd(m,n):
  x = max(m, n)
  y = min(m, n)
  
  while x % y != 0:
    z = x % y
    x = y
    y = z
  return y

def lcm(m,n):
  return m * n // gcd(m, n)

A = list(map(int, input().split()))
print(lcm(A[0], A[1]))

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

#define mem(f, v) memset(f,v,sizeof(f))
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

typedef long long ll;
const int maxn = 100010;
const int inf = ~(1u << 31u);
const ll linf = ~(1llu << 63u);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    ll a[10];
    for(int i = 1; i <= 3; i ++) cin >> a[i];
    sort(a+1, a+1+3);
    if(a[1]%2 == 0 or a[2] % 2 == 0 or a[3] % 2 == 0) cout <<"0";
    else cout << a[1] * a[2];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

int main()
{
  ll N;
  std::cin >> N;

  ll ans = 1;
  for (ll i = 1; i <= N; i++) {
    ans *= i;
    ans = ans % (ll)(1e9+7);
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;
 
int mx_one, mn_one = 1e9;
 
int length (int l, int r, int d)
{
	return r - l + min (abs (r) + abs (l - d), abs (l) + abs (r - d));
}
 
int n;
 
string s, t;
 
int check (int x)
{
	vector < pair <int, int> > side (n), s_comp;
	string con;
 
	for (int i = 0; i < n; i++)
		if (s[i] == t[(i + n + x) % n]) con += '0';
		else con += '1';
 
	int to = mx_one - n;
 
	for (int i = 0; i < n; i++)
	{
		if (t[i] == '1') to = i;
 
		side[i].first = i - to;
	}
 
	to = mn_one + n;
 
	for (int i = n - 1; i >= 0; i--)
	{
		if (t[i] == '1') to = i;
 
		side[i].second = to - i;
	}
 
	for (int i = 0; i < n; i++)
		if (con[i] == '1') s_comp.push_back (side[i]);
 
	if (s_comp.empty ()) return abs (x);
 
	sort (s_comp.begin(), s_comp.end());
 
	int r = 0;
 
	int ans = s_comp.back ().first + abs (x + s_comp.back ().first);
 
	for (int i = s_comp.size () - 1; i > 0; i--)
	{
		r = max (r, s_comp[i].second);
		ans = min (ans, length (-s_comp[i-1].first, r, x));
	}
 
	r = max (r, s_comp[0].second);
 
	ans = min (ans, abs (r) + abs (x - r));
 
	return ans + s_comp.size ();
}
 
int main ()
{
	int ans = 1e9;
 
	cin >> s >> t;
 
	n = s.length ();
 
	for (int i = 0; i < n; i++)
		if (t[i] == '1')
		{
			mx_one = i;
			mn_one = min (mn_one, i);
		}
 
	if (mn_one == 1e9)
	{
		for (int i = 0; i < n; i++)
			if (s[i] == '1')
			{
				cout << -1;
				return 0;
			}
		cout << 0;
		return 0;
	}
 
	for (int i = 0; i < n; i++)
		ans = min (ans, min (check (i), check (i - n)));
 
	cout << ans;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 510000;
char s[MAXN];
int z[MAXN];
int gfl[MAXN];


int main() {
	scanf("%s", s);
	int n = strlen(s);
	int fl = 0;
	for (int i = 0; i < n; ++i)
		if (s[i] != s[0])
			fl = 1;
	if (!fl) {
		cout << n << "\n" << 1 << "\n";
		return 0;
	}
	z[0] = 0;
	int l = 0, r = 0;
	for (int i = 1; i < n; ++i) {
		if (r > i)
			z[i] = min(r - i, z[i - l]);
		while (i + z[i] < n && s[z[i]] == s[i + z[i]])
			++z[i];
		if (i + z[i] > r)
			r = i + z[i], l = i;
	}
	fl = 0;
	for (int i = 1; i < n; ++i) {
		if (n % i != 0 || i + z[i] != n)
			continue;
		fl = 1;
		break;
	}
	if (fl != 1) {
		cout << 1 << "\n" << 1 << "\n";
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		for (int j = i + i; j <= i + z[i]; j += i)
			gfl[j] = 1;
	}
	reverse(s, s + n);
	z[0] = 0;
	l = 0, r = 0;
	for (int i = 1; i < n; ++i) {
		z[i] = 0;
		if (r > i)
			z[i] = min(r - i, z[i - l]);
		while (i + z[i] < n && s[z[i]] == s[i + z[i]])
			++z[i];
		if (i + z[i] > r)
			r = i + z[i], l = i;
	}
	for (int i = 1; i < n; ++i) {
		for (int j = i + i; j <= i + z[i]; j += i)
			gfl[n - j] = 1;
	}
	cout << 2 << "\n";
	int ans = 0;
	for (int i = 1; i < n; ++i)
		if (!gfl[i])
			++ans;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 4608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;


int main() {
	vector<int> lst;
	int n; cin >> n;
	lst.assign(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> lst[i];
	}

	vector<int> query;
	cin >> n;
	query.assign(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> query[i];
	}

	int sum = 0;
	for (int i = 0; i < query.size(); i++) {
		int q = query[i];
		for (int i = 0; i < lst.size(); i++) {
			if (lst[i] == q) {
				sum++;
				break;
			}
		}
	}
	cout << sum << endl;



	return 0;

}





Measured memory_bytes: 3140
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	h1 := nextInt()
	m1 := nextInt()
	h2 := nextInt()
	m2 := nextInt()
	k := nextInt()
	t1 := h1*60 + m1
	t2 := h2*60 + m2
	fmt.Println(t2 - t1 - k)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  ll K;
  cin >> K;

  int N = 50;
  vector<ll> ret(N, 0);
  REP(i,N) ret[i] = K / N + i;

  REP(i,K % N) {
    REP(j,N) {
      if(j == i) ret[j] += N;
      else --ret[j];
    }
  }

  cout << N << endl;
  REP(i,N) {
    if(i) cout << " ";
    cout << ret[i];
  }
  cout << endl;
  return 0;
}



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

int main(){
    int n, a, b; cin >> n >> a >> b;
    int k = b - a - 1;
    if(k == 0) cout << "Borys" << endl;
    else if(k & 1) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<int> ve;
    for(int i = 0 ; i < s.size() ; i++){
        if(ve.size() == k)break;
        if(s[i]=='o'){
            ve.push_back(i);
            i += c;
        }
    }
    vector<int> ans;
//    for(int i = 0 ; i < ve.size() ; i++){
//        cout << ve[i] << ' ' ;
//    }
//    cout << endl;
    int now = n-1;
    for(int i = ve.size() - 1 ; i >= 0 ; i--){
        while(s[now] != 'o'){
            now--;
        }
//        cout << ve[i] << ' ' << now << endl;
        if(now != ve[i]){
            now -= c + 1;
        }else{
            ans.push_back(ve[i]);
            now -= c + 1;
        }
    }
    sort(ans.begin(),ans.end());
    for(int i = 0 ; i < ans.size() ; i++){
        cout << ans[i] + 1 << endl;
    }
}


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, m, q; cin >> n >> m >> q;
	using jeng = pair<pii, pii>;
	vector<jeng> v(q); cin >> v;
	vi a(n);
	int ans = 0;
	function<void(int)> ha = [&] (int u) {
		if (u >= n) {
			int cur = 0;
			for (auto [ab, cd] : v) {
				auto [ai, bi] = ab;
				auto [ci, di] = cd;
				ai--, bi--;
				if (a[bi] - a[ai] == ci) {
					cur += di;
				}
			}
			ans = max(ans, cur);
		} else {
			int mn = 1;
			if (u > 0) mn = a[u - 1];
			for (int j = mn; j <= m; j++) {
				a[u] = j;
				ha(u + 1);
			}
		}
	};
	ha(0);
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	string s[10];
	
	s[1]="SAT";
	s[2]="FRI";
	s[3]="THU";
	s[4]="WED";
	s[5]="TUE";
	s[6]="MON";
	s[7]="SUN";
	
	string value;
	cin>>value;
	for(int i=1;i<8;i++)
	{
		if(value == s[i])
		{
			cout<<i;
			break;
		}
	}
	
}

Measured memory_bytes: 3576
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}
// {{{ MaxFlow
class MaxFlow{
    private:
        // destination, capacity, reverse edge index
        const ll inf=1e18;
        struct edge { ll to, cap, rev; };
        ll _n;
        vector<vector<edge>> G;
        vector<bool> used;

        ll dfs (ll src, ll dst, ll flow){
            if (src==dst)
                return flow;
            used[src]=true;
            rep(i,0,G[src].size()){
                edge &e = G[src][i];
                if (!used[e.to] && e.cap > 0) {
                    ll d = dfs(e.to, dst, min(flow, e.cap));
                    if (d>0){
                        e.cap -= d;
                        G[e.to][e.rev].cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }

    public:
        MaxFlow (ll numOfVertex){
            _n = numOfVertex;
            G = vector<vector<edge>>(_n);
        }

        // 0<=src,dst<numOfVertex
        void addEdge(ll src, ll dst, ll cap) {
            G[src].push_back(edge{dst, cap, (ll)G[dst].size()});
            G[dst].push_back(edge{src, 0, (ll)G[src].size()-1});
        }

        ll maxFlow(ll src, ll dst){
            ll flow = 0;
            while(true){
                used = vector<bool>(_n, false);
                ll f = dfs(src, dst, inf);
                if (f==0){
                    return flow;
                }
                flow += f;
            }
        }
};
// }}}

ll n,m;
vector<vector<ll>> edge; // vertex id -> next vertex id's
vector<bool> used;

ll f(ll cur){
    ll res = 0;
    used[cur] = true;
    for (auto nex: edge[cur]){
        if (used[nex]){
            continue;
        }
        res += f(nex); 
    }


    if (res > 0){
        used[cur] = false;
        return res;
    }

    bool last = true;
    for(auto u: used) last &= u;
    used[cur] = false;
    return last ? 1 : 0;
}

signed main() {
    cin>>n>>m;
    edge.resize(n, vector<ll>());
    used.resize(n, false);
    rep(i,0,m){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    cout<<f(0)<<endl;
    return 0;
}


Measured memory_bytes: 256
/// referenced: https://beta.atcoder.jp/contests/abc104/submissions/3018117
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
constexpr int MOD=1'000'000'007;
vector<int>power(100'000,3);
void init(){
  power[0]=1;
  for(int i=1;i<power.size();++i)
    power[i]=power[i-1]*power[i]%MOD;
}
string S;
main(){
  init();
  cin>>S;
  vector<int>a,c,ql,qr(S.size());
  a=c=ql=qr;
  for(int i=0;i<S.size();++i)if(S[i]=='A')a[i]=1;
  for(int i=0;i<S.size();++i)if(S[i]=='C')c[i]=1;
  for(int i=0;i<S.size();++i)if(S[i]=='?')ql[i]=qr[i]=1;
  for(int i=1;i<S.size();++i)a[i]+=a[i-1];
  for(int i=1;i<S.size();++i)ql[i]+=ql[i-1];
  for(int i=S.size()-2;i>=0;--i)c[i]+=c[i+1];
  for(int i=S.size()-2;i>=0;--i)qr[i]+=qr[i+1];
  int n=0;
  for(int i=1;i<S.size()-1;++i){
    if(S[i]=='B'||S[i]=='?'){
      int left=a[i-1]*power[ql[i-1]]%MOD;
      left+=ql[i-1]*power[ql[i-1]-1]%MOD;
      left%=MOD;
      int right=c[i+1]*power[qr[i+1]]%MOD;
      right+=qr[i+1]*power[qr[i+1]-1]%MOD;
      right%=MOD;
      n=(n+left*right%MOD)%MOD;
      // printf("%ld,%ld\n",left,right);
    }
  }
  cout<<n<<endl;
}


Measured memory_bytes: 4352
module Main where

import           Control.Monad
import Control.Monad.Writer


newtype DiffList a = DiffList { getDiffList :: [a] -> [a] }  
toDiffList :: [a] -> DiffList a  
toDiffList xs = DiffList (xs++)  
  
fromDiffList :: DiffList a -> [a]  
fromDiffList (DiffList f) = f []  

instance Monoid (DiffList a) where  
    mempty = DiffList (\xs -> [] ++ xs)  
    (DiffList f) `mappend` (DiffList g) = DiffList (\xs -> f (g xs))  

main :: IO ()
main = do
    [h, _] <- (map read . words) <$> getLine
    list   <- map (map read . words) <$> (replicateM h) getLine
    let w=do
            res<-(sequence . map goRight . enumerate2d) list
            (goRight . map last) res
            return ()
    let (_,log)=runWriter w

    putStr
        $(unlines .((show . length .fromDiffList) log :) . map ((unwords . map show) . (\((a, b), (c, d)) -> [a, b, c, d])).fromDiffList)
        log

goRight
    :: [((Int, Int), Int)] -> Writer (DiffList ((Int, Int), (Int, Int))) [((Int, Int), Int)]
goRight []  = return []
goRight [x] = return [x]
goRight (a@(aPoint, aValue) : b@(bPoint, _) : xs) = do
    if even aValue then
        do
            res<-goRight (b : xs)
            return $ a:res
    else
        do
            res<-goRight (mapSnd (+ 1) b : xs)
            tell $ toDiffList [(aPoint, bPoint)]
            return $ mapSnd (subtract 1) a : res

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)

mapTuple :: (t1 -> a) -> (t2 -> b) -> (t1, t2) -> (a, b)
mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst :: (t1 -> a) -> (t1, b) -> (a, b)
mapFst = flip mapTuple id

mapSnd :: (t2 -> b) -> (a, t2) -> (a, b)
mapSnd = mapTuple id
    

Measured memory_bytes: 95356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if((v - w) * t >= abs(a - b))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node [] L = new Node[n];
        for(int i=0;i<n;i++){
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            Node v = new Node();
            v.element(id,-1,left,right);
            L[id] = v;
        }
        for(Node v:L){
            if(v.left!=-1) L[v.left].parent = v.id;
            if(v.right!=-1) L[v.right].parent = v.id;
        }
        for(Node v:L){
            if(v.parent==-1){
                System.out.println("Preorder");
                preorder(L,v.id);
                System.out.println();
                System.out.println("Inorder");
                inorder(L,v.id);
                System.out.println();
                System.out.println("Postorder");
                postorder(L,v.id);
                System.out.println();
                break;
            }
        }
    }
    public static void preorder(Node [] L,int id){
        System.out.print(" "+id);
        if(L[id].left!=-1)preorder(L,L[id].left);
        if(L[id].right!=-1)preorder(L,L[id].right);
    }
    public static void inorder(Node [] L,int id){
        if(L[id].left!=-1)inorder(L,L[id].left);
        System.out.print(" "+id);
        if(L[id].right!=-1)inorder(L,L[id].right);
    }
    public static void postorder(Node []L,int id){
        if(L[id].left!=-1) postorder(L,L[id].left);
        if(L[id].right!=-1) postorder(L,L[id].right);
        System.out.print(" "+id);
    }
    public static class Node{
        int id,parent,left,right;
        public void element(int id,int parent,int left,int right){
            this.id = id;
            this.left = left;
            this.right = right;
            this.parent = parent;
        }
    }
}


Measured memory_bytes: 26360
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N;
	lls H;
	cin >> N;
	cinv(H, N);

	ll score = 0;
	ll maxScore = 0;
	for (int i = 0; i < N-1; i++) {//<>↓↓H[i]をループ i = 0～N - 2

		if (H[i] >= H[i + 1]) {
			score++;
		}
		else {
			score = 0;
		}

		maxScore = MAX(maxScore, score);
	}

	cout << maxScore << '\n';

	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n>>m;
    vector<string>str;
    string svar;
    for(i=0;i<n;i++){cin>>svar;str.pb(svar);}
    sort(str.begin(),str.end());
    for(i=0;i<str.size();i++)
    {
        cout<<str[i];
    }
}

Measured memory_bytes: 3624
from sys import stdin
from sys import setrecursionlimit
from itertools import accumulate
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(accumulate(a[::-1]))
b = b[::-1]
#print(b)

if n == 0:
    if a[0] == 1:
        print(1)
    else:
        print(-1)
    exit()    

if a[0] != 0:
    print(-1)
    exit()

ne = [0]*(n+1)

ne[0] = 1
point = 1

for i in range(1,n):
    point_ma = min(ne[i-1]*2,b[i+1]+a[i])
    if a[i] > point_ma:
        print(-1)
        exit()
    ne[i] = point_ma-a[i]
    point += point_ma

if ne[n-1]*2 < a[n]:
    print(-1)
    exit()

point += a[n]
ne[n] = 0

print(point)

Measured memory_bytes: 22516
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, T, E;
	static int[] x;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}

	static boolean read(){
		if(!sc.hasNext())return false;
		N = sc.nextInt();
		T = sc.nextInt();
		E = sc.nextInt();
		x = new int[N];
		for(int i = 0; i < x.length; i++){
			x[i] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		int min = T - E;
		int max = T + E;
		int res = -1;
		for(int i = 0; i < x.length; i++){
			for(int time = min; time <= max; time++){
				if(time % x[i] == 0){
					res = i+1;
					break;
				}
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 20452
#if 0
#endif

#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
using namespace std;

unordered_set<string> S;

int main()
{
    int num;
    cin >> num;
    for (int i = 0; i < num; i++)
    {
        string word, key;
        cin >> word >> key;
        if (word == "insert")
        {
            S.insert(key);
        }
        else if (word == "find")
        {
            auto itr = S.find(key);
            if (itr == S.end())
            {
                cout << "no" << endl;
            }
            else
            {
                cout << "yes" << endl;
            }
        }
    }
}



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

int main(){
	for(int i=0;i<9;i++){
		string cls;
		int mo,ev;
		cin>>cls>>mo>>ev;
		int sum=mo+ev;
		int money=mo*200+ev*300;
		cout<<cls<<" "<<sum<<" "<<money<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(A < B && B < C) {
			System.out.println("Yes");
		}
		else {

			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26372
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
int main() {
	int N;
	cin>>N;
	Graph G;
	for(int i=0;i<N;i++){
		Edges E;
		G.push_back(E);
	}
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(Edge(a,b,1));
		G[b].pb(Edge(b,a,1));
	}
	vint Pa,Pb;
	vector<Weight> Da,Db;
	shortestPath(G,0,Da,Pa);
	shortestPath(G,N-1,Db,Pb);

	int a=0,b=0;
	for(int i=0;i<N;i++){
		if(Da[i]<=Db[i])
			a++;
		else
			b++;
	}
	if(a>b)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 9584
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <atcoder/all>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[200005],R[200005],coef[200005];
void make(){
	F[0] = 1;
	for(int i=1;i<200005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<200005;i++) R[i] = modpow(F[i],mod-2);
	coef[0] = 1;
	for(int i=2;i<200005;i+=2){
		coef[i] = coef[i-2] * i % mod * (i-1) % mod * R[2] % mod;
	}
	for(int i=0;i<200005;i++) coef[i] = coef[i] * R[i/2] % mod;
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int n, h[100005];

struct S{
	vector<int>vec;
	bool operator < (const S & a) const{
		return vec.size() > a.vec.size();
	}
};
int main(){
	make();
	cin >> n;
	repn(i, 2*n){
		int a; cin >> a; h[a] ++;
	}
	queue<S>que;
	rep(i, 100005){
		vector<int>vec({1});
		ll cur = 1;
		for(int j=1;j*2<=h[i];j++){
			cur = cur * (h[i]+2-j*2) % mod * (h[i]+1-j*2) % mod * R[2] % mod;
			vec.pb((int)(cur * R[j] % mod));
		}
		que.push(S{vec});
	}
	while(que.size() >= 2){
		auto a = que.front(); que.pop();
		auto b = que.front(); que.pop();
		
		auto c = convolution(a.vec, b.vec);
		que.push(S{c});
	}
	auto X = que.front().vec;
	ll ans = 0;
	for(int i=0;i<X.size();i++){
		if(i%2==0) ans += 1LL * X[i] * coef[2*n-i*2] % mod;
		else ans -= 1LL * X[i] * coef[2*n-i*2] % mod;
	}
	cout << (ans%mod+mod)%mod << '\n';
}

Measured memory_bytes: 14828
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class CFennecVsMonster {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,k;
        s2(n,k);
        vi h(n);
        f(i,0,n){
            s(h[i]);
        }
        sort(range(h));
        int sum = 0;
        f(i,0,n-k){
            sum+=h[i];
        }
        out<<sum<<endl;
	}
};


integer main() {
	CFennecVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005],x=0,y=0,b;
int main() 
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];    
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			if(x<y)
			{
				x=a[i];
				i++;			
			}    
			else
			    y=a[i];
			i++;
		}
		if(x!=0 and y!=0)
		    break;
	}
	cout<<(long long)(x)*y;
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main (String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s;
        while ((s = br.readLine()) != null) {
            String[] str = s.split(" ");
            int x = Integer.parseInt(str[0]);
            int y = Integer.parseInt(str[1]);
            if (x == 0 && y == 0) {
                break;
            }
            if (x < y) {
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            }
        }
    }
}


Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    multiset<ll>s;s.insert(a[0]);
    rep(i,1,n-1){
        ll mi=*s.begin();
        if(a[i]<=mi){
            s.insert(a[i]);
            continue;
        }
        auto p=s.lower_bound(a[i]);
        p--;
        s.erase(p);
        s.insert(a[i]);
    }
    cout<<s.size()<<endl;
    
    return 0;
}







Measured memory_bytes: 5760