akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iterator>
#include <tuple>
using namespace std;
using ll = long long;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    cout << 0 << endl;
  else
    cout << min(a * b, min(b * c, c * a)) << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int n, m, l;
  cin >> n >> m >> l;
  VI k(n), s(m);
  REP(i, n) cin >> k[i], k[i]--;
  REP(i, m) cin >> s[i];

  FOR(i, 1, m) s[i] += s[i-1];
  sort(ALL(k));

  auto sum = [&](int from, int to) {
    if(to < from) swap(from, to);
    return (s[to] - (from >= 1 ? s[from-1] : 0)) / l;
  };

  VVI dp(n, VI(n, -1));
  function<int(int,int)> dfs = [&](int x, int y) -> int {
    if(dp[x][y] >= 0) return dp[x][y];
    int nxt = max(x, y) + 1;
    if(nxt == n) {
      int tmp = min(x, y);
      return sum(k[tmp], k[n-1]);
    }
    int vl = dfs(nxt, y) + sum(k[x], k[nxt]);
    int vr = dfs(x, nxt) + sum(k[y], k[nxt]);
    return dp[x][y] = min(vl, vr);
  };

  cout << dfs(0, 0) << endl;

  return 0;
}



Measured memory_bytes: 35336
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    X,K,D = map(int,input().split())

    if X == 0:
        if K%2 ==0:
            res = 0
        else:
            res = D
        print(res)
        sys.exit()

    if X%D == 0:
        if abs(X // D) <= K:
            if (K - X // D)%2 == 0:
                res = 0
            else:
                res = D
        else:
            if X >= 0:
                res = abs(X - K * D)
            else:
                res = abs(X + K * D)
        print(res)
        sys.exit()

    bestp = X % D
    bestm = bestp - D

    ablep = False

    if abs(X-bestp)//D <= K:
        ablep = True

    ablem = False

    if abs(X-bestm)//D <= K:
        ablem = True

    if (not ablep) & (not ablem):
        if X >= 0:
            res = abs(X-K*D)
        else:
            res = abs(X+K*D)
        print(res)
        sys.exit()

    res = []

    if ablep:
        if X >= bestp:
            resid = K - (X - bestp) // D
        else:
            resid = K - (bestp - X) // D
        if resid%2 == 0:
            res.append(abs(bestp))
        else:
            res.append(abs(bestp-D))
            res.append(abs(bestp+D))

    if ablem:
        if X >= bestm:
            resid = K - (X - bestm) // D
        else:
            resid = K - (bestm - X) // D
        if resid%2 == 0:
            res.append(abs(bestm))
        else:
            res.append(abs(bestm-D))
            res.append(abs(bestm+D))

    res = min(res)
    print(res)



main()


Measured memory_bytes: 9240
s = input()
t = input()
match = [0] * 26
for i in range(len(s)):
    if match[ord(s[i])-97] == 0:
        match[ord(s[i])-97] = t[i]
    if match[ord(s[i])-97] != t[i]:
        print('No')
        break
else:
    for i in match:
        if i != 0 and match.count(i) != 1:
            print('No')
            break
    else: print('Yes')
    
    

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

const int INF = 2e9;
const LL LINF = 3e18;

LL n;
LL a[200010];
LL ans = 0;

LL solve(LL first)
{
  LL ret = 0;
  LL *p1, *p2;
  p1 = lower_bound(a + first, a + n + first, a[n] / 3 + a[first]);
  p2 = lower_bound(p1, a + n + first, (a[n + first] - *p1) / 2 + *p1);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  p2 = lower_bound(p1, a + n + first, (a[n + first] - *p1) / 2 + *p1);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  /*
  p2 = lower_bound(a + first, a + n + first, a[n] / 3 * 2 + a[first]);
  p1 = lower_bound(a + first, p1, (*p2 - a[first]) / 2 + a[first]);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  p1 = lower_bound(a + first, p1, (*p2 - a[first]) / 2 + a[first]);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));*/
  return ret;
}

int main()
{
  scanf("%lld", &n);
  for(LL i = 1; i <= n; i++)
    scanf("%lld", &a[i]);

  for(LL i = n + 1; i <= 2 * n; i++)
    a[i] = a[i - n];

  for(LL i = 2; i <= 2 * n; i++)
    a[i] += a[i - 1];

  for(LL i = 0; i < n; i++)
    ans = max(ans, solve(i));

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2748
//#pragma warning(disable:4996)
//#include <Windows.h>
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

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

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

void input();
void solve();

void daminput();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	//daminput();
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

int N, P;
string S;

void input() {
	cin >> N >> P;
	cin >> S;
}

void daminput() {
}

int modpow(int base, int p) {
	if (p == 0)return 1;
	if (p == 1)return base % P;
	int ans = modpow(base, p >> 1);
	ans = (ans * ans) % P;
	if (p & 1)ans = (ans * base) % P;
	return ans;
}

void solve() {
	reverse(S.begin(), S.end());
	LL ans = 0;
	VI VS(N + 1, 0);
	for (int n = 1; n <= N; n++)
	{
		VS[n] = S[n - 1] - '0';
	}
	if (P == 2 || P == 5) {
		for (int n = 1; n <= N; n++)
		{
			if (VS[n] % P == 0) {
				ans += (N-n+1);
			}
		}
	}
	else {
		VI memo(P, 0);
		memo[0]++;
		int sum = 0;
		for (int n = 1; n <= N; n++)
		{
			sum += (modpow(10, n) * VS[n]) % P;
			sum %= P;
			ans += memo[sum];
			memo[sum]++;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 4016
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,m;
char p[505][505] = {0},k;
int r[505][505] = {0},b[505][505] = {0};

int main(){
	cin >> n >> m;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			cin >> k;
			if(k == '#') r[i][j] = b[i][j] = p[i][j] = 1;
		}
	}
	for(int i = 1;i <= n;i ++) r[i][1] = b[i][m] = 1;
	for(int i = 1;i <= n;i ++){
		for(int j = 2;j < m;j ++){
			if(i & 1) r[i][j] = 1;
			else b[i][j] = 1;
		}
	}
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			printf("%c",r[i][j] ? '#' : '.');
		}
		printf("\n");
	}
	printf("\n");
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			printf("%c",b[i][j] ? '#' : '.');
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2944
s = input()
n1 = int(s[0:2])
n2 = int(s[2:4])

flag1 = False
flag2 = False
if n1 >= 0 and n2 >= 1 and n2 <= 12:
    flag1 = True
if n1 >= 1 and n1 <= 12 and n2 >= 0:
    flag2 = True

if flag1 and flag2:
    print('AMBIGUOUS')
elif flag1:
    print('YYMM')
elif flag2:
    print('MMYY')
else:
    print('NA')

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    string s;
    std::cin >> s;
    int n=s.size();
    int ans=0;
   // std::cout << n << std::endl;
    ans=0;
    std::vector<int> a(2019);
    rep(i,n){
        std::vector<int> aa(2019);
        rep(j,2019){
           aa[(j*10+(s[i]-'0'))%2019]+=a[j];
        }
        ans+=aa[0];
     //   std::cout << a[0] << std::endl;
        aa[s[i]-'0']++;
        rep(j,2019)a[j]=aa[j];
       // std::cout << s[i]-'0' << std::endl;
    }
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3668
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 1e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;char ls;ls = getchar();
    while (!isdigit(ls)){
        if (!(ls ^ 45)) kr = -1;
        ls = getchar();
    }
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;char ls;ls = getchar();
    while (!isdigit(ls))ls = getchar();
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs;
}
inline void writeull(ull x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
int a[109],b[109];
int main()
{
    int t=1;
    // t = read();
    while(t--){
        int n=read(),ans=0;
        for (int i=1;i<n;i++){
            if(n%i==0){
                ans+=(n/i-1);
            }else ans+=n/i;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <bitset>
#include <cmath>
#include <vector>
#include <memory>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ulong = unsigned long;
using ushort = unsigned short;
using uchar = unsigned char;

int main() {
#ifdef __TEST_CODE
    // A dumb way of inlining test cases
    stringstream input_s(
            "1000000"
    );
    stringstream output_s;

    string expected_out("266666333332\n"
    );
    expected_out += "\n";
    istream &in = input_s;
    ostream &out = output_s;
#else
    istream& in = cin;
        ostream& out = cout;
#endif


    long long n;
    in >> n;
    long long result = 0;
    for (long long i = 1; i <= n; ++i) {
        if ((i % 3 != 0) && (i % 5 != 0)) {
            result += i;
        }
    }

    out << result << endl;


#ifdef __TEST_CODE
    string actual_out = output_s.str();
    cout << actual_out;
    cout << "Output correct: " << (expected_out == actual_out) << endl;
#endif
    return 0;
}


Measured memory_bytes: 3604
//created by krishna
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull;
#define debug(x) cout<<"the value of "<<#x<<" is "<<x<<endl;
int main()
{
    int n;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<endl;
    
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
  long long n, k, ans=0;
  string s;
  cin >> n >> k >> s;
  vector<long long> vec;
  long long cnt=0;
  s+='.';
  for(int i=0;i<n;i++){
    cnt++;
    if(s[i+1] != s[i]){
      vec.push_back(cnt);
      cnt=0;
    }else{
      ans++;
    }
  }
  long long ans1=0, ans2=0, kk=k;
  for(size_t i=1;i<vec.size();i+=2){
    if(i == vec.size()-1){
      ans1++;
    }else{
      ans1+=2;
    }
    kk--;
    if(kk==0) break;
  }
  kk=k;
  for(size_t i=0;i<vec.size();i+=2){
    if(i == vec.size()-1 or i == 0){
      ans2++;
    }else{
      ans2+=2;
    }
    kk--;
    if(kk==0) break;
  }
  cout << min(n-1, ans+max(ans1, ans2)) << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	else cout << "Yes" << endl;
	VI v(2 * n - 1);
	REP(i, 2 * n - 1)v[i] = i + 1;
	swap(v[x - 1], v[n - 1]);
	swap(v[0], v[n - 2]);
	swap(v[2 * n - 2], v[n]);
	REP(i, 2 * n - 1)cout << v[i] << endl;
	return 0;


}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

class strongly_connected_components{
public:
	vector<vector<int> > G, rG;
	vector<int> used, vs;
	vector<int> cmp; //cmp[v] := ??????v?????????????????£??????????????????????????????????????????
	strongly_connected_components(const vector<vector<int> > &g, const vector<vector<int> > &rg, int n): G(g), rG(rg), cmp(n), used(n){
		exec();
	}
	int exec(){
		/*
		rep(i, G.size()){
			for(auto t : G[i]){
				printf("%d->%d\n", i, t);
			}
		}
		*/
		fill(used.begin(), used.end(), 0);
		for (int i = 0; i < G.size(); ++i){
			if(!used[i]) dfs(i);
		}
		fill(used.begin(), used.end(), 0);
		int k = 0;
		for (int i = vs.size() - 1; i >= 0; --i){
			if(!used[vs[i]]){
				rdfs(vs[i], k++);
			}
		}
		return k; //scc?????°
	}
	int operator[](int i){//??£???????????????????????????
        return cmp[i];
    }
private:
	void dfs(int curr){
		used[curr] = true;
		for(auto next : G[curr]){
			if(!used[next]) dfs(next);
		}
		vs.push_back(curr);
	}
	void rdfs(int curr, int k){
		used[curr] = true;
		cmp[curr] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
		for(auto next : rG[curr]){
			if(!used[next]) rdfs(next, k);
		}
	}
};


int main(void){
	int v, e; cin >> v >> e;
	vector<vector<int> > g(v), rg(v);
	rep(i, e){
		int s, t; cin >> s >> t;
		g[s].pb(t);
		rg[t].pb(s);
	}

	strongly_connected_components scc(g, rg, v);

	scc.exec();
	int q; cin >> q;

	rep(i, q){
		int u, v; cin >> u >> v;
		if(scc[u] == scc[v]){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 5572
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, R;
	vector<int> V, W;
	while (cin >> N >> R) {
		if (N == 0 && R == 0) break;
		V.clear();
		for (int i = 0; i < N; i++) {
			V.push_back(N - i);
		}
		for (int i = 0; i < R; i++) {
			int P, C;
			W.clear();
			cin >> P >> C;
			for (int j = P - 1; j < P + C - 1; j++) {
				W.push_back(V[j]);
			}
			for (int j = 0; j < P - 1; j++) {
				W.push_back(V[j]);
			}
			for (int j = P + C - 1; j < N; j++) {
				W.push_back(V[j]);
			}
			V = W;
		}
		cout << V[0] << endl;
	}
}


Measured memory_bytes: 3108
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<vector<int>>edge(N + 1);
	vector<bool>loop(N + 1, false);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>dis(N + 1, INT_MAX);
	dis[1] = 0;
	queue<int>Q;
	Q.push(1);
	while (!Q.empty()) {
		int cn = Q.front();
		int c = dis[cn];
		Q.pop();
		for (auto i : edge[cn]) {
			if (dis[i] > c + 1) {
				dis[i] = c + 1;
				Q.push(i);
			}
		}
	}
	bool complete = false;
	for (int i = 1; i <= N; i++) {
		for (auto j : edge[i]) {
			if (dis[i] % 2 == dis[j] % 2) {
				complete = true;
			}
		}
	}
	long long int odd = 0, even = 0;
	for (int i = 1; i <= N; i++) {
		if (dis[i] % 2) {
			odd++;
		}
		else {
			even++;
		}
	}
	if (complete) {
		cout << N*(N - 1) / 2 - M << endl;
	}
	else {
		cout << odd*even - M << endl;
	}
	return 0;
}


Measured memory_bytes: 6272
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void)
{
	int a[5], n, i;
	
	for(i = 0; i < 5; i++){
		scanf("%d", &a[i]);
	}
	
	sort(a, a+5);
	
	for (i = 0; i < 5; i++){
		
		printf("%d", a[4 - i]);
		if (i != 4){
			printf(" ");
		}
	}
	printf("\n");
	
	return(0);
}
	

Measured memory_bytes: 1044
import java.util.Scanner;
 
public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int n = scan.nextInt();
            if (n == 0) break;
            int[] s = new int[n];
            double m = 0;
            double a = 0;
            for (int i = 0; i < n; i++) {
                s[i] = scan.nextInt();
                m += s[i];
            }
            m = m/n;
            for (int i = 0; i < n; i++) {
                a += (s[i] - m) * (s[i] - m);
            }
            System.out.println(Math.sqrt(a/n));
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 31396
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    bool flag=true;
    if(s1.size()==s2.size()-1)
    {
       for(int i=0;i<s1.size();i++)
       {
           if(s1[i]!=s2[i])
           {
               flag=false;
               break;
           }
       }
       if(flag==true)
       {
           cout<<"Yes";
       }
       else
       {
           cout<<"No";
       }
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a,b,i,x,y;

    cin>>a>>b;

    for(i = 0; i <= 1000; i++)
    {
         x = i*.08;
         y = i*.1;
         if(x == a && y==b)
         {
              cout<<i<<endl;
              return 0;
         }
    }
    cout<<-1<<endl;

     return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;
 
inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

const int N = 500005;
char str[N];
int fa[N], fb[N], n;

void kmp(int *f){
	f[1] = 0;
	REP(i, 2, n){
		int p = f[i - 1];
		while (p && str[p + 1] != str[i]) p = f[p];
		if (str[p + 1] == str[i]) ++p;
		f[i] = p;
	}
}

int main(){
	scanf("%s", str + 1);
	n = strlen(str + 1);
	kmp(fa);
	if (n % (n - fa[n]) == 0 && n - fa[n] == 1){
		cout << n << endl << 1 << endl;
		return 0;
	}
	else if (n % (n - fa[n]) || n / (n - fa[n]) == 1){
		cout << 1 << endl << 1 << endl;
		return 0;
	}
	reverse(str + 1, str + n + 1);
	kmp(fb);
	int ans = 0;
	REP(i, 1, n - 1){
		int j = n - i;
		if ((i % (i - fa[i]) == 0 && i / (i - fa[i]) > 1)
		 || (j % (j - fb[j]) == 0 && j / (j - fb[j]) > 1));
		else ++ans;
	}
	cout << 2 << endl << ans << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    int ans=1000000;
    cin >> n;
    vector<int> x(n);
    rep(i,n)  cin >> x.at(i);
    
    for(int p=1; p<=100; p++){
        int hp=0;
    rep(i,n){
        hp += pow(x.at(i) - p,2);
    }
    ans = min(ans,hp);
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long unsigned int ll;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W, 0));
  deque<pair<int, int>> remaining;
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      A[i][j] = s[j] == '#'? 1 : 0;
      if (s[j] == '#') {
        A[i][j] = 1;
        remaining.push_back(make_pair(i, j));
      } else {
        A[i][j] = 0;
      }
    }
  }
  int ans = 0;
  while (!remaining.empty()) {
    deque<pair<int, int>> _next;
    for (auto p: remaining) {
      int i = p.first;
      int j = p.second;
      A[i][j] = 2;
      if (i > 0 && A[i-1][j] == 0) {
        A[i-1][j] = 1;
        _next.push_back(make_pair(i-1, j));
      }
      if (i < H - 1 && A[i+1][j] == 0) {
        A[i+1][j] = 1;
        _next.push_back(make_pair(i+1, j));
      }
      if (j > 0 && A[i][j-1] == 0) {
        A[i][j-1] = 1;
        _next.push_back(make_pair(i, j-1));
      }
      if (j < W - 1 && A[i][j+1] == 0) {
        A[i][j+1] = 1;
        _next.push_back(make_pair(i, j+1));
      }
    }
    remaining = _next;
    ans++;
  }
  if (ans == 0) {
    cout << 0 << endl;
  } else {
    cout << ans - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 12432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<string> s;
  s.resize(N);
  for(int i = 0; i < N; i++){    
    cin >> s[i];
  }
  int ac=0,wa=0,tle=0,re = 0;

  for(int i = 0; i < N; i++){
    if(s[i] == "AC"){
      ac++;
    } else if(s[i]  == "WA"){
      wa++;
    } else if(s[i] == "TLE"){
      tle++;
    } else if(s[i] == "RE"){
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 6428
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,K,S,i,j,k;

int main()
{
  cin >>N>>K>>S;
  
  if(N==K)
  {
    for(i=0;i<N;i++)
    {
      cout << S << " ";
    }
    return 0;
  }
  else
  {
    if(S==1)
    {
      for(i=0;i<K;i++)
      {
        cout << 1 << " ";
      }
      for(i=0;i<N-K;i++)
      {
        cout << 2 << " ";
      }
      return 0;
    }
    else
    {
      for(i=0;i<K+1;i++)
      {
        if(i%2==0)
        {
          cout <<S-1<< " ";
        }
        else
        {
          cout <<1<< " ";
        }
      }
      
      if(S<10)
      {
        for(i=0;i<N-K-1;i++)
        {
          cout <<100<< " ";
        }
      }
      else
      {
      for(i=0;i<N-K-1;i++)
        {
          cout <<S-2<< " ";
        }
      }
      return 0;
    }
  }
}

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

ll parseTotal(ll t)
{
    ll total=1;
    for(int i=1;i<=t;i++)
    {
        total *= i;
    }
    return total;
}

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

    ll total=K;
    if(N-1>0)
        total *= std::pow(K-1,N-1);

    std::cout << total;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
ll mod=1e9+7;


int main(){
    ll n;
    int k;
    cin>>n>>k;
    int digit=0;
    while(n>0){
        n/=k;
        digit++;
    }
    cout<<digit<<endl;
    return 0;
}

Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24312
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        for(int i=0;i<=N;i++){
            for(int j=0;j<=N-i;j++){
                if(Y==i*10000+j*5000+(N-i-j)*1000){
                        System.out.println(i+" "+j+" "+(N-i-j));
                        return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 25172
n, m, l = map(int, input().split())

AL = []
for i in range(n):
 ail = list(map(int,input().split()))
 AL.append(ail)

BL = []
for i in range(m):
 bil = list(map(int,input().split()))
 BL.append(bil)

for i in range(n):
 for j in range(l - 1):
  CI = 0
  for k in range(m):
   CI += AL[i][k] * BL[k][j]
  print(str(CI) + " ", end="")
 CI = 0
 for k in range(m):
  CI += AL[i][k] * BL[k][-1]
 print(str(CI))

Measured memory_bytes: 8584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n;
vector<ll> a;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  cin >> n;
  a.resize(n);
  rep(i,n) {
    cin >> a[i];
  }
  set<ll> st;
  rep(i,1ll<<n) {
    ll now = 0;
    rep(j,n) {
      if ((i>>j)&1) {
        now += a[j];
      }
    }
    st.insert(now);
  }

  ll q;
  cin >> q;
  rep(iter,q) {
    ll m;
    cin >> m;
    if (st.find(m) != st.end()) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		long ans=0;
		for (int i=0; i<n; i++)
			ans+=(i+1)*(long)(n-i);
		for (int i=1; i<n; i++) {
			int a=fs.nextInt()-1, b=fs.nextInt()-1;
			int min=Math.min(a, b), max=Math.max(a, b);
			ans-=(min+1)*(long)(n-max);
		}
		System.out.println(ans);
	}
	

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if((A==B && B == C) || (A != B && B != C && A != C)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>


using namespace std;
using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;


double calc(int n, int m, int d)
{
	double x=2.0*(n-d)/n/n;
	if(d==0) return 0.5*x*(m-1);
	return x*(m-1);
}


int main(void)
{
	int n, m, d;

	while(scanf("%d%d%d", &n, &m, &d)==3)
	{
		printf("%.10f\n", calc(n, m, d));
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	if (n >= 30)puts("Yes");
	else {
		puts("No");
	}
	return 0;
}


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

int main()
{
	int n, i , a[10];
	n=10;
	for (i=1;i<=n;i++) cin >>a[i];
	int j,tam;
	for (i=1;i<=n-1;i++)
	 for (j=i+1;j<=n;j++)
		 if (a[i]<a[j]) { tam=a[i];a[i]=a[j];a[j]=tam;}
	cout << a[1] << endl;
	cout << a[2] << endl;
	cout << a[3] << endl;
	return 0;
}

Measured memory_bytes: 1160
from heapq import heappop as pop
from heapq import heappush as push
INF = 1000000000000

def bfs(lst, used, que, w, h):
  v, y, x  = pop(que)
  if y > 0 and not used[y - 1][x]:
    push(que, (lst[y - 1][x], y - 1, x))
    used[y - 1][x] = True
  if h > y + 1 and not used[y + 1][x]:
    push(que, (lst[y + 1][x], y + 1, x))
    used[y + 1][x] = True
  if x > 0 and not used[y][x - 1]:
    push(que, (lst[y][x - 1], y, x - 1))
    used[y][x - 1] = True
  if w > x + 1 and not used[y][x + 1]:
    push(que, (lst[y][x + 1], y, x + 1))
    used[y][x + 1] = True
  return v

def make_dic(lst, w, h, x, y):
  que = [(1, y, x)]
  used = [[False] * w for _ in range(h)]
  used[y][x] = True
  dic = [[0, 0]]
  app = dic.append
  Max = 0
  acc = 0

  while que:
    v = bfs(lst, used, que, w, h)
    acc += 1
    if v > Max:
      app([v, acc])
      Max = v
    else:
      dic[-1][1] += 1
  return dic

def solve():
  while True:

    R = int(input())
    if not R:
      break

    w1, h1, x1, y1 = map(int, input().split())
    lst1 = [list(map(int, input().split())) for _ in range(h1)]
  
    w2, h2, x2, y2 = map(int, input().split())
    lst2 = [list(map(int, input().split())) for _ in range(h2)]
  
    dic1 = make_dic(lst1, w1, h1, x1 - 1, y1 - 1)
    dic2 = make_dic(lst2, w2, h2, x2 - 1, y2 - 1)
  
    end1 = len(dic1)
    end2 = len(dic2)
    ind1 = 0
    ind2 = end2 - 1
    ans = INF
  
    while ind1 < end1 and ind2 > 0:
      r1, sum1 = dic1[ind1]
      r2, sum2 = dic2[ind2]
  
      if sum1 + sum2 < R:
        ind1 += 1
        continue
  
      while ind2 > 0 and sum1 + sum2 >= R:
        ind2 -= 1
        r2, sum2 = dic2[ind2]
  
      if ind2 == 0 and sum1 + sum2 >= R:
        rs = r1 + r2
        if rs < ans:
          ans = rs
        break
  
      else:
        ind2 += 1
        r2 = dic2[ind2][0]
        rs = r1 + r2
        if rs < ans:
          ans = rs
  
      ind1 += 1
    print(ans)
 
solve()


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

const int INF = 1001001001;



int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>h(n);
    rep(i,n){
      cin>>h[i];
    }
    vector<ll>a(m);
    vector<ll>b(m);
    rep(i,m){
      cin>>a[i]>>b[i];
    }
    vector<ll>vec(n,1);
    rep(i,m){
      if(h[a[i]-1]>h[b[i]-1]){
        if(vec[a[i]-1]!=0){
          vec[a[i]-1]=2;
        }
        vec[b[i]-1]=0;
      }else if(h[a[i]-1]==h[b[i]-1]){
        vec[a[i]-1]=0;
        vec[b[i]-1]=0;
      }else{
        if(vec[b[i]-1]!=0){
          vec[b[i]-1]=2;
        }
        vec[a[i]-1]=0;
      }
    }
    ll ans=0;
    rep(i,n){
      if(vec[i]==2 || vec[i]==1){
        ans++;
      }
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 6428
#include <cstdlib>
#include <iostream>
#include <string>
#include <list>
#include <map>
using namespace std;

class Team
{
	static int mCount;
	int mTeamID;
	int mCorrect;
	map< int, int > mWorng;
	int mPenalty;

public:
	int Correct()const{ return mCorrect; }
	int Penalty()const{ return mPenalty; }
	int TeamID()const{ return mTeamID; }
	bool IsHigherThan(const Team& t)const
	{
		if(mCorrect > t.Correct())
			return true;
		else if(mCorrect==t.Correct() && mPenalty < t.Penalty())
			return true;
		return false;
	}

private:
	Team():mCorrect(0), mPenalty(0),mTeamID(++mCount){}

public:
	Team(const Team& t):mCorrect(t.mCorrect), mPenalty(t.mPenalty), mTeamID(t.mTeamID){}

	static void* operator new[](size_t s){ mCount=0; return malloc(s); }
	static Team* New(size_t s){ return new Team[s]; }
	void Correct(int pID, int time)
	{
		mCorrect++;
		if(mWorng.count(pID) == 0)
		{
			mPenalty += time;
		}
		else
		{
			map<int, int>::iterator i=mWorng.find(pID);
			mPenalty += (*i).second*1200 +time;
			mWorng.erase(i);
		}
	}
	void Worng(int pID)
	{
		if(mWorng.count(pID) == 0)
		{
			pair<int, int> worngData;
			worngData.first  = pID;
			worngData.second = 1;
			mWorng.insert(worngData);
		}
		else
		{
			map<int, int>::iterator i=mWorng.find(pID);
			(*i).second++;
		}
	}
};
int Team::mCount = 0;

int main(void)
{
	istream& in =cin;
	ostream& out=cout;
	const string correct="CORRECT", worng="WORNG";
	int teamN, probN, logN;
	while(1)
	{
		in >> teamN >> probN >> logN;
		if(teamN == 0)break;
		Team* team=Team::New(teamN);
		for(int i=0; i<logN; i++)
		{
			string command;
			int tID, pID, time;
			in >> tID >> pID >> time >> command;
			
			if(command == correct)
				team[tID-1].Correct(pID, time);
			else
				team[tID-1].Worng(pID);
		}

		list<Team> teamRank;
		teamRank.push_back(team[0]);
		for(int i=1; i<teamN; i++)
		{
			list<Team>::iterator it=teamRank.begin();
			while(it != teamRank.end())
			{
				if(team[i].IsHigherThan(*it))
				{
					teamRank.insert(it, (team[i]));
					break;
				}
				it++;
			}
			if(it == teamRank.end())
				teamRank.push_back(team[i]);
		}
		
		list<Team>::iterator it=teamRank.begin();
		while(it != teamRank.end())
		{
			out << (*it).TeamID() << ' ' << (*it).Correct() << ' ' << (*it).Penalty() << endl;
			it++;
		}
		delete[] team;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

int main(){
    
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    
    ll l1 = min(Q * 4, min(H * 2, S));
    ll l2 = min(l1 * 2, D);
    
    cout << (N / 2) * l2 + (N % 2) * l1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    # player = {"a": [], "b": [], "c": []}
    # for k in player:
    #     player[k] = list(input())
    player = {i:list(input()) for i in 'abc'}
    p = 'a'
    while player[p]:
        p = player[p].pop(0)
    print(p.upper())

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<stdio.h>
#define MAX 10000000

int size, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest, t;
  l = 2 * i;
  r = 2 * i + 1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ) {
    t = A[i]; 
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}

int main() {
	int i;
  scanf("%d", &size);
  for ( i = 1; i <= size; i++ ) {
  	scanf("%d", &A[i]);
  }
  
  for ( i = size / 2; i >= 1; i-- ) {
  	maxHeapify(i);
  }
  
  for ( i = 1; i <= size; i++ ) {
    printf(" %d", A[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 3812
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Bool (bool)

match :: String -> String -> Bool
match []     _      = True
match _      []     = False
match (a:as) (b:bs)
    | b == '?' || a == b = match as bs
    | otherwise          = False

main :: IO ()
main = do
    ss <- getLine
    ts <- getLine
    let n = length ss
    let ss' = reverse . tails $ ss
    case filter (match ts) ss' of
        []     -> putStrLn "UNRESTORABLE"
        (xs:_) -> do
            let a = ts ++ drop (length ts) xs
            let b = take (n - length a) ss ++ a
            let ans = fmap (\c -> bool c 'a' (c == '?')) b
            putStrLn ans

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

int main() {
  string s;
  cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main(){
  int X,Y;
  cin>>X>>Y;
  string S="No";
   for(int a=0;a<101;a++){
     for(int b=0;b<101;b++){
       if(X==a+b&&Y==2*a+4*b){
         S="Yes";
         break;
       }
     } 
   }
    cout<<S<<endl;
 }

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int w;
	char s[1007];
	scanf("%s",s);
	scanf("%d",&w);
	for (int i = 0; i < strlen(s); i += w)	printf("%c", s[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,T = map(int,input().split())
As = list(map(int,input().split()))

mns = [0] * N
mxs = [0] * N

mns[0] = As[0]
mxs[N-1] = As[N-1]

for i in range(1, N):
    j = N - i - 1
    mns[i] = min(As[i], mns[i-1])
    mxs[j] = max(As[j], mxs[j+1])

# print(mns)
# print(mxs)

mx_diff = -1
pairs = set()
for i in range(1, N):
    diff = mxs[i] - mns[i]
    if diff > mx_diff:
        mx_diff = diff
        pairs.clear()
    if diff >= mx_diff:
        pairs.add((mns[i], mxs[i]))
print(len(pairs))
    




Measured memory_bytes: 15060
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

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

    bool ok = (a.back() == b.front()) && (b.back() == c.front());
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256