akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  int x, t;
  std::cin >> x >> t;
  cout(std::max((int)0, x - t));
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math

def calc(arr, query):
    ret = 0
    # print(arr)\
    for q in query:
        if arr[q[1] - 1] - arr[q[0] - 1] == q[2]:
            ret += q[3]

    return ret

def dfs(n, m, query, tlen, tail, score, deq):
    if tlen == n:
        return calc(list(deq), query)
    else:
        for i in range(tail, m+1):
            deq.append(i)
            ret = dfs(n, m, query, tlen+1, i, score, deq)
            if ret > score:
                score = ret
            deq.pop()

    return score




def main():
    n,m,q = getList()
    query = []
    for _ in range(q):
        query.append(getList())
    deq = deque([1])
    ans = dfs(n, m ,query, 1, 1, 0, deq)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 72276
def readints():
    return list(map(int, input().split()))


N, M = readints()
CS = [None]*3
for i in range(M):
    S, C = readints()
    if CS[S-1] != None and CS[S-1] != C:
        print(-1)
        exit()
    CS[S-1] = C


def check(x):
    s = str(x)
    if not (len(s) == N):
        return False
    for i in range(len(s)):
        if CS[i] == None:
            continue
        if not CS[i] == int(s[i]):
            return False
    return True


for x in range(1000):
    if check(x):
        print(x)
        exit()
print(-1)


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

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    long long a[A],b[B],x[M],y[M],c[M];
    long long ma = LONG_LONG_MAX;
    long long mb = LONG_LONG_MAX;
    rep(i,A){
        cin >> a[i];
        ma = min(a[i],ma);
    }
    rep(i,B){
        cin >> b[i];
        mb = min(b[i],mb);
    }
    rep(i,M){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    long long res = ma + mb;
    rep(i,M){
        res = min(res,a[x[i]] + b[y[i]] - c[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int n,q,A[2001],Q[201];

main(){

  int i,judge;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i = 0; i < q; i++){
    scanf("%d",&Q[i]);
  }

  for(i = 0; i < q; i++){

    judge = solve(0,Q[i]);

    if(judge == 1){
      printf("yes\n");
    } else {
      printf("no\n");
    }

  }

  return 0;
 
}

int solve(int p, int t){
 
  if(t == 0){
    // printf("%d %d\n",p,t);
    return 1;
  } else if(t < 0){
    // printf("%d %d\n",p,t);
    return 0;
  } else if(p > n){
    // printf("%d %d\n",p,t);
    return 0;
  } else if(solve(p+1,t-A[p]) == 1){
    return 1;
  } else if(solve(p+1,t) == 1){
    return 1;
  }

}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
vii dp;

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    string s,t, ans; cin >> s >> t;
    dp.resize(s.size()+1, vi(t.size()+1));
    for(int i = 0; i < s.size(); ++i) {
        for(int j = 0; j < t.size(); ++j) {
            if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    int i = (int)s.size()-1;
    int j = (int)t.size()-1;
    while(i>=0&&j>=0) {
        if(dp[i+1][j+1]==dp[i+1][j]) {
            --j;
        }
        else if(dp[i+1][j+1]==dp[i][j+1]) {
            --i;
        }
        else if(dp[i+1][j+1]==dp[i][j] + 1){
            ans = s[i] + ans;
            --i;--j;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 35712
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = []
for i in range(N):
	A.append(ri())

queue = deque()

queue.appendleft(A[0])
for i in range(1, N):
	idx = bisect_left(queue, A[i])
	if idx == 0:
		queue.appendleft(A[i])
	else:
		queue[idx-1] = A[i]
print(len(queue))


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

int main() {
int N;
if (cin >> N) {
if (N > 0) {
for (int a = 0;;) {
char x;
if (cin >> x) {
//cout << "文字データ '" << x << "' が入力されました。" << endl;
++a;
if (x == 'Y') {
cout << "Four" << endl;
break;
}
else if (a == N) {
cout << "Three" << endl;
break;
}
}
else {
//cout << "文字データが入力されませんでした。処理を続けることは出来ません。" << endl;
break;
}
}
}
}
return 0;
}

/*
一行目に入力したNが0より大きいときに、
カウンタ変数aを0で初期化した後、
文字Xを一つ入力して、
①その後XがYの時はFourとして出力、
②XがYでなくてなおかつカウンタ変数aがNになってしまった時は3と出力、
③XがYでなく、カウンタ変数aもN以下の場合はif(cin==X)まで戻る
戻った後はまた文字Xを一つ入力
以下a==Nになるまでループ
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M, Q;

    cin >> N >> M >> Q;

    vector<int> L(N + 2);
    vector<int> R(N + 2);

    vector<int> LC(N + 2);
    vector<int> RC(N + 2);

    vector<vector<int> > S(N + 2);

    vector<vector<int> > ans(N + 2, vector<int>(N + 2));

    for(int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        L[l]++;
        R[r]++;

        S[l].push_back(r);
    }

    int count = 0;

    for(int i = 0; i <= N; i++) {
        count += L[i];
        int lc = M - count;
        int rc = 0;
        for(int j = 0; j < S[i].size(); j++) {
            R[S[i][j]]--;
        }
        for(int j = N + 1; j > i; j--) {
            rc += R[j];
            ans[i][j] = lc - rc;
        }
    }

/*
    for(int i = 0; i <= N + 1; i++) {
        cout << endl;
        for(int j = 0; j <= N + 1; j++) {
            cout << ans[i][j] << " ";
        }
    }
*/
    vector<int> ql(Q);
    vector<int> qr(Q);

    for(int i = 0; i < Q; i++) {
        cin >> ql[i] >> qr[i];
        ql[i]--;
        qr[i]++;
    }

    for(int i = 0; i < Q; i++) {
        cout << ans[ql[i]][qr[i]] << endl;
    }
}

Measured memory_bytes: 3968
#include <iostream>
using namespace std;
int main(){
  int N, k;
  cin >> N >> k;
  long long int t = 0LL;
  for(int i = 1; i < N; ++i){
    t += t/(k-1) + 1;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3088
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

string S;

void solve() {
	cin >> S;
	int a = stoi(S.substr(0, 2));
	int b = stoi(S.substr(2, 2));
	bool isMMYY = false;
	bool isYYMM = false;
	if (a >= 1 && a <= 12)isMMYY = true;
	if (b >= 1 && b <= 12)isYYMM = true;
	if (isYYMM && isMMYY)cout << "AMBIGUOUS" << endl;
	else if (isYYMM)cout << "YYMM" << endl;
	else if (isMMYY)cout << "MMYY" << endl;
	else cout << "NA" << endl;
	return;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>
#include <set>
#include <cassert>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

const int MAXN = 10;
const int INF = 1e3;

template<typename T1, typename T2> inline void chkmin(T1 & a, const T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chkmax(T1 & a, const T2 b) { if (a < b) a = b; }

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(0), cout.tie(0);
    // freopen(s"input.txt", "r", stdin);
    long long a, b, n, x;
    cin >> a >> b >> n;
    x = min(b - 1, n);
    cout << (a * (x % b) - (a * x % b)) / b;
    // for (int x = 1; x <= n; ++x) {
    // 	cout << (a * x / b) - a * (x / b) << ' ' << (a * (x % b) - (a * x % b)) / b << '\n';
    // }

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define PII pair<ll, ll>
#define F first
#define S second
using namespace std;
PII a[100];
ll n, k, ans=9e20;

main() {
	int i, j, l;
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a[i].F>>a[i].S;
	sort(a, a+n);
	for(i=0; i<=n-k; i++) {
		vector<ll> v;
		for(j=0; j<k-1; j++) v.push_back(a[i+j].S);
		for(j=k-1; i+j<n; j++) {
			v.push_back(a[i+j].S);
			sort(v.begin(), v.end());
			for(l=0; l+k<=v.size(); l++)
				ans = min(ans, (v[l+k-1]-v[l]) * (a[i+j].F-a[i].F));
		}
	}
	cout<<ans;
	return 0;
}

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

int main()
{
  int x, h;
  while (cin >> x >> h && !(x == 0 && h == 0)) {
    const double l = hypot(h, x/2.0);
    const double s = 2*x*l + x*x;
    printf("%.6f\n", s);
  }
  return 0;
}

Measured memory_bytes: 0
while True:
    n, q = map(int, input().split())
    d = {}

    if n == 0 and q == 0:
        break

    for i in range(n):
        era, years, now = input().split()
        begin = int(now) - int(years) + 1
        d[era] = [begin, int(now)]

    for i in range(q):
        year = int(input())
        for e, y in d.items():
            if year >= y[0] and year <= y[1]:
                print(e, year - y[0] + 1)
                break
        else:
            print('Unknown')

Measured memory_bytes: 7908
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int n;

int query(int x){
    cout << x << endl;
    flusz

    string s;
    cin >> s;

    if (s[0] == 'M'){
        return 1;
    }else if (s[0] == 'F'){
        return 2;
    }else{
        exit(0);
    }
}

void solve()
{
    cin >> n;

    int l = 0, r = n-1;

    int akt = query(0);
    int last = 0;

    while(1){
        int mid = (l+r)/2;
        if (mid == l){
            mid++;
        }
        int x = query(mid);



        if ( (abs(last-mid)%2 == 1 && akt != x) || (abs(last-mid)%2 == 0 && akt == x)){
            l = mid;
            last = mid;
            akt = x;
        }else{
            r = mid;
        }           
    }

    return;
}

int32_t main()
{
    test=1;

    while(test--)
    {
        solve();
    }

  return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

vvll g;
vector<bool> seen;
vll from;

void solve() {
    ll n, m;
    cin >> n >> m;
    g = vvll(n);
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    seen = vector<bool>(n, false);
    from = vll(n, -1);
    queue<ll> q;
    seen[0] = true;
    q.push(0);
    while(!q.empty()) {
        ll i = q.front();
        q.pop();
        for(auto j : g[i]) {
            if(seen[j]) continue;
            from[j] = i;
            seen[j] = true;
            q.push(j);
        }
    }
    cout << "Yes" << endl;
    for(ll i = 1; i <= n - 1; i++) {
        cout << from[i] + 1 << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 13048
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int gcd(int a, int b);

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    if(A[0] < K){
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    
    int G = gcd(A[0], A[1]);
    for(int i = 1; i < N; ++i){
        int x = max(G, A[i]);
        int y = min(G, A[i]);
        G = gcd(x, y);
    }
    
    if(K % G == 0){
        cout << "POSSIBLE\n";
    }
    else{
        cout << "IMPOSSIBLE\n";
    }
}

int gcd(int a, int b){
    if(b == 0)      return a;
    
    return gcd(b, a % b);
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class WarshallFloyd{
	vector<vector<ll>> dist;
public:
	void CalcShortestPath(ConnectNodeInfo& connect){
		int V = connect.size();
		dist.resize(V,vector<ll>(V,1LL<<60));

		REP(i,V){
			dist[i][i]=0;
			int U = connect[i].size();
			REP(j,U){
				dist[i][connect[i][j].first] = connect[i][j].second;
			}
		}

		REP(k,V){
			REP(i,V){
				REP(j,V){
					if(dist[i][k]!=(1LL<<60) && dist[k][j]!=(1LL<<60)){
						dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					}
				}
			}
		}
	}
	bool HasNegativeLoop(){
		bool flag = false;
		for(int i=0,ei=dist.size();i<ei;i++){
			if(dist[i][i]<0){
				flag = true;
				break;
			}
		}
		return flag;
	}
	ll CalcDiameter(){
		ll diameter = -(1LL<<60);
		int V = dist.size();
		REP(i,V){
			REP(j,V){
				if(dist[i][j]<1LL<<60){
					diameter = max(diameter,dist[i][j]);
				}
			}
		}
		return diameter;
	}
	ll GetDistance(int i,int j){
		return dist[i][j];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	ConnectNodeInfo connect(H*W);
	vector<vector<int>> M(H,vector<int>(W,0));
	
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#') M[i][j]=1;
		}
	}

	REP(i,H){
		REP(j,W){
			if(i>0 && !M[i][j] && M[i-1][j]==0){
				connect.AddNonDirectionalConnection(j+i*W,j+(i-1)*W,1);
			}
			if(j>0 && !M[i][j] && M[i][j-1]==0){
				connect.AddNonDirectionalConnection(j+i*W,j-1+i*W,1);
			}
		}
	}

	WarshallFloyd WF;
	WF.CalcShortestPath(connect);
	ll maxD=0;
	int S=W*H;
	REP(i,S){
		for(int j=i;j<S;j++){
			ll D = WF.GetDistance(i,j);
			if(D<1LL<<60 && D>maxD){
				maxD = D;
			}
		}
	}
	out(maxD);
	return 0;
}


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

int main() {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < 5; i++) {
    if (vec.at(i) == 0) {
      cout << i + 1;
      break;
    }
  }
  
  
  
}

Measured memory_bytes: 3592
inx,iny = map(int,input().split())
if inx in [4,6,9,11]:
  gx = 2
elif inx == 2:
  gx = 3
else:
  gx = 1
if iny in [4,6,9,11]:
  gy = 2
elif iny == 2:
  gy = 3
else:
  gy = 1
  
if gx == gy:
  print("Yes")
else:
  print("No")

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

using namespace std;

const int N = 55;

int n;
pair < int, int > a[N];

int main(){
	ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL); 

  set < pair < int, int > > points;

  cin >> n;
  for(int i = 1; i <= n; ++i) {
    cin >> a[i].first >> a[i].second;
    points.emplace(a[i]);  
  }

  int ans = n;
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) if(i != j) {
      int p = a[i].first - a[j].first, q = a[i].second - a[j].second;
      int ret = 0;
      for(int k = 1; k <= n; ++k) {
        if(points.count(make_pair(a[k].first - p, a[k].second - q)));
        else {
          ++ret;
        }
      }
      ans = min(ans, ret);
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long x;
	long long ans = 0;
	cin >> x;
	ans += (x / 500) * 1000;
	x -= (x / 500) * 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
	return 0;
}

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


int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int n;std::cin>>n;
	std::vector<int> nstone(n);for(int& x:nstone)std::cin>>x;
	std::vector<std::vector<int>> ad;
	ad.resize(n);
	for(int _=n-1;_--;){
		int u,v;std::cin>>u>>v;
		ad[--u].push_back(--v);
		ad[v].push_back(u);
	}

	std::vector<int> stones(n);
	std::iota(begin(stones),end(stones),0);
	std::sort(begin(stones),end(stones),[&](int i,int j){
			return nstone[i]<nstone[j];
			});

	enum class State{
		unknown,win,lose
	};
	std::vector<State> state(n);
	for(int x:stones){
		if(std::any_of(begin(ad[x]),end(ad[x]),[&](int i){
				return nstone[i]<nstone[x]&&state[i]==State::lose;
				})){
			state[x]=State::win;
		}else
			state[x]=State::lose;
	}
	for(int i=0;i<n;++i)
		if(state[i]==State::win)
			std::cout<<i+1<<' ';
	std::cout<<'\n';
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace AtCoder.Question
{
    public class QuestionD
    {
        public static void Main(string[] args)
        {
            var x = Decimal.Parse(Console.ReadLine());

            var fifthDic = new Dictionary<Decimal, Decimal>();

            for (Decimal i = -1000; i <= 1000; i++)
            {
                var fifth = i * i * i * i * i;
                if (!fifthDic.ContainsKey(fifth))
                {
                    fifthDic.Add(fifth, i);
                }
            }

            foreach (var kv in fifthDic)
            {
                if (fifthDic.ContainsKey(kv.Key - x))
                {
                    Console.WriteLine($"{kv.Value} {fifthDic[kv.Key - x]}");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 28128
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;

int main() {
    char a, ans = 'A';
    cin >> a;
    if ('a' <= a && a <= 'z') ans = 'a';
    cout << ans << endl;
}

Measured memory_bytes: 3616
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

sum_B = sum(B)
for i in range(0,N-1):
  if A[i]+1 == A[i+1]:
    sum_B += C[A[i]-1]
    
print(sum_B)

Measured memory_bytes: 3064
n = int(input())
S = list(input())
for _ in range(n-1):
    tmp = list(input())
    next_array = []
    for i in S:
        if i in tmp:
            next_array.append(i)
            tmp.remove(i)
    S = next_array
S.sort()
ans = ''
for i in S:
    ans += i
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;

vector<ll> v;
void  divisors(ll n){
	for(ll i=1; i<=sqrt(n); i++) {
		if(n%i==0) {v.pb(i);
			    v.pb(n/i);  }
	}
	sort(all(v));
}
int main()
{
	std::ios::sync_with_stdio(false);
	ll n,m;
	ll ans=1;
	cin>>n>>m;
	divisors(m);

	ll l=0;
	ll r=v.size()-1;
//	cout<<r<<endl;
	//return 0;
	while(l<=r) {
		ll mid=(l+r)/2;
		if(m/v[mid]>=n) {
			ans=v[mid];
			l=mid+1;
		}
		else{
			r=mid-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

namespace std {

template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	vector<int> perm;
	auto solve = std::y_combinator([&](auto self, int N, string T, int base = 1, int loS = 0, int loT = 0) -> void {
		if (N == 0) {
			perm[loS] = loT;
			return;
		}
		for (int v = 0; v < 3; v++) {
			string nT;
			int nV = v;
			for (char c : T) {
				if (c == 'S') {
					if (!nT.empty() && nT.back() == 'S') nT.pop_back();
					else nT += 'S';
					if (nV) nV = 3 - nV;
				} else {
					if (nV == 2) {
						nT += 'R';
						nV = 0;
					} else {
						nV++;
					}
				}
			}
			self(N-1, std::move(nT), base * 3, loS + base *v, loT + base * nV);
		}
	});

	int N; string T; cin >> N >> T;
	int p3 = 1; for (int i = 0; i < N; i++) p3 *= 3;
	perm.resize(p3);
	solve(N, T);
	for (int z = 0; z < p3; z++) {
		cout << perm[z] << " \n"[false && z+1==p3];
	}
	cout << '\n';

	return 0;
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int fa[1000010],N;
char s[1000010];
int main()
{
	scanf("%s",s+1);N=strlen(s+1);
	if(s[1]!='1'||s[N]!='0')
	{
		cout<<"-1";return 0;
	}
	for(rint i=2;i<N;++i)
	{
		if(s[i]!=s[N-i])
		{
			cout<<"-1";return 0;
		}
	}
	cout<<"1 2\n";
	int cnt=2;
	for(rint i=2;i<N;++i)
	{
		cout<<cnt<<' '<<i+1<<"\n";
		if(s[i]=='1') cnt=i+1;
	}
	return 0;
}




Measured memory_bytes: 1536
#include <iostream>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a,b) (((a)-(b))>0?((a)-(b)):((b)-(a)))

using namespace std;

int main(){
	int X; cin >> X;
	
	if( X < 600 ) cout << 8;
	else if( X < 800 ) cout << 7;
	else if( X < 1000 ) cout << 6;
	else if( X < 1200 ) cout << 5;
	else if( X < 1400 ) cout << 4;
	else if( X < 1600 ) cout << 3;
	else if( X < 1800 ) cout << 2;
	else if( X < 2000 ) cout << 1;
	
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
#include <ios>
#include <iomanip>
#include <set>
#include <array>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
 
int main(){
 
    int n,m;
    scanf("%d %d\n",&n,&m);
    array<int,100001> ids,idt;
    vector<int> grid[100001];
    
    REP(i,m){
        scanf("%d %d\n",&ids[i],&idt[i]);
 
        grid[ids[i]].push_back(idt[i]);
    }
    
 
    REP(i,n){
        sort(grid[i + 1].begin(), grid[i + 1].end());
    }
 
    
    REP(i,m){
        
        printf("%06d%06d\n", ids[i], (int)(lower_bound(grid[ids[i]].begin(),grid[ids[i]].end(), idt[i])-grid[ids[i]].begin()) + 1);
    }
 
    return 0;
}

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

using namespace std;


map<long long, long long> prime_factors(long long P,long long N) {
    map<long long, long long> res;
    if(P == 1) { 
        res[P] = 1;
        return res;
    }
    long long tm=P;
    for(long long i = 2 ; pow(i,N) <= P; ++i) {
        while(tm % i == 0) {
            ++res[i]; 
            tm /= i;
        }
    }
    if(tm==P) res[P] = 1;
    return res;
}



int main(){
    long long N,P;

    cin>>N>>P;
    long long ans=1;

    if(N==1){
        cout<<P<<endl;
        return 0;
    }


    map<long long ,long long > res=prime_factors(P,N);
    for(auto it = res.begin(); it != res.end(); ++it){
        if(it->second>=N){
            long long test=(it->second/N);
            if(test<=0)test=1;
            ans*=pow(it->first,test);
            
        }
    }



    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b <= a)cout << "delicious" << endl;
	else if (b > a&&b <= x + a)cout << "safe" << endl;
	else cout << "dangerous" << endl;
	int z;
	cin >> z;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		int xk = abs(K - x);
		if (x > xk) {
			ans += xk * 2;
		}
		else {
			ans += x * 2;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int A, B, C, X;
    int count = 0;

    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                int sum = 500 * i + 100 * j + 50 * k;
                if(sum == X) {
                    count += 1;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
static int desc(const void *a, const void *b);
static int asc(const void *a, const void *b);
 
int main (void){
    int n,k,i,j;
    int x,y,z;
    int a,b,m;
    int min = 2000000000;
    int mina = 2000000000;
    int minb = 2000000000;
    a = b = m = z = 0;
    int count = 0;
    double dx;
    int box_a[200001]={};
    int box_b[200001]={};
    char text[200001]={};
    char s[200001]={};
    char t[200001]={};
    char alf[256] = {"abcdefghijklmnopqrstuvwxyz"};
    char alfb[256] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    char sample_text[256];
 
    // Input Area //
    scanf("%d %d",&k,&n);
    box_a[0] = 0;
    for (i = 1; i <= n; i++){
        scanf("%d",&box_a[i]);
        box_b[i-1] = box_a[i] - box_a[i - 1]; 
    }
    
    box_b[n] = k - box_a[n]; 

    
    qsort(box_b,n + 1,sizeof(int),asc);
    for (i = 0; i < n; i++){
       z = z + box_b[i];
    }
    if (box_a[n] - box_a[1] > z){
        printf("%d",z);
    }else{
        printf("%d",box_a[n] - box_a[1]); 
    }
    


    //scanf("%s %s",s,t);
    //scanf("%d %d",&x,&y);
    //scanf("%s",text);
 
    /*
    if(strcmp(text,s)==0){
        x--;
    }else if(strcmp(text,t)==0){
        y--;
    }
    */
    //printf("%d %d",x,y);
    //scanf("%s",&sample_text);
    //scanf("%s",&text);
 
    /*
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    printf("\n");
    qsort(box,n,sizeof(int),desc);
    
    */
    // Output Area //
    
    /*
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    */
 
}
 
static int desc(const void *a, const void *b){
    return *(int *) b - *(int *) a;
}
 
static int asc(const void *a, const void *b){
    return *(int *) a - *(int *) b;
}
 
 
/* KonoLvBANK
 
配列降順ソート
qsort(box,n,sizeof(int),desc);
配列昇順ソート
qsort(box,n,sizeof(int),asc);
 
アルファベットを次の単語に変えるやつ
    while(1){
        if (text[i] == '\0'){
            break;
        }
        for(j = 0; j < 26; j++){
            if (text[i] == alf[j]){
                if (j != 25){
                    text[i] = alf[j + 1];
                }else{
                    text[i] = alf[0];
                }
                break;
            }
        }
        i++;
    }
    */

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

int main(int argc, char *argv[]){
  long long N,A,B,C,D,E;
  long long min=1000000000000001;
  int memo=0;
  vector<long long> vec(5,0);
  cin>>N;
  cin>>A;
  if(A<min){
    min=A;
    memo=1;
  }
  cin>>B;
  if(B<min){
    min=B;
    memo=2;
  }
 cin>>C;
 if(C<min){
    min=C;
    memo=3;
 }
 cin>>D;
  if(D<min){
    min=D;
    memo=4;
  }
 cin>>E;
  if(E<min){
    min=E;
    memo=5;
  }
  if(N/min==0){
    cout<<5<<endl;
    return 0;
  }
  else{
    if(N%min==0)cout<<(N/min)+4;
    else cout<<(N/min)+5;
  }
}
  


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

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

typedef long long ll;

const int INF = 1e8;

int main() {
  int n, k; cin >> n >> k;
  
  cout << dec << k*(int)pow(k-1, n-1) << endl;
}


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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	unordered_map<int, int> a;
	for (int i = 0; i < n; i++)
	{
		int ai;
		cin >> ai;
		auto it = a.find(ai);
		if (it != a.end()) it->second++;
		else a[ai] = 1;
	}
	vector<int> va;
	va.reserve(a.size());
	for (auto&& p : a) va.push_back(p.second);
	sort(va.begin(), va.end());
	int num = 0;
	for (int i = 0; i < (int)va.size() - k; i++) num += va[i];
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 9288
import std.stdio, std.range, std.algorithm, std.conv, std.string, std.array, std.typecons, std.format;

void main() {
    long r,g,b,n;
    readf("%d %d %d %d", &r, &g, &b, &n);

    long ans = 0;
    for (long i = 0; r*i <= n; i++) {
    for (long j = 0; r*i + b*j <= n; j++) {
        if ((n - (r*i + b*j)) % g == 0)  {
            ans++;
        }
    }
    }
    writeln(ans);

}


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

using namespace std;

const int maxi=1e6+6;
#define pb push_back
int t,n;
string s;
map<int,int> mp;
int main()
{
    cin>>n;

    for (int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        mp[x]++;
    }
    int m;
    cin>>m;

    for (int i=0;i<m;i++)
    {
        int x;
        scanf("%d",&x);
        if (!mp[x])
        {
          printf("NO\n");
          return 0;
        }

        mp[x]--;
    }

   printf("YES\n");
    return 0;
}
//uradim prva cetiri i aj za Beograd (veliki prljavi grad)


Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int N=100005;

struct E{
	int x,y,w;
}mem[N];
int n,m,k,x,y,w,r1,r2,c1,c2,cnt;
ll ans;
int f[N],g[N],c[N];

int find1(int k){
	if (f[k]!=k) f[k]=find1(f[k]);
	return f[k];
}

int find2(int k){
	if (g[k]!=k) g[k]=find2(g[k]);
	return g[k];
}

bool cmp(E a,E b){
	return a.w<b.w;
}

int main(){
	int i;
	scanf("%d%d%d",&n,&m,&k);
	for (i=1;i<=n;i++) scanf("%d",&c[i]);
	for (i=1;i<=k;i++) g[i]=i;
	for (i=1;i<=n;i++) f[i]=i;
	for (i=1;i<=m;i++) scanf("%d%d%d",&mem[i].x,&mem[i].y,&mem[i].w);
	sort(mem+1,mem+1+m,cmp);
	for (i=1;i<=m;i++){
		if (cnt==k-1) break;
		x=find1(mem[i].x); y=find1(mem[i].y); w=mem[i].w;
		if (x==y) continue;
		f[x]=y; c1=c[x]; c2=c[y];
		c[y]=c2?c2:c1;
		if (c1&&c2){
			c1=find2(c1); c2=find2(c2);
			if (c1==c2) continue;
			g[c1]=c2; ans+=1ll*w; cnt++;
		}
		else cnt++,ans+=1ll*w;
	}
	if (cnt!=k-1) ans=-1;
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
int main()
{
	int n;
	cin >> n;
	if (n < 5) {
		vector<int> p(n);
		iota(p.begin(), p.end(), 1);

		ll ans = 0;
		ll sum = 0;
		do {
			int i = 1;
			for (int v : p) {
				sum += v % i;
				i++;
			}
			ans = max(ans, sum);
			sum = 0;
		} while (next_permutation(p.begin(), p.end()));
		cout << ans << endl;
		return 0;
	}
	else{
		ll ans = 0;
		for (int i = 2; i < n; i++)  ans += i;
		ans++;
		cout << ans << endl;
		return 0;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

//vector<ll> ;

void answer(){
    ll n,m=0,ans=0,f=0;
    double x;
    cin>>n>>m;
    cout<<min(n%m,abs(n%m - m));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

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

using namespace std;

const int k = 3;

int main() {
    int n;
    cin >> n;
    int a[n + 1][k + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i][1] >> a[i][2] >> a[i][3];
    }
    int dp[n + 1][k + 1];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            int m = (j + 1) % 3;
            int l = (j - 1) % 3;
            if (m == 0) {m += 3;}
            if (l == 0) {l += 3;}
            dp[i][j] = a[i][j] + std::max(dp[i - 1][m], dp[i - 1][l]);
        }
    }
    //for (int i = 1; i <= n; i++) {
      //  for (int j = 1; j <= k; j++) {
     //       std::cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
   // }
    cout << std::max(dp[n][1], std::max(dp[n][2], dp[n][3]));
    return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
#ABC127 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def C(n,r):
    return fact[n]*pow(fact[n-r],mod-2,mod)*pow(fact[r],mod-2,mod) % mod

n,m,k = LI()

fact = [1]*(n*m+1)
for i in range(1,n*m+1):
    fact[i] = i*fact[i-1]
    fact[i] %= mod

ans = 0
"""xの差"""
for d in range(1,m):
    ans += d*(m-d)*n*n
    ans %= mod

"""yの差"""
for d in range(1,n):
    ans += d*(n-d)*m*m
    ans %= mod

ans *= C(n*m-2,k-2)
ans %= mod
print(ans)


Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,h;
	cin>>n>>h;
	long long int a[n],i,c=0;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	if(h>=n)
	cout<<0<<endl;
	else
	{
		for(i=0;i<=n-1-h;i++)
		{
			c=c+a[i];
		}
		cout<<c<<endl;
	}
	
	return 0;
	
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            char [][] map = new char [8][8];
            char [][] nmap = new char [8][8];
            for(int i=0;i<8;i++)
            	map[i] = scan.next().toCharArray();
            rotate(map,nmap);
            System.out.println("90");
            showmap(nmap);
            rotate(nmap,map);
            System.out.println("180");
            showmap(map);
            rotate(map,nmap);
            System.out.println("270");
            showmap(nmap);
        }
        public static void rotate (char[][] map ,char [][] nmap){
        	for(int i=0;i<8;i++)
        		for(int j=0;j<8;j++)
        			nmap[i][j] = map[7-j][i];
        }
        public static void showmap(char [][] map){
        	for(int i=0;i<8;i++)
        		System.out.println(map[i]);
        }
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int mi  = 100000;
    int ans = 0;
    if ((a +b) > c*2) {
        mi = min(mi,x);
        mi = min(mi,y);
        x -= mi;
        y -= mi;
        mi = mi *2;
        ans += mi*c;
    }
    if (a < 2*c) {
       ans += a*x; 
    } else {
        ans += (2*c) *x;
    }
    if (b <2*c) {
        ans += b*y;
    } else {
        ans += (2*c) * y;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let xs = reads float
    List.sumBy (fun x -> 1. / x) xs
    |> fun x -> 1. / x
    |> printfn "%.6f"
    0

Measured memory_bytes: 14044
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


signed main(){

	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> mp;
	rep(i, N){
		cin >> A[i];
		mp[A[i]]++;
	}

	sort(A.rbegin(), A.rend());

	int ans = 0;
	rep(i, N){
		if (mp[A[i]] <= 0) continue;

		for (int sum = 2; sum <= (1LL << 31); sum *= 2){
			if (sum <= A[i]) continue;
			int r = sum - A[i];
			if (r > A[i]) continue;

			if (r == A[i]){
				if (mp[A[i]] >= 2){
					ans++;
					mp[A[i]] -= 2;
				}
			}
			else if (mp[r] > 0){
				ans++;
				mp[r]--;
				mp[A[i]]--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int s[N];
  for (int i = 0; i < N; i++) cin >> s[i];

  long long ans = 0;
  int passed[N] = {};
  for (int c = 1; c < N; c++) {
    long long point = 0;
    for (int k = 0; k < N; k++) {
      int s1 = N - 1 - k * c;
      int s2 = k * c;

      if (s1 == s2) break;
      if ((k + 1) * c >= N - 1) break;
      if (passed[s1] == c) break;
      if (passed[s2] == c) break;

      point += s[s1] + s[s2];
      ans = max(ans, point);

      passed[s1] = passed[s2] = c;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << "0\n";
    else
        cout << "10\n";

    return 0;
}


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

int d[100][101];
bool b[100];
vector<P>E[100];
struct st {
	int p, c, l;
};
bool operator<(st a, st b) {
	return a.c > b.c;
}
int main() {
	int n, m, l, k, a, h;
	while (scanf("%d%d%d%d%d%d", &n, &m, &l, &k, &a, &h), n) {
		memset(b, 0, sizeof(b));
		rep(i, n)E[i].clear();
		rep(i, l) {
			int t; scanf("%d", &t);
			b[t] = true;
		}
		rep(i, k) {
			int x, y, t; scanf("%d%d%d", &x, &y, &t);
			E[x].push_back(P(t, y));
			E[y].push_back(P(t, x));
		}
		priority_queue<st>que;
		memset(d, 0x3f, sizeof(d));
		que.push({ a,0,m });
		d[a][m] = 0;
		while (!que.empty()) {
			st s = que.top(); que.pop();
			if (d[s.p][s.l] != s.c)continue;
			for (P u : E[s.p]) {
				if (s.l - u.first < 0)continue;
				if (b[u.second]) {
					for (int i = s.l - u.first; i <= m; i++) {
						if (d[u.second][i] > s.c + u.first + i - (s.l - u.first)) {
							d[u.second][i] = s.c + u.first + i - (s.l - u.first);
							que.push({ u.second,d[u.second][i],i });
						}
						else break;
					}
				}
				else if (d[u.second][s.l - u.first] > s.c + u.first) {
					d[u.second][s.l - u.first] = s.c + u.first;
					que.push({ u.second,s.c + u.first,s.l - u.first });
				}
			}
		}
		int Min = INF;
		for (int i = 0; i <= m; i++)Min = min(Min, d[h][i]);
		if (Min == INF)puts("Help!");
		else printf("%d\n", Min);
	}
}

Measured memory_bytes: 3376
x,y = map(int,input().split())
ans = 0
mod = 10**9+7

if (x+y)%3 == 0:
    m = (2*y-x)//3
    n = (2*x-y)//3
    if m >= 0 and n >= 0:
        fac = [1]*(m+n+1)
        for i in range(2,m+n+1): 
            fac[i] = fac[i-1]*i % mod
        ans = fac[m+n]*(pow(fac[m],mod-2,mod)*pow(fac[n],mod-2,mod)%mod)%mod

print(ans)

Measured memory_bytes: 29300
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int,input().split())

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060