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

int main() {
  int N, K , X, Y;
  cin  >> N >> K >> X >> Y;
  
  if (N <= K) {
  	cout << N * X << endl;
  }
  else {
  	cout << K * X + (N - K) * Y << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		h1, a1, h2, a2 int
	)

	fmt.Scan(&h1, &a1, &h2, &a2)

	if ((h1 + a2 -1) / a2) >= ((h2 + a1 -1) / a1) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
   vector<int>v(n);
   f(n)cin>>v[i];
   //reverse(v.begin(),v.end());
   vector<int> dp(n+1,0);
   dp[0]=0;
   dp[1]=1;
     int answer=1;
   for(int i=2;i<=n;i++)
   {
       if(v[i-1]<=v[i-2]) dp[i]=dp[i-1]+1;
       else dp[i]=1;

       answer=max(dp[i],answer);


   }


   cout<<answer-1<<endl;






}

Measured memory_bytes: 4784
N, M = map(int,input().split())

def intm(x):
    return int(x)*-1
A = list(map(intm, input().split()))

import heapq

heapq.heapify(A)
while M>0:
    a = -heapq.heappop(A) // 2
    heapq.heappush(A,-a)
    M -= 1
   

print(-sum(A))


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, k;
	cin >> n >> k;

	int aa[110] = {};
	int ans = n;
	for(int i = 0;i < k;i++){
		int d;
		cin >> d;
		while(d--){
			int a;
			cin >> a;
			aa[a]++;
			if(aa[a] == 1) ans--;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
s = input()
K = int(input())
n = len(s)
A = []
for i in range(n):
    if n < K:
       for j in range(n-i): 
           A.append(s[i:j+i+1])
    else:
       for j in range(K):
           A.append(s[i:i+j+1])
B = set(A)
C = []
for i in B:
    C.append(i)
C.sort()
print(C[K-1])

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n + 1];
    int res = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        if (a[a[i]] == i)
            res++;
    cout << res/2;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };

	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll a,b,c;
		cin>>a>>b>>c;

		cout<<((a+b-1)/b)*c<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

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

int main(){
    int n, a, b, c, d;

    cin >> n;
    a = n%10;
    b = (n%100)/10;
    c = (n%1000)/100;
    d = n/1000;

    if(a==b || b==c || c==d){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    t = 0
    if n % 2 == 0:
        t = 1
    for i in range(n):
        if i % 2 == n % 2 and i != 0:
            t += 2
        if a[i] != t:
            print(0)
            exit()
    print((2 ** (n // 2)) % mod)


if __name__ == '__main__':
    solve()


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

using namespace std;

typedef long long int lli;

double dp[301][301][301] = { 0 }; // x1, x2, x3
int n;

double rec(int a, int b, int c) {
    if (a<0 || b<0 || c<0 || a+b+c == 0) return 0.;
    if (dp[a][b][c]) return dp[a][b][c];

    double res = (a*rec(a-1, b, c)
                + b*rec(a+1, b-1, c)
                + c*rec(a, b+1, c-1) ) / n + 1.;
    res /= 1. - (double)(n-a-b-c)/n;

    return dp[a][b][c] = res;
}

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

    cin >> n;
    int a, start[3] = { 0 };
    for (int i=0; i<n; i++) {
        cin >> a;
        start[a-1]++;
    }

    printf("%.10f", rec(start[0], start[1], start[2]));

    return 0;
}


Measured memory_bytes: 213248
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;

	rep(i,N+1){
		if(((ll)log10(i) + 1) % 2 == 1) ans ++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import math
def is_prime(n):
    if n == 2: return True
    if n < 2 or n % 2 == 0: return False
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0: return False
        i += 1
    return True

n = int(input())
ans = 0
for i in range(n):
    num = int(input())
    if is_prime(num): ans += 1
print(ans)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (n/(a+b)) * a;
  n %= a+b;
  if (n > a) {
    cout << ans + a << endl;
  } else {
    cout << ans + n << endl;
  }
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

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

int main() {
	int n; cin >> n;
	vll a(n); Loop(i, n) cin >> a[i];
	vll b(n);
	Loop(i, n) {
		if (i % 2 == 0) b[0] += a[i];
		else b[0] -= a[i];
	}
	b[0] /= 2;
	Loop1(i, n - 1) {
		b[i] = a[i - 1] - b[i - 1];
	}
	Loop(i, n) {
		b[i] *= 2;
	}
	printv(b);
}

Measured memory_bytes: 2944
(N, A, B), Vs = readlines.map{|l| l.split.map(&:to_i)}

class Integer
  def !
    return 1 if self.zero?
    (1 .. self).inject(:*)
  end

  def C(m)
    self.! / (self - m).! / m.!
  end
end

v = Vs.sort.reverse
a = v.take(A)
ans = a.inject(:+) / A.to_f
m = a.min
x, y = v.count(m), a.count(m)
c = x.C y
i = A
(A ... B).each do |i|
  if v[i] == ans
    c += x.C(y += 1)
  else
    break
  end
end
puts ans, c

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc178_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = CIn.ReadLong();
      var b = CIn.ReadLong();
      var c = CIn.ReadLong();
      var d = CIn.ReadLong();

      var max = new[] { a * c, a * d, b * c, b * d }.Max();

      Console.WriteLine(max);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 28340
let () =
  let (n:int),(quantum:int) = Scanf.scanf "%d %d\n" (fun a b -> a,b) in
  let (q: (string * int) Queue.t) = Queue.create () in
  for i=1 to n do
    Queue.push (Scanf.scanf "%s %d\n" (fun a b -> a,b)) q
  done;
  let rec round_robin (sum:int) = match Queue.is_empty q with
      true -> ()
    | false ->
      match Queue.pop q with
        p,t when t <= quantum ->
        let s = sum + t in
        Printf.printf "%s %d\n" p s;
        round_robin s
      | p,t ->
        Queue.push (p,t-quantum) q;
        round_robin (sum+quantum)
  in
  round_robin 0

Measured memory_bytes: 12596
#include <stdio.h>
#include <string.h>
#include <algorithm>

char s[212345];
bool find_A = false;
int cou, ans;

int main(void)
{
	scanf("%s", &s);
	
	for (int i = 0; i < strlen(s); ++i)
	{
		if (find_A == false && s[i] == 'A')
		{
			find_A = true;
		}
		if (find_A == true)
		{
			++cou;
			if (s[i] == 'Z')
			{
				ans = std::max(ans, cou);
			}
		}
	}

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

Measured memory_bytes: 384
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int x;
    cin >> x;
    cout << 1 - x << '\n';
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= a + b)PRI("YES");
	else PRI("NO");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n);
    multiset<int> S;
    for (int &x : a) {
        cin >> x;
        S.insert(x);
    }
    for (int &x : a) {
        S.erase(S.lower_bound(x));
        cout << *(--(S.end())) << "\n";
        S.insert(x);
    }
}


Measured memory_bytes: 11904
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    S=input()
    C=[[0,0] for _ in range(n)] #i以下の#の数，i以上の.の数
    cunt=0
    for i,s in enumerate(S):
        if s=='#':
            cunt+=1
        C[i][0]=cunt
    cunt=0
    for i in range(n-1,-1,-1):
        if S[i]=='.':
            cunt+=1
        C[i][1]=cunt  
    ans=C[0][1]
    for i in range(n-1):#.#をとる位置
        ans=min(ans,C[i][0]+C[i+1][1])
    ans=min(ans,C[n-1][0])
    print(ans)

if __name__=='__main__':
    main()

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long 

using namespace std ;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

int dp[MAXN][2] , a[MAXN] , ps[MAXN][2];

int nxt[MAXN][2] ;

int32_t main()
{
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    int n , x[2];
    cin >> n >> x[0] >> x[1] ;
    for(int i = 0 ; i < n ; i ++ )
        cin >> a[i] ;
    dp[n-1][0] = dp[n-1][1] = 1 ;
    int last[2] ;
    last[0] = last[1] = n  ;
    dp[n][0] = dp[n][1] = 1 ;
    ps[n-1][0] = ps[n-1][1] = 1 ;
    nxt[n-1][0] = nxt[n-1][1] = n ;
    for(int i = n - 2 ; i > -1 ; i -- )
    {
        for(int q = 0 ; q < 2 ; q ++ ) {
            int j = lower_bound(a,a+n,a[i]+x[q]) - a ;
            if(last[q]<j)
                continue ;
            if(j==i+1)
                dp[i][q] = (dp[i+1][0] + dp[i+1][1]) % MOD ;
            else
                dp[i][q] = dp[j-1][1-q] ;
        }
        if(a[i+1]-a[i]<x[0])
            last[1] = i + 1  ;
        if(a[i+1]-a[i]<x[1])
            last[0] = i + 1 ;
    }
    cout << (dp[0][0] + dp[0][1] ) % MOD << endl ; ;
}

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

namespace ABC085
{
    class C
    {
        static void Main(string[] args)
        {
            var NY = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NY[0];
            var Y = NY[1];
            for (int i = 0; i <= N; i++)
                for (int j = 0; j <= N - i; j++)
                {
                    var k = N - i - j;
                    if (10000 * i + 5000 * j + 1000 * k == Y)
                    {
                        Console.WriteLine(string.Join(" ", i, j, k));
                        return;
                    }
                }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

const int N = 410;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll mult(ll x, ll y)
{
	return (x * y) % MOD;
}
ll add(ll x, ll y)
{
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}

int n, m;
int a[N][2];
ll dp[N][N];
ll b[N][N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i][0]);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i][1]);
	for (int i = 0; i < n; i++)
	{
		for (int z = a[i][0]; z <= a[i][1]; z++)
		{
			ll x = 1;
			for (int c = 0; c <= m; c++)
			{
				b[i][c] = add(b[i][c], x);
				x = mult(x, z);
			}
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int x = 0; x <= m; x++)
			dp[1][x] = 0;
		for (int x = 0; x <= m; x++)
			for (int y = 0; x + y <= m; y++)
				dp[1][x + y] = add(dp[1][x + y], mult(dp[0][x], b[i][y]));
		for (int x = 0; x <= m; x++)
			dp[0][x] = dp[1][x];
	}
	printf("%lld\n", dp[0][m]);

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,vl[3030][3030],dp[3030][3030][4];
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<k;i++)
	{
		long long a,b,c;
		cin>>a>>b>>c;
		vl[a][b]=c;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<=3;k++)
			{
				if(k!=3)
				{
					dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]+vl[i][j]);
				}
				dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
				dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
				if(k!=3)
				{
					dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+vl[i][j]);
				}
			}
		}
	}
	cout<<max(dp[n][m][0]+vl[n][m],max(dp[n][m][1]+vl[n][m],max(dp[n][m][2]+vl[n][m],dp[n][m][3])))<<endl;
	return 0;
}

Measured memory_bytes: 358484
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
typedef pair<pair<int, int>, int> ppi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 2e5 + 3;
int N, M;
string s, t;
int main(){
    fio(0);
    cin >> N >> M;
    cin >> s >> t;
    ll mul = 1LL * N * M;
    ll g = __gcd(N, M);
    ll le = N / g, ri = M / g;
    mul /= g;
    ll lcm = mul;
    bool flag = true;
    int id1 = 0, id2 = 0;
    while(id1 < N && id2 < M){
        if(s[id1] != t[id2]){
            flag = false;
            break;
        }
        id1 += le, id2 += ri;
    }
    if(flag){
        printf("%lld\n", lcm);
    }
    else{
        puts("-1");
    }
	return 0;
}


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

struct SuffixArray{
  Int n,k;
  string S;
  vector<Int> sa,lcp;
  SuffixArray(){}
  SuffixArray(string& S):S(S){init();}
  void init(){
    n=S.length();
    S.push_back('$');
    build_sa();
  }
  void build_sa(){
    sa.clear();
    sa.resize(n+1,0);
    iota(sa.begin(),sa.end(),0);
    sort(sa.begin(),sa.end(),
	 [&](Int a,Int b){
	   if(S[a]==S[b]) return a>b;
	   return S[a]<S[b];
	 });
    vector<Int> c(n+1,0),r(n+1),cnt(n+1),s(n+1);
    for(Int i=0;i<=n;i++) r[i]=S[i];
    for(Int len=1;len<=n;len*=2){
      for(Int i=0;i<=n;i++){
	 c[sa[i]]=
	   i>0 &&
	   r[sa[i-1]]==r[sa[i]] &&
	   sa[i-1]+len<=n &&
	   r[sa[i-1]+len/2]==r[sa[i]+len/2] ?
	   c[sa[i-1]]:i;
      }
      iota(cnt.begin(),cnt.end(),0);
      copy(sa.begin(),sa.end(),r.begin());
      for(Int i=0;i<=n;i++){
	Int s1=r[i]-len;
	if(s1>=0) sa[cnt[c[s1]]++]=s1;
      }
      c.swap(r);
    }
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  string s;
  cin>>n>>k>>s;
  auto calc=[](Int x){return x*(x+1)/2;};
  Int zs=0;
  vector<Int> cnt(n+1,1);
  for(Int i=0;i<n;i++){
    if(s[i]=='0'){
      if(i+1>=n||s[i+1]!='0') zs+=calc(cnt[i]);
      if(i+1<n) cnt[i+1]+=cnt[i];
      cnt[i]=0;
    }
  }
  if(k<=zs){
    cout<<0<<endl;
    return 0;
  }
  k-=zs+1;
  vector<Int> sum(n+1,0);
  for(Int i=0;i<n;i++) sum[i+1]=sum[i]+cnt[i];
  Int len=1;
  while(k>=sum[n+1-len]&&len<n) k-=sum[n+1-(len++)];
  SuffixArray sa(s);
  Int pos=0;
  for(Int i=1;i<=n;i++){
    if(s[sa.sa[i]]=='0'||sa.sa[i]+len>n) continue;
    //cout<<len<<" "<<i<<" "<<k<<endl;
    if(k>=0) pos=sa.sa[i];
    k-=cnt[sa.sa[i]];
  }
  cout<<s.substr(pos,len)<<endl;
  return 0;
}



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int a, b;
  cin >> a >> b;
  cout << (b + a - 3) / (a - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int main()
{ 
int ht,st,ha,sa;
cin>>ht>>st>>ha>>sa;
while(true)
{ha-=st;
    if(ha<=0) {
        cout<<"Yes";goto end;
        
    }
    
    ht-=sa;
    if(ht<=0) {
        cout<<"No";goto end;
        
    }
    
}
end:;



return 0;
}











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

int main()
{
	char S[4];
	int i;
	scanf("%s", S);
	for (i = 0;i < 3;i++)
	{
		if (S[i] == S[i + 1])
		{
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n,m;
int p[100005];
int find(int x){
	if(x!=p[x])p[x]=find(p[x]);
	return p[x];
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)p[i]=i;
	int a,b,c,f_a,f_b,ans=0;
	while(m--){
		cin>>a>>b>>c;
		f_a=find(a);
		f_b=find(b);
		if(f_a!=f_b)p[f_a]=f_b;
	}
	for(int i=1;i<=100005;i++)
	if(i==p[i])ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	s := readString()
	s = s[:len(s)-1]
	var ans int
	for i := 1; i+i <= len(s); i++ {
		if s[:i] == s[i:i+i] {
			ans = max(ans, i)
		}
	}
	println(ans * 2)
}

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


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N; std::cin >> N;
  int keta_min = INT_MAX;
  for (LL i = 1; i*i <= N; ++i) {
    if (N%i == 0) {
#if DEBUG
      std::cout << "origin: " << i << ", " << N/i << std::endl;
#endif
      keta_min = std::min(keta_min, static_cast<int>(log10(N/i)) + 1);
    }
  }
  std::cout << keta_min << std::endl;
}


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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n; cin >> n;
    vi a(n);
    for(int& u : a) cin >> u;
    int q; cin >> q;
    ll sum = 0;
    map< int, int > m;
    for(int i = 0; i < n; i++){
        sum += a[i];
        m[a[i]]++;
    }
    while(q--){
        int b, c; cin >> b >> c;
        sum -= m[b] * 1ll * b;
        int x = m[b];
        m[b] = 0;
        m[c] += x;
        sum += x * 1ll * c;
        cout << sum << '\n';
    }
    
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 8016
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    regex e(R"(,)");
    cout << regex_replace(s, e, " ") << endl;
    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
li=[list(input()) for i in range(h)]
yoko=[[1,0],[-1,0],[0,1],[0,-1]]
import itertools
for i in range(h):
  for j in range(w):
    if li[i][j]=="#":
      flag=0
      for dx,dy in yoko:
        if h>i+dx>=0 and w>j+dy>=0:
          if li[i+dx][j+dy]=="#":
            flag+=1
      if flag==0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
def prime_list(n):
    # n以下の自然数で素数か否かのリストを作成
    ans = [True for _ in range(n+1)]
    ans[0] = False
    ans[1] = False
    for i in range(2,n+1):
        if ans[i]:
            for j in range(2*i,n+1,i):
                ans[j] = False
    return ans

prime = prime_list(10**5)
like = [0 for i in range(10**5+1)]
for i in range(3,10**5+1,2):
    if prime[i] and prime[(i+1)//2]:
        like[i] = 1
for i in range(1,10**5+1):
    like[i] += like[i-1]

q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(like[r]-like[l-1])

Measured memory_bytes: 52656
H = []
W = []
while True:
    input_item = list(map(int, input().split()))
    if input_item == [0, 0]:
        break
    H.append(input_item[0])
    W.append(input_item[1])

for i in range(len(H)):
    h = H[i]
    w = W[i]
    for _ in range(h):
        print("#"*w)
    print()


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int>a(m);
  rep(i,m)cin>>a[i];
  int cnt=0;
  int tmp=0;
  rep(i,m){
    if(x>a[i])cnt++;
    else tmp++;
  }
  cout <<min(cnt,tmp)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <map>
using namespace std;
map< string, string > mm;
string st;
int main() {
	mm["Sunny"]= "Cloudy", mm["Cloudy"]= "Rainy", mm["Rainy"]= "Sunny";
	cin >> st;
	cout << mm[st] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                1000005
#define inf              999999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type, less<int >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//________________________________________________________________________________________________________________
bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
    if(a.first>b.first) return true;
    if(a.first<b.first) return false;
    if(a.second<b.second) return true;
    else return false;

}
bool ok=false;
ll vis[N],infact[N];
ll t,n,m,x,p,r,y,z,mod=998244353,ans;
vector<ll>v;
string s,s1;
int main()
{
    cin>>n>>s>>s1;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<s1[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
  N, M = map(int, input().split())
  if N == 1 and M == 1:
    print(0)
  elif N == 0 or N == 1:
    print(combinations_count(M, 2))
  elif M == 0 or M == 1:
    print(combinations_count(N, 2))
  else:
    print(combinations_count(N, 2) + combinations_count(M, 2))
if __name__ == '__main__':
  	main()

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int pow(int a, int b);

int main(){
    int N;
    int p[15] = {2,3,5,7,11,13,17,19,23,29,31, 37, 41, 43, 47};
    int cnt[15];
    int c3 = 0, c5 = 0, c15 = 0, c25 = 0, c75 = 0;

    cin >> N;
    for(int i = 0; i <  15; i++){
        cnt[i] = 0;
        for(int j = 1; j <= 7; j++){
            if(N < pow(p[i], j)) break;
            cnt[i] += (N/pow(p[i], j));
        }
    }

    for(int i = 0; i <  15; i++){
        if(cnt[i]+1 >= 3){
            c3++;
        }if(cnt[i]+1 >= 5){
            c5++;
        }if(cnt[i]+1 >= 15){
            c15++;
        }if(cnt[i]+1 >= 25){
            c25++;
        }if(cnt[i]+1 >= 75){
            c75++;
        }
    }
    
    cout << (c3-2)*(c5-1)*c5/2 + c15*(c5-1) + c25*(c3-1) + c75 << endl; 

}

int pow(int a, int b){
    int ans = 1;
    for(int i = 0; i < b; i++){
        ans *= a;
    }
    return ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            long n = Long.parseLong(br.readLine());
            long total = 1;
            for (long i = 1; i <= n; i++) {
                total = (total * i) % (1000000000 + 7);
            }
            System.out.println(total);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

int a[200];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int p, q; cin >> p >> q;
		a[i] = p == q;
	}
	for (int i = 0; i + 2 < n; i++) {
		if (a[i] && a[i + 1] && a[i + 2]) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(){
    int A1, A2, A3;
    std::cin >> A1 >> A2 >> A3;

    if(A1 + A2 + A3 >= 22){
        std::cout << "bust" << std::endl;
    }
    else{
        std::cout << "win" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
*s, = map(int, input().split())
q = int(input())
*t, = map(int, input().split())

ans = 0
for v in t:
    si, ei = 0, n-1
    while si < (ei-1):
        mi = (si+ei)//2
        if v < s[mi]:
            ei = mi
        else:
            si = mi
    if s[si] == v or s[ei] == v:
        ans += 1
print(ans)



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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    string s;
    cin >> s;
    string a(begin(s), begin(s) + n), b(rbegin(s), rbegin(s) + n);

    using pstr = pair<string, string>;
    map<pstr, i64> cnt;
    for (i64 i = 0; i < (1 << n); i++) {
        string ar, ab;
        for (i64 j = 0; j < n; j++) {
            ((i >> j) & 1 ? ar : ab).push_back(s[j]);
        }
        cnt[{ar, ab}]++;
    }

    i64 ans = 0;
    for (i64 i = 0; i <= n; i++) {
        vector<i64> sel(n);
        fill(begin(sel) + i, end(sel), 1);

        do {
            string br, bb;
            for (i64 j = 0; j < n; j++) {
                (sel[j] ? br : bb).push_back(b[j]);
            }
            ans += cnt[{br, bb}];
        } while (next_permutation(all(sel)));
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 91904
#include<iostream>
using namespace std;
int main() {
    int ans = 700;
    string S;
    cin >> S;
    if(S[0] == 'o') {
        ans += 100;
    }
    if(S[1] == 'o') {
        ans += 100;
    }
    if(S[2] == 'o') {
        ans += 100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H,N = map(int,input().split())

data = []

for i in range(N):
  A,B = map(int,input().split())
  data.append([A,B])

dp = [0] * (H+1)

for i in range(1,H+1):
    dp[i] = min([dp[max(0,i-data[j][0])] + data[j][1] for j in range(N)])
    #print(dp)
print(dp[H])

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

int main() {
    int n;
    cin>>n;
    int t[n];
    int sum=0;
    for (int i=0;i<n;i++) {
        cin>>t[i];
        sum+=t[i];
    }
    int a,b;
    int m;
    cin>>m;
    while (m--) {
        cin>>a>>b;
        cout<<sum-t[a-1]+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
d,g=map(int,input().split())
p=[]
c=[]
for l in range(d):
    t1,t2=map(int,input().split())
    p.append(t1)
    c.append(t2)
ans=1e9
for i in range(1<<d):
    s=0
    n=0
    r=-1
    for j in range(d):
        if(i>>j & 1):
            s+=100*(j+1)*p[j]+c[j]
            n+=p[j]
        else:
            r=j
    if(s<g):
        s1=100*(r+1)
        ne=(g-s+s1-1)//s1
        if(ne>=p[r]):continue
        n+=ne
    ans=min(ans,n)
print(ans)

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var hList = new List<int>();
            var wList = new List<int>();

            while (true)
            {
                String s = Console.ReadLine();
                String[] strInputList = s.Split();
                int h = int.Parse(strInputList[0]);
                int w = int.Parse(strInputList[1]);

                if (h == 0 && w == 0)
                {
                    break;
                }

                hList.Add(h);
                wList.Add(w);
            }

            String simbol;
            String simbols;

            for (int i = 0; i < hList.Count; i++)
            {
                int hLine = hList[i];
                int wNumber = wList[i];

                for(int j = 1; j <= hLine; j++)
                {
                    simbol = null;
                    simbols = null;

                    for (int k = 1; k <= wNumber; k++)
                    {
                        int num = j + k;

                        if (num % 2 == 0)
                        {
                            simbol = "#";
                        }else
                        {
                            simbol = ".";
                        }
                        simbols = simbols + simbol;
                    }
                    Console.WriteLine(simbols);
                }
                Console.WriteLine("");
            }  
        }
    }
}


Measured memory_bytes: 17972
s = input()

dp3 = 1
dp2 = 0
dp1 = 0
dp0 = 0

n = 10 ** 9 + 7

for i in reversed(range((len(s)))):
    if s[i] == '?':
        m = 3
    else:
        m = 1

    if s[i] == '?':
        m1 = 3
    else:
        m1 = 1

    if s[i] == '?' or s[i] == 'C':
        m2 = 1
    else:
        m2 = 0

    if s[i] == '?' or s[i] == 'B':
        m3 = 1
    else:
        m3 = 0

    if s[i] == '?' or s[i] == 'A':
        m4 = 1
    else:
        m4 = 0

    t_dp3 = (m * dp3) % n
    t_dp2 = (m1 * dp2 + m2 * dp3) % n
    t_dp1 = (m1 * dp1 + m3 * dp2) % n
    t_dp0 = (m1 * dp0 + m4 * dp1) % n
    dp3 = t_dp3
    dp2 = t_dp2
    dp1 = t_dp1
    dp0 = t_dp0

ans = dp0
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    cout << 800*N-(N/15)*200 << endl;



}


Measured memory_bytes: 256