akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    for i in 0..n {
        print!("ACL");
    }
    println!("");
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N;cin>>N;
  vector<int> vec(N+1,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int ANS = 0;
  int STOPS = 0;
  int POS = STOPS;
  while(STOPS <N)
  {
    if((POS == STOPS)&&vec[STOPS] == 0)
    {
      STOPS++;
      POS = STOPS;
      continue;
      //0が続くなら何もしない。
    }

    if(vec[POS]==0)
    {
      ANS++;
      POS = STOPS;
      //STOPSにPOSを戻してANSを++する。
      continue;
    }
    vec[POS++]--;
  }
  cout<<ANS<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

int main(){
    int d, n;
    cin >> d >> n;
    int res = 1;
    for(int i = 0; i < d; i++){
        res *= 100;
    }
    if(n != 100) res *= n;
    else res *= 101;

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	s1[0] += 'A' - 'a';
	s2[0] += 'A' - 'a';
	s3[0] += 'A' - 'a';
	cout <<s1[0]<<s2[0]<<s3[0]<< endl;
}

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

s = 0
for i in range(n-1):
    s += abs(a[i+1] - a[i])
s += abs(a[0]) + abs(a[-1])

for i in range(n):
    mae = 0 if i == 0 else a[i-1]
    ato = 0 if i == n-1 else a[i+1]
    q = abs(a[i] - mae) + abs(ato - a[i])
    w = abs(ato - mae)
    print(s - q + w)


Measured memory_bytes: 14048
#include <stdio.h>

int main(){
	
	char d[15] = "yyy/01/30";
	scanf("%s", &d);
	
	d[0] = '2';
	d[1] = '0';
	d[2] = '1';
	d[3] = '8';
	
	printf("%s", d);
	
	return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    
    int N,M;
    cin >>N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin >>s[i];
    }
    cin >>M;
    vector<string> t(M);
    for(int i=0;i<M;i++){
        cin >>t[i];
    }
    vector<int> sc(N,0),tc(M,0);
    int mmax=0;
    int money=0;
    
    for(int j=0;j<N;j++){
        money=0;
        for(int i=0;i<N;i++){ 
            if(s[i]==s[j]) money++;
        }
        for(int i=0;i<M;i++){
            if(t[i]==s[j]) money--;
        }
        if(mmax<money) mmax=money;
    }

    cout <<mmax;

    return 0;
}

Measured memory_bytes: 256
char a[2][204];n,m,i,j,c,p;main(s){for(;i=scanf(m="%d %[^\n] %[^\n]",&n,a,a+1)>2;printf(m>n?"NA\n":"%d\n",m)){for(;~i;m>c?m=c:0,--i)for(j=i,c=p=0;s=a[j][p+p]-50,c<=n&&!s|n+~p;)p+=p<n&&s?~s|a[j][p+p+2]-49?j=!j,++c,2:1:-1;}}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int h, w;
	char a[1000][1000];
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++)cin >> a[i][j];
	}
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) {
			if (i == 0 || j == 0 || i == h + 1 || j == w + 1)a[i][j] = '#';
		}
	}
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++)cout << a[i][j];
		cout << endl;
	}
	int x;
	cin >> x;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 2e5 + 5, mod = 1e9 + 7;
 
int n;
int siz[N], mul[N], ans[N];
vector<int> g[N];
 
int pw(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)
            res = (ll)res * x % mod;
        x = (ll)x * x % mod;
        y >>= 1;
    }
    return res; 
}
 
void dfs(int u, int fa) {
    siz[u] = 1, mul[u] = 1;
    for (auto v : g[u]) 
        if (v != fa) {
            dfs(v, u);
            siz[u] += siz[v];
            mul[u] = (ll)mul[u] * mul[v] % mod;
        }
    mul[u] = (ll)mul[u] * siz[u] % mod;
}
 
void dfs2(int u, int fa, int fromFa) {
    if (u != 1)
        ans[u] = (ll)mul[u] * pw(siz[u], mod - 2) % mod * n % mod * fromFa % mod;
    else 
        ans[u] = (ll)mul[u] * fromFa % mod; 
    for (auto v : g[u]) 
        if (v != fa) {
            int tmp = (ll)fromFa * mul[u] % mod * pw(mul[v], mod - 2) % mod * pw(siz[u], mod - 2) % mod * (n - siz[v]) % mod;
            dfs2(v, u, tmp);
        }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 0);
    dfs2(1, 0, 1);
    int x = 1;
    for (int i = 1; i <= n; i++)
        x = (ll)x * i % mod;
    for (int i = 1; i <= n; i++)
        cout << (ll)x * pw(ans[i], mod - 2) % mod << '\n';
    return 0; 
}

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

bool test = true;
int tt = 1;
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(s) (int)(s.size())

struct fio
{
    fio()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(10);
    }
} fio;

const ll mod = (ll)(1e9 + 7);

long long powerf(ll a, ll b) {
	ll ret = 1;
	while(b > 0) {
		if(b % 2) {
			ret = (ret * a) % mod;
		}
		a = (a * a) % mod;
		b = b / 2;
	}
	return ret;
}

int main() 
{
    ll n;
    cin >> n;
    cout << (powerf(10LL, n) + powerf(8LL, n) - (2 * powerf(9LL, n)) % mod + mod) % mod;
}



Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    if(k==1){
	cout<<n*n*n<<endl;
    }else if(k%2==0){
	long long e = n/k;
	long long o = (n+k/2)/k;
	cout<<e*e*e+o*o*o<<endl;
    }else{
	long long c=n/k;
	cout<<c*c*c<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  int now=0;
  cin>>x;
  for(int i=1;i<1000000000;i++){
    now+=i;
    if(now>=x){
      cout<<i<<endl;
      return(0);
    }
  }
  return(0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0,_end_=(n); i<_end_;++i)
#define per(i,n) for(int i=(n)-1; i>=0 ; --i)
#define forn(i,l,r) for(int i=(l),_end_=(r); i<=_end_;++i)
using namespace std;
typedef long long ll;
const ll linf=1ll<<60;
const ll mod=1e9+7;
int n,m,K;
ll dp[21][1100005],pd[1100005][21];
int xjt[21][21],pw2[21];
inline void ADD(int &x,const int &y)
{
	x=(x+y<mod) ? (x+y) : (x+y-mod);
	return;
}
inline int lowbit(const int &i){ return i&(-i); }
void trans(int i)
{
	rep(s,1<<n)
	{
		memset(pd[s],0,sizeof(pd[s][0])*(n+1));
		bool f=1;
		rep(j,n) if(~xjt[i][j] && ((s>>j)&1) !=xjt[i][j]){ f=0; break; }
		pd[s][0]=(f ? dp[i-1][s] : 0);
	}
	ll tmp;
	rep(i,n) rep(s,1<<n) if(tmp=pd[s][i]) 
	{
		if(!((s>>i)&1))
		{
			int t=pw2[n]^pw2[i+1];
			t &=s;
			pd[s^lowbit(t)|(1<<i)][i+1]+=tmp;
		}
		pd[s][i+1]+=tmp;
	}
	rep(s,1<<n) dp[i][s]=pd[s][n]%mod;
	return;
}

int main()
{
	rep(i,21) pw2[i]=(1<<i)-1;
	scanf("%d%d%d",&n,&m,&K);
	memset(xjt,-1,sizeof xjt);
	rep(i,K)
	{
		int x,y;scanf("%d%d",&x,&y);
		scanf("%d",&xjt[x][y-1]);
	}
	--n;
	rep(s,1<<n) dp[0][s]=1;
	forn(i,1,m) trans(i);
	printf("%d\n",dp[m][(1<<n)-1]);
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b; cin>>a>>b;
  cout<<a*b<<endl;
  
}

Measured memory_bytes: 3556
from collections import deque
k = int(input())

ans = deque([i for i in range(1, 10)])


def generate_lunlun(x):
    y = x % 10
    if 0 <= y-1:
        yield 10*x + y-1
    yield 10*x + y
    if y+1 < 10:
        yield 10*x + y+1


cnt = 0
while True:
    x = ans.popleft()
    for i in generate_lunlun(x):
        ans.append(i)
    cnt += 1
    if cnt == k:
        print(x)
        break

Measured memory_bytes: 11980
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long s, xx1, yy1, xx2, yy2, xx3, yy3;
	cin >> s;
	xx1 = 0; yy1 = 0;
	xx2 = 1000000000; yy2 = 1;
	if (s % 1000000000 == 0) {
		yy3 = s / 1000000000;
		xx3 = 0;
	}
	else {
		yy3 = s / 1000000000 + 1;
		xx3 = yy3 * 1000000000 - s;
	}

	cout << xx1 << " " << yy1 << " " << xx2 << " " << yy2 << " " << xx3 << " " << yy3 << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

N = input()

for i in range(3):
    if N[i] == '7':
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 9156
import sys
input = sys.stdin.readline
def main():
  n=int(input())
  l=tuple(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      if now<=s:now=s+a
      else:now=(now+d-1)//d*d+a
    print(now)
if __name__=="__main__":
  main()

Measured memory_bytes: 3188
raw_time = int(raw_input())
 
if 0 <= raw_time < 86400:
    hour = raw_time / 3600
    min = (raw_time - hour * 3600) / 60
    sec = (raw_time - hour * 3600 - min * 60)
    print("%d:%d:%d")%(hour, min, sec)

Measured memory_bytes: 6420
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  if (s == "RRR")
    Cout(3);
  else {
    rep(i, Size(s) - 1) {
      string co = "";
      co += s[i];
      co += s[i + 1];
      if (co == "RR") {
        Cout(2);
        return 0;
      }
    }
    rep(i, Size(s)) {
      if (s[i] == 'R') {
        Cout(1);
        return 0;
      }
    }
    Cout(0);
  }
  return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict
dic=defaultdict(list)
while True:
    try:
        w,p=raw_input().split()
	dic[w].append(int(p))
    except EOFError:
	for w in sorted(dic):
            print w
            dic[w].sort()
            print " ".join(map(str,dic[w]))
	break

Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <array>

struct robot_t
{
	long long pos;
    long long range;
  	int sync_i;
  	int next;
  	long long comb;
  	robot_t() {}
  	robot_t(long long pos, long long range, int sync_i, int next, long long comb) : pos(pos), range(range), sync_i(sync_i), next(next), comb(comb) {}
};

int main()
{
  	int n = 0;
  	std::cin>>n;
  	std::vector<robot_t> robots(n);
    for(auto &robot : robots)
    {
        std::cin >> robot.pos >> robot.range;
    }
    std::sort(robots.begin(), robots.end(), [&](auto &&a, auto &&b)->bool{ return (a.pos != b.pos) ? (a.pos < b.pos) : (a.range < b.range); });
  	robots.emplace_back(1000000001LL, 1LL, n-1, 0, 1LL);
  	int j;
  	int sup;
  	for(int i = n-1; i >= 0; i--)
    {
      	auto &robot = robots[i];
      	sup = robot.pos + robot.range;
      	robot.sync_i = i;
      	j = i+1;
      	while(robots[j].pos < sup && j < n)
        {
          	if(robots[j].sync_i > robot.sync_i) robot.sync_i = robots[j].sync_i;
            j = robots[j].next;
        }
      	robot.next = j;
        robot.comb = (robots[robot.sync_i+1].comb + robots[i+1].comb) % 998244353LL;
    }
    std::cout << robots[0].comb << "\n";
    return 0;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    // cout << 5 / 3 << endl;

    if (((double)d / (double)s) <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  ll hm1 = 60 * h1 + m1;
  ll hm2 = 60 * h2 + m2;

  cout << hm2 - hm1 - k << endl;

  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		(new Solver()).Solve();
	}
}


public struct Range
{
	public int L;
	public int R;

	public Range(int l, int r)
	{
		L = l;
		R = r;
	}
}


public class Solver
{
	private int N;
	private int[] a;
	private int[] inv;
	private SegmentTree<int> st;

	public Solver()
	{
		N = GetInt();
		a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = GetInt() - 1;

		inv = new int[N];
		for(int i = 0; i < N; i++)
			inv[a[i]] = i;

		st = new SegmentTree<int>(N, int.MaxValue, (x, y) => (int)Math.Min(x, y));
		for(int i = 0; i < N; i++)
			st.Update(i, a[i]);
	}

	public void Solve()
	{
		long ans = 0;
		var queue = new Queue<Range>();
		queue.Enqueue(new Range(0, N));
		while(queue.Count > 0)
		{
			var range = queue.Dequeue();
			int l = range.L;
			int r = range.R;

			int min = st.Query(l, r);
			int i = inv[min];
			ans += (long)(min + 1) * (long)(i - l + 1) * (long)(r - i);

			if(i > l)
				queue.Enqueue(new Range(l, i));

			if(i + 1 < r)
				queue.Enqueue(new Range(i + 1, r));		
		}
		Console.WriteLine(ans);
	}
}


public class SegmentTree<T>
{
	private int N;
	private T INI;
	private Func<T, T, T> Func;
	private T[] dat;

	public SegmentTree(int n, T ini, Func<T, T, T> func)
	{
		N = 1;		
		while(N < n)
			N <<= 1;

		INI = ini;
		Func = func;
			
		dat = new T[2 * N - 1];
		for(int i = 0; i < 2 * N - 1; i++)
			dat[i] = INI;
	}

	public void Update(int k, T a)
	{
		k += N - 1;
		dat[k] = a;
		while(k > 0)
		{
			k = (k - 1) / 2;
			dat[k] = Func(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	public T Query(int a, int b, int k = 0, int l = 0, int r = -1)
	{
		if(r == -1)
			r = N;

		if(r <= a || b <= l)
			return INI;

		if(a <= l && r <= b)
			return dat[k];
		else
		{
			T vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = Query(a, b, k * 2 + 2, (l + r) / 2, r);
			return Func(vl, vr);
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 32092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long

int main(){
    int n,i,tmp,maxn,res;
    vector<ll> h;
    cin >> n;
    forN(i,n){
        cin >> tmp;
        h.push_back(tmp);
    }
    maxn = 0;
    res = 0;
    forN(i,n-1){
        if(h[i]>=h[i+1]) maxn++;
        else{
            res = max(maxn,res);
            maxn = 0;
        }
    }
    res = max(maxn,res);
    cout << res << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <math.h>
int main(void){
	int n,x[100],y[100],i,t;
	double d1=0,d2=0,d3=0,di=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	for(i=0;i<n;i++){
		t=x[i]-y[i];
		if(t<0)
			t=-t;
		d1+=t;
		d2+=t*t;
		d3+=t*t*t;
		if(di<t) di=t;
	}
	d2=pow(d2,1./2);
	d3=pow(d3,1./3);
	printf("%.6f\n%.6f\n%.6f\n%.6f\n",d1,d2,d3,di);
	return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
using namespace std;
string str;
ll n,d;
ll dp[10005][101][2];
int test = 0;
void print_mat(int idx)
{
	cout<<"index :"<<idx<<endl;
	cout<<"loose :"<<endl;

	for(int i=0;i<d;i++)
		cout<<i<<" : "<<dp[idx][i][0]<<endl;

	cout<<"tight :"<<endl;

	for(int i=0;i<d;i++)
		cout<<i<<" : "<<dp[idx][i][1]<<endl;

}
void foo()
{
	int val = str[n-1]-'0';


	memset(dp,0,sizeof(dp));

	for(int i=0;i<=9;i++)
	{
		dp[n-1][i%d][0]++;
	}

	for(int i=0;i<=val;i++)
	{
		dp[n-1][i%d][1]++;
	}

	for(ll idx=n-2;idx>=0;idx--)
	{
		if(test) print_mat(idx+1);

		val = str[idx]-'0';
		for(int i=0;i<=9;i++)
		{
			for(int j=0;j<d;j++)
			{
				dp[idx][(i+j)%d][0] = (dp[idx][(i+j)%d][0]+dp[idx+1][j][0])%mod;
				//if(dp[idx][(i+j)%d][0] < 0) dp[idx][(i+j)%d][0]+=mod;
				//else dp[idx][(i+j)%d][0] = dp[idx][(i+j)%d][0]%mod;
			}
		}

		for(int i=0;i<val;i++)
		{
			for(int j=0;j<d;j++)
			{
				dp[idx][(i+j)%d][1] = (dp[idx][(i+j)%d][1]+dp[idx+1][j][0])%mod;
				//if(dp[idx][(i+j)%d][1] <0) dp[idx][(i+j)%d][1]+=mod;
				//else dp[idx][(i+j)%d][1] = dp[idx][(i+j)%d][1]%mod;
			}
		}

		for(int j=0;j<d;j++)
		{
			dp[idx][(val+j)%d][1] = (dp[idx][(val+j)%d][1]+dp[idx+1][j][1])%mod;
			//if(dp[idx][(val+j)%d][1] < 0) dp[idx][(val+j)%d][1]+=mod;
			//else dp[idx][(val+j)%d][1] = dp[idx][(val+j)%d][1] % mod;
		}
	}


	ll ans = dp[0][0][1]-1;
	if(ans < 0) ans+=mod;
	cout<<ans<<endl;

}
int main()
{
	cin>>str;
	n = str.length();
	cin>>d;
	foo();
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000000;
using namespace std;
int n,m,a[11];
vector <int> coin;
int used[11];
void saiki(int sum,int k){
  for(int i=k;i<n;i++) {
    if(used[i]==1) continue;
    used[i]=1;
    coin.push_back(sum+a[i]);
    saiki(sum+a[i],i+1);
    used[i] = 0;
  }
}

int main() {
  while(1){
    cin >> n >> m;
    if(n==0&&m==0) break;
    coin.clear();
    for(int i=0;i<n;i++)cin >> a[i];
    saiki(0,0);

    int dp[100010]={};
    for(int i=1;i<=m;i++) dp[i] = INF;
    for(int i=0;i<coin.size();i++)
      for(int j=0;j<=m;j++)
	for(int k=1;j+coin[i]*k<=m && dp[j+coin[i]*k]>dp[j]+k;k++) dp[j+coin[i]*k] = dp[j]+k; 
    cout <<dp[m]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1616
import java.util.*;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc=new Scanner(System.in);
        //A();
        B();
        //C();
        //D();
    }
    public static void A(){
        int n=sc.nextInt();
        int m=sc.nextInt();
        System.out.println((n-2*m>0)?n-2*m:0);
    }
    public static void B(){
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        int sum=0;
        for(int i=0;i<n-1;i++)
            for(int j=i+1;j<n;j++)
                sum+=a[i]*a[j];
        System.out.println(sum);
    }
    public static void C(){
        int n=sc.nextInt();
        char []po=sc.next().toCharArray();
        char c=po[0];
        String a=""+c;
        for(int i=1;i<n;i++)
            if(c!=(c=po[i]))
                a+=c;
        System.out.println(a);
    }
    public static void D(){
        int n=sc.nextInt();
        int []a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        Arrays.sort(a);
        long ans=0;
        for(int i=0;i<n-2;i++){
            int kk=i+1;
            for(int j=i+1;j<n-1;j++){
                for(int k=(Math.max(kk,j));k<n;k++)
                    if(!(a[i]+a[j]>a[k]))
                        break;
                    else kk=k;
                ans+=kk-j;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21712
N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[2])
else:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int n,m,x;cin>>n>>m>>x;
	int ans = INF;
	vector<int> c(n);
	// for(int i = 0; i < n; i++) {
	// 	cin>>c[i];
	// }
	vector<vector<int>> a(n,vector<int>(m));
	for(int i = 0; i < n; i++) {
		cin>>c[i];
		for(int j = 0; j < m; j++) {
			cin>>a[i][j];
		}
	}
	for(int bit = 0; bit < 1 << n; bit++) {
		vector<int> b(n,0);
		int cost = 0;
		for(int i = 0; i < n; i++) {
			if ((bit >> i) & 1){
				cost += c[i];
				for(int j = 0; j < m; j++) {
					b[j] += a[i][j];
				}
			}
		}
		bool flag = true;
		for(int i = 0; i < m; i++) {
			if (b[i] < x){
				flag = false;
			}
		}
		if (flag){
			ans = min(ans,cost);
		}
	}
	if (ans == INF){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  int n, k;
  cin >> n >> k;

  if (n > k) {
    cout << 0 << endl;
    return 0;
  }

  auto factorials = MakeFactorialTable(n + k + 1);
  auto c_fn = [&factorials](int x, int y) {
    return factorials[x] / factorials[y] / factorials[x - y];
  };
  FiniteField value = c_fn(k, n);
  cout << value.Value() << endl;
}



Measured memory_bytes: 3160
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            if ((cin.ReadInt() * cin.ReadInt()) % 2 == 0)
            	WriteLine("Even");
            else
                WriteLine("Odd");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


Measured memory_bytes: 13268
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint comb(int n, int x) {
  mint p = 1, q = 1;
  rep(i, x) {
    p *= (n - i);
    q *= (i + 1);
  }
  return p / q;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint sum = mint(2).pow(n) - 1 - comb(n, a) - comb(n, b);
  cout << sum.x << endl;
  return 0;
}


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

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


void solve(long long P, long long Q, long long R){
    vector<ll>a(3);
    a[0]=P;
    a[1]=Q;
    a[2]=R;
    sort(a.begin(),a.end());

    cout<<a[0]+a[1]<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long P;
    scanf("%lld",&P);
    long long Q;
    scanf("%lld",&Q);
    long long R;
    scanf("%lld",&R);
    solve(P, Q, R);
    return 0;
}


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

int main(){
	int n,tot,x,y,z;
	cin>>n>>tot;
	
	for(x=0;x<=n;x++)
		for(y=0;y<=n;y++){
			z=n-x-y;
			if(z>=0&&x*10000+y*5000+z*1000==tot){
				cout<<x<<' '<<y<<' '<<z<<endl;
				return 0;
			}
		}
		cout<<"-1 -1 -1"<<endl;
		return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m,a[555][555]; bool s[555];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=m;++i) s[i]=1;
	int ans=1e9;
	for(int p=1;p<=m;++p)
	{
		int cnt[555];
		for(int j=1;j<=m;++j) cnt[j]=0;
		for(int i=1;i<=n;++i)
		{
			int r=0;
			for(int j=1;j<=m&&!r;++j)
				if(s[a[i][j]]) r=a[i][j];
			++cnt[r];
		}
		pii mx(-1,-1);
		for(int j=1;j<=m;++j)
			mx=max(mx,pii(cnt[j],j));
		int sb=mx.se; s[sb]=0;
		ans=min(ans,mx.fi);
	}
	printf("%d\n",ans);
}


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

const ll mod = 1000000007;
struct mint{
  ll v;
  mint(ll a=0):v((a%mod+mod)%mod){}
  mint operator-() const {
    return mint(-v);
  }
  mint& operator+=(const mint a){
    if ((v += a.v) >= mod) v -= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if ((v += mod - a.v) >= mod) v -= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (v *= a.v) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  // 2^t
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }

  // for prime mod
  // Fermat's little theorem : a^(p-1) = 1 (mod p) when p is prime and a = 1 (mod p)
  mint inv() const {
    return pow(mod - 2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }

  // k < 10^6, n < 10^9
  static mint comb(ll n, int k){
    mint num(1), den(1);
    for(int i=0; i<k; i++){
      num *= mint(n-i);
      den *= mint(i+1);
    }
    return num / den;
  }
};

// for cout << 
ostream& operator<<(ostream& stream, const mint a){
  stream << a.v;
  return stream;
}

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

  mint ans(2), ca, cb;
  ans = ans.pow(n);
  ca = ca.comb(n, a);
  cb = cb.comb(n, b);
  ans = ans - 1 - ca - cb;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

inline int addmod(int a, int b) { return (a + b) % MOD; }

int n, m;
int f[MAXN][MAXN][2];

inline int get(int i, int j, int k) {
    if(0 <= j && j <= n) {
        return f[i][j][k];
    }
    return 0;
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) f[0][i][0] = 1;
    f[0][0][1] = 1;
    for(int i = 1; i <= m; i++) {
        for(int j = 0; j <= n; j++) {
            int a = get(i - 1, j + 1, 0);
            int b = get(i - 1, j, 0);
            int c = get(i - 1, j - 1, 0);

            int x = get(i - 1, j + 1, 1);
            int y = get(i - 1, j, 1);
            int z = get(i - 1, j - 1, 1);

            if(j != 0) {
                f[i][j][0] = addmod(f[i][j][0], a);
                f[i][j][0] = addmod(f[i][j][0], c);
                if(j != n) {
                    f[i][j][0] = addmod(f[i][j][0], b);
                }
                if(j != 1) {
                    f[i][j][0] = addmod(f[i][j][0], b);
                }
            }

            f[i][j][1] = addmod(f[i][j][1], x);
            f[i][j][1] = addmod(f[i][j][1], z);
            if(j != n) {
                f[i][j][1] = addmod(f[i][j][1], y);
            }
            if(j != 0) {
                f[i][j][1] = addmod(f[i][j][1], y);
            }
            if(j == 0) {
                f[i][j][1] = addmod(f[i][j][1], a);
                f[i][j][1] = addmod(f[i][j][1], c);
                f[i][j][1] = addmod(f[i][j][1], b);
            }
            if(j == 1) {
                f[i][j][1] = addmod(f[i][j][1], b);
            }

        }
    }
    int ans = 0;
    for(int j = 0; j <= n; j++) ans = addmod(ans, f[m][j][1]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 2e5 + 5;
ll f[maxn], invf[maxn];
ll power(ll a, ll p){
    if(p == 0) return 1;
    if(p == 1) return a % mod;
    if(p & 1) return a * power(a, p - 1) % mod;
    ll r = power(a, p / 2);
    return r * r % mod;
}
void gen(){
    f[0] = invf[0] = 1;
    for(ll i = 1; i < maxn; i++){
        f[i] = i * f[i-1] % mod;
        invf[i] = power(i, mod - 2) * invf[i-1] % mod;
    }
}
ll C(ll n, ll r){
    ll ret = f[n];
    ret *= invf[n - r];
    ret %= mod;
    ret *= invf[r];
    ret %= mod;
    return ret;
}

int main() {
    gen();
    IO;
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        ll val = C(n - 1, i);
        val *= power(m - 1, n - i - 1);
        ans += (val % mod);
        ans %= mod;
    }
    cout << ans * m % mod << '\n';
    return 0;
}
/*
5 1000000
4 5 2 3 5
 */

Measured memory_bytes: 6780
#include<stdio.h>
#include<math.h>
int main(void) {
	
	int i,j,num,s1,s2,min=0;
	int w[100] = { 0 };
	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf("%d", &w[i]);
		min += w[i];
	}

	for (i = 0; i < num-1; i++) {
		s1 = s2 = 0;
		for (j = 0; j <= i; j++) {
			s1 += w[j];
		}
		for (j = i + 1; j < num; j++) {
			s2 += w[j];
		}
		if (abs(s1 - s2) < min) {
			min = abs(s1 - s2);
		}
	}
	printf("%d", min);

	return 0;
}

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

typedef long long ll;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    
    for(int i=0; i<N; i++){
        int a; cin >> a;
        A[i] = a-i-1;
    }
    
    sort(A.begin(), A.end());
    
    int x = A[N/2];
    ll ans = 0;
    for(int i=0; i<N; i++)
        ans += abs(A[i]-x);
        
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))
H_memo = [1]*N
for _ in range(M):
    Ai, Bi = map(int, input().split())
    if H[Ai-1] > H[Bi-1]:
        H_memo[Bi-1] = 0
    elif H[Ai-1] < H[Bi-1]:
        H_memo[Ai-1] = 0
    else:
        H_memo[Bi-1] = 0
        H_memo[Ai-1] = 0
print(sum(H_memo))


Measured memory_bytes: 20108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n,i,m;
cin>>n;
map<ll,ll> mp;
for(i=0;i<n-1;i++)
{
cin>>m;
mp[m]++;
}
for(i=1;i<=n;i++)
    cout<<mp[i]<<endl;
    return 0;
}



Measured memory_bytes: 16136
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
bool bar[35][15];
int v[15][35];
int n,m,p,d;
int main()
{
	while(1)
	{
		for(int i=0;i<35;i++)
		{
			for(int j=0;j<15;j++)
			{
				bar[i][j]=false;
				v[j][i]=0;
			}
		}
		cin >> n;
		if(n==0)break;
		cin >> m;
		cin >> p;
		cin >> d;
		for(int i=0;i<d;i++)
		{
			string s;
			cin >> s;
			for(int j=0;j<s.size();j++)
			{
				if(s[j]=='1')bar[i+1][j+1]=true;
			}
		}
		for(int i=1;i<=n;i++)
		{
			v[i][0]=i;
		}
		for(int i=1;i<=d;i++)
		{
			for(int j=1;j<=n;j++)
			{
				v[j][i]=v[j][i-1];
			}
			for(int j=1;j<n;j++)
			{
				if(bar[i][j])swap(v[j][i],v[j+1][i]);
			}
		}
		if(v[p][d]==m)
		{
			cout << 0 << endl;
			continue;
		}
		for(int i=1;i<=d;i++)
		{
			for(int j=1;j<n;j++)
			{
				if(!bar[i][j-1]&&!bar[i][j]&&!bar[i][j+1]&&((v[j][i]==v[p][d]&&v[j+1][i]==m)||(v[j][i]==m&&v[j+1][i]==v[p][d])))
				{
					cout << i << ' ' << j << endl;
					goto end;
				}
			}
		}
		cout << 1 << endl;
		end: continue;
	}
	return 0;
}

Measured memory_bytes: 1208
use std::io::{stdin, Read};
use std::str::FromStr;
#[allow(unused_imports)]
use std::{cmp, mem, process};
#[allow(unused_imports)]
use std::collections::{HashSet, BTreeMap, BTreeSet};
static mut sum: usize = 0;
unsafe fn dfs(u: usize, p: usize, e: &Vec<Vec<usize>>, k: usize, flag: &Vec<bool>) -> usize {
    let mut height = 1;
    for to in &e[u].clone() {
        if *to == p {
            continue;
        }
        height = cmp::max(height, dfs(*to, u, &e, k, &flag) + 1);
    }
    //println!("{}:{}", u, height);
    if height == k && u != 0 && !flag[u] {
        sum += 1;
        0
    } else {
        height
    }
}
fn main() {
    unsafe {
        let n = read::<usize>();
        let k = read::<usize>();
        let mut a = read_vec::<usize>(n);
        let mut rev_e = vec![vec![]; n];
        for i in &mut a {
            *i -= 1;
        }
        if a[0] != 0 {
            sum += 1;
            a[0] = 1;
        }
        let mut flag = vec![false; n];
        for i in 1..a.len() {
            if a[i] == 0 {
                flag[i] = true;
            }
            rev_e[a[i]].push(i);
        }
        let mut dep = vec![0; n];
        dfs(0, n, &rev_e, k, &flag);
        println!("{}", sum);
    }

}


#[allow(dead_code)]
fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for _ in 0..n {
        let a = read::<T>();
        v.push(a);
    }
    v
}
#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}


Measured memory_bytes: 23420
#include<stdio.h>

int main(void){
	int n,k,c,cc,tmp,c_max;
	int card[102];
	int i,j,l,m;

	while(scanf("%d %d",&n,&k) && n != 0 && k != 0){
		for(i=0;i<n;i++)
			scanf("%d",&card[i]);
		c_max=0;
		cc = 0;
		tmp = 1;
		for(i=0;i<=n-k;i++){
			for(j=i;j<k+i;j++){
				tmp*=card[j];
			}
			if(tmp > cc)
				cc = tmp;
			tmp=1;
		}

		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				tmp = card[i];
				card[i] = card[j];
				card[j] = tmp;

				c = 1;
				for(l=0;l<=n-k;l++){
					for(m=l;m<k+l;m++){
						c*=card[m];
					}
					if(c > c_max)
						c_max = c;
					c=1;
				}

				tmp = card[i];
				card[i] = card[j];
				card[j] = tmp;
			}
		}
	
		if(c_max - cc >= 0)
			printf("%d\n",c_max-cc);
		else
			printf("NO GAME\n");
	}
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a+b+1) /2 << endl;
    return 0;
}



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


std::vector<int> pre, in;
int pos;
std::vector<int> tmp;

int reconstruction(int l, int r){
    if(l == r){
        return 0;
    }

    int c = pre[pos++];
    int m = std::distance(in.begin(), find(in.begin(), in.end(), c));
    reconstruction(l, m);
    reconstruction(m+1, r);

    //std::cout << c << std::endl;
    tmp.push_back(c);
}

int main(void){

    int n;
    std::cin >> n;
    pos = 0;
    pre.resize(n);
    in.resize(n);
    for(int i = 0; i < n; i++){
        std::cin >> pre[i];
    }

    for(int i = 0; i < n; i++){
        std::cin >> in[i];
    }

    reconstruction(0, n);
    for(int i = 0; i < n; i++){
        if(i != 0) std::cout << " ";
        std::cout << tmp[i];
    }
    std::cout << std::endl;



    return 0;
}


Measured memory_bytes: 3168