akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  tmp = input.split(" ");
  var a = parseInt(tmp[0], 10);
  var b = parseInt(tmp[1], 10);
  var s = ((a * b) % 2 == 0) ? "Even" : "Odd";
  console.log('%s',s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N;
ll A[200000],sum,ans;
map<ll, ll> B;
queue<ll> C;


long long comb(long long n) {
	return (n * (n - 1)) / 2;
}



int main() {
	cin >> N;
	B[0] = 1;
	FOR(i, 0, N) {
		ll unko; cin >> unko;
		sum += unko;
		
		
			if (B[sum] == 1) {
				C.push(sum);
			}
			B[sum]++;
		
		
	}
	while (!C.empty()) {
		ll part = C.front();
		C.pop();
		ans += comb(B[part]);
	}
	ct(ans);

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] -= i;
    }
    map<ll, ll> count;
    for(auto v : A){
        if(count.count(v)==0) count[v] = 0;
        count[v]++;
    }
    ll res = 0;
    for(int i=0; i<N; i++){
        auto v = -A[i] - 2*i;
        if(count.count(v) == 0) continue;
        res += count[v];
    }
    cout << res << endl;

    return 0;
}

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

int main()
{

  int e;
  while(cin >> e, e){
    int minx = 1111111111;

    for(int i = 0; i*i <= e; i++){
      for(int j = 0; j*j*j <= e; j++){

        int z = e-(i*i+j*j*j);
        int tmp = i*i + j*j*j + z;

        if(z >= 0 && tmp == e){
          minx = min(minx, i+j+z);

        }

      }
    }

    cout << minx << endl;

  }

  return 0;

}



Measured memory_bytes: 3068
#!python3

import numpy as np


def LI():
    return list(map(int, input().split()))

# input
N, M, X = LI()
CA = np.array([LI() for _ in range(N)])

INF = 10 ** 15


def main():
    n = 2 ** N
    ans = INF
    for i in range(1, n):
        b = format(i, "0{}b".format(N))
        c = 0
        l = np.zeros(M)
        for j in range(N):
            if b[j] == "1":
                c += CA[j][0]
                l += CA[j][1:]
        if (l >= X).all():
            ans = min(ans, c)

    ans = -1 if ans == INF else ans
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27240
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

int dp[3010][6020];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    vector<P> ab(n);
    for(int i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ALL(ab));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 6020; j++) {
            if(j < t) {
                chmax(dp[i + 1][j + ab[i].first], dp[i][j] + ab[i].second);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    int ans = -INF;
    for(int i = 0; i < 6020; i++) {
        chmax(ans, dp[n][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 69888
import collections

S = input()

Q = int(input())

list1 = collections.deque()
list2 = []
flag = 1

for _ in range(Q):
    op = input().split()
    if len(op) == 1:
        flag *= -1
    else:
        if flag == 1:
            if op[1] == '1':
                list1.appendleft(op[2])
            else:
                list2.append(op[2])
        else:
            if op[1] == '1':
                list2.append(op[2])
            else:
                list1.appendleft(op[2])

if flag == 1:
    print("".join(list1) + S + "".join(list2))
else:
    print(("".join(list1) + S + "".join(list2))[::-1])


Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = to - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int r, g, b;
  int x;
  cin >> r >> g >> b;
  cin >> x;
  int left = x;

  while(r >= g && left > 0) {
    g *= 2;
    left--;
  }

  while(g >= b && left > 0) {
    b *= 2;
    left--;
  }

  if(r < g && g < b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>
#define vec2(var, n, m)  vector<vector<int>> var(n, vector<int>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrst(s,n);

  vec2(num, n, 26);
  rep(i,n){
    rep(j,s[i].size()){
      num[i][s[i][j]-'a']++;
    }
  }

  rep(i,26){
    int tmp=100000000;
    rep(j,n){
      chmin(tmp, num[j][i]);
    }
    while(tmp){
      char x = 'a' + i;
      cout << x;
      tmp--;
    }
  }
  cout << "\n";

}


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

int main() {
	int r,g,b,N;
	cin >> r >> g >> b;
	N = r * 100 + g * 10 + b;
	
	if (N % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int n, A, B, C;
vi l;
int dfs(int i, int a, int b, int c)
{
    if (i == n)
    {
        if (a == 0 || b == 0 || c == 0)
        {
            return INT_MAX;
        }
        else
        {
            return abs(A - a) + abs(B - b) + abs(C - c) - 30;
        }
    }
    int o = dfs(i + 1, a, b, c);
    int p = dfs(i + 1, a + l[i], b, c) + 10;
    int q = dfs(i + 1, a, b + l[i], c) + 10;
    int r = dfs(i + 1, a, b, c + l[i]) + 10;
    return min({o, p, q, r});
}
signed main()
{
    cin >> n >> A >> B >> C;
    l.resize(n);
    rep(i, n)
    {
        cin >> l[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void){
  
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  
  if((n-1)%(k-1)==0){
    cout<<(n-1)/(k-1);
  }
  else{
    cout<<(n-1)/(k-1)+1;
  }
  
}

Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
#define N 40
#define INF 1000
#define Pair pair<int,int>
#define x first
#define y second

using namespace std;

int h, w;
int data[N][N];
bool H[N][N], V[N][N];
int X[]={-1, 0, 0, 1};
int Y[]={0, -1, 1, 0};

void init(){
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      data[i][j]=INF;
      H[i][j]=true;
      V[i][j]=true;
    }
  }
}

void input(){
  for(int i=0; i<2*h-1; ++i){
    if(i%2){
      for(int j=0; j<w; ++j) cin >> H[i/2][j];
    }else{
      for(int j=0; j<w-1; ++j) cin >> V[i/2][j];
    }
  }
}

bool check(const Pair& p, int& k){
  if(!(p.x>=0 && p.x<h)) return false;
  if(!(p.y>=0 && p.y<w)) return false;
  if(data[p.x][p.y]<INF) return false;
  if(k==0) return !H[p.x][p.y];
  if(k==1) return !V[p.x][p.y];
  if(k==2) return !V[p.x][p.y-1];
  if(k==3) return !H[p.x-1][p.y];
  return false;
}

int bfs(){
  queue<Pair> qu;
  qu.push(Pair(0,0));
  data[0][0]=1;
  while(!qu.empty() && data[h-1][w-1]==INF){
    int s=qu.size();
    for(int i=0; i<s; ++i){
      Pair p1=qu.front(); qu.pop();
      for(int j=0; j<4; ++j){
	Pair p2(p1.x+X[j], p1.y+Y[j]);
	if(check(p2,j)){
	  data[p2.x][p2.y] = data[p1.x][p1.y] + 1;
	  qu.push(p2);
	}
      }
    }
  }
  return data[h-1][w-1];
}

int main(){
  while(1){
    cin >> w >> h;
    if(!w && !h) break;
    init();
    input();
    int ans=bfs();
    cout << (ans!=INF ? ans : 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            sum += w[i];
        }
        int minDiff = Integer.MAX_VALUE;
        int group1 = 0;
        int group2 = sum;
        for (int i = 0; i < n - 1; i++) {
            group1 += w[i];
            group2 -= w[i];
            minDiff = Math.min(Math.abs(group1 - group2), minDiff);
        }
        System.out.println(minDiff);
    }

}


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

int main() {

    int a, b;

    cin >> a >> b;

    if(a == b) {
        cout << "a == b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }

}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n,d;cin>>n>>d;
    int sum=0;
    int cnt=0;
    while(sum<n){
        cnt++;
        sum+=(2*d+1);
    }
    co(cnt);
}


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

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

using namespace std;

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << '\n';
}

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

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main(void)
{
    using namespace std;
    int n;
    cin >> n;
    cout << lcm(2, n) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast", "unroll-loops", "loop-nest-optimize")

#include <bits/stdc++.h>

#define REP(i, n) REPI(i, 0, n)
#define REP1(i, n) REPI(i, 1, n)
#define REPI(i, init, n) for(int i = init; i < n; i++)
#define MS(arr, val) memset(arr, val, sizeof(arr))
#define SZ(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
#define EB emplace_back
#define UB upper_bound
#define LB lower_bound
#define FS first
#define SC second

#ifdef __WIN32__
inline size_t fread_unlocked(void *_buf, int _sz, int _cnt, FILE *_stream)
{
	return fread(_buf, _sz, _cnt, _stream);
}//fread_unlocked
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
//typedef pair<int, int> P;

char buf[100000];

inline char gc()
{
	static char *st = buf, *ed = buf;

	if (st >= ed)
	{
		st = buf;
		ed = st + fread_unlocked(buf, 1, sizeof(buf), stdin);

		if (st == ed) return EOF;
	}//if

	return *(st++);
}//gc

template<class T>
inline bool rit(T &_a)
{
	char _c = gc();
	bool neg = false;
	for (; _c < '0' || _c > '9'; _c = gc())
	{
		if (_c == EOF) return false;
		if (_c == '-') neg = true;
	}//for

	for (_a = 0; _c >= '0' && _c <= '9'; _c = gc())
		_a = _a * 10 + _c - '0';

	if (neg) _a = -_a;

	return true;
}//rit

template<class S, class ...T>
inline bool rit(S &_a, T&... _b)
{
	if (!rit(_a)) return false;
	return rit(_b...);
}//rit

//============================================================================//

const int MAX_N = 1e3 + 10;
//const int INF8 = 0x3f;
//const int INF32 = 0x3f3f3f3f;
//const int MOD = 1e9 + 7;
//const int MOD = 46337; //maximum prime int for multiplying
//const LL MOD = 2999999929; //maximum prime LL for multiplying
//const LL INF64 = 0x3f3f3f3f3f3f3f3f;
//const DB PI = acos(-1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N;
	LL t, T[MAX_N], A[MAX_N];
	
	rit(N);
	REP(i, N) rit(T[i], A[i]);
	
	REP1(i, N)
	{
		t = max(T[i - 1] / T[i] + (T[i - 1] % T[i] != 0), A[i - 1] / A[i] + (A[i - 1] % A[i] != 0));
		T[i] *= t;
		A[i] *= t;
	}//REP 1
	
	cout << T[N - 1] + A[N - 1];
	
	return 0;
}//main

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, q;
   cin >> n >> q;
   vector<tuple<int, int, int>> a;
   rep(i, 0, n) {
      int x, s, t;
      cin >> s >> t >> x;
      a.emplace_back(x, s - x, t - x);
   }
   sort(a.begin(), a.end());

   set<P> s;

   rep(i, 0, q) {
      int d;
      cin >> d;
      s.insert(P(d, i));
   }

   vector<int> ans(q, -1);
   rep(i, 0, n) {
      int x, l, r;
      tie(x, l, r) = a[i];
      auto it = s.lower_bound(P(l, -1));
      while (it != s.end()) {
         if (it->first >= r) break;
         ans[it->second] = x;
         s.erase(it++);
      }
   }
   rep(i, 0, q) cout << ans[i] << endl;
   return 0;
}

Measured memory_bytes: 15804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll tot = 0;
    rep(i, n) tot += a[i];
    ll ans = 0;
    rep(i, n-1) {
        tot -= a[i];
        ans += (a[i]*(tot%MOD))%MOD;
        ans %= MOD;
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 4032
module SS = Set.Make(String)

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let rec doit set i =
    if i = n then ()
    else
      match split_on_char ' ' (read_line ()) with
      | ["find"; s] ->
        begin
          print_endline (if SS.mem s set then "yes" else "no");
          doit set (i + 1)
        end
      | [_; s] -> doit (SS.add s set) (i + 1)
      | _ -> assert false in
  doit SS.empty 0

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

int main(){
    int n,z,w;
    cin>>n>>z>>w;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==1){
        cout<<abs(a[n-1]-w)<<endl;
    }else{
        cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B < C + D){
    cout << "Right" << endl;
  }else if (A + B == C + D){
    cout << "Balanced" << endl;
  }else{
    cout << "Left" << endl;
  } 
}

Measured memory_bytes: 256
import sys
f = sys.stdin
N = int(f.readline()[:-1])
A = tuple(map(int, f.readline().split(' ')))
d = dict()
result = 'YES'
for a in A:
    try:
        if d[a]:
            result = 'NO'
            break
    except Exception:
        d[a] = True

print(result)

Measured memory_bytes: 32924
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 100001;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define FAIL {printf("NO\n"); return 0;}

int N;
char S[MAXN];
int C[26];
LL ans;

int main() {
#ifdef OJ
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	scanf("%d", &N);
	scanf("%s", S);

	for (int i = 0; i < N; i++) {
		int c = S[i] - 'a';

		LL tmp = 1;
		for (int k = 0; k < 26; k++) if (k != c) {
			tmp = tmp * (C[k] + 1) % MOD;
		}

		ans = (ans + tmp) % MOD;
		C[c]++;

		//printf("%c %lld %lld\n", S[i], tmp, ans);
	}

	printf("%lld", ans);

	printf("\n");
	return 0;
}


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

using ll = long long;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    ll L = 1;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] /= 2;
        L = lcm(L, a[i]);
        if (L > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < N; i++) {
        if ((L / a[i]) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M / L + 1) / 2 << endl;
}

Measured memory_bytes: 640
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int S = int.Parse(Console.ReadLine());
			int h, m, s;
			h = S / 3600;
			m = (S - 3600 * h) / 60;
			s = S - 3600 * h - 60 * m;
			Console.WriteLine("{0}:{1}:{2}", h, m, s);
		}
	}
}

Measured memory_bytes: 9100
using System;
using System.Linq;
class Program{
    static void Main(){
        int[] abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = abc[0], b = abc[1], c = abc[2];
        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
            Console.WriteLine(0);
        else
            Console.WriteLine(Math.Min(Math.Min((long)a * b, (long)b * c), (long)c * a));
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

using namespace std;
typedef long long llong;

void CMaximumVolume(std::istream& in, std::ostream& out) {
  int L;
  in >> L;
  double x = (double) L / 3.0;
  cout << setprecision(12) << x * x * x << endl;
}

int main(int argc, char** argv) { CMaximumVolume(cin, cout); return 0; }


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

struct Info{
	char name[50];
	int year;
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

int main(){

	int N,Q;
	scanf("%d %d",&N,&Q);
	Info info[N+1];

	strcpy(info[0].name,"kogakubu10gokan\0");
	info[0].year = 1;

	for(int i = 1; i <= N; i++){
		scanf("%d %s",&info[i].year,info[i].name);
	}

	for(int i = 1; i <= N-1; i++){
		for(int k = N-1; k >= i; k--){
			if(info[k].year < info[k-1].year)swap(info[k],info[k-1]);
		}
	}

	if(Q >= info[N].year){
		printf("%s\n",info[N].name);
		return 0;
	}

	int index;

	for(index = 0; info[index].year <= Q; index++);


	printf("%s\n",info[index-1].name);

	return 0;
}

Measured memory_bytes: 2692
#include <stdio.h>
#include <math.h>

int abs(int a)
{
 return (int)sqrt(a*a); 
}

int main()
{
  int a, b, c;
  int d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  
  if( abs(a-c) <= d)
  {
    printf("Yes\n");
    return 0;
  }
  if( (a <= b && b <= c) || (a<= b && b >= c) )
    if( abs(a-b) <= d && abs(b-c) <= d)
    {
      printf("Yes\n");
      return 0;
    }
  printf("No\n");
  return 0;
}
  

Measured memory_bytes: 128
x, y = map(int, input().split())

def calc(x, y):
    for i in range(x + 1):
        for j in range (x + 1 - i):
            if i * 10000 + j * 5000 + (x - i - j) * 1000 == y:
                return  print(i, j, (x - i - j))
    return print('-1 -1 -1')
calc(x, y)

Measured memory_bytes: 3060
// top down approach
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define MOD ll(1e9L+7)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 
#define t2() ll tt2; cin>>tt2; for(ll tti=1;tti<=tt2;tti++)
#define printcj "Case #"<<tti<<": "
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";

const ll sz=100001;
ll n,k,a[sz];
bool dp[sz];

int main()
{
    fastio;
    ll i,j;
    cin>>n>>k;
    for(i=0;i<n;i++)cin>>a[i];
    
    // dp[i] = true if first player can win if initial k==i
    dp[0] = 0;
    for(i=1;i<=k;i++){
        dp[i] = false;
        for(j=0;j<n;j++)
            if(a[j]<=i && !dp[i-a[j]])
                dp[i] = true;
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
    

    
}

Measured memory_bytes: 3712
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"NO\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}



int main() {

    get(n);
    map<string, ll> vals;

    rep2(i,1,n+1) {
        string a = to_string(i);
        string key; key+=a[0]; key+=a[a.length()-1];
        vals[key]++;
    } 

    // debug_map(vals);
    ll sum = 0;
    rep2(i,1,n+1) {
        string a = to_string(i);
        string key; key+=a[0]; key+=a[a.length()-1];
        string revkey = key; reverse(ALL(revkey));
        sum += vals[revkey];
    }

    printf("%lld\n", sum);

    return 0;  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		int ans = 1145141919;
		for (int y = 0; y <= 1000; y++) {
			for (int z = 0; z <= 100; z++) {
				if (n < y*y + z*z*z)continue;
				ans = min(ans, n - y*y - z*z*z + y + z);
			}
		}
		cout << ans << endl;
	}return 0;
}

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

int main() {
int H, W;
  cin >> H >> W;
  vector <char> S(W+2);
  for (int i = 0; i<W+2; i++){
    S.at(i) = '#';
  }
  for (int i = 0; i<W+2; i++){
    if(i != W+1){
  cout << S.at(i);
  }
    else{
       cout << S.at(i) << endl;
    }
  }
  for (int j = 0; j<H;j++){
   for (int i = 0; i<W+2; i++){
     if (i == 0|i == W + 1){
       S.at(i) = '#';
     }
         else{
           cin >> S.at(i);
         }
   }
  for (int i = 0; i<W+2; i++){
    if (i != W+1){
  cout << S.at(i);
  }
    else{
       cout << S.at(i) << endl;
    }
  }
  }
  for (int i = 0; i<W+2; i++){
    S.at(i) = '#';
  }
  for (int i = 0; i<W+2; i++){
    if(i != W+1){
  cout << S.at(i);
  }
    else{
       cout << S.at(i) << endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int fib(int);
int dp[50];

int main()
{int a,i;

  for(i=0;i<50;i++)
    {
      dp[i]=-1;
    }
  
  scanf("%d",&a);
  printf("%d\n",fib(a));
  return 0;
}


int fib(int a)
{
  
  if(a==0 || a==1)
    return dp[a] = 1;
  if (dp[a] != -1)return dp[a];
  return dp[a]=fib(a-2)+fib(a-1);
}



Measured memory_bytes: 2112
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n, k = wi()
    a = n % k
    b = abs(a - k)
    print(min(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)
#define LARGENUM 1000000007


int main(){
    int n,k;
    cin >> n >> k;
    long long counter = 0;
    rep(i,k,n+2){
        counter += i * (n - i + 1) + 1;
    }
    cout << counter % LARGENUM << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  long long a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  long long ans = 0;
  if (c * 2 < a + b) {
    // ABピザを買うほうがお得
    ans = c * 2 * min(x, y);
    ans += x < y ? b * (y - x) : a * (x - y);
    ans = min(ans, c * 2 * max(x, y));
  } else {
    ans = x * a + y * b;
  }

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

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	n := scanInt(sc)
	var limit uint64 = 1
	for i := 0; i < 18; i++ {
		limit *= 10
	}
	var exp float64 = 1
	var res uint64 = 1
	over := false
	for i := 0; i < n; i++ {
		c := scanUint(sc)
		if c == 0 {
			fmt.Println("0")
			return
		}
		exp *= float64(c)
		res *= c
		if res > limit || exp > 1e18 {
			over = true
			res = 1
		}
	}
	if over {
		fmt.Println("-1")
		return
	}
	fmt.Println(res)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanUint(sc *bufio.Scanner) uint64 {
	sc.Scan()
	u, _ := strconv.ParseUint(sc.Text(), 10, 64)
	return u
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

/*
struct Edge{
  int to;
  int weight;
  Edge(int t,int w) : to(t). weight(w) { }
};
*/

using Graph = vector<vector<int>>;

//深さ優先探索
vector<bool> seen;
vector<int64_t> A;
int64_t root = INF;

void dfs(const Graph &G, int v){
  if(!seen[v]){
    seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
    for(auto next_v : G[v]){
      if (seen[next_v]) continue; // next_v が探索済みだったらスルー
      dfs(G, next_v); // 再帰的に探索
    } 
    root = v;
  }
}

void dfs1(const Graph &G, int v){
  seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto next_v : G[v]){
    if (seen[next_v]) continue; // next_v が探索済みだったらスルー
    A[next_v] += A[v];
    dfs1(G, next_v); // 再帰的に探索
  } 
}


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

  int N, Q; cin >> N >> Q;
  
  Graph G(N+1);
  for(int i=1;i<N;i++){
    int A, B;
    cin >> A >> B;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  seen.assign(N+1, false); // 全頂点を「未訪問」にして初期化
  A.assign(N+1, 0);

  /*
  for(int i=1;i<=N;i++){
    dfs(G, i);
  }
  */
  
  for(int i=0;i<Q;i++){
    int64_t a, b;
    cin >> a >> b;
    A[a] += b;
  }

  /*
  for(int i=1;i<=N;i++){
    seen[i] = false;
  }
  */

  dfs1(G, 1);

  for(int i=1;i<=N;i++){
    cout << A[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 24320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            foreach (var v in Console.ReadLine().Split(' '))
            {
                var v2 = int.Parse(v);

                if (v2 % 2 != 0)
                    continue;

                if (v2 % 3 != 0 && v2 % 5 != 0)
                {
                    Console.WriteLine("DENIED");
                    return;
                }
            }

            Console.WriteLine("APPROVED");
        }
    }
}


Measured memory_bytes: 17720
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<c&&b<c){cout<<a+b<<endl;}
  else if(a<b&&c<b){cout<<a+c<<endl;}
  else if(b<a&&c<a){cout<<b+c<<endl;}
  else if(a==b&&b==c){cout<<a+b<<endl;}
  else if(a==b&&c<a){cout<<a+c<<endl;}
  else if(a==c&&b<a){cout<<a+b<<endl;}
  else{cout<<a+b<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000005];
int main()
{
	ll n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<n;i++)
	for(int j=i+1;j<=n;j++)
	ans+=a[i]*a[j];
	cout<<ans;
} 

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[5140],p;
  int ct;
  bool b[50000];
  memset(b,0,50000);
  a[0]=2;
  j=1;
  b[2]=1;
  for(i=3;i<50000;i+=2){
    l=(int)sqrt(i)+1;
    for(k=3;k<l;k+=2){
      if(i%k==0)
	break;
    }
    if(k>=l){
      a[j]=i;
      j++;
      b[i]=1;
    }
  }
  while(cin>>p&&p){
    if(p%2){
      if(b[p-2])
	ct=1;
      else
	ct=0;
    }else{
      ct=0;
      for(i=0;a[i]*2<=p;i++){
	if(b[p-a[i]])
	  ct++;
      }
    }
    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int l,r;cin>>l>>r;
    if(r-l+1>=2019){
        cout<<0<<endl;
        return 0;
    }
    int a=(r-l)*(r-l+1)/2;
    vin mod(a);
    int k=0;
    rep2(i,l,r){
        rep2(j,i+1,r+1){
            mod[k]=((i%2019)*(j%2019))%2019;
            k++;
        }
    }
    sort(all(mod));
    cout<<mod[0]<<endl;
}

Measured memory_bytes: 8192
(defun ramen (str)
  (let ((n 700))
    (cond
      ((char= #\o (char str 0)) (setf n (+ n 100))))
    (cond
      ((char= #\o (char str 1)) (setf n (+ n 100))))
    (cond
      ((char= #\o (char str 2)) (setf n (+ n 100))))
    (format t "~A~%" n)))

(ramen (read-line))

Measured memory_bytes: 12388
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace  std;

const double cos60 = cos(M_PI / 3);
const double sin60 = sin(M_PI / 3);

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }
  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }

  ~StPnt() { }
};

void fnInput(int &rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnKochCrv( const StPnt &cnroPnt1, const StPnt &cnroPnt2, vector<StPnt> &rvoRtnPnt)
{
  rvoRtnPnt[0] = cnroPnt1;
  rvoRtnPnt[1].m_nx = (2 * cnroPnt1.m_nx + cnroPnt2.m_nx) / 3;
  rvoRtnPnt[1].m_ny = (2 * cnroPnt1.m_ny + cnroPnt2.m_ny) / 3;
  rvoRtnPnt[3].m_nx = (cnroPnt1.m_nx + 2 * cnroPnt2.m_nx) / 3;
  rvoRtnPnt[3].m_ny = (cnroPnt1.m_ny + 2 * cnroPnt2.m_ny) / 3;

  rvoRtnPnt[2].m_nx =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * cos60 
                     - (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * sin60 + rvoRtnPnt[1].m_nx;
  rvoRtnPnt[2].m_ny =  (rvoRtnPnt[3].m_nx - rvoRtnPnt[1].m_nx) * sin60 
                     + (rvoRtnPnt[3].m_ny - rvoRtnPnt[1].m_ny) * cos60 + rvoRtnPnt[1].m_ny;

  rvoRtnPnt[4] = cnroPnt2;
}

void fnKochCtl(int nRcSiz, vector<vector<StPnt>> &rvvoPnt)
{
  StPnt oPntB(0.0, 0.0);
  StPnt oPntE(100.0, 0.0);

  rvvoPnt.resize(7);
  rvvoPnt[0].clear();
  rvvoPnt[0].push_back(oPntB);
  rvvoPnt[0].push_back(oPntE);

  for (int nRc = 0; nRc < nRcSiz; nRc++)
  {
    rvvoPnt[nRc + 1].clear();
    rvvoPnt[nRc + 1].push_back(oPntB);
    for (int i = 0; i < rvvoPnt[nRc].size() - 1; i++)
    {
      StPnt oPnt1 = rvvoPnt[nRc][i];
      StPnt oPnt2 = rvvoPnt[nRc][i + 1];
      vector<StPnt> voRtnPnt(5);

      fnKochCrv(oPnt1, oPnt2, voRtnPnt);
      for (int j = 1; j < 5; j++)
        rvvoPnt[nRc + 1].push_back(voRtnPnt[j]);
    }
  }
}

void fnResult(int nRcSiz, const vector<vector<StPnt>> &cnrvvoPnt)
{
  for (int i = 0; i < cnrvvoPnt[nRcSiz].size(); i++)
    cout << cnrvvoPnt[nRcSiz][i].m_nx << " " << cnrvvoPnt[nRcSiz][i].m_ny << endl;
}

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

  int nRcSiz;
  vector<vector<StPnt>> vvoPnt;

  fnInput(nRcSiz);
  fnKochCtl(nRcSiz, vvoPnt);

  fnResult(nRcSiz, vvoPnt);

  return 0;
}

Measured memory_bytes: 1392
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>

int main() {
	int x;
	std::cin >> x;
	std::string ans = (x < 1200) ? "ABC" : "ARC";
	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
vector<lld>v[200005];
lld visited[200005];
lld ctr=0;
void dfs(lld c)
{
    visited[c]=1;
    ctr++;
    for(lld x:v[c])
    {
        if(visited[x]==0)
            dfs(x);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n,m;
        set<pair<lld,lld>>s;
        cin>>n>>m;

        for(i=0;i<m;i++)
        {   lld a,b;
            cin>>a>>b;
            if(s.find({a,b})!=s.end() || s.find({b,a})!=s.end())
                continue;
            s.insert({a,b});
            s.insert({b,a});
            v[a].push_back(b);
            v[b].push_back(a);
        }
        lld ans=0;
        memset(visited,0,sizeof(visited));
        for(i=1;i<=n;i++)
            if(visited[i]==0)
        {
            ctr=0;
            dfs(i);
            ans=max(ans,ctr);
        }
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 47236
from operator import mul
from functools import reduce
def comb2(n,r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under
def comb3(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, M, K = LI()

cou = int(0)
#maxL = N + M -2
L = int(0)
#距離i+1の組み合わせ

#for i in range(maxL):
for j in range(N):
    L += (N - j - 1) * (M ** 2) * (j + 1)
for j in range(M):
    L += (M - j - 1) * (N ** 2) * (j + 1)
#    for j in range(i+2):
#        if i>1 and i+1>j>0:
#            L[i] += max((N-j)*(M-(1+i)+j),0)*(i+1)*2
#        else:
#            L[i] += max(((N - j) * (M - (1 + i) + j)), 0) * (i + 1)

cou = comb3(N*M-2,K-2)%mod

ans = cou *L%mod

print(ans)

Measured memory_bytes: 52788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_F = 30;

/* typedef */

typedef vector<int> vi;
typedef long long ll;

/* global variables */

int n;
vi ds[MAX_F + 1];
ll dp[MAX_F + 1][MAX_N], allpcs;
int min_d;

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    for (int d = 1; d <= MAX_F; d++) ds[d].clear();

    for (int i = 0; i < n; i++) {
      int fi, d;
      cin >> fi;
      for (int j = 0; j < fi; j++) {
	cin >> d;
	ds[d].push_back(i);
      }

      dp[0][i] = 1LL << i;
    }

    allpcs = (1LL << n) - 1;
    min_d = -1;

    for (int d = 1; d <= MAX_F; d++) {
      ll pj = 0;
      for (vi::iterator vit = ds[d].begin(); vit != ds[d].end(); vit++)
	pj |= dp[d - 1][*vit];

      if (pj == allpcs) {
	min_d = d;
	break;
      }

      memcpy(dp[d], dp[d - 1], sizeof(ll) * n);
      
      for (vi::iterator vit = ds[d].begin(); vit != ds[d].end(); vit++)
	dp[d][*vit] = pj;
    }
    
    cout << min_d << endl;
  }

  return 0;
}

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

int main()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		int a,b,c;
		cin >> a >> b >> c;
		if (b*c >= a) cout << "Yes";
		else cout << "No";
		return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    double N, M; cin >> N >> M;
    cout << fixed << setprecision(10) << N/M << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14159265358979323846264
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ld a,b,h,m;
	cin >>a >>b >>h >>m;
	ld ma=m*6;
	ld ha=h*30+m/2.0;
	ld ang=abs(ma-ha);
	ang=min(ang,360-ang);
	ld co=ang*3.14159265358979/180.0;
	ld ans=a*a+b*b-2*a*b*cos(co);
	ans=sqrt(ans);
	printf ("%.20Lf",ans);
	return 0;
}
/******************************************************************************
4.56425719433005195810
4.56425719433005567605
******************************************************************************/


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

using namespace std;

int main()
{
    int n;

    cin>>n;

    int mat[n][3];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>mat[i][j];
        }
    }

    int dp[n][3];

    dp[0][0] = mat[0][0];

    dp[0][1] = mat[0][1];

    dp[0][2] = mat[0][2];

    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if(j == 0)
            {
                dp[i][j] = max(dp[i-1][1] + mat[i][j], dp[i-1][2] + mat[i][j]);
            }
            else if(j == 1)
            { 
                dp[i][j] = max(dp[i-1][0] + mat[i][j], dp[i-1][2] + mat[i][j]);
            }
            else
            {
                dp[i][j] = max(dp[i-1][0] + mat[i][j], dp[i-1][1] + mat[i][j]);
            }
        }
    }

    int najveci = dp[n-1][0];

    najveci = max(dp[n-1][1], najveci);

    najveci = max(dp[n-1][2], najveci);

    cout<<najveci;

    return 0;
}

Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
int counti=0;
int main()
{
	long long int n,s1=0;
	cin>>n;
	long long int a[n+5],b[n+5];
	for(int i=1;i<=n+1;i++)
	{
		cin>>a[i];
		s1+=a[i];
	}
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=n;i>=1;i--)
		if(b[i]>=a[i+1])
		{
			b[i]-=a[i+1];
			a[i+1]=0;
			if(b[i]>=a[i])
			{
				b[i]-=a[i];
				a[i]=0;
			}
			else
			{
				a[i]-=b[i];
				b[i]=0;	
			}
		}
		else
		{	
			a[i+1]-=b[i];
			b[i]=0;	
		}
	if(a[1]<=b[1])
	{

		b[1]-=a[1];
		a[1]=0;
	}
	else
	{
		a[1]-=b[1];
		b[1]=0;
	}
		
	long long int s=0;

		
	for(int i=1;i<=n+1;i++)
		s+=a[i];
	cout<<s1-s;
		
	return 0;
}

Measured memory_bytes: 1792
N = int(input().strip())
A = list(map(int, input().strip().split(" ")))
B = list(map(int, input().strip().split(" ")))
C = list(map(int, input().strip().split(" ")))

M = 0
pre_a = -1

for a in A:
  M += B[a - 1]
  
  if (a - pre_a) == 1:
    M += C[a - 2]
    
  pre_a = a

print(M)

Measured memory_bytes: 3060