akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline

K = int(readline())
S = readline().rstrip()
S = len(S)
N = K + S

DIV = 10 ** 9 + 7
n = (10 ** 6) * 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % DIV )
    inverse.append( ( -inverse[DIV % i] * (DIV//i) ) % DIV )
    g2.append( (g2[-1] * inverse[-1]) % DIV )

def nCr(n, r, DIV):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % DIV

# K = 3, S = 5のとき
# ..X.X.X.
# Xが取る3か所を選んだ上で、
# 最も右のXよりも右のマス：各26通り
# 最も右のXを含む、それより左のマス：Xのマスは1通り、それ以外は各25通り
# 最も右のXが
# ..X.....　の状態から、
# .......X  
# の状態について、場合の数を求める

ans = 0
for xpos in range(S, N + 1):
  # xpos箇所からK箇所を選ぶ場合の数
  # 一番右に1個固定した状態で、残りのxpos - 1か所からS - 1個を選ぶ
  pat = nCr(xpos - 1, S - 1, DIV)
#  print("xpos",xpos,"ncr",ncr)
#  print(S,"from",xpos,"pat",pat)
  # その場合の数に対して、X以外の文字の選び方は25 ** (X - S)通りある
#  print("25 for",xpos - S,"boxes")
  pat *= pow(25, xpos - S, DIV)
  pat %= DIV
  
  # 残りのマスに対しては26通りずつ選べる
#  print("26 for ",N - xpos,"boxes")
  pat *= pow(26, N - xpos, DIV)
  pat %= DIV
#  print("xpos",xpos,"pat",pat)
  
  ans += pat
  ans %= DIV

print(ans)

Measured memory_bytes: 310888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[1 << 12];

int main(){
  int N, M;

  cin >> N >> M;

  for(int i=0; i<(1<<N); i++)
    dp[i] = LLINF;

  dp[0] = 0;

  for (int i=0; i<M; i++) {
    int a, b, c;
    cin >> a >> b;

    int bit = 0;
    for (int j=0; j<b; j++) {
      cin >> c;
      bit |= 1 << (c-1);
    }

    for(int j=(1<<N)-1; j>=0; j--)
      dp[j|bit] = min(dp[j|bit], dp[j] + a);
  }

  if (dp[(1<<N)-1] == LLINF)
    puts("-1");
  else
    printf("%lld\n", dp[(1<<N)-1]);

  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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
typedef vector<int> vec;

int main(){
  
  int A,B,M;
  cin >> A >> B >> M;
  vec a(A);
  vec b(B);
  rep(i,A) cin >> a[i];
  rep(i,B) cin >> b[i];
  int ans = vecmin(a)+vecmin(b);
  rep(i,M){
    int x,y,z;
    cin >> x >> y >> z;
    ans = min(ans, a[x-1]+b[y-1]-z);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

    string s;
    cin >> s;
    vector<string> a = {
        "Sunny", 
        "Cloudy", 
        "Rainy"
    };
    for (int i = 0; i < 3; i++) {
        if (s == a[i]) {
            cout << a[(i + 1) % 3] << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    if (n==1) {
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a >> b;

    int ans = a + b;
    
    
    
    cerr << ans << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 998244353, 2000000>;
comb cb;
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}
void sub(int &a, const int &b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	vector<int> X(1000100, 0);
	int tot = 0;
	int tot2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		add(tot, A[i]);
		add(tot2, (A[i] * A[i]) % MOD);
		X[A[i]]++;
	}

	vector<int> cnt(1000100, 0);

	vector<int> sum(1000100);
	vector<int> sum2(1000100);
	vector<int> S(1000100, -1);
	vector<int> T(1000100, 0);
	for (int i = 2; i < 1000100; i++) {

		int x = (i - 1) * cb.inv(i) % MOD;
		T[i] = x - T[i];
		if (T[i] < 0)T[i] += MOD;
		for (int j = i; j < 1000100; j += i) {
			cnt[j]++;
			if (j > i)add(T[j], T[i]);
			if (X[j] > 0) {
				sum[i] += j * X[j];
				sum2[i] += j * j * X[j];
			}
		}


	}
	int inv2 = (MOD + 1) / 2;
	res = (tot * tot) % MOD;
	sub(res, tot2);
	res = (res * inv2) % MOD;
	for (int i = 2; i < 1000100; i++) {
		if (sum[i] > 0 || sum2[i] > 0) {
			sum[i] %= MOD;
			int t = sum[i] * sum[i] - sum2[i];
			t %= MOD; t += MOD; t %= MOD;
			t = (t * inv2) % MOD;
			t = (t * T[i]) % MOD;
			//cerr << i << " " << t << endl;

			sub(res, t);

		}
	}


	cout << res << endl;
}

Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

void rot(array<string, 8> &a){
    string tmp = a[0];
    rep(i, 3) a[i] = a[(i + 1) % 4];
    a[3] = tmp;
    tmp = a[4];
    rep(i, 3) a[4+i] = a[4 + (i + 1) % 4];
    a[7] = tmp;
}

bool check(set<array<string, 8>> &S, array<string, 8> a){
    rep(_, 4){
        if(S.find(a) != S.end()) return false;
        rot(a);
    }
    reverse(a.begin(), a.end());
    rep(_, 4){
        if(S.find(a) != S.end()) return false;
        rot(a);
    }
    return true;
}

void add(set<array<string, 8>> &S, array<string, 8> a){
    if(!check(S, a)) return;
    array<string, 8> b = {a[0], a[3], a[7], a[4], a[1], a[2], a[6], a[5]};
    if(!check(S, b)) return;
    array<string, 8> c = {a[0], a[4], a[5], a[1], a[3], a[7], a[6], a[2]};
    if(!check(S, c)) return;
    S.insert(a);
}

int main(){
    string s;
    while(getline(cin, s)){
        array<string, 8> a;
        for(int i=0, l=0; i<8; ++i){
            int r = l;
            while(r < (int)s.size() && s[r] != ' '){
                ++r;
            }
            a[i] = s.substr(l, r - l);
            l = r + 1;
        }
        sort(a.begin(), a.end());
        set<array<string, 8>> S;
        do{
            add(S, a);
        }while(next_permutation(a.begin(), a.end()));
        printf("%d\n", S.size());
    }
}


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

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans1 = a[n - 1];
    int ans2 = 0;
    int k = (ans1 + 1) / 2;
    for(int i = 0; i < n; i++){
        if(abs(k - a[i]) < abs(k - ans2))
            ans2 = a[i];
     }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int D = sc.nextInt();
  int X = sc.nextInt();
  int ans = 0;
  for(int i = 0;i < N;i++){
    int a = sc.nextInt();
    int day = 0;
    while(day*a + 1 <= D){
      day++;
    }
    ans += day;
  }
  System.out.println(ans + X);
}}


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

using namespace std;

int h, w;
char a[100][100];

void delete_row(int row_i) {
    for (int i = row_i; i < h - 1; ++i) {
        for (int j = 0; j < w; ++j) {
            a[i][j] = a[i + 1][j];
        }
    }
}

void delete_column(int col_j) {
    for (int j = col_j; j < w - 1; ++j) {
        for (int i = 0; i < h; ++i) {
            a[i][j] = a[i][j + 1];
        }
    }

}

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

    cin >> h >> w;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    for (int i = h - 1; i >= 0; --i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == '#') break;
            if (j == w - 1) {
                delete_row(i);
                h--;
            }
        }
    }

    for (int j = w - 1; j >= 0; --j) {
        for (int i = 0; i < h; ++i) {
            if (a[i][j] == '#') break;
            if (i == h - 1) {
                delete_column(j);
                w--;
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << a[i][j];
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
c = list(input())

a = 0
b = 0
for i in range(N):
    if (c[i] == 'R'):
        a +=1
ans = max(a,b)
for i in range(N):
    if (c[i] == 'R'):
        a -= 1
    else:
        b += 1
    now = max(a,b)
    ans = min(ans,now)
print(ans)

Measured memory_bytes: 10652
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	double A, B, T;
	cin >> A >> B >> T;
	cout << (int)((T + 0.5) / A) * B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[100005];
int n,x,ans=1e9;
int main(){
   cin>>n>>x;
   for(int i=1;i<=n;i++)
   {
   	  cin>>a[i];
   	  a[i]=abs(a[i]-x);
   	  ans=min(a[i],ans);
   }
    for(int i=1;i<=n;i++) 
      ans=__gcd(ans,a[i]);
      cout<<ans;
	return 0;
}


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

int main(void){
    int N,M;
    while(cin>>N>>M,N|M){
        vector<int> a(M+1);
        rep(i,N){
            int d,v;
            cin>>d>>v;
            a[d]=max(a[d],v);
        }
        int sum=0;
        rep1(i,M)sum+=a[i];
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;
  int b = n % 500;
  int c = a - b;
  if(c >= 0){
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;
#define INF 1000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/


int main(){
    int N;
    cin>>N;
    vector<P> V;
    if(N%2==0){
        for(int i=1;i<=N/2;i++){
            V.push_back(P(i,N+1-i));
        }
    }else{
        for(int i=0;i<=N/2;i++){
            V.push_back(P(i,N-i));
        }
    }
    if(N%2==0) cout<<N*(N-1)/2-N/2<<endl;
    else cout<<N*(N-1)/2-N/2<<endl;
    for(int i=0;i<(int)V.size();i++){
        for(int j=0;j<2;j++){
            int x;
            if(j==0) x=V[i].first;
            else x=V[i].second;
            if(x==0) continue;
            for(int k=i+1;k<(int)V.size();k++){
                cout<<x<<" "<<V[k].first<<endl;
                cout<<x<<" "<<V[k].second<<endl;
            }
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 1000005;
const ll MOD = 1000000007ll;

ll n, m, x, A[MAXN], DP[MAXN];

int main() {
    scanf("%lld%lld", &n, &m);

    for (int i = 0; i < m; i++) {
        scanf("%lld", &x);
        A[x] = 1;
    }

    if (n >= 1 && !A[n - 1]) {
        DP[n - 1] = 1;
    }

    if (n >= 2 && !A[n - 2]) {
        DP[n - 2] = 1 + DP[n - 1];
    }

    for (int i = n - 3; i >= 0; i--) {
        if (!A[i]) {
            DP[i] = (DP[i + 1] + DP[i + 2]) % MOD;
        }
    }

    printf("%lld\n", DP[0]);

    return 0;
}

Measured memory_bytes: 5120
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = Math.max(a,Math.max(b,c));
        int count = 0;
        int tmp;
        if(a != max){
            tmp = (max - a) / 2;
            count += tmp;
            a += tmp * 2;
        }
        if(b != max){
            tmp = (max - b) / 2;
            count += tmp;
            b += tmp * 2;
        }
        
        if(c != max){
            tmp = (max - c) / 2;
            count += tmp;
            c += tmp * 2;
        }
        switch(max * 3 - a - b - c){
            case 1:
                count += 2;
                break;
            case 2:
                count += 1;
                break;
            default:
                break;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 20820
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

for i in range(len(p_list)):
  p_list[i] += 1
  p_list[i] /= 2

sum_p = sum(p_list[0:K])
ans = sum_p
for i in range(1, N-K+1):
  sum_p = sum_p - p_list[i-1] + p_list[i+K-1]
  if ans < sum_p:
    ans = sum_p

print(ans)


Measured memory_bytes: 71792
#include<iostream>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
if(x < 0):
    x = -x

ans = 0
if (x - d * k < 0):
        k -= (x + d - 1) // d
        now = x - (x + d - 1) // d * d
        if (k % 2 == 0):
            ans = abs(now)
        else:
            ans = now + d
else:
    ans = x - d * k
print(ans)


Measured memory_bytes: 61684
N = int(input())
As = list(map(int, input().split()))
"""
3
5 2 4
2^xについて調べる
"""

ans = 0
for a in As:
    while True:
        if a%2 == 0:
            ans += 1
            a //= 2
        else:
            break
print(ans)

Measured memory_bytes: 4148
#include<iostream>
#include<vector>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
  int n;
  cin>>n;
  vector<int>f(n);
  vector<vector<bool> >in(n,vector<bool>(31));
  vector<int>sa(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    loop(j,a-1,b)in[i][j]=true;
    sa[i]=b-a;
  }

  int out=0;
  rep(i,31){
    bool h=false;
    int tmp=1e8;
    rep(j,n)if(in[j][i]){
      if(!h){
	if(f[j]){
	  tmp=j;
	}
	else {
	  h=true;
	  tmp=j;
	}
      }else{
	if(!f[j]&&sa[tmp]>sa[j])tmp=j;
      }
    }
    if(h)out+=100;
    else out+=50;
    f[tmp]=true;
  
  }
  cout<<out<<endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
ll n,f[1000005],s;
int main()
{
    cin>>n;
    f[n]=n;
    f[n-1]=n*n%1000000007;
    for(reg int i=n-2;i>=1;i--)
    {
        s=(s+f[i+3])%1000000007;
        f[i]=(f[i+1]+(n-1)*(n-1)%1000000007+s+i+1)%1000000007;
    }
    printf("%d\n",f[1]);
}

Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int a,b;cin>>a>>b;
   int cnt = 0;
   for(int i=a;i<=b;i++){
       string s = to_string(i);
       string t = s;
       reverse(ALL(t));
       if(s==t)cnt++;
   }
   cout<<cnt;
}



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    string a, b, c; cin >> a >> b >> c;

    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            if (k == 1) {
                cout << i << endl;
                break;
            } else {
                k--;
            }
        }
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n, m, q = nm()
query = [tuple(nm()) for _ in range(q)]
def dfs(lis):
    if len(lis) >= n:
        yield lis
    else:
        v = 1 if not lis else lis[-1]
        for i in range(v, m+1):
            yield from dfs(lis + [i])

ans = -10**12
E = dfs(list())
for lis in E:
    sc = 0
    for a, b, c, d in query:
        if lis[b-1] - lis[a-1] == c:
            sc += d
    ans = max(ans, sc)
print(ans)


Measured memory_bytes: 9240
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

count = 0

x.sort()
y.sort()

# print(x)
# print(y)

for Z in range(200):
    if X < Z-100 and Z-100 <= Y:
        if x[N-1] < Z-100 and y[0] >= Z-100:
            count += 1
            # print(Z-100)


if count != 0:
    print('No War')
else:
    print('War')

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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin>>s;
    switch (s.back()) {
        case '2':
        case '4':
        case '5':
        case '7':
        case '9':
        cout<<"hon"<<endl;
        break;
        case '0':
        case '1':
        case '6':
        case '8':
        cout<<"pon"<<endl;
        break;
        case '3':
        cout<<"bon"<<endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2)
    cout<<"No";
  else{
       string s1=s.substr(0,s.size()/2);
       string s2=s.substr(s.size()/2,s.size()/2);
    if(s1==s2)
      cout<<"Yes";
    else
      cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3588
/* Ashish Joshi
   NIT Hamirpur */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
const int MAXN = 300005;

int  t[4*MAXN];

void build(int a[],int v, int tl, int tr){
    if(tl == tr){
        t[v] = a[tl];
    }else{
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2 + 1, tm + 1, tr);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}

int query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm))
           , query(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, int new_v){
    if(tl == tr){
        t[v] = max(t[v],new_v);
    }else{
        int tm = (tl + tr)/2;
        if(pos <= tm){
            update(v*2, tl, tm, pos, new_v);
        }else{
            update(v*2 + 1, tm + 1, tr, pos, new_v);
        }
        t[v] = max(t[v*2],t[v*2 + 1]);
    }
}

int dp[MAXN];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int temp[MAXN]={0};
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    build(temp,1,0,MAXN-1);
    int ans=0;
    for(int i=0;i<n;i++){
        int l = max(0, a[i] - k), r = min(a[i] + k, (int)MAXN-1);
        int val = query(1, 0, MAXN-1, l, r);
        ans=max(ans,val+1);
        update(1, 0, MAXN-1, a[i], val+1);
    }
    cout<<ans;

}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(a >= k) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    N=len(S)
    ans=0
    
    import itertools
    
    for ite in itertools.product([0,1], repeat=(N-1)):
        L=list(ite)+[1]
        L2=[0]
        for i in range(N):
            if L[i]==1:
                L2.append(i+1)
        
        temp=0
        
        for i in range(1,len(L2)):
            temp+=int(S[L2[i-1]:L2[i]])
            
        ans+=temp
        
    print(ans)
        

main()


Measured memory_bytes: 40944
#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[i];

    if(A[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    long long res = 0;
    for(int i=1; i<N; ++i) {
        if(A[i] - A[i - 1] > 1) {
            cout << -1 << endl;
            return 0;
        } else if(A[i] - A[i - 1] == 1) {
            ++res;
        } else {
            res += A[i];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
/**
 *    author:  tourist
 *    created: 07.12.2019 13:03:26       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, L;
  cin >> n >> L;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int s = (t[i] - 1) / (2 * L);
    ans += s * (2 * L);
    t[i] -= s * (2 * L);
  }
  vector<bool> canL(n, false);
  vector<bool> canR(n, false);
  for (int i = 0; i < n; i++) {
    if (t[i] <= 2 * x[i]) {
      canL[i] = true;
    }
    if (t[i] <= 2 * (L - x[i])) {
      canR[i] = true;
    }
  }
  int mx = 0;
  int bal = 0;
  int pairs = 0;
  for (int i = 0; i < n - 1; i++) {
    if (!canL[i] && !canR[i]) {
      continue;
    }
    if (canL[i] && canR[i]) {
      if (bal > 0) {
        ++mx;
        --bal;
        ++pairs;
      } else {
        ++bal;
      }
      continue;
    }
    if (canL[i]) {
      ++bal;
    }
    if (canR[i]) {
      if (bal > 0) {
        ++mx;
        --bal;
      } else {
        if (pairs > 0) {
          ++bal;
          --pairs;
        }
      }
    }
  }
  mx += (canR[n - 1] ? 0 : -1);
  ans += (n - mx) * (2LL * L);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <stack>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int N[20005];

int main()
{
	string S;
	cin >> S;

	stack<int> s;
	REP(i, S.length())
	{
		if (S[i] == '\\')
		{
			s.push(i);
		}
		if (S[i] == '/' && !s.empty())
		{
			int t = s.top(); s.pop();
			N[t]++;
			N[i]--;
		}
	}
	FOR(i, S.length(), 1)
	{
		N[i] += N[i - 1];
	}

	vector<int> ans;
	int n = 0;
	int sum = 0;
	REP(i, S.length())
	{
		if (N[i] == 0 && n > 0)
		{
			ans.push_back(n);
			sum += n;
			n = 0;
			continue;
		}
		n += N[i];
	}
	if (n > 0)
	{
		sum += n;
		ans.push_back(n);
	}

	cout << sum << endl;
	cout << ans.size();
	REP(i, ans.size())
	{
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 1e5 + 5;

ll a[maxn];
ll b[maxn];
ll Sum[maxn * 2];
ll add[maxn * 2];
ll sub[maxn * 2];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    ll sum = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (1LL * n * (n + 1) / 2)){
        cout << "NO" << endl;
        return 0;
    }
    ll x = sum / (1LL * n * (n + 1) / 2);
    for(int i = 0;i < n;i++){
        int pre = (i + n - 1) % n;
        ll delta = a[i] - a[pre];
        if((x - delta) % n){
            cout << "NO" << endl;
            return 0;
        }
        ll d = (x - delta) / n;
        if(d < 0 or d > x){
            cout << "NO" << endl;
            return 0;
        }
        b[i] = d;
    }
    for(int i = 0;i < n;i++){
        add[i] += b[i];
        sub[i + n] += b[i];
    } 
    ll now = 0;
    ll S = 0;
    for(int i = 0;i < n * 2;i++){
        now -= sub[i]; 
        S -= sub[i] * n;
        now += add[i];
        S += now;
        Sum[i] = S;
    }
    for(int i = n;i < 2 * n;i++){
        Sum[i - n] += Sum[i];
    }
    for(int i = 0;i < n;i++){
        if(Sum[i] != a[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 5760
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void main() {
    int n = read();
    int[] a = reads();

    int ans;
    foreach (i; 1..n) {
        if (a[i-1] == a[i]) {
            a[i] = a[i-1]-10002;
            ans++;
        }
    }
    writeln(ans);
}

Measured memory_bytes: 256
//	Totally unrelated and not AT ALL stolen from hohohaha's, generic_placeholder_name's or katoriyuu's template
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

using namespace std;

#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx")
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define rep(i,s,end) for(int i = (s); i <  (end); ++i)
#define rep0(i, end) for(int i =   0; i <= (end); ++i)
#define rep1(i, end) for(int i =   1; i <= (end); ++i)
#define lb lower_bound
#define ub upper_bound

#define vt vector
#define endl "\n"

#define fileopen(filename, in_type, out_type) if (fopen(filename in_type, "r")) {freopen(filename in_type, "r", stdin);freopen(filename out_type, "w", stdout);}
#define local_input(x) if (x && fopen("input.txt","r")) freopen("input.txt","r",stdin);
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fscan(x)   scanf("%d",  &x)
#define fscandb(x) scanf("%lf", &x)
#define fscanll(x) scanf("%lld",&x)
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

#define int ll
#define db double
#define ll long long
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work?
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);
#define ed 2160
#define mn 100001
constexpr int mx = 1e10+1;
int n,x,ans = 0;
int p[ed], sz = 0;
bool is_prime[ed];
int group[mn], inv[mn];
map<int,int> cunt;
void sieve()
{
	int i = 2;
	for(; i * i < ed; ++i) if(!is_prime[i]){
		for(int j = (p[sz++] = i)*i; j < ed; j += i){
			is_prime[j] = true;
		}
	}
	for(; i < ed; ++i) if(!is_prime[i]) p[sz++] = i; 
	return;
}
signed main()
{
	fastio;
	sieve();
	cin >> n; rep(pos,0,n){
		cin >> x;
		for(int j = 0, k = 8; k <= x && j < sz; ++j, k = p[j]*p[j]*p[j]) 
			while(x % k == 0) x /= k;
		if(++cunt[x] == 1){
			group[pos] = x, inv[pos] = 1;
			for(int j = 0, k = 4; p[j] <= x && j < sz; ++j, k = p[j]*p[j]){
				if(k <= x && x % k == 0){
					inv[pos] *= p[j], x /= k;
				}
				else if(x % p[j] == 0){
					inv[pos] *= k, x /= p[j];
				}
			}
			int xxx = sqrt(x);
			if(xxx * xxx == x){
				inv[pos] *= xxx;
			}
			else{
				inv[pos] *= x*x;
			}
			// cerr << group[pos] << ' ' << inv[pos] << endl;
		}
	}
	if(cunt[1]) ++ans, cunt[1] = 0;
	while(n--) if(group[n]){
		ans += max(cunt[group[n]], cunt[inv[n]]),
		cunt[group[n]] = cunt[inv[n]] = 0;
	}
	cout << ans;
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there a one in my row of exclamation marks?




Measured memory_bytes: 17644
#include <stdio.h>
#include <stdlib.h>

int main(){
	int H, W, N, a, i, j, sum;
	scanf("%d%d", &H, &W);
	scanf("%d", &N);
	int *HW = (int *)malloc(sizeof(int) * H * W);
	for(i = 1, sum = 0; i <= N; i++){
		scanf("%d", &a);
		for(j = 0; j < a; j++){
			HW[sum + j] = i;
		}
		sum += j;
	}
/*	printf("test\n");
	for(i = 0; i < H * W; i++){
		printf("%d ", HW[i]);
	}
	printf("\n");
*/	for(i = 0; i < H; i++){
		if(i % 2 == 0){
			for(j = 0; j < W; j++){
				printf("%d ", HW[W * i + j]);
			}
		}
		else{
			for(j = W - 1; j >= 0; j--){
				printf("%d ", HW[W * i + j]);
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long DP[2];
void Read()
{
    int N, P;
    cin >> N >> P;
    DP[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        int x;
        cin >> x;
        x %= 2;
        long long a = DP[0], b = DP[1];
        if(x == 0)
        {
            DP[0] += a;
            DP[1] += b;
        }
        else
        {
            DP[0] += b;
            DP[1] += a;
        }
    }
    cout << DP[P] << "\n";
}
int main()
{
    Read();
    return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

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

#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = sz(s), cnt = 0, ans = 0;
    for (int i=0; i<n; i++) {
        if (s[i] == 'B') {
            cnt++;
        } else {
            ans += cnt;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<map>

#define MOD 10000

using namespace std;

map<int,int>data;

int dp[200][3][3]={0};

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		data[a]=b;
	}
	
	for(int i=1;i<=n;i++){
		map<int,int>::iterator pa;
		bool it=false;
		if(data.find(i)!=data.end()){
			pa=data.find(i);
			it=true;
		}
		
		if(i==1){
			if(it){
				dp[i][pa->second-1][1]=1;
			}
			else {
				for(int j=0;j<3;j++){
					dp[i][j][1]=1;
				}
			}
		}
		else {
			if(it){
				for(int j=0;j<3;j++){
					if(j!=pa->second-1)dp[i][pa->second-1][1]+=dp[i-1][j][1]+dp[i-1][j][2];
					dp[i][pa->second-1][1]%=MOD;
				}
				dp[i][pa->second-1][2]+=dp[i-1][pa->second-1][1];
			}
		
			else {
				for(int k=0;k<3;k++){
					for(int j=0;j<3;j++){
						if(j!=k)dp[i][k][1]+=dp[i-1][j][1]+dp[i-1][j][2];
						dp[i][k][1]%=MOD;
					}
					dp[i][k][2]+=dp[i-1][k][1];
					dp[i][k][2]%=MOD;
				}
				
			}
		}
		
	}
	
	int ans=0;
	for(int i=0;i<3;i++){
		ans+=dp[n][i][1]+dp[n][i][2];
	}
	cout<<ans%MOD<<endl;
}	

Measured memory_bytes: 1204
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String line1;
        line1 = sc.nextLine();
        String[] k_n_s = line1.split(" ");
        int N = Integer.parseInt(k_n_s[0]);
        int K = Integer.parseInt(k_n_s[1]);
        int[] kn = new int[N];
        for (int i=0;i<N;i++){
            kn[i] = Integer.parseInt(sc.nextLine());
        }
        // System.out.println("\n");
        Arrays.sort(kn);
        // System.out.println("=======");
        // for (int k:kn){
          // System.out.println(k);
        // }
        // final int INF = (int)Math.pow(10, 9) + 7;
        int min = 1000000000;
        int diff = 0;
        // int min = INF;

        for(int i=0;i<N-K+1;i++){
            diff = kn[K-1+i]-kn[i];
            if (min > diff){
                min = diff;
            }
        }
        // System.out.println("\n");
        // System.out.println("min:");
        System.out.println(min);
    }
}


Measured memory_bytes: 93396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int n; cin >> n;

    for(int i = 1; i <= 9; ++i)
    for(int j = 1; j <= 9; ++j){
        if(i*j==n){
            cout << "Yes";
        return 0;
        }
    }
    cout <<"No";

    return 0;

}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 10000+10;
LL dp[MAX];

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

  int N;
  cin >> N;
  VL ws(N), ss(N), vs(N);
  REP(i,N) cin >> ws[i] >> ss[i] >> vs[i];

  VI ix(N);
  iota(ALL(ix), 0);
  sort(ALL(ix), [&](const int i, const int j){ return ws[i] + ss[i] < ws[j] + ss[j];});


  LL ans = 0;
  for(int i: ix){
    for(int w=ss[i];w>=0;--w){
      if(w + ws[i] >= MAX) maxi(ans, dp[w] + vs[i]);
      else maxi(dp[w+ws[i]], dp[w] + vs[i]);
    }
  }

  REP(i,MAX) maxi(ans, dp[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    l, r = 0, 0
    for a in A:
        if a < X:
            l += 1
        else:
            r += 1

    print(min(l, r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define inf 1000000009
#define ll long long
using namespace std;
char a[1000009],b[1000009];
int len,dp[1000009][2];
int main()
{
    scanf("%s",a);
    len=strlen(a);
    for(int i=0; i<=len; i++)
        for(int j=0; j<2; j++)
            dp[i][j]=inf;
    for(int i=1; i<=len; i++)
        b[i]=a[len-i];
    dp[0][0]=0;
    for(int i=1; i<=len; i++)
    {
        dp[i][0]=min(dp[i][0],dp[i-1][0]+b[i]-'0');
        if(b[i]!='9')
            dp[i][0]=min(dp[i][0],dp[i-1][1]+b[i]-'0');
        if(b[i]!='0')
            dp[i][1]=min(dp[i][1],dp[i-1][0]+10-(b[i]-'0')+1);
        dp[i][1]=min(dp[i][1],dp[i-1][1]+9-(b[i]-'0'));
    }
    printf("%d",min(dp[len][0],dp[len][1]));
    return 0;
}


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

int main(){
	int n[101] = {0}, temp, max = -1;
	while(cin >>temp){
		n[temp]++;
		if(n[temp] > max) max = n[temp];
	}
	for(int i = 1; i <= 100; i++){
		if(n[i] >= max) cout <<i <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int gcd(int a,int b){
    if(a<b) gcd(b,a);
    int g;
    while(g=a%b){
        a=b;
        b=g;
    }
    return b;
}

int main(){
    int a,b,k;scanf("%d%d%d",&a,&b,&k);
    int g=gcd(a,b);
    int i=0;
    while(k>0){
      i++;
      k-=g%i?0:1;
    }
    printf("%d",g/i);
    return 0;
}


Measured memory_bytes: 128
def check():
    S = input()
    dp = [False]*len(S)
    dp[-1]=True
    for i in range(1,len(S)):
        dp[i] = (dp[i-5]&(S[max(0,i-4):i+1]in['dream','erase']))|(dp[i-7]&(S[max(0,i-6):i+1]=='dreamer'))|(dp[i-6]&(S[max(0,i-5):i+1]=='eraser'))

    if dp[-1]:
        return 'YES'
    return 'NO'
print(check())

Measured memory_bytes: 42096
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
  {
  int d, n;
  cin >> d >> n;
  
  cout << (n == 100 ? 101 : n) * (d == 0 ? 1 : d == 1 ? 100 : 10000) << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	int m = 26;
	int d;
	cin >> d;

	vector<ll> c(m);
	rep(i, m) cin >> c[i];

	vector<vector<ll>> s(d, vector<ll>(m));
	rep(i, d) rep(j, m) cin >> s[i][j];

	vector<ll> pen(m, 0);

	vector<ll> t(d);
	rep(i, d) {
		cin >> t[i];
		t[i]--;
	}
	
	int l;
	cin >> l;

	vector<ll> e(l), q(l);
	rep(i, l) {
		cin >> e[i] >> q[i];
		e[i]--; q[i]--;
	}
	rep(i, l){
		t[e[i]] = q[i];
		ll sat = 0;
		rep(j, m) pen[j] = 0;
		rep(i, d){
			rep(j, m) pen[j] += c[j];
			sat += s[i][t[i]];
			pen[t[i]] = 0;
			rep(j, m) sat -= pen[j];
		}
		cout << sat << endl;
	}


}


Measured memory_bytes: 4600
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string s;
    cin >> s;
    vector<char> result;
    for(char c : s)
        if (c == 'B') {
            if (result.size())
                result.pop_back();
        }
        else
            result.push_back(c);

    cout << string(ALL(result)) << endl;

    return 0;
};


Measured memory_bytes: 256