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

int main(){
        ll w,h,x,y,jud=0;
        cin >> w >> h >> x >> y;
        if(x==w/2.0&&y==h/2.0) jud = 1;
        cout << (w*h)/2.0 << " " << jud << endl;
        return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    vector<int64_t> x(n);
    for (auto i : irange(0L, n)) {
        cin >> x[i];
    }

    int64_t ans = 0;
    for (auto i : irange(1L, n)) {
        ans += min((x[i] - x[i - 1]) * a, b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

#define MAX_SIZE 1000000

using namespace std;

void sieve(bool *a) {
    a[0] = a[1] = true;
    
    for(int i = 2;i < MAX_SIZE;i++) {
        if(!a[i]) {
            for(int j = 2;(i * j) < MAX_SIZE;j++) {
                a[i * j] = true;
            }
        }
    }
}

int main() {
    bool not_prime[MAX_SIZE] = { false };
    
    sieve(not_prime);
    
    int n, cnt;
    
    while(cin >> n) {
        cnt = 0;
        
        for(int i = 0;i <= n;i++) {
            if(!not_prime[i]) {
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
int n, m;

int main() {
  cin >> n >> m;
  vector<pair<int, int>> key;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j, b) {
      int c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    key.emplace_back(s, a);
  }

  vector<int> dp(1 << n, INF);  // 2^n
  dp[0] = 0;
  rep(s, 1 << n) {
    rep(i, m) {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 5e3 + 10;
pair<int, pair<int, int>> Edges[nax];
int n, m, p, u, v, w;

void solve()
{
	cin >> n >> m >> p;
	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v >> w;
		Edges[i] = {v, {u, w - p}};
	}
	vector<vector<ll>> dp(2, vector<ll>(n + 1, -1e18));
	bool curr, prev;
	prev = true;
	curr = false;
	dp[prev][1] = 0;
	for (int step = 1; step < 5 * n; ++step)
	{
		for (int i = 0; i < m; ++i)
		{
			int parent = Edges[i].s.f;
			int cost = Edges[i].s.s;
			int child = Edges[i].f;
			dp[curr][child] = max(dp[curr][child], cost + dp[prev][parent]);
		}
		prev = !prev;
		curr = !curr;
	}
	ll here = max(dp[curr][n], dp[prev][n]);
	for (int step = 1; step < 5 * n; ++step)
	{
		for (int i = 0; i < m; ++i)
		{
			int parent = Edges[i].s.f;
			int cost = Edges[i].s.s;
			int child = Edges[i].f;
			dp[curr][child] = max(dp[curr][child], cost + dp[prev][parent]);
		}
		prev = !prev;
		curr = !curr;
	}
	ll here2 = max(dp[curr][n], dp[prev][n]);
	db(here, here2);
	if (here2 > here)
		cout << -1 << '\n';
	else
		cout << max(here, 0LL) << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int INF = 1001001001;

vector<P> a[3];

bool isBingo() {
  rep(i, 3) {
    int c = 0;
    rep(j, 3) {
      if(a[i][j].second) c++;
    }
    if(c==3) return true;
  }

  rep(i, 3) {
    int c = 0;
    rep(j, 3) {
      if(a[j][i].second) c++;
    }
    if(c==3) return true;
  }

  int c = 0;
  rep(i, 3) {
    if(a[i][i].second) c++;
  }
  if(c==3) return true;

  c = 0;
  rep(i, 3) {
    if(a[i][2-i].second) c++;
  }
  if(c==3) return true;
  return false;
}

bool hasNum(int b) {
  rep(i, 3) {
    rep(j, 3) {
      if(a[i][j].first == b) {
        a[i][j].second = 1;
        return true;
      }
    }
  }
  return false;
}

int main() {
  rep(i, 3) {
    rep(j, 3) {
      int v;
      cin >> v;
      a[i].push_back(P(v, 0));
    }
  }

  int ans = 0;
  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    hasNum(b);
  }
  if(isBingo()) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
S = list(input())

if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
  print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
  print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import sys

#+++++
		
def main():
	s = input()
	if len(s) == 1:
		return 1
	
	ls=list(s)
	cc=ls[0]
	count=1
	nl=[]
	for c in ls[1:]:
		if c == cc:
			count+=1
		else:
			nl.append(count)
			cc=c
			count=1
	nl.append(count)
	
	nnl=[]
	ret=0
	for i in nl:
		b = i % 3
		if b != 0:
			ret += 1
			
		k = i // 3
		ret += k* 2
		nnl.append(b)

	cc=1
	for i in nnl:
		#print(i,nnl,ret)
		if cc == 2 and i == 2:
			cc = 0
			ret +=1
		elif cc != 2 and i == 2:
			cc=2
		elif cc == 2 and i == 0:
			pass
		else:
			cc=0
	
	print(ret)

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 8168
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x;

  ll b = 100;
  ll count = 0;
  while(b < x) {
    count++;
    b = b  * 1.01;
  }

  cout << count << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  ll K, A, B; cin >> K >> A >> B;
  if (A <= B){
    if (A >= K){
      cout << 1 << endl;
    }else{
      cout << -1 << endl;
    }
  }else{
    ll N1 = (K - B) / (A - B) + 1;
    if((K - B) % (A - B) == 0) N1--;
    cout << 2 * (N1 - 1) + 1 << endl;
  }
  
  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll a[n+1];
 vector<ll>b;
 rep(i,0,n){
  sc(a[i]);
  push(b,a[i]);
 }
 sort(b);
 rep(i,0,n){
  if(a[i]<=b[n/2-1])pr(b[n/2]);
  else pr(b[n/2-1]);
 }

  
  
return 0;}

Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }

  int ave=0;
  if(sum%N*2>=N)  ave=sum/N+1;
  else  ave=sum/N;
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=(a.at(i)-ave)*(a.at(i)-ave);
  }
  cout << ans << endl;
  
  return 0;
}


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

int pq(int q,int m){
  int cnt=0;
  for(int i=0;i<10;i++){
    m=m/q;
    cnt+=m;
  }
  return cnt;
}

int main(){
  int n,c[5]={},p[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  cin>>n;
  for(int i=0;i<15;i++){
    if(pq(p[i],n)>=2) c[0]++;
    if(pq(p[i],n)>=4) c[1]++;
    if(pq(p[i],n)>=14) c[2]++;
    if(pq(p[i],n)>=24) c[3]++;
    if(pq(p[i],n)>=74) c[4]++;
  }
  cout<<c[4]+(c[0]-1)*c[3]+c[2]*(c[1]-1)+c[1]*(c[1]-1)*(c[0]-2)/2;
}

Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    ll n;
    cin>>n;
    ll ans = n*(n-1)/2;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41196
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.length();
    
    int Ret = 0;
    for (int n = 0; n < N/2; ++n) {
        if (S[n] != S[N-1-n]) ++Ret;
    }
    cout << Ret << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int R = sc.nextInt();

        //double PI = 3.1415926535897932;
        double PI = 3.14159265;
        double v = 2 *R* PI;

        System.out.println(v);

    }
}

Measured memory_bytes: 35908
C = [0]*3
C1 = [[0]*2]*3
C2 = [[0]*3]*2
flg = False
for i in range(3):
  C[i] = list(map(int, input().split()))
for i in range(2):
  for j in range(2):
    if(C[i][j] -C[i][j+1] != C[i+1][j] -C[i+1][j+1]):
      flg = True
for i in range(2):
  for j in range(2):
    if(C[i][j] -C[i+1][j] != C[i][j+1] -C[i+1][j+1]):
      flg = True
print("No" if flg else "Yes")

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

ll f(ll n,ll a){
	for(ll i=1;i<n;i++){
		a+=a*i;
		a=a%1000000007;
	}
	return a;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,a=1,b=1;
	cin>>n>>k;
	if(n==k){
		a=f(n,a);
		b=f(k,b);
		cout<<(2*a*b)%1000000007<<endl;
	}else if(abs(n-k)<=1){
		a=f(n,a);
		b=f(k,b);
		cout<<(a*b)%1000000007<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}


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

int N;
#define MAXN 200000
#define SIZE 2000
#define MOD 1000000007LL
int A[MAXN], B[MAXN];
long long D[2 * SIZE + 1][2 * SIZE + 1];
long long I[4 * SIZE + 1], F[4 * SIZE + 1], IF[4 * SIZE + 1];
long long R;

int main() {
  I[1] = F[0] = F[1] = IF[0] = IF[1] = 1;
  for(int i = 2; i <= 4 * SIZE; ++i) {
    I[i] = MOD - (MOD / i) * I[MOD % i] % MOD;
    F[i] = i * F[i - 1] % MOD;
    IF[i] = I[i] * IF[i - 1] % MOD;
  }
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
    ++D[SIZE - A[i]][SIZE - B[i]];
  }
  for(int x = 0; x <= 2 * SIZE; ++x) for(int y = 0; y <= 2 * SIZE; ++y) {
    if(x > 0) (D[x][y] += D[x - 1][y]) %= MOD;
    if(y > 0) (D[x][y] += D[x][y - 1]) %= MOD;
  }
  for(int i = 0; i < N; ++i) {
    (R += D[SIZE + A[i]][SIZE + B[i]]) %= MOD;
    (R += MOD -
      F[A[i] * 2 + B[i] * 2] * IF[A[i] * 2] % MOD * IF[B[i] * 2] % MOD) %= MOD;
  }
  cout << R * I[2] % MOD << endl;
  return 0;
}


Measured memory_bytes: 127232
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i,len;
    char str[1220];
    
    scanf("%[^\n]",str);
    len=strlen(str);
    
    for(i=0;i<len;i++){
        if('A'<=str[i] && str[i]<='Z'){
            str[i]+=32;
        }else if('a'<=str[i] && str[i]<='z'){
            str[i]-=32;
        }
    }
    printf("%s\n",str);
    return 0;
}



Measured memory_bytes: 2132
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, C;
	int[][] D;
	int[][] c;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		C = Integer.parseInt(tokens[1]);
		D = new int[C][C];
		for (int i = 0; i < C; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < C; ++j) {
				D[i][j] = Integer.parseInt(tokens[j]);
			}
		}
		c = new int[N][N];
		for (int i = 0; i < N; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < N; ++j) {
				c[i][j] = Integer.parseInt(tokens[j]) - 1;
			}
		}
	}

	long calc(int[] colPattern, int[][] counts) {
		long result = 0L;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < C; ++j) {
				if (colPattern[i] != j) {
					result += (long) counts[i][j] * (long) D[j][colPattern[i]];
				}
			}
		}

		return result;
	}

	void calc() {
		int[][] counts = new int[3][C];
		for (int i = 0; i < 3; ++i) {
			Arrays.fill(counts[i], 0);
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				counts[(i + j) % 3][c[i][j]]++;
			}
		}

		long min = Long.MAX_VALUE / 2;
		for (int i = 0; i < C; ++i) {
			for (int j = 0; j < C; ++j) {
				if (i == j) {
					continue;
				}
				for (int k = 0; k < C; ++k) {
					if (i == k || j == k) {
						continue;
					}
					int[] colPattern = new int[3];
					colPattern[0] = i;
					colPattern[1] = j;
					colPattern[2] = k;
					min = Math.min(min, calc(colPattern, counts));
				}
			}
		}
		System.out.println(min);

	}

	void showResult() {
	}
}

Measured memory_bytes: 46840
n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
    name=input()
    n=name[0]
    if n=="M":
        m+=1
    if n=="A":
        a+=1
    if n=="R":
        r+=1
    if n=="C":
        c+=1
    if n=="H":
        h+=1
lst=[m,a,r,c,h]
ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=lst[i]*lst[j]*lst[k]
print(ans)

Measured memory_bytes: 3064
// ABC044_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;
    
    // calculation
    if (N <= K) {
        cout << N*X << "\n";
    } else {
        cout << K*X + (N-K)*Y << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define vi vector<int>
#define umap unordered_map
#define pii pair<int, int>
#define vpii vector<pii>
#define uset unordered_set
#define frw(i, a, b) for(int i = (a); i < (b); i++)
#define bck(i, a, b) for(int i = (a); i > (b); i--)
#define T() int testcases; cin >> testcases; frw(TC, 1, testcases + 1)
#define tez ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define fi first
#define se second
#define pow asdihagsiduh
#define pub push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)(a.size())
#define sq(a) ((a) * (a))

#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> 
void ZZ(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}

//console o/p without variable names
#define trace1(...) ZZZ(__VA_ARGS__)
template<typename Arg1>
void ZZZ(Arg1&& arg1){
    cerr << arg1 << endl;
}
template<typename Arg1, typename... Args>
void ZZZ(Arg1&& arg1, Args&&... args){
    cerr << arg1 << ' ';
    ZZZ(args...);
}

//attribution : https://codeforces.com/blog/entry/23554
int n;
double x[1005], y[1005], X, Y, d, e;

double dist(double a, double b) {
    return a*a + b*b;
}

signed main() {
    cin >> n;
    frw(i, 0, n){
        cin >> x[i] >> y[i];
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    double P = 0.1;
    frw(i, 0, 30000){
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        frw(j, 1, n){
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    cout << fixed << setprecision(6) << sqrt(d);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,ans;
    cin>>n>>m;
    if(n>m)swap(n,m);
    if(n==1&&m==1)ans=1;
    else if(n==1)ans=m-2;
    else ans=(n-2)*(m-2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
l, r = [0]*q, [0]*q
for i in range(q):
    l[i], r[i] = map(int, input().split())

cs = [0]*(n+1)
for i in range(n):
    if i+1 < n and s[i] == 'A' and s[i+1] == 'C':
        cs[i+1] = cs[i] + 1
    else:
        cs[i+1] = cs[i]

for i in range(q):
    print(cs[r[i]-1] - cs[l[i]-1])


Measured memory_bytes: 14228
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datC = readLine
    // Make RRRRR...WWWW
    val numR = datC.filter(_ == 'R').length
    val numWinRArea = datC.substring(0, numR).filter(_ == 'W').length

    //println(datC.filter(_ == 'R'))
    //println(datC.substring(0, numR))
    println(numWinRArea)
  }
}


Measured memory_bytes: 56872
#include <stdio.h>

int N;
char C[271828];

int main(void) {
	int i;
	int aka = 0;
	int count = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%271827s", C) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (C[i] == 'R') aka++;
	}
	for (i = 0; i < aka; i++) {
		if (C[i] != 'R') count++;
	}
	printf("%d\n", count);
	return 0;
}

/*

白赤 → NG

赤…赤白…白

*/


Measured memory_bytes: 1872
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    map<int, int> mp;
    ll ans = 0;
    ll sum = 0;
    ll base = 1;
    mp[0] = 1;
    for(char c : S){
        sum += base*(c-'0');
        sum %= 2019;
        base *= 10;
        base %= 2019;
        if(mp.count(sum)) ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>
int main(void)
{
    int i,n,x,a,b;
    double total,ava,suv,d,c;
    
    for(b=1; b<300; b++){
        scanf("%d",&n);
        if(n==0)break;
        int data[n];
        for(x=0; x<n; x++){
            scanf("%d",&data[x]);
        }
        total=0;
        for(i=0; i<n; i++){
            total+=data[i];
        }
        ava=total/n;
        suv=0;
        for(a=0; a<n; a++){
            suv+=(data[a]-ava)*(data[a]-ava);
        }
        d=suv/n;
        c=sqrt(d);
        printf("%f\n",c);
    }
    return 0;
    
}



Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		double x=scan.nextDouble();
		System.out.printf("%.6f %.6f",(Math.PI*x*x),(2*Math.PI*x));
		System.out.println();

	}

}

Measured memory_bytes: 19056
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

    vector <int> A(no_of_elements + 1);
    for(int i = 1; i <= no_of_elements; i++)
        cin >> A[i];

    vector <int> prefix_gcd(no_of_elements + 1, 0);
    for(int i = 1; i <= no_of_elements; i++)
        prefix_gcd[i] = __gcd(prefix_gcd[i - 1], A[i]);

    vector <int> suffix_gcd(no_of_elements + 2, 0);
    for(int i = no_of_elements; i >= 1; i--)
        suffix_gcd[i] = __gcd(suffix_gcd[i + 1], A[i]);

    int best_gcd = 0;
    for(int i = 1; i <= no_of_elements; i++)
    {
        int gcd_without_this = __gcd(prefix_gcd[i - 1], suffix_gcd[i + 1]);

        best_gcd = max(best_gcd, gcd_without_this);
    }

    cout << best_gcd;

    return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll N, A, B;
    scanf("%lld %lld %lld", &N, &A, &B);
    printf("%lld\n", min(B, A*N));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
  ll N; cin >> N;
  vector<ll> A(N+1);
  vector<ll> B(N+1);
  vector<ll> C(N+1);
  ll i;
  for(i=1; i<N+1; i++) {
    cin >> A[i];
    B[A[i]]++;
  }

  ll ans = 0;

  for(i=1; i<N+1; i++) {
    if(B[i]<2){
      C[i] = 0;
    }
    else C[i] = (B[i] - 1) * (B[i] - 2) / 2;
    B[i] = B[i] * (B[i] - 1) / 2;
    ans += B[i];
  }
  ll anss;
  for(i=1; i<N+1; i++){
    anss = ans - B[A[i]] + C[A[i]];
    AA(anss);
  }
  
  return 0;
}


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

int main()
{
	string str;
	// n:S m:c 
	cin >> str;
	int cnt_a = -1, cnt_z = -1, result = 0;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'A') {
			cnt_a = i;
			break;
		}
	}
	for (int i = str.size()-1; i >= 0; i--) {
		if (str[i] == 'Z') {
			cnt_z = i;
			break;
		}
	}
	if (cnt_a < cnt_z) {
		result = cnt_z - cnt_a + 1;
	}

	cout << result << endl;

	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
typedef long long ll;
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; }

const long long INF = 1LL << 60;
int D;
long long G;
vector<long long> p, c;

int main() {
	cin >> D >> G;
	p.resize(D); c.resize(D);
	for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

	long long res = 1 << 29;
	for (int bit = 0; bit < (1 << D); ++bit) {
		long long sum = 0;
		long long num = 0;
		for (int i = 0; i < D; ++i) {
			if (bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), num += p[i];
		}
		if (sum >= G) res = min(res, num);
		else {
			for (int i = D - 1; i >= 0; --i) {
				if (bit & (1 << i)) continue;
				for (int j = 0; j < p[i]; ++j) {
					if (sum >= G) break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
en =0
bt =0
for i in range(N):
    a,b =input().split()
    if b =="JPY":
        en +=float(a)
    elif b =="BTC":
        bt +=float(a)
ans =en +bt *380000.0
print(ans)

Measured memory_bytes: 9120
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("\\D+");

		int secNum = 0;
		while(sc.hasNext())
		{
			secNum += sc.nextInt();
		}
		System.out.println(secNum);
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<limits.h>
#define MAX 100
#define INF INT_MAX
#define WHITE 0
#define BLACK 1
#define GRAY 2

void MST(int);

int m[MAX][MAX]; //m[u][v]にuからvへの辺の重みを記録
int d[MAX]; //MSTに属する頂点と属さない頂点をつなぐ辺の最小の重み

int main(){
  int n, u, k, v, c; //kはuの出次数の数, vはuに隣接する頂点, cはuとvを繋ぐ辺の重み
  int i, j;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d", &u, &k);
    for(j=0;j<k;j++){
      scanf("%d %d", &v, &c);
      m[u][v] = c;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(m[i][j] == 0) m[i][j] = INF;
    }
  }

  MST(n);
  
  for(i=0;i<n;i++) printf("%d %d\n", i, d[i]);
  
  return 0;
}

void MST(int n){
  int color[n]; //color[v]にvの状態を記録
  int min;
  int u; //MSTに新たに加える頂点
  int i, v;
  
  //初期化
  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;

  while(1){
    min = INF; //重みの最小値を十分大きな値に設定
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
	min = d[i];
	u = i;
      }
    }

    if(min == INF) break;

    color[u] = BLACK;
    
    for(v=0;v<n;v++){
      if(color[v] != BLACK && m[u][v] != INF){
	if(d[u] + m[u][v] < d[v]){
	  d[v] = d[u] + m[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

}



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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a < 3200)
		cout << "red" << '\n';
	else
		cout << s << '\n';



	return 0;
}

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

using namespace std;

int main(){
    vector<int> v{0,0,0};
    for (int i = 0;i<3;i++){
        cin >> v[i];
    }

    sort(v.begin(),v.end());
    int sum = 0;
    for(int i = 0;i<3;i++){
        if (i!=0){
            sum += v[i]-v[i-1];
        }
    }

    cout<<sum<<endl;


}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const circle = radius => {
  const r = Number(radius);
  const area = (Math.pow(r, 2) * Math.PI).toFixed(6);
  const circumference = (2 * r * Math.PI).toFixed(6);

  console.log([area, circumference].join(' '));
};

circle(input);



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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> V(N);
  int ans = 0;
  int term = 0;
  
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  
  for (int i=0; i<=min(N,K); i++) {
    for (int j=0; j<=min(N,K)-i; j++) {
      term = 0;
      vector<int> tmp(i+j,0);
      for (int k=0; k<i; k++) {
        term += V[k];
        tmp[k] = V[k];
      }
      for (int k=0; k<j; k++) {
        term += V[N-k-1];
        tmp[i+k] = V[N-k-1];
      }
      sort(tmp.begin(),tmp.end());
      for (int k=0; k<min(i+j,K-i-j); k++) {
        if (tmp[k] < 0) {
          term += abs(tmp[k]);
        }
      }
      ans = max(ans,term);
    }
  }
  
  cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  set<int>b;
  for(int i=0;i<N;i++){
    b.insert(a.at(i));
  }
  cout<<b.size()<< endl;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

const string h[] = {"dream","dreamer","erase","eraser"};

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		int p = SZ(s);
		while(p > 0){
			bool f = true;
			REP(i,4){
				if(p >= SZ(h[i])){
					DEBUG(i);
					DEBUG(s.substr(p-SZ(h[i]),SZ(h[i])));
					if(s.substr(p-SZ(h[i]),SZ(h[i])) == h[i]){
						p -= SZ(h[i]);
						f = false;
					}
				}
			}
			DEBUG(p);
			if(f) break;
		}
		if(p == 0){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


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

int main() {
    uint64_t n;
    std::cin >> n;

    const auto limit = std::sqrt(n);
    uint64_t answer = n - 1;

    for(int i = 1; i <= limit; ++i) {
        if(n % i == 0) {
            answer = std::min(answer, i + n / i - 2);
        }
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
priority_queue<ll> pq;
ll val;

int main() {
	scanf("%lld %lld", &N, &K);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &val);
		pq.push(val);
	}
	while(K) {
		ll temp = pq.top();
		temp /= 2;
		pq.pop();
		pq.push(temp);
		K--;
	}
	ll sum = 0;
	while(!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1400
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static int mod=1000000007;
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        long m,a,r,c,h;
        m=a=r=c=h=0;
        for (int i = 0; i <n; i++) {
            String s=sc.next();
            switch (s.charAt(0)){
                case 'M':m++;break;
                case 'A':a++;break;
                case 'R':r++;break;
                case 'C':c++;break;
                case 'H':h++;break;
                default:break;
            }
        }
        out.println(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c +a*r*h + a*c*h + r*c*h );
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}


Measured memory_bytes: 44892
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a(), k = o.a();
  var r = o.a(), s = o.a(), p = o.a();
  var t = o.a(1).split("");
  var ans = 0;
  var pt = {r:p,s:r,p:s};
  for(var i = 0; i < k; i++){
    ans += pt[t[i]];
  }
  for(; i < n; i++){
    if(t[i] === t[i-k])t[i] = "0";
    else ans += pt[t[i]];
  }
  return ans;
}

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <cassert>
#define REP(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using Mat = vector<vector<ll>>;
using Arr = vector<ll>;

constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 55;

ll n, k;
Mat mat;

Mat mul(Mat& a, Mat& b) {
	int na = a.size();
	int ma = a[0].size();
	int nb = b.size();
	int mb = b[0].size();
	assert(ma == nb);

	Mat res(na, Arr(mb));
	for (int i = 0; i < na; ++i)
		for (int j = 0; j < mb; ++j)
			for (int k = 0; k < ma; ++k)
				res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % MOD;
	return res;
}

Mat pow(Mat& a, ll e) {
	Mat res(n, Arr(n));
	for (int i = 0; i < n; ++i) res[i][i] = 1;
	while (e) {
		if (e & 1) res = mul(res, a);
		a = mul(a, a);
		e >>= 1;
	}
	return res;
}

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

	mat.resize(n, Arr(n));
	REP(i, n) REP(j, n) cin >> mat[i][j];
	auto res = pow(mat, k);

	ll ans = 0;
	REP(i, n) REP(j, n) ans = (ans + res[i][j]) % MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
def main():
    global A
    N = int(input())
    A = int(input())

    if N > 500:
        calc(N%500)
    
    elif N < 500:
        calc(N)

    else:
        print('Yes')

def calc(yen):
    if yen > A:
        print('No')
    else:
        print('Yes')




if __name__ == '__main__':
    main()


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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



int main(){
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  for (int i = 0; i < n-1; i++) {
    ll minv = i * c - (n-1-i)*d;
    ll maxv = i * d - (n-1-i)*c;
    if(b-a >= minv && b-a <= maxv){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

}


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

signed main(){
	int n,x=1000,b;
	cin>>n;
	
	int a[n+1];
	
	for(int i=1;i<=n;i++) 
        cin>>a[i];
        
	for(int i=1;i<n;i++)
		if(a[i+1]>a[i]){
			b=x/a[i];
			x%=a[i];
			b*=a[i+1];
			x+=b;
		}
		
	cout<<x<<"\n";
	return 0;
}

Measured memory_bytes: 3604
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;

int main(){
    string s,t; cin>>s>>t;
    ll n=s.size();
    for(char c='a';c<='z';c++){
        rep(j,n){
            if(s[j]==c){
                char cs=s[j],ct=t[j];
                for(ll k=j;k<n;k++){
                    if(s[k]==cs&&t[k]!=ct){
                        cout<<"No"<<endl;
                        return 0;
                    }
                    else if(s[k]!=cs&&t[k]==ct){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
                break;
            }
        }
    }
    cout<<"Yes"<<endl;
}



























































































Measured memory_bytes: 3920
N=int(input())
A=list(map(int,input().split()))+[0]
B=list(map(int,input().split()))
C=list(map(int,input().split()))+[0]

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

Measured memory_bytes: 3064
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[200005],br[200005];
int main(){
  cin>>n;
  REP(i,n) scanf("%d%d",&ar[i],&br[i]);

  lint res=0;
  lint tot=accumulate(ar,ar+n,0ll);
  REP(i,n){
    if(ar[i]>br[i]){
      chmax(res,tot-br[i]);
    }
  }
  cout<<res<<endl;

  return 0;
}





Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> num(n);
  for(int i = 0;i <= n - 1;i++){
    cin >> num[i];
  }
  vector<int> ans(n);
  bool can = true;
  for(int i = n - 1;i >= 0;i--){
    bool find = false;
    for(int j = num.size() - 1;j >= 0;j--){
      //cout << j << endl;
      if(num[j] == j + 1){
        find = true;
        ans[i] = j;
        num.erase(num.begin() + j);
        //cout<<1<<endl;
        break;
      }
    }
    if(!find)can = false;
  }
  if(can){
    for(int i = 0;i <= n - 1;i++){
      cout << ans[i] + 1 << endl;
      //cout<<0<<endl;
    }
  }
  else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0';
    return tmp*f;
}
inline ll power(ll a,ll b)
{
	ll tmp=1;
	for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;}
	return tmp;
}
using namespace std;
struct data{
	ll val,d;
}a[100010];
ll sum[100010],mx[100010][2];
int n;
ll c;
bool cmp(data a,data b){return a.d<b.d;}
int main()
{
	int i;
	n=read(); c=read();
	for(i=1;i<=n;i++)a[i].d=read(),a[i].val=read();
	sort(a+1,a+n+1,cmp);
	sum[0]=0;
	for(i=1;i<=n;i++)sum[i]=sum[i-1]+a[i].val;
	mx[0][0]=mx[n+1][1]=0;
	for(i=1;i<=n;i++)mx[i][0]=max(mx[i-1][0],sum[i]-a[i].d);
	for(i=n;i;i--)mx[i][1]=max(mx[i+1][1],(sum[n]-sum[i-1])-(c-a[i].d));
	//for(i=1;i<=n;i++)printf("%lld %lld\n",mx[i][0],mx[i][1]);
	ll ans=0;
	for(i=1;i<=n;i++)
		ans=max(ans,max(sum[i]-a[i].d,sum[i]-a[i].d*2+mx[i+1][1]))
		/*,printf("%d %lld %lld\n",i,sum[i]-a[i].d,sum[i]-a[i].d*2+mx[i+1][1])*/;
	for(i=n;i;i--)
		ans=max(ans,max((sum[n]-sum[i-1])-(c-a[i].d),(sum[n]-sum[i-1])-(c-a[i].d)*2+mx[i-1][0]))
		/*,printf("%d %lld %lld\n",i,(sum[n]-sum[i-1])-(c-a[i].d),(sum[n]-sum[i-1])-(c-a[i].d)*2+mx[i-1][0])*/;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] k = new int[M + 1];
		int[][] s = new int[M + 1][N + 1];
		int[] p = new int[M + 1];
		for (int i = 1; i <= M; i++) {
			k[i] = sc.nextInt();
			for (int j = 1; j <= k[i]; j++)
				s[i][j] = sc.nextInt();
		}
		for (int i = 1; i <= M; i++)
			p[i] = sc.nextInt();
		int count = 0;
		int ans = 0;
		int[] denkyu = new int[M + 1];

		for (int i = 0; i < (1 << N); i++) {
			for (int a = 0; a < N; a++) {
				if (((i >> a) & 1) == 0) {
					for (int g = 1; g <= M; g++) {
						for (int h = 1; h <= k[g]; h++) {
							if (s[g][h] == a + 1)
								denkyu[g]++;
						}
					}
				}
			}
			for (int z = 1; z <= M; z++) {
				if (denkyu[z] % 2 == p[z])
					count++;
			}

			if (count == M) {
				ans++;
				count = 0;
			} else
				count = 0;

			for (int j = 1; j <= M; j++)
				denkyu[j] = 0;
		}

		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long march[5]={};
	long long ans=0;
	string s;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s[0]=='M')
		march[0]++;
		if(s[0]=='A')
		march[1]++;
		if(s[0]=='R')
		march[2]++;
		if(s[0]=='C')
		march[3]++;
		if(s[0]=='H')
		march[4]++;
	}
	for(int i=0;i<3;i++)
	{
		for(int j=i+1;j<4;j++)
		{
			for(int k=j+1;k<5;k++)
			{
				ans+=march[i]*march[j]*march[k];
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

nR = S.count('R')
nG = S.count('G')
nB = S.count('B')

ans = nR*nG*nB

for x in range(1,N):
    for i in range(1,N):
        j = i+x
        k = i+2*x
        if k > N:
            break
        if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[k-1] != S[i-1]:
            ans -= 1

print(ans)






Measured memory_bytes: 67784