akhauriyash/Code-Regression huggingface dataset:
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

fac = [1]
inv = [1]

for i in range(1, H+W+1) :
    fac.append(fac[-1] * i % MOD)
    inv.append(pow(fac[-1], MOD - 2, MOD))
    
ret = 0
for i in range(H-A) :
    ret += fac[i+B-1]*inv[i]*inv[B-1]*fac[H+W-i-B-2]*inv[H-i-1]*inv[W-B-1]%MOD
    ret %= MOD
    
print(ret)

Measured memory_bytes: 67056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n);
  int maxNum = 0;
  rep(i, n){
    cin >> a[i];
    maxNum = maxNum < a[i] ? a[i] : maxNum;
  }
  int half = maxNum / 2;
  int nearPos = -1;
  int nearNum = 2000000000;
  rep(i, n){
    if(maxNum == a[i]) continue;
    if(abs(a[i] - half) < nearNum){
      nearNum = abs(a[i] - half);
      nearPos = i;
    }
  }
  cout << maxNum << " " << a[nearPos] << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int count=0;
        for (int i=0; i<n; i++) {
            if (i+1 != a[i]) {
                count++;
            }
        }
        if (count<=2) {
            System.out.println("YES");
        }
        else System.out.println("NO");
    }
}


Measured memory_bytes: 23124
room = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(4):
    for j in range(3):
        for k in range(10):
            room[i][j].append(0)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    room[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" "+" ".join(map(str, room[i][j])))
    if i != 3: print("#"*20)


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

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

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

vector<string> button = {
    "kakutei", " .,!?", "cab",  "fde", "igh",
    "ljk",     "omn",   "spqr", "vtu", "zwxy",
};

void solve() {
    string s, ans = "";
    cin >> s;
    vector<int> ncnt(10, 0);
    for(int i = 0; i < s.size(); i++) {
        int now = s[i] - '0';
        if(now == 0) {
            if(i == 0) {
                continue;
            }
            int pre = s[i - 1] - '0';
            if(pre == 0) {
                continue;
            }
            ans += button[pre][ncnt[pre]];
            ncnt.assign(10, 0);
        } else {
            ncnt[now] = (ncnt[now] + 1) % (int)button[now].size();
        }
    }
    cout << ans << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int total = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                mp[total]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cout << mp[i] << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  vector<ui> A(N);
  for(auto& a : A) cin >> a;
  auto res = std::minmax_element(A.begin(), A.end());

  cout
    << *res.second - *res.first
    << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    else{
        ll ten_n =1;
        ll nine_n=1;
        ll eight_n=1;

        rep(i,n)ten_n = (ten_n*10)%mod;
        rep(i,n)nine_n = (nine_n*9)%mod;
        rep(i,n)eight_n = (eight_n*8)%mod;

        ll ans = ten_n - ((2*nine_n)%mod) + eight_n;

        if(ans <0)cout << ans + mod << endl;
        else cout << ans <<endl;
    
        return 0;
    }
}

Measured memory_bytes: 3564
var
  n,m,i,j,s:longint;
  a:array[0..51,0..51]of char;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
      read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
  begin
    for j:=1 to m do
    if  a[i,j]='#' then write(a[i,j]) else
    begin
      s:=0;
      if a[i-1,j-1]='#' then inc(s);
      if a[i-1,j]='#' then inc(s);
      if a[i-1,j+1]='#' then inc(s);
      if a[i,j-1]='#' then inc(s);
      if a[i,j+1]='#' then inc(s);
      if a[i+1,j-1]='#' then inc(s);
      if a[i+1,j]='#' then inc(s);
      if a[i+1,j+1]='#' then inc(s);
      write(s);
     end;
     writeln;
    end;
end.


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100
int num[MAXN+5];
int main() {
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0){
		cout<<"Zero";
		return 0;
	}
	if(a>0&&b>0){
		cout<<"Positive";
		return 0;
	}
	int k=b-a+1;
	if(k%2==0) cout<<"Positive";
	else cout<<"Negative";
	return 0;
}

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

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

const ll INF = 1LL << 60;
ll d[35][35];
ll C[3][35];

int main() {
	int n, c;
	cin >> n >> c;
	REP(i, c) REP(j, c) cin >> d[i][j];
	REP(i, n) {
		REP(j, n) {
			ll c;
			cin >> c;
			C[(i + j) % 3][c]++;
		}
	}
	
	ll ans = INF;
	REP(i, c) {
		REP(j, c) {
			REP(k, c) {
				ll dif = 0;
				if (i == j || j == k || k == i) continue;
				REP(l, c) {
					dif += d[l][i] * C[0][l];
				}
				REP(l, c) {
					dif += d[l][j] * C[1][l];
				}
				REP(l, c) {
					dif += d[l][k] * C[2][l];
				}
				ans = min(ans, dif);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){
  double n,k;
  double ans=0.0;
  
  cin >> n >> k;
  
  for(int i=1;i<=n;i++){
    /*出目がi*/
    /*出目がK以上のとき*/
    if(i>=k){
      ans += 1.0/n; //コインを振る必要はない
    }
    /*出目がK未満のとき*/
    else{
      //コインを振る必要がある
      double face;
      double num=i;
      /*face回連続で表を出す必要がある*/
      for(face=0;num<k;face++){
        num *= 2.0;
      }
      ans += 1/n*pow(0.5,face);
    }
  }
  
  //cout << ans << endl;
  printf("%.12f\n",ans);
  
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num_list = new ArrayList<Integer>();
		for(int i = 0; i < 3; i++) {
			num_list.add(sc.nextInt());
		}
		Collections.sort(num_list);
		System.out.println(num_list.get(0) + " " +num_list.get(1) + " " + num_list.get(2));
		sc.close();
	}
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _fastio_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
	std::string s, t;
	std::cin >> s >> t;
	
	const std::size_t n = s.length(), m = t.length();
	
	int ans = n;
	for (std::size_t i = 0; i + m <= n; i++) {
		const std::string str = s.substr(i, m);
		int val = 0;
		for (std::size_t j = 0; j < m; j++) {
			if (str[j] != t[j]) val++;
		}
		chmin(ans, val);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 3656
// AOJ 2780: Best Matched Pair
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int a[1001];

char buf[6001], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int check(int k)
{
	int n = k % 10;
	while (1) {
		k /= 10;
		if (!k) break;
		if (--n != k % 10) return 0;
	}
	return 1;
}

int main()
{
	int n, i, j, x, ans;

	fgets(p=buf, 10, stdin), n = getint();
	fgets(p=buf, sizeof(buf), stdin);
	for (i = 0; i < n; i++) a[i] = getint(), p++;
	qsort(a, n, sizeof(int), cmp);
	ans = -1;
	for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
		if (check(x = a[i]*a[j])) { ans = x; goto done; }
	}
done:
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    int score = 0;
    for(int i = 0; i < n-1; ++i){
        if(s[i] == s[i+1])  ++score;
    }
    int ans = min(score + 2*k, n-1);
    cout << ans << endl;
}

Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto H = RD;
	auto W = RD;
	auto N = RD;

	writeln(N / max(H, W) + (N % max(H, W) != 0 ? 1 : 0));
	stdout.flush;
	debug readln;
}


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

#define rep(i,n) for(i=0;i<(int)(n);i++)
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  int i,sum=0;
  rep(i,n) cin>>a[i];
  rep(i,n){
    sum+=min(a[i],abs(k-a[i]));
  }
  cout<<sum*2<<endl;
}


Measured memory_bytes: 256
import sys

for s0 in sys.stdin:
  s=s0[:-1]
  d,c=s.split("=")
  a,b=d.split("+")
  f=any([e!=e[0]=="X" for e in [a,b,c]])

  m="NA"
  s=d+"=="+c
  for e in "0123456789"[f:]:
    if eval(s.replace("X",e)): m=e; break
  print m

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

int main()
{
    int h, a, ans = 0;
    cin >> h >> a;
    while (h > 0)
    {
        h -= a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  double r;
  cin>>r;
  double c=6.28*r;
  cout<<fixed<<setprecision(2)<<c<<endl;
  return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int x,y,z,n,m,s,t;
	cin>>x>>y>>z>>n>>m>>s>>t;
	--s;--t;
	vector<vector<int>> v(x+y+z+n+m);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		--a;--b;
		v[a].push_back(x+y+z+i);
		v[x+y+z+i].push_back(a);
		v[x+b].push_back(x+y+z+i);
		v[x+y+z+i].push_back(x+b);
	}
	rep(i,m){
		int a,b;
		cin>>a>>b;
		--a;--b;
		v[x+a].push_back(x+y+z+n+i);
		v[x+y+z+n+i].push_back(x+a);
		v[x+y+b].push_back(x+y+z+n+i);
		v[x+y+z+n+i].push_back(x+y+b);
	}
	vector<int> dist(x+y+z+n+m,inf);
	dist[x+y+z+s]=0;
	queue<int> q;
	q.push(x+y+z+s);
	while(q.size()){
		int c=q.front();q.pop();
		for(auto to:v[c]){
			if(dist[to]==inf){
				dist[to]=dist[c]+1;
				q.push(to);
			}
		}
	}
	if(dist[x+y+z+n+t]==inf)cout<<-1<<endl;
	else cout<<dist[x+y+z+n+t]/2<<endl;
	return 0;
}


Measured memory_bytes: 29792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, K;
  cin >> N >> K;
  ll ans = 1;

  for (int i = 0; i < N; i++) {
    if(i == 0) ans = ans*K;
    else ans = ans*(K-1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3600
import Control.Monad

solve :: Int -> Int -> [Int] -> Int
solve d1 d2 [x, y   ] = d2
solve d1 d2 [x, y, z] = dn
  where a  = d1 + abs (z - x)
        b  = d2 + abs (z - y)
        dn = min a b
solve d1 d2 (x:y:z:h) = solve d2 dn (y:z:h)
  where a  = d1 + abs (z - x)
        b  = d2 + abs (z - y)
        dn = min a b


main = do
  _ <- getLine
  h@(h0:h1:hs) <- map read . words <$> getLine
  print $ solve 0 (abs (h0 - h1)) h


Measured memory_bytes: 20200
def main():
  n=int(input())
  rain=[int(i) for i in input().split()]
  
  test=0
  for i in range(n):
    test=rain[i]-test
  ans=test
  
  fall=[0]*n
  fall[0]=test
  for i in range(n-1):
    tmp=rain[i]-fall[i]//2
    fall[i+1]=2*tmp
  
  print(*fall)
if __name__=='__main__':
  main()

Measured memory_bytes: 14024
#include<stdio.h>

int main()
{
  int n;
  int a=1;
  scanf("%d",&n);
  if(n<2)
    printf("%d",a);
  else if(2<=n&&n<4)
    printf("%d",a*2);
  else if(4<=n&&n<8)
    printf("%d",a*2*2);
  else if(8<=n&&n<16)
    printf("%d",a*2*2*2);
  else if(16<=n&&n<32)
    printf("%d",a*2*2*2*2);
  else if(32<=n&&n<64)
    printf("%d",a*2*2*2*2*2);
  else if(64<=n&&n<=100)
    printf("%d",a*2*2*2*2*2*2);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
long long n;
cin>>n;
long long n1,h,w;
int flag=0;
for(long long i=1;i<=3500;i++){
for(long long j=1;j<=3500;j++){
long long mul=i*j*n;
long long sum=4*(i*j)-(i*n)-(j*n);
if(sum>0){
long long ans=mul/sum;
long long ans1=mul%sum;
if(ans1==0){
n1=i;
h=j;
w=ans;
flag=1;
break;
}
}
if(flag==1)
break;
}
if(flag==1)
break;
}
cout<<n1<<" "<<h<<" "<<w;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define ull unsigned long long
#define MAXN 3010
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#define allof(x) x.begin(), x.end()
#define DEBUG 1
// #define NOT_DMOJ 0
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int LCM (int a, int b) { return a * b / GCD(a, b); }
inline ll PowMod (ll a, ll b, ll mod) { ll val = 1; while (b) { if (b & 1) val = (val * a) % mod; a = (a * a) % mod; b >>= 1; } return val; }

// https://atcoder.jp/contests/dp/tasks/dp_f

ll DP[MAXN][MAXN];
string s, t, ans;

inline ll LCS (ll a, ll b) {
	if (a == s.size() || b == t.size()) return 0LL;
	ll &res = DP[a][b];
	if (~res) return res;
	ll maxx = 0LL;
	if (s[a] == t[b]) {
		maxx = max(maxx, LCS(a + 1, b + 1) + 1);
	}
	maxx = max(maxx, max(LCS(a + 1, b), LCS(a, b + 1)));
	return res = maxx;
}

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	memset(DP, -1, sizeof(DP));
	cin >> s >> t;
	LCS(0, 0);
	int l = 0, r = 0;
	while (l < s.size() && r < t.size()) {
		if (s[l] == t[r]) {
			ans += s[l];
			++l, ++r;
		}
		else if (LCS(l + 1, r) > LCS(l, r + 1)) ++l;
		else ++r;
	}
	cout << ans << "\n";
	return 0;
}

/* 
 * Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 */

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

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

ll dp[500001];
const ll MOD =998244353;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> l(k),r(k);
	for(int i = 0;i<k;i++)
	{
		cin >> l[i]>>r[i];
	}
	dp[0]=1;
	dp[1] = MOD-1;
	for(int i = 0;i<n;i++)
	{
		(dp[i+1] += dp[i])%=MOD;
		for(int j =0;j<k;j++)
		{
			(dp[i+l[j]]+= dp[i])%=MOD;
			(dp[i+r[j]+1] += MOD-dp[i])%=MOD;
		}
	}
	
	cout<<dp[n-1]<<endl;

	
}


Measured memory_bytes: 6660
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int sum = 0;
    vi s(n);
    rep(i,n) cin >> s[i];
    rep(i,n) sum += s[i];
    if(sum%10 != 0) {
        cout << sum << endl;
        return 0;
    }
    int mn = inf;
    rep(i,n) {
        if(s[i]%10 == 0) continue;
        chmin(mn,s[i]);
    }
    cout << (mn == inf ? 0 : sum-mn) << endl;
}


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

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL Q;scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  UL s,t; scanf("%u%u",&s,&t);
  if(c==0){
   int m=1000000000;
   for(UL i=s; i<t; i++) m=min(m,A[i]);
   printf("%d\n",m);
  }else if(c==1){
   int m=-1000000000;
   for(UL i=s; i<t; i++) m=max(m,A[i]);
   printf("%d\n",m);
  }
 }
 return 0;
}




Measured memory_bytes: 3188
n = gets.to_i
h = gets.split.map(&:to_i)
t = [0]*n
l,ans = 0,0
while l != n
  l = 0
  while l < n && h[l] == t[l]
    l += 1
  end
  r = l
  while r < n && h[r] > t[r]
    r += 1
  end
  l.upto(r-1) do |i|
    t[i] += 1
  end
  ans += 1
end
p ans-1

Measured memory_bytes: 1788
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        ss: chars,
    }
    let mut ss = ss;
    let mut i = 0;
    let mut vs = Vec::new();
    while i + 1 < ss.len() {
        if ss[i] == 'B' && ss[i + 1] == 'C' {
            vs.push('D');
            i+=2;
        } else {
            vs.push(ss[i]);
            i+=1;
        }
    }
    //let mut i = vs.len() - 1;
    let mut cnt = 0;
    /*
    while i as i64 >= 0 {
        if v[i] == 'A' {
            cnt += a - i - 1;
            a -= 1;
        } else if v[i] == 'B' && v[i] == 'C' {
            a = i;
        }
        i-=1;
    }
    */
    let mut a = vs.len() as i64;
    let mut len = vs.len() as i64 - 1;
    //println!("{:?}", vs);
    for (k, v) in vs.into_iter().rev().enumerate() {
        let k = len - k as i64;
        //println!("{}", k);
        if v == 'A' {
            cnt += a - k as i64 - 1;
            // print!("{} ", a - k as i64 - 1);
            a -= 1;
        } else if v == 'B' || v == 'C' {
            a = k as i64;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
#include<algorithm>
using namespace std; 
#define int long long
#define float double
#define LMT 100000000000
#define int long long 
#define lp(i,n) for( i=0;i<n;i++)
const int H=1001,W=1001,mod=1000000000+7;
int dp[H][W]; 


int32_t main(){
  #ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  freopen("output.txt", "w", stdout); 
 #endif
  int h,w,i,j;
  cin>>h>>w;char ch;
  memset(dp,0,sizeof(dp));
  int a[h][w],dx[2]={0,-1},dy[2]={-1,0};
  dp[0][0]=1;
  lp(i,h)for(int j=0;j<w;j++){cin>>ch;a[i][j]=ch=='.';}
  for(int i=0;i<h;i++)for(int j=0;j<w;j++){
    if(!a[i][j])continue;
       for(int k=0;k<2;k++)
          {
            int r=i+dx[k],c=j+dy[k];
            if((r<h && r>=0) &&(c>=0 && c<w)){
              dp[i][j]=(dp[i][j]+dp[r][c])%mod;
            }
          }
  }
  cout<<dp[h-1][w-1]<<endl;;
} 

Measured memory_bytes: 19208
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>


using namespace std;

int main(void) {
    int n,l;
    int eat = 999;
    int sum = 0;
    cin >> n >> l;

    for(int i=1; i<=n; i++) {
        sum += l + i - 1;
        if( abs(eat) > abs(l+i-1) ) {
            eat = l+i-1;
            // cout << eat << " ";
        }
    }
    // cout << endl;

    cout << sum - eat << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  set<int> st;
  rep(i,n){
    int a;
    cin >> a;
    if(st.count(a)) st.erase(a);
    else st.insert(a);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int[] a = nia(n);

        long MOD = 1000000007;

        if (n % 2 == 1) {
            int[] cnt = new int[n];
            for (int i = 0; i < n; i++) {
                cnt[a[i]]++;
            }

            for (int i = 2; i < n; i += 2) {
                if (cnt[i] != 2) {
                    out.println(0);
                    return;
                }
            }

            if (cnt[0] != 1) {
                out.println(0);
                return;
            }
        } else {
            int[] cnt = new int[n];
            for (int i = 0; i < n; i++) {
                cnt[a[i]]++;
            }

            for (int i = 1; i < n; i += 2) {
                if (cnt[i] != 2) {
                    out.println(0);
                    return;
                }
            }
        }

        long i = 1;
        for (int j = 0; j < n / 2; j++) {
            i = (i * 2) % MOD;
        }

        out.println(i);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 22548
N = int(input().rstrip())

A = []
for i in range(N):
  line = input().rstrip()
  A.append(line)
  
print('AC x', A.count('AC'))
print('WA x', A.count('WA'))
print('TLE x', A.count('TLE'))
print('RE x', A.count('RE'))

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

bool check(string &a,int i){
  if(i+3>(int)a.size()) return 0;
  return a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C';
}

string ABC="ABC"; 
bool dfs(string sta){
  if(sta==ABC)return 1;
  if(sta.size()<=3)return 0;

  bool used[3]={1,1,1};
  for(int i=0;i<sta.size();)
    if(check(sta,i)) i+=3;
    else used[sta[i++]-'A']=0;

  
  for(int i=0;i<3;i++){
    if(!used[i])continue;
    string nx="";
    int j=0;
    while(j<(int)sta.size())
      if(check(sta,j))nx+=ABC[i],j+=3;
      else nx+=sta[j++];
    if(nx.size()==sta.size())return 0;
    if(dfs(nx))return 1;
  }
  return 0;
}

int main(){
  string str;
  cin>>str;
  cout<<(dfs(str)? "Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 21796
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    ll n; cin >> n;
    ll ans=0;
    rep(i,n+1){
        if(i%3==0 || i%5==0)continue;
        ans += i;
    }
    cout << ans << endl;
	return 0;
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	string S;  cin >> S;

	int ans = 0;
	for(int i = 0 ; i < N - 2 ; i++)
			if(S.substr(i, 3) == "ABC")  ans++;

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


Measured memory_bytes: 256
#! /usr/bin/env python3

n, m, qq = map(int, input().split())

lr = [[0 for i in range(n + 1)] for j in range(n + 1)]

for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

for i in range(1, n + 1):
    for j in range(1, n + 1):
        lr[i][j] += lr[i][j-1]
for j in range(1, n + 1):
    for i in range(1, n + 1):
        lr[i][j] += lr[i-1][j]


res = []
for _ in range(qq):
    ans = 0
    p, q = map(int, input().split())
    ans += lr[q][q] + lr[p-1][p-1] - lr[p-1][q] - lr[q][p-1]
    res.append(ans)

for row in res:
    print(row)


Measured memory_bytes: 17688
#include <iostream>
#include <vector>
#include <queue>
#include <cstdlib>

typedef long long ll;
using namespace std;
int main()
{
	priority_queue<int,vector<int>,greater<int>> max_que;
	priority_queue<int,vector<int>,less<int>> min_que;

	int N ;
	cin >> N ;

	vector<int> Data(N*3);
	vector<ll> max_val(N+1);
	vector<ll> min_val(N+1);

	for( int i = 0; i < N*3; i++ ){
		cin >> Data[i] ;
	}
	
	ll sum = 0 ;
	for( int i = 0 ; i < N; i++){
		max_que.push(Data[i]);
		sum += Data[i] ;
	}
	max_val[0] = sum ;
	for( int i = 0; i < N; i++ ){
		int minval = max_que.top();
		if( minval < Data[N+i]){
			max_que.pop();
			max_que.push( Data[N+i]) ;
			sum += ( Data[N+i] - minval );
		}
		max_val[i+1] = sum ;	
	}

	sum = 0;
	for( int i = N*2; i < N*3; i++){
		min_que.push(Data[i]);
		sum += Data[i] ;
	}
	min_val[N] = sum ;
	for( int i = N*2-1; i >= N; i--){
		int maxval = min_que.top();
		if( maxval > Data[i]){
			min_que.pop();
			min_que.push(Data[i]);
			sum += (Data[i]-maxval);
		}
		min_val[i-N] = sum ;
	}

	ll ans = max_val[0] - min_val[0];
	for( int i = 1; i <= N; i++ )
	{
		ll newval = max_val[i]-min_val[i] ;
		if( ans < newval ){
			ans = newval ;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(int argc, char const *argv[]) {
  ll n, q;std::cin >> n >> q;
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    scanf("%lld",&c[i]);
    c[i]--;
    x[c[i]].push_back(i);
  }
  LazySegmentTree seg(vll(n+1, 0));
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;std::cin >> l >> r;
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    // pre ~ i まで + 1
    seg.add(pre, i+1, 1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.getsum(l, l+1);
    }
  }
  re(i, q) std::cout << ans[i] << '\n';
  return 0;
}


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

int main(){
	int n;cin>>n; int mx=1e9, ct=0, a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) {
		if (mx>=a[i]) ct++, mx=a[i];
	}
	cout<<ct<<endl;
}

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

int main() {
  int x,n=0;
  cin>>x>>n;
  vector<int> vec(n);
  rep(i,n){
    cin>>vec.at(i);
  }
  
  int j=x;
  int ansp,ansm=0;
  bool next=false;
  
  while(true){
    rep(i,n){
      if(j==vec.at(i)){
        j++;
        //i=0;
        next=true;
        continue;
      }
    }
    if(next){
      next=false;
      continue;
    }
    ansp=j;
    //cout<<ansp;
    break;
  }
  
  j=x;
  
  while(true){
    rep(i,n){
      if(j==vec.at(i)){
        j--;
        //i=0;
        next=true;
        continue;
      }
    }
    if(next){
      next=false;
      continue;
    }
    ansm=j;
    //cout<<ansm;
    break;
  }
  
  if(abs(ansp-x)<abs(ansm-x)){
    cout<<ansp;
  }else{
    cout<<ansm;
  }
}


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

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n,1);
//  cout << n << endl;
  rep(i,n-1){
    if(s[i]=='R'&& s[i+1]=='R') {
      ans[i+2] += ans[i];
      ans[i] =0;
    }
    if(s[i]=='R'&& s[i+1]=='L') continue;
  }
  for(int i=n-1; i>=1; i--){
    if(s[i]=='L'&& s[i-1]=='L') {
      ans[i-2] += ans[i];
      ans[i] =0;
    }
    if(s[i]=='L'&& s[i-1]=='R') continue;
  }
  rep(i,n) cout << ans[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007

vector<int> parent;
int find(int x){
  int y=parent[x];
  while(parent[y]!=y){
    y=find(y);
  }
  return parent[x]=y;
}

void unite(int a,int b){
  int x=find(a);
  int y=find(b);
  if(x!=y){
    parent[y]=x;
  }
}
int main(){
  int N,M;
  cin>>N>>M;
  parent.resize(N);
  for(int i=0;i<N;i++){
    parent[i]=i;
  }
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    A--;
    B--;
    unite(A,B);
  }

  set<int> s;
  for(int i=0;i<N;i++){
    s.insert(find(i));
  }
  cout<<s.size()-1<<endl;
}


Measured memory_bytes: 7424
// All Heil Fire Lord Zuko

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad";
    else
        cout << "Good";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=1e6+2,M=1e6+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	if(c==0)
	{
		// c++;
		int tot=0;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='o') tot++;
		}
		int su=0;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='x') continue;
			if(su+tot-su-1<k)
			{
				cout<<i+1<<"\n";
			}
			su++;
		}
		return 0;
		// return 0;
	}
	int dp1[n];
	for(int i=0;i<n;i++) dp1[i]=0;
	for(int i=0;i<n;i++)
	{
		if(i>0) dp1[i]=dp1[i-1];
		if(s[i]=='x') continue;
		if(i-c-1<0)
		{
			dp1[i]=max(dp1[i],1LL);
		}
		else{
			dp1[i]=max(dp1[i],1+dp1[i-c-1]);
		}
	}
	// for(int i=0;i<n;i++)
	// {
	// 	cout<<dp1[i]<<" ";
	// }
	// return 0;
	int dp2[n]={0};
	for(int i=n-1;i>=0;i--)
	{
		if(i<n-1) dp2[i]=dp2[i+1];
		if(s[i]=='x') continue;
		if(i+c+1>=n)
		{
			dp2[i]=max(dp2[i],1LL);
		}
		else{
			dp2[i]=max(dp2[i],1+dp2[i+c+1]);
		}	
	}
	int lol[n];
	for(int i=0;i<n;i++)
	{
		if(i+c+1<n)
		{
			lol[i]=dp1[i]+dp2[i+c+1];
		}
		else lol[i]=dp1[i];
	}
	// for(int i=0;i<n;i++)
	// {
	// 	cout<<lol[i]<<" ";
	// }
	// return 0;
	multiset<int> se;
	// vector<int> ans;
	int okk[n]={0};
	for(int i=0;i<n;i++)
	{
		if(se.size()==0)
		{
			// cout<<se.size()<<"\n";
			// cout<<"*";
		}
		else{
			if(s[i]=='o'){
				auto kek=se.end();
				kek--;
				int val=*kek;
				okk[i]=val;
				// cout<<"*";
				// if(val<k)
				// {
				// 	ans.pb(i);
				// }
			}
		}
		// cout<<"*";
		se.insert(lol[i]);
		if(se.size()>c)
		{
			se.erase(se.find(lol[i-c]));
		}
	}
	int lol1[n];
	for(int i=n-1;i>=0;i--)
	{
		if(i-c-1>=0)
		{
			lol1[i]=dp2[i]+dp1[i-c-1];
		}
		else lol1[i]=dp2[i];
	}
	se.clear();
	// vector<int> ans;
	int okk1[n]={0};
	for(int i=n-1;i>=0;i--)
	{
		if(se.size()==0)
		{

		}
		else{
			if(s[i]=='o'){
				auto kek=se.end();
				kek--;
				int val=*kek;
				okk1[i]=val;
			}
		}
		se.insert(lol1[i]);
		if(se.size()>c)
		{
			se.erase(se.find(lol1[i+c]));
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='x') continue;
		// cout<<okk[i]<<" "<<okk1[i]<<"\n";
		if(max(okk[i],okk1[i])<k)
		{
			cout<<i+1<<"\n";
		}
	}
	// for(auto x:ans)
	// {
	// 	cout<<x+1<<"\n";
	// }
}
//  
// dp1[i],dp2[j]
// j-i+1>=c
// dp1[i]+dp2[j]>=k
// 
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 10004
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

n = int(sys.stdin.buffer.readline())
s = sys.stdin.buffer.readline().decode().rstrip()

ok = 0
for i in range(len(s)):
    if s[i:i+3] == 'ABC':
        ok += 1
print(ok)


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

int main() {
  int N;
  int K;
  int A = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int B = 0;
    int C = 0;
    
    B = A * 2;
    C = A + K;
    
    if (B > C) {
      A = C;
    }
    else {
      A = B;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int a,b;
set<string> ans;

void solve(int a, int b, string cur){
    if(a==0 && b==0){
        ans.insert(cur);
    } else if(a==b || max(a,b)<=4){
        if(a!=0) solve(a-1,b,"A"+cur);
        if(b!=0) solve(a,b-1,"B"+cur);
    } else {
        if(a>b) solve(a-1,b,"A"+cur);
        else solve(a,b-1,"B"+cur);
    }
}

int main(){
    cin >> a >> b;
    solve(a,b,"");
    for(auto & s : ans){
        cout << s << endl;
    }
}

Measured memory_bytes: 1220
import math
A, B, H, M = map(int, input().split())
a = 30*H + M/2
b = 6*M
if a > b:
    tmp = a
    a = b
    b = tmp
c = b - a
if c > 180:
    c = 360 - c
l = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(c)))
print(l)


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
int n,q,k;
int a[100005];
int c;
int main() {
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++) {
		scanf("%d",&c);
		a[c]++;
	}
	for(int i=1;i<=n;i++) 
		if(a[i]+k>q) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	return 0;
}

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

const int MAX_N = 201000;
ll D, A;
int N;
pair<ll, ll> XH[MAX_N];
ll damage[MAX_N]; // damage[i] := i番目の要素はどれだけダメージを受けたか
int r_range[MAX_N]; // r_range[i] = j -> Xi に対して、 Xj - Xi <= 2Dを満たす最も右側の要素番号がj

int right_bound(ll A) {
    int left = -1;
    int right = N;
    while(abs(right-left) > 1) {
        int mid = (left + right)/2;
        if(XH[mid].first > A) right = mid;
        else left = mid;
    }
    return left;
}

void init(){
    sort(XH, XH + N);
    for(int i = 0; i < N; ++i) { r_range[i] = right_bound(XH[i].first + 2*D); }
    //for(int i = 0; i < N; ++i) printf("%d\n", r_range[i]);
}

int main()
{
    scanf("%d %lld %lld", &N, &D, &A);
    for(int i = 0; i < N; ++i) scanf("%lld %lld", &XH[i].first, &XH[i].second);

    init();
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        XH[i].second -= damage[i];
        ll k = (max(0LL, XH[i].second) + A - 1)/A;
        res += k;
        damage[i] += A*k;
        damage[r_range[i] + 1] -= A*k;
        damage[i+1] += damage[i];
    }
    printf("%lld\n" , res);
    return 0;
}

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

int main() {
  // エラトステネスのふるい
  int MAX = 101010;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
  }

  // 2017-like 数かどうか
  vector<int> a(MAX, 0);
  rep(i, MAX) {
    if (i % 2 == 0) continue;
    if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
  }

  // 累積和
  vector<int> s(MAX + 1, 0);
  rep(i, MAX) s[i + 1] = s[i] + a[i];

  // クエリ処理
  int q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    ++r;

    cout << s[r] - s[l] << endl;
  }
}

Measured memory_bytes: 4452