akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    
    int ans = 0;
    ans = ans + N * ( N - 1 ) / 2;
    ans = ans + M * ( M - 1 ) / 2;
    cout << ans << endl;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


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

    for (int i = a; i <= b; i++) {
        if (i < a+k or i > b-k) cout << i << endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int n;
    int i,j;
    int f;
    scanf("%d", &n);
    f = 0;
    for(i = 1;i < 10;i ++){
        if(n % i == 0 && n / i < 10){
            f = 1;
            break;
        }
    }
    if(f == 1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

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

int main() {
    int N,K;
    string S;
    cin >> N>>K>>S;
    if(S.at(K-1) == 'A') S.at(K-1) = 'a';
    else if(S.at(K-1) == 'B') S.at(K-1) = 'b';
    else S.at(K-1) = 'c';
    cout << S <<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  string S; cin>>S;
  vector<int>A(N-1);
  for(int i=0;i<N-1;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='C')A[i]++;
    A[i]+=A[i-1];
  }
  for(int i=0;i<K;i++){
    int a,b; cin>>a>>b;
    cout<<A[b-2]-A[a-2]<<endl;
  }
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;

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

    int odd = 0;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (a % 2 == 1)
            odd++;
    }

    if (odd % 2 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

int main() {
  int array[5], mod[5];
  for (int i = 0; i < 5; ++i) {
    cin >> array[i];
    mod[i] = array[i] % 10;
  }
  
  int sum = 0;
  int min_mod = 9;
  int min_index = -1;
  for (int i = 0; i < 5; ++i) {
    if (mod[i] == 0)
      sum += array[i];
    else if (min_mod >= mod[i]) {
      min_mod = mod[i];
      min_index = i;
    }
  }
  
  for (int i = 0; i < 5; ++i) {
    if (mod[i] && i != min_index)
      sum += (array[i] + 10) / 10 * 10;
  }
  
  if (min_index != -1)
    sum += array[min_index];
  
  cout << sum << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<map>
typedef long long ll;
using namespace std;
ll maxheight(int nod,vector<int> &dp,map<int,vector<int>> &graph)
{
    if(graph[nod].size()==0)
        return 0;
    else if(dp[nod-1]!=0)
        return dp[nod-1];
    else
    {
        ll x=0;
        for (ll i=0;i<ll(graph[nod].size());i++)
        {
            x=max(1+maxheight(graph[nod][i],dp,graph),x);
        }
        dp[nod-1]=x;
        //cout<<nod-1<<" "<<x<<endl;
        return x;
    }
}
int main()
{
    ll vert,edg,x,y;
    cin>>vert>>edg;
    map<int,vector<int>> graph;
    vector<int> dp (vert,0);
    for (int i=0;i<edg;i++)
    {
        cin>>x>>y;
        graph[x].push_back(y);
    }
    ll ans=0;
    for (int i=0;i<vert;i++)
    {
        ans=max(ans,maxheight(i+1,dp,graph));
    }
    cout<<ans;
}

Measured memory_bytes: 16384
import math
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    # mean
    mean = sum(a)/len(a)
    # variance
    for i in range(len(a)):
        a[i] = a[i] - mean
        a[i] = a[i]**2
    vari = sum(a)/len(a)
    s_devi = math.sqrt(vari)
    print(s_devi)


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

int main() {
    string S;
    cin >> S;
    int top = 0;
    for(int i=0; i<3; i++){
        if(S.at(i)=='o') top++;
    }
    cout << 700 + 100*top << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int X;
  cin >> X;
  int ans = 10 - X / 200;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

#define MOD 1000000007

using namespace std;

#define MAX 200001 //2 * 10^6 ここを最低限にしておかないと絶対にいらない計算をやっちゃう
#define MOD 1000000007

using namespace std;

long fac[MAX];
long finv[MAX];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void fac_table(){
    fac[0] = 1;
    for(int i=1; i<MAX; i++){
        fac[i] = fac[i-1] * i;
        fac[i] %= MOD;
    }
}


long comb(int n, int k){
    if(k == 1) return n;
    else {
        long ans = comb(n, k-1) * (n-k+1);
        ans %= MOD;
        ans *= modinv(k, MOD);
        ans %= MOD;
        return ans;
    }
}



long q_pow(long x, long n){
    if(n == 0) return 1;
    if(n==1) return x;
    else if(n%2 == 0) return q_pow(x*x%MOD, n/2);
    else return x * q_pow(x, n-1) % MOD;
}

int main(){
    long n, a, b;
    cin >> n >> a >> b;
    cout << (q_pow(2, n) - comb(n, a) - comb(n, b) - 1 + 2 * MOD) % MOD << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define bk back()
#define pb push_back

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(x,a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
    // cin.exceptions(cin.failbit);
    // throws exception when do smth illegal
    // ex. try to read letter into int
    if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int dp[600][MX];

int32_t main() {

    setIO();

    int N; cin >> N;

    vi v(N),w(N);
    F0R(i,N) cin >> v[i] >> w[i];

    int lim = min(512,N);
    F0R(i,MX) {
        dp[0][i] = (i >= w[0] ? v[0] : 0);
    }

    FOR(i,1,lim) {
        int par  = (i-1)/2;
        F0R(j,MX) {
            dp[i][j] = dp[par][j];
            if (j >= w[i]) {
                dp[i][j] = max(dp[i][j],dp[par][j-w[i]]+v[i]);
            }
        }
    }

    int t; cin >> t;
    
    while(t--) {
        int ver,L; cin >> ver >> L;
        --ver;

        vi arr;
        while(ver >= lim) {
            arr.pb(ver); ver = (ver-1)/2;
        }

        int n = sz(arr); ll res = 0;
        F0R(mask,1<<n) {
            ll sv = 0, sw = 0;
            F0R(i,n) {
                if (mask&(1<<i)) {
                    sv += v[arr[i]];
                    sw += w[arr[i]];
                }
            }

            if (sw <= L) {
                res = max(res,dp[ver][L-sw]+sv);
            }
        }

        cout << res << "\n";
    }
}


Measured memory_bytes: 405308
#include <iostream>

using namespace std;

int main() {
    int N, X[110], sum = 0, P = 0, ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        sum += X[i];
    }
    P = (int) (1.0 * sum / N + 0.5);
    for (int i = 0; i < N; i++) {
        ans += (X[i] - P) * (X[i] - P);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }
ll a[200000];

int main() {
    init();
	int n, k;
	cin >> n >> k;
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, n - k) {
		if (a[i] >= a[i + k]) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 5152
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
    x=(po(10,n)+po(8,n))%mod;
    x=(x-2ll*po(9,n))%mod;
    x+=mod;
    x%=mod;
    
    
    cout<< x <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3692
/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

class Main {
    public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] dp = new int[3];
		dp[0] = s.charAt(0)=='R'?1:0;
		int max = dp[0];
		for(int i = 1; i<s.length(); i++) {
		    dp[i] = s.charAt(i)=='R'?dp[i-1]+1:0;
		    max = Math.max(max, dp[i]);
		}
		System.out.println(max);
	}
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, V[int(1e5+5)];
Pii cnt1[int(1e5+5)], cnt2[int(1e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> V[i];
    if (i % 2 == 0){
      cnt1[V[i]].fi++;
    }else{
      cnt2[V[i]].fi++;
    }
  }

  for (int i = 0; i <= 1e5; i++){
    cnt1[i].se = i;
    cnt2[i].se = i;
  }
  sort(cnt1, cnt1 + int(1e5+1), greater<Pii>());
  sort(cnt2, cnt2 + int(1e5+1), greater<Pii>());

  int ans;
  if (cnt1[0].se != cnt2[0].se){
    ans = N - (cnt1[0].fi + cnt2[0].fi); 
  }else{
    ans = N - max(cnt1[1].fi+cnt2[0].fi, cnt1[0].fi+cnt2[1].fi);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 5544
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

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

int main() {
    string s;
    cin >> s;
    if(s == "SAT") cout << 1;
    else if(s == "SUN") cout << 7;
    else if(s == "MON") cout << 6;
    else if(s == "TUE") cout << 5;
    else if(s == "WED") cout << 4;
    else if(s == "THU") cout << 3;
    else if(s == "FRI") cout << 2;
}


Measured memory_bytes: 256
import itertools
class dice():
    def __init__(self,number):
        self.number = number
 
    def korokoro(self,com):
        if com == 'E':
            self.number = [self.number[i] for i in [3,1,0,5,4,2]]
        if com == 'S':
            self.number = [self.number[i] for i in [4,0,2,3,5,1]]
        if com == 'N':
            self.number = [self.number[i] for i in [1,5,2,3,0,4]]
        if com == 'W':
            self.number = [self.number[i] for i in [2,1,5,0,4,3]]
def checker(d1,d2):
    for com in 'EEEENEEEENEEEENEEEENWSEEEENNEEEE':
        d1.korokoro(com)
        if d1.number == d2.number:
            ans = 'Yes'
            break
        else:
            ans = 'No'
    return ans
n = int(input())
saikoro = {}
for _ in range(n):
    saikoro[_] = dice([int(x) for x in input().split()])
l = list(itertools.combinations(saikoro.keys(),2))
for __ in l:
    test1 = saikoro[__[0]]
    test2 = saikoro[__[1]]
    if checker(test1,test2) == 'Yes':
        answer = 'No'
        break
    else:
        answer = 'Yes'
print(answer)



Measured memory_bytes: 5996
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;

long long a[20000],r,m,n,dis[500][500];
long long x,y,c;
long long ans,minn;

int main(){
	cin>>n>>m>>r;
	for(int i=1;i<=r;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++) dis[i][j]=0x3f3f3f3f;
	for(int i=1;i<=m;i++){
		cin>>x>>y>>c;
		dis[x][y]=c;
		dis[y][x]=c;
	}	
		for(int i=1;i<=n;i++) dis[i][i]=0;
	for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++){
		dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	}
	ans=0x7fffffff;
	int rk[233];
	for (int i=1; i<=r; i++) {
		rk[i]=i;
	}
	do {
		long long minn=0;
		for (int i=2; i<=r; i++) {
			minn+=dis[a[rk[i-1]]][a[rk[i]]];
		}
		ans=min(minn, ans);
	} while (next_permutation(rk+1, rk+1+r));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var a = int.Parse(s.Substring(0,2));
            var b = int.Parse(s.Substring(2,2));

            if((1 <= a && a <= 12) && (1 <= b && b <= 12)){
                Console.WriteLine("AMBIGUOUS");
            }else if(1 <= b && b <= 12){
                Console.WriteLine("YYMM");
            }else if(1 <= a && a <= 12){
                Console.WriteLine("MMYY");
            }else{
                Console.WriteLine("NA");
            }
        }
    }
}


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

template<typename T> struct Dinic{
	struct edge{
		int to,rev;
		T cap;
	};
	vector< vector<edge> > G;
	vector<int> level,iter;
	void init(int n){
		G.assign(n,vector<edge>());
		level.assign(n,0);
		iter.assign(n,0);
	}
	void add_edge(int from,int to,T cap){
		G [from].push_back(edge{to,int(G [to].size()),cap});
		G [to].push_back(edge{from,int(G [from].size()) - 1,0});
	}
	void bfs(int s){
		fill(level.begin(),level.end(),-1);
		queue<int> q;
		level [s] = 0;
		q.push(s);
		while(q.empty() == false){
			int curr = q.front();
			q.pop();
			for(int i = 0;i < int(G [curr].size());i++){
				edge& e = G [curr] [i];
				if(e.cap > 0 && level [e.to] < 0){
					level [e.to] = level [curr] + 1;
					q.push(e.to);
				}
			}
		}
	}
	T dfs(int curr,int t,T f){
		if(curr == t) return f;
		for(int& i = iter [curr];i < int(G [curr].size());i++){
			edge& e = G [curr] [i];
			if(e.cap > 0 && level [e.to] > level [curr]){
				T d = dfs(e.to,t,min<T>(f,e.cap));
				if(d == 0) continue;
				e.cap -= d;
				G [e.to] [e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
	T max_flow(int s,int t){
		T flow = 0,d;
		while(true){
			bfs(s);
			if(level [t] < 0) break;
			fill(iter.begin(),iter.end(),0);
			while((d = dfs(s,t,numeric_limits<T>::max())) > 0) flow += d;
		}
		return flow;
	}
};

int N;
vector<ll> A;
const ll INF = 1e17;

int main()
{
	scanf("%d",&N);
	A.assign(N,0ll);
	FOR(i,0,N){
		scanf("%lld",&A [i]);
	}

	Dinic<ll> din;
	din.init(N + 2);
	int s = 0,t = N + 1;

	ll ans = 0;
	FOR(i,1,N + 1){
		if(A [i - 1] >= 0){
			ans += A [i - 1];
			din.add_edge(s,i,A [i - 1]);
			din.add_edge(i,t,0);
		}
		else{
			din.add_edge(s,i,0);
			din.add_edge(i,t,-A [i - 1]);
		}
		for(int j = i * 2;j <= N;j += i){
			din.add_edge(j,i,INF);
		}
	}
	ans -= din.max_flow(s,t);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string s, t, u;
    int a, b;
    
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    
    if(u == s){
        cout << a - 1 << ' ' << b;
    }
    else{
        cout << a << ' ' << b - 1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>{std::forward<T>(func)};
}

int main() {
  int N;
  std::cin >> N;
  std::vector<std::vector<int>> graph(N);
  for (int i: range(0, N - 1)) {
    int x, y;
    std::cin >> x >> y;
    --x; --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  std::cout << (make_fix_point([&](auto &&dfs, int u, int p) -> int {
    int grundy = 0;
    for (int v: graph[u]) {
      if (v != p) {
        grundy ^= dfs(v, u) + 1;
      }
    }
    return grundy;
  })(0, -1) > 0 ? "Alice" : "Bob") << '\n';
  return 0;
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u)a--;
    if(t == u)b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3608
A,B,M = map(int,input().split())

reizouko = list(map(int,input().split()))
renji = list(map(int,input().split()))

kupon_min = 10**11

for i in range(M):
    x,y,c = map(int,input().split())
    kupon_min = min(kupon_min,reizouko[x-1] + renji[y-1] - c)

normal_min = min(reizouko) + min(renji)

print(min(normal_min,kupon_min))

Measured memory_bytes: 18736
a = input().split(" ")

x = [int(a[0]),int(a[1])]
y = [int(a[2]),int(a[3])]

ans = []

for i in x:
  for j in y:
    s = i*j
    
    ans.append(s)
ans.sort(reverse = True)  
print(ans[0])

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

const int str_MAX = 101;
char s[str_MAX], p[str_MAX];
char str[str_MAX * 2] = {};

int main(){
	cin >> s;
	cin >> p;
	strcpy(str, s);
	strcat(str, s);
	if (strstr(str,p)==NULL){
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3092
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = sorted(LIST(), reverse=True)

h = 0
w = 0
reg = n-1
for i in range(n-1):
   if a[i] == a[i+1]:
        h = a[i]
        reg = i
        break
for i in range(reg+2, n-1):
   if a[i] == a[i+1]:
        w = a[i]
        break

print(h*w)

Measured memory_bytes: 21312
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] ABCD = readln.chomp.split.to!(int[]);
  int A = ABCD[0],
      B = ABCD[1],
      C = ABCD[2],
      D = ABCD[3];
  int L = A + B,
      R = C + D;

  if (L > R) {
    writeln("Left");
  } else if (L == R) {
    writeln("Balanced");
  } else {
    writeln("Right");
  }
}


Measured memory_bytes: 256
import scala.io.StdIn._
import java.io.PrintWriter
import java.util.Arrays
object Main extends App {
  val sr = new StdinReader
  val n, m = sr.nextInt
  case class City(id: Int, p: Int, year: Int, var no: Int = 0)
  val pys = (1 to m).map{i => City(i, sr.nextInt, sr.nextInt)}
  def numbering(cities: Seq[City]): Unit =
    cities.sortBy(_.year).zipWithIndex.foreach {case (c, no) => c.no = no + 1}
  val pyMap = pys.groupBy(_.p).values.foreach(numbering)
  val w = new PrintWriter(System.out)
  val f = new java.text.DecimalFormat("000000000000")
  pys.foreach {c => w.println(f.format(c.p * 1000000L + c.no)) }
  w.flush
}

class StdinReader {
  val is = System.in
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = is.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  def nextInt: Int = {
    @scala.annotation.tailrec
    def r(i: Int, reading: Boolean): Int = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0, false)
  }
}

Measured memory_bytes: 129332
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    if(sum==1)
        printf("10\n");
    else
        printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
*s, = map(int, list(input()))
gap = len(s)
ans = 0
for i in range(2 ** (gap - 1)): # x通り出てくる
    fmr = ""
    for j in range(gap):
        fmr += str(s[j])
        if (i >> j) & 1:
            fmr += "+"
    ans += eval(fmr)
print(ans)

Measured memory_bytes: 3188
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define cmax(_i,_j) ((_i)<(_j)?(_i)=(_j):0)
#define cmin(_i,_j) ((_i)>(_j)?(_i)=(_j):0)
#define N 200005
using namespace std;
namespace runzhe2000
{
	int n, a[N];
	void main()
	{
		scanf("%d",&n);
		for(int i = 1; i <= n; i++) scanf("%d",&a[i]), a[i] -= i;
		sort(a+1, a+1+n); int x = a[n/2+1]; long long ans = 0;
		for(int i = 1; i <= n; i++) ans += abs(x-a[i]);
		printf("%lld\n",ans);
	}
}
int main()
{
	runzhe2000::main();
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define INF 1000000000

typedef pair<int, int> Pii;
typedef pair<int, Pii> P; // time, town, coldtime

struct edge {int to, cost; };

int coldtown[110];
int d[110][110];

int main() {
    while(true) {
        int n, m, l, k, a, h;
        cin >> n >> m >> l >> k >> a >> h;
        if (n == 0) break;

        vector<edge> g[110];
        // initialization
        REP(i, n) {
            REP(j, m+1) {
                d[i][j] = INF;
            }
        }
        d[h][0] = 0;

        // cold town
        REP(i, n) coldtown[i] = 0;
        REP(i, l) {
            int idx;
            cin >> idx;
            coldtown[idx] = 1;
        }

        REP(i, k) {
            int x, y, t;
            cin >> x >> y >> t;

            edge e1;
            e1.to = y;
            e1.cost = t;
            g[x].push_back(e1);

            edge e2;
            e2.to = x;
            e2.cost = t;
            g[y].push_back(e2);
        }

        // dijkstra
        priority_queue<P> que;
        P p = P(0, Pii(h, 0));
        que.push(p);

        while(!que.empty()) {
            P p = que.top(); que.pop();
            int time = p.first;
            int town = p.second.first;
            int ctime = p.second.second;
            if (d[town][ctime] < time) continue;

            REP(i, g[town].size()) {
                int to = g[town][i].to;
                int cost = g[town][i].cost;

                if (m < ctime + cost) continue; // cannot achieve
                
                int ntime, nctime;
                if (coldtown[to]) {
                    ntime = time + cost + (cost + ctime);
                    nctime = 0;
                } else {
                    ntime = time + cost;
                    nctime = ctime + cost;
                }
                if (d[to][nctime] > ntime) {
                    d[to][nctime] = ntime;
                    que.push(P(ntime, Pii(to, nctime)));
                }
            }
        }

        int output = INF;
        REP(i, m+1) {
            if (d[a][i] != INF) {
                int ctime = (d[a][i] - i) / 2;
                output = min(d[a][i] - min(ctime, m-i), output);
            }
        }

        if (output == INF) {
            cout << "Help!" << endl;
        } else {
            cout << output << endl;
        }
    }
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int X,Y,Z,ans;
  cin>>X>>Y>>Z;
  for(int i=0;;i++){
  	if(X<Y*i+Z*(i+1)){
      ans=i-1;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
const ver : array[1..4] of ansistring = ('AC', 'WA', 'TLE', 'RE'); 
var n, i, j : longint;
    s : ansistring;
    c : array[1..4] of longint;

begin
    readln(n);
    fillchar(c, sizeof(c), 0);
    for i := 1 to n do 
    begin
        readln(s);
        for j := 1 to 4 do
        begin
            if (s = ver[j]) then inc(c[j]);
        end;
    end;
    for i := 1 to 4 do writeln(ver[i], ' x ', c[i]);
end.

Measured memory_bytes: 1372
import fractions

a, b, c, d = map(int, input().split())

def get_muls(n):
    return (b // n) - ((a - 1) // n)

res = b - (a - 1) - get_muls(c) - get_muls(d) + get_muls(c * d // fractions.gcd(c, d))
print(res)

Measured memory_bytes: 5048
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define INT INT_MAX
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int M = 1e5 + 1;
int N, W;
int wt[M], val[M];

// Top-Down Solution = Remove read-only arguments and redundant arguments
// and cache the results
// Time = (Range of possible values of the variable arguments) * (Time Compl of each function call)
// O(N * Weight) Time (Pseudo Polynomial)
// O(N * Weight) Space
int Top_Down(vector<vector<int>> dp, int i, int curr_w=W) {
    // Base Cases
    if(i == 0 || curr_w == 0) return 0;

    if(dp[i][curr_w] != -1) return dp[i][curr_w];

    // Choice
    if(wt[i] > curr_w)
        return Top_Down(dp, i-1, curr_w);

    int incl = Top_Down(dp, i-1, curr_w - wt[i]) + val[i];
    int excl = Top_Down(dp, i-1, curr_w);

    return (dp[i][curr_w] = max(incl, excl));
}

// O(N * Weight) Time & Space
int Bottom_Up() {
    vector<vector<int>> dp(N+1, vector<int>(W+1, 0));
    for(int i = 1; i <= N; ++i) {
        for(int curr_w = 1; curr_w <= W; ++curr_w) {
            if(wt[i] > curr_w) {
                dp[i][curr_w] = dp[i-1][curr_w];
                continue;
            }
            int incl = dp[i-1][curr_w - wt[i]] + val[i];
            int excl = dp[i-1][curr_w];
            dp[i][curr_w] = max(incl, excl);
        }
    }
    return dp[N][W];
}

// O(N * Weight) Time | O(Weight) Space using 2 Arrays
int Bottom_Up2() {
    vector<int> dpi_1(W+1, 0);
    vector<int> dpi(W+1, 0);
    for(int i = 1; i <= N; ++i) {
        for(int curr_w = 1; curr_w <= W; ++curr_w) {
            if(wt[i] > curr_w) {
                dpi[curr_w] = dpi_1[curr_w];
                continue;
            }
            int incl = dpi_1[curr_w - wt[i]] + val[i];
            int excl = dpi_1[curr_w];
            dpi[curr_w] = max(incl, excl);
        }
        dpi_1 = dpi;
    }
    return dpi[W];
}

// O(N * Weight) Time | O(Weight) Space using 1 Arrays
int Bottom_Up3() {
    vector<int> dp(W+1, 0);
    for(int i = 1; i <= N; ++i) {
        for(int curr_W = W; curr_W >= 1; --curr_W) {
            if(wt[i] <= curr_W) {
                dp[curr_W] = max(dp[curr_W],
                                dp[curr_W - wt[i]] + val[i]);
            }
        }
    }
    return dp[W];
}

int32_t main() {
    IOS;
    cin >> N >> W;
    // vector<vector<int>> dp(N+1, vector<int>(W+1, -1));
    for(int i = 1; i <= N; ++i) {cin >> wt[i]; cin >> val[i];}
    cout << Bottom_Up3() << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int sum(int x) {
    int s = 0;
    while (x > 0) {
        s += x % 10;
        x /= 10;
    }
    return s;
}

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int res = MAX_INT;
    for (int i = 1 ; i < n; i++) {
        int j = n - i;
        int s = sum(i) + sum(j);
        res = std::min(res, s);

    }
    cout << res;

    return 0;
}

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

int main() {
   int n;
   cin >> n;
   vector<vector<int>> G(n+1);
   for (int i=0; i<n; i++) {
       int u,k;
       cin >> u >> k;
       for (int j=0; j<k; j++) {
           int v;
           cin >> v;
           G[u].push_back(v);
       }
   }
   vector<int> c(n+1,-1);
   queue<int> q;
   q.push(1);
   c[1]=0;
   while(!q.empty()) {
       int a=q.front();
       q.pop();
       for (auto b:G[a]){
           if (c[b]==-1) {
           q.push(b);c[b]=true;c[b]=c[a]+1;
           }
       }
   }
   for (int i=0; i<n; i++) {
       cout << i+1 << " " << c[i+1] << endl;
   }
}


Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//Did the Question on the basis of a permutation of numbers.

#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            char c;
            cin>>c;
            int k=c;
            if(c<=96) cout<<"A";
            else cout<<"a";



       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <string>

int main()
{

	int N[5];
	std::cin >> N[1];
	std::cin >> N[2];
	std::cin >> N[3];
	std::cin >> N[4];

	int check[4] = { 0,0,0,0 };

	for (int i = 1; i < 5; i++) {
		if (N[i] == 1) {
			check[0] = 1;
		}
		else if (N[i] == 9) {
			check[1] = 1;
		}
		else if (N[i] == 7) {
			check[2] = 1;
		}
		else if (N[i] == 4) {
			check[3] = 1;
		}
	}

	if (check[0] * check[1] * check[2] * check[3] == 1) {
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	string s;
	cin >> s;

	int k = inf; // 最大の整数K

	// 左右に隣り合う2つをすべての操作に対して同じ対応をしてしまうと
	// その2つの色は同じまま
	// もしその2つが違う数字ならば、アウト
	// よって違う数字で隣り合う場合は、その真ん中を右端または左端
	// としなきゃならない

	// 全部白、黒なら別の対応をする
	int wNum = 0;
	int bNum = 0;
	rep(i, (int)s.size()) {
		if (s[i] == '0') wNum++;
		else bNum++;
	}

	if (wNum == 0 || bNum == 0) {
		cout << (int)s.size() << endl;
		return 0;
	}

	Rep(i, 1, (int)s.size()) {
		if (s[i] != s[i - 1]) {
			k = min(k, max(i, (int)s.size() - i));
		}
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 512
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

solve n scs = loop scs list
  where
    list = case n of 1 -> [0..9]
                     2 -> [10..99]
                     _ -> [100..999]

    loop [] ns = if null ns then -1 else head ns
    loop ((s,c):xs) ns = if null ns then -1 else loop xs (filter (check s c) ns)

check s c number = ns !! (s-1) == c
  where
    ns = dissNumber number

dissNumber :: Int -> [Int]
dissNumber x = if x == 0 then [0] else loop x []
  where
    loop 0 list = list
    loop n list = loop (n `div` 10) (n `mod`10:list)

main = do
  (n,m) <- (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
  scs <-  VU.replicateM m $ (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector
  print $ solve n $ VU.toList scs


Measured memory_bytes: 636
n, k = map(int, input().split())
p = list(map(float, input().split()))
tmp = sum(p[:k])
ans = 0

for i in range(k, n):
    tmp = tmp + p[i] - p[i - k]
    ans = max(ans, tmp)

ans = max(ans, tmp)
print((ans + k) / 2)

Measured memory_bytes: 23144
//2017-10-13
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (2000+5)
#define M (4000000+5)

const int P = 1e9 + 7;

int Pow(int a, int anum){
	int ret = 1;
	while(anum){
		if(anum & 1) ret = 1ll * ret * a % P;
		a = 1ll * a * a % P; anum >>= 1;
	}
	return ret;
}

int fac[M], rfac[M], f[N][N];

void Init(int n){
	fac[0] = rfac[0] = 1;
	For(i, 1, n) fac[i] = 1ll * fac[i-1] * i % P;

	rfac[n] = Pow(fac[n], P-2);
	Forr(i, n-1, 1) rfac[i] = 1ll * rfac[i+1] * (i+1) % P;
}

int C(int a, int b){
	if(a < b) return 0;
	return 1ll * fac[a] * rfac[b] % P * 1ll * rfac[a-b] % P;
}

int main(){
	Init(4000000);

	int n, k;
	scanf("%d%d", &n, &k);
	
	if(k == 1){
		puts("1"); return 0;
	}
	
	f[0][0] = 1;
	For(i, 0, n) For(j, i, n){
		if(i < n) (f[i+1][j] += f[i][j]) %= P;
		if(j < n) (f[i][j+1] += 1ll * C(i+(j+1)*(k-1)-1, k-2) * f[i][j] % P) %= P;
	}
	printf("%d\n", 1ll * f[n][n] * fac[n] % P);

	return 0;
}

Measured memory_bytes: 47360
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%M;

        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<pair<int,int>>primeFactors(int n)
{
    vector<pair<int,int>>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
    }
    if(x>0)
    v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
        }
        if(y>0)
        v.pb({i,y});
    }
    if (n > 2)
        v.pb({n,1});
    return v;
}
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void solve()
{
int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
int x=(h2-h1+24)%24;
x*=60;
x+=(m2-m1);
cout<<x-k<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{

solve();

}
}


Measured memory_bytes: 3672
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s=br.readLine().trim();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x=0;
	long long int a=0;
	long long int b=0;
	long long int c=0;
	long long int d=0;
	a=x%500;
	cin>>x;
	a=x%500;
	b=x/500;
	b*=1000;
	if(a==0)
	{
		cout<<b<<endl;
	}
	else 
	{
		c=a/5;
		c*=5;
		d=b+c;
		cout<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 9999999999
#define PI 3.14159265359

using namespace std;
int main()
{
	int a,b,h,m;
	long double arg,ans;
	cin >> a>>b>>h>>m;
	arg=abs((long double)(30*h+0.5*m-6*m));
	if (arg>=360.0) arg-=360.0;
	arg*=PI/180.0;
	ans=(long double)(a*a+b*b-2*a*b*cos(arg));
	cout << setprecision(15) << sqrt(ans) << endl;
	return 0;
}

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

int main(){
  int64_t n ; 
  cin >> n ; 
  
  
  ///////////////////////素因数分解
  vector<pair<int64_t , int>> fs ; 
  for(int64_t i = 2 ; i*i <= n ; i++){
    int x = 0 ; 
    while(n%i == 0 ){
      n /= i ; 
      x++ ;
    }
    fs.emplace_back(i,x) ;    
  }
  if( n != 1)  fs.emplace_back(n,1) ; 
  
  //////////////////
  int ans = 0 ; 
  
  for(auto p : fs){
    int x = p.second ; 
    int b = 1 ; 
    while ( b <= x){
      x -= b ; 
      b++ ; 
      ans++ ; 
    }
  }
  
  cout << ans << endl ; 
  
  
}

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

using namespace std;

//#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

ll dp[maxn][2];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> m;
    _rep(i, 0, n-1)cin >> a[i],m[a[i]]++;
    sort(all(a));

    a.erase(unique(all(a)),a.end());
    debug(a);
    ll cnt = 0;
    n = a.size();
    _for(i, 0, n){
        _for(j, i+1, n){
            _for(k, j+1, n){
                if(a[k]< a[i]+ a[j]){
                    cnt+= m[a[k]]*m[a[j]]*m[a[i]];
                }
            }

        }
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 6232