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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N, cnt = 0;
    cin >> N;
    set <int> s;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if (tmp >= 3200) {
            cnt++;
            continue;
        }
        s.insert(tmp/400);
    }
    cout << max(1, int(s.size())) << " " << int(s.size()) + cnt << endl;

    return 0;
}


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

thickness=[1]*(N+1)
Npatty=[1]*(N+1)

for i in range(1,N+1):
  thickness[i]=2*thickness[i-1]+3
  Npatty[i]=2*Npatty[i-1]+1

#print(thickness,Npatty)  
def countpatty(N,K):
  if K==1:
    if N==0:
      return 1
    else:
      return 0
  if 2<=K<=thickness[N-1]+1:
    return countpatty(N-1,K-1)
  if K==thickness[N-1]+2:
    return Npatty[N-1]+1
  if thickness[N-1]+3<=K<=thickness[N]-1:
    return Npatty[N-1]+1+countpatty(N-1,K-2-thickness[N-1])
  if K==thickness[N]:
    return 2*Npatty[N-1]+1

print(countpatty(N,K))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>n;
    fun(i)cin>>a[i],b[a[i]]++;
    if(b[1]){
        out(b[1]>=2?0:1)
        return 0;
    }
    fun(i)
    {

        if(b[a[i]]>=2)continue;
        int key=0;
        for(int j=2;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                if((b[j] or b[a[i]/j])) {
                    key = 1;
                    break;
                }
            }
        }
        if(!key) {
            ans++;
        }
    }
    out(ans)
    return 0;
}


Measured memory_bytes: 13020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n, M;
	cin >> n >> M;
	map<int, pair<string, int>> m;
	int ac = 0, wa = 0;
	while (M--) {
		int i;
		string s;
		cin >> i >> s;
		if (s == "WA") {
			if (m[i].first != "AC") {
				if (!m.count(i))
					m[i] = {s, 1};
				m[i].second++;
			} 
		} else {
			if (m[i].first != "AC") {
				ac++;
				m[i].first = s;
				wa += m[i].second;
			}
		}
	}
	cout << ac << " " << wa << endl;
}


Measured memory_bytes: 11264
from itertools import combinations, product


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]

val = sorted(get("iii"))

if val[0] + val[1] == val[2]:
    put("Yes")
else:
    put("No")

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

const int MX = 1e6 + 5, MOD = 998244353;
int N, freq[MX], w[MX], inv[MX], freqDivs[MX];
vi A;

int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	inv[1] = 1;
	for(int i = 2; i < MX; ++i)
		inv[i] = (MOD - (MOD / i) * 1LL * inv[MOD % i] % MOD) % MOD;

	for (int i = 1; i < MX; ++i) {
		w[i] = (w[i] + inv[i]) % MOD;
		for (int j = 2 * i; j < MX; j += i)
			w[j] = (w[j] - w[i] + MOD) % MOD;
	}

	cin >> N;

	A.assign(N, 0);

	int ans = 0;

	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		ans = (ans - A[i] + MOD) % MOD;
		++freq[A[i]];
	}

	for (int i = 1; i < MX; ++i)
		for (int j = i; j < MX; j += i)
			freqDivs[i] = (freqDivs[i] + (freq[j] * 1LL * j) % MOD) % MOD;


	for (int i = 1; i < MX; ++i)
		ans = (ans + w[i] * 1LL * ((freqDivs[i] * 1LL * freqDivs[i]) % MOD)) % MOD;

	cout << (ans * 1LL * inv[2]) % MOD << '\n';


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,m;
ll dp[5010][5010];
int main() {
	scanf("%d%d",&n,&m);
	swap(n,m);
	rep(i,1,n+1) dp[i][0]=1;
	rep(j,1,m+1) {
		ll s=0;
		rep(i,1,n+1) {
			dp[i][j]=((i+1)*dp[i][j-1]+s)%mod;
			s=(s*2+i*dp[i][j-1])%mod;
			//rep(k,1,i) dp[i][j]=(dp[i][j]+(i-k)*powmod(2,k-1)%mod*dp[i-k][j-1])%mod;
			//printf("%d %d %lld\n",i,j,dp[i][j]);
		}
	}
	printf("%lld\n",dp[n][m]);
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

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

const int N = 52;
int n;
int a[N], b[N];

bool can(vector<int> const& u) {
    static bool e[N][N];
    memset(e, 0, sizeof(e));
    for (int i = 0; i < N; ++i)
        e[i][i] = 1;
    for (int i = 0; i < N; ++i)
        for (int x : u)
            e[i][i % x] = 1;
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                e[i][j] |= (e[i][k] && e[k][j]);
    for (int i = 0; i < n; ++i)
        if (!e[a[i]][b[i]])
            return 0;
    return 1;
}

int main() {
    ios::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];

    vector<int> uu(N);
    iota(all(uu), 1);
    if (!can(uu)) {
        cout << "-1\n";
        return 0;
    }

    vector<int> u;
    ll ans = 0;
    for (int k = 50; k >= 1; --k) {
        vector<int> u1 = u;
        for (int i = 1; i < k; ++i)
            u1.push_back(i);
        if (can(u1))
            continue;
        u.push_back(k);
        ans += (1LL << k);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

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

int MOD;

inline void add(int &x,ll y) {
  x=(x+y)%MOD;
}

inline void sub(int &x,ll y) {
  x=(x-y)%MOD;
}

pr num[505];
int f[2][255];

int main() {
  int n;
  scanf("%d%d",&n,&MOD);
  int cnt=0;
  for(int i=0;i<n;i++) {
  	int r1=0;
  	while (r1*r1+i*i<n*n) r1++;
  	int r2=r1;
  	while (r2<2*n-1&&(r2+1)*(r2+1)+i*i<=4*n*n) r2++;
  	num[++cnt]=pr(r1,r2+1);
  }
  for(int i=n;i<2*n;i++) {
  	int r=0;
  	while (r<2*n-1&&(r+1)*(r+1)+i*i<=4*n*n) r++;
  	num[++cnt]=pr(r+1,0);
  }
  sort(num+1,num+cnt+1);
  int ans=0;
  for(int i=0;i<=n;i++) {
  	int cur=0;
  	memset(f[cur],0,sizeof(f[cur]));
  	f[cur][0]=1;
  	int s1=0,s2=0;
  	for(int j=1;j<=cnt;j++) {
  		cur^=1;
  		memset(f[cur],0,sizeof(f[cur]));
  		if (!num[j].SE) {
  			int u=num[j].FR-s2,t=min(i,s1);
  			for(int k=0;k<=t;k++)
  			  if (f[cur^1][k]) add(f[cur][k],(ll)f[cur^1][k]*(u-k));
  			s2++;
		  }
		else {
			int u=num[j].FR-s2,v=num[j].SE-i-n-s1,t=min(i,s1);
			for(int k=0;k<=t;k++)
			  if (f[cur^1][k]) {
			  	add(f[cur][k],(ll)f[cur^1][k]*(v+k));
			  	sub(f[cur][k+1],(ll)f[cur^1][k]*(u-k));
			  }
			s1++;
		}
	  }
	add(ans,f[cur][i]);
  }
  printf("%d\n",(ans+MOD)%MOD);
  return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
matrix = [[0]*(N+1) for _ in range(N)]

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

for i in range(N):
    for j in range(1, N+1):
        matrix[i][j] += matrix[i][j-1]

for _ in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p-1, q):
        ans += matrix[i][q]-matrix[i][p-1]
    print(ans)


Measured memory_bytes: 53208
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int gcd(int a, int b) {
  return (b ? gcd(b, a % b) : a);
}

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

int x;

bool read() {
  if (scanf("%d", &x) < 1) {
    return false;
  }
  return true;
}

void solve() {
  int y = lcm(x, 360);
  printf("%d\n", y / x);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ln;
  cin>>n;
  ln=n%10;
  if(ln==3){
    cout<<"bon"<<endl;
  }else if(ln==0||ln==1||ln==6||ln==8){
    cout<<"pon"<<endl;;
  }else cout<<"hon"<<endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D, X;
	vector<int> A;
	cin >> N >> D >> X;
	for(int i = 0; i < N; i++) {
		int x;
		cin >> x;
		A.push_back(x);
	}

	int rslt = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 1; j <= D; j = j + A[i]) {
			rslt += 1;
		}
	}
	rslt += X;
	cout << rslt << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int a,b,c,d,area1,area2;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    area1=a*b;area2=c*d;
    if(area1>area2)
    {
        printf("%d",area1);
    }
    else if(area2>area1)
    {
        printf("%d",area2);
    }
    else
    {
        printf("%d",area1|area2);
    }
    return 0;
}


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

int main(){
  long long X,K,D;  cin >> X >> K >> D;
  if(X<0) X *= -1;
  long long a = X/D;
  long long ans = X%D;

  if((max(K,a) - min(K,a))%2 == 0){
    if(K<a) ans = X - K*D;
    cout << ans << endl;
  }else{
    a++;
    ans = -(ans - D);
    if(K<a) ans = X - K*D;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;

  return 0;
}

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

ll INF = 1e+18;
int iINF = 1e9;
int MAXI = 1e8 + 1;
using vec = vector<int>;

int 
main()
{
  int N; cin >> N;
  vector<vector<int>> arr(N);
  rep(i, 0, N){
    int a, b, c; cin >> a >> b >> c;
    arr[i].push_back(a);
    arr[i].push_back(b);
    arr[i].push_back(c);
  }
  vector<vector<int>> dp(N, vec(3, 0));
  dp[0][0] = arr[0][0];
  dp[0][1] = arr[0][1];
  dp[0][2] = arr[0][2];

  rep(i, 0, N - 1){
    rep(j, 0, 3){
      rep(k, 0, 3){
        if(j == k) continue;
          if(dp[i + 1][k] < dp[i][j] + arr[i + 1][k]) dp[i + 1][k] = dp[i][j] + arr[i + 1][k];
      }
    }
  }

  int ans = 0;
  rep(i, 0, 3){
    if(dp[N - 1][i] > ans) ans = dp[N - 1][i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 14068
#include<stdio.h>
int main(){

int n, q, i, j, ans = 0;
int s[10000], t[500];

  scanf("%d", &n);
for(i = 0; i < n; i++){
  scanf("%d", &s[i]);
}
  scanf("%d", &q);
for(i = 0; i < q; i++){
  scanf("%d", &t[i]);
}
for(i = 0; i < q; i++){
  for(j = 0; j < n; j++){
    if(t[i] == s[j]){
      ans++;
      break;
    }
  }
}

  printf("%d\n", ans);

  return 0;
}

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

int isprime(int num){
  if(num < 2) return 0;
  else if(num == 2) return 1;
  else if(num % 2 == 0) return 0;

  int i,j,k,l;
  l = (int)sqrt(num);
  for(i=3;i<=l;i+=2){
    if(num%i == 0) return 0;
  }
  return 1;
}

int main() {
  int i,n,num[10000];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
    if(isprime(num[i]) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}



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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  long long ans = 0;
  int stage = 0;
  int back = 0;
  for (auto c : s) {
    if (c == 'A') {
      if (stage) {
        stage = back = 0;
      } else {
        ans += back;
      }
    } else if (c == 'B') {
      if (stage) {
        stage = 0;
        back++;
      } else {
        stage = back = 0;
      }
    } else {
      if (stage) {
        back = 0;
      } else {
        stage = 1;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 720
/*Hatsune Miku 4ever!*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _for(i,a,b) for(int i = (a);i < b;i ++)
#define _rep(i,a,b) for(int i = (a);i > b;i --)
#define INF 0x3f3f3f3f
#define mod 1000000007
#define lowbit(x) ((x)&(-x))
#define pb push_back
#define MIKU 39
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug() printf("Miku Check OK!\n")
#define maxn 10003

int main()
{
	Design;
	string s, t;
	cin >> s >> t;
	int ans = INF;
	_for(i,0,s.size()-t.size()+1)
	{
		int tmpans = 0;
		_for(j,0,t.size())
			if(s[i+j]!=t[j])
				tmpans ++;
		ans = min(ans,tmpans);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>
int main(){
  int H, W, h, w;
  scanf("%d%d%d%d", &H,&W,&h,&w);
  if(H%h==0 && W%w==0){
    puts("No");
    return 0;
  }
  puts("Yes");
  for(int i=0; i<H; ++i,puts(""))
    for(int j=0; j<W; ++j)
      if(i%h==h-1 && j%w==w-1) printf("-999999 ");
      else if(i%h==0 && j%w==0) printf("999998 ");
      else printf("0 ");
  return 0;
}

Measured memory_bytes: 2048
import sys
import math
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    S = input().strip()

    MOD = 10 ** 9 + 7

    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    def cmb(n, k, p):
        if (k < 0) or (n < k):
            return 0
        r = min(k, n - k)
        return fact[n] * factinv[k] * factinv[n - k] % p

    N = 10 ** 6 * 2
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    ans = 0
    for i in range(K + 1):
        if len(S) == 1:
            ans += pow(25, i, MOD) * pow(26, K - i, MOD)
        else:
            ans += pow(25, i, MOD) * cmb(i + len(S) - 1, len(S) - 1, MOD) * pow(26, K - i, MOD)

    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 234856
N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())
BC = []

for i in range(Q):
    b, c = (int(i) for i in input().split())
    BC.append((b,c))

sums = [0] * 100001

init_sum = sum(A)
for a in A:
    sums[a] += 1

for res in BC:
    sums[res[1]] += sums[res[0]]
    init_sum += (res[1] - res[0]) * sums[res[0]]
    sums[res[0]] = 0
    print(init_sum)
    

Measured memory_bytes: 85156
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define vsort(vec) sort(vec.begin(),vec.end())
using namespace std;
signed main() {
	int n, k, cnt = 0;
	vector<P> vec;
	cin >> n >> k;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		vec.push_back(make_pair(a, b));
	}
	vsort(vec);
	rep(i, n) {
		cnt += vec[i].second;
		if (cnt >= k) {
			cout << vec[i].first << endl;
			break;
		}
	}
	system("PAUSE");
	return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n);
    int mod = 1e9+7;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    vector<int> asum(n, 0);
    asum[n-1] = a[n-1];
    for(int i=n-2; i>=0; i--){
        asum[i] = (asum[i+1] + a[i]) % mod;
    }

    int ans = 0;
    for(int i=0; i<n-1; i++){
        ans = (ans + asum[i+1]*a[i]) % mod;
    }
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 6432
#include <cstdio>
using namespace std;

char s[200002];
bool Avs[200002];
bool Bvs[200002];

int main(){
  int N, A, B, C, D; scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
  scanf("%s", s + 1);

  Avs[A] = true;
  for(int i = A + 1; i <= N; i++){
    if(s[i] == '#') continue;
    Avs[i] = (i - 1 >= 1 && Avs[i - 1]) || (i - 2 >= 1 && Avs[i - 2]);
  }

  Bvs[B] = true;
  for(int i = B + 1; i <= N; i++){
    if(s[i] == '#') continue;
    Bvs[i] = (i - 1 >= 1 && Bvs[i - 1]) || (i - 2 >= 1 && Bvs[i - 2]);
  }

  if(!Avs[C] || !Bvs[D]){ puts("No"); return 0; }
  if(D > C){ puts("Yes"); return 0; }

  if(C > D){
    bool pos = false;

    for(int i = B; i <= D; i++){
      if(Bvs[i] && i - 1 >= 1 && Avs[i - 1] && i + 1 <= N && Avs[i + 1]){ pos = true; break; }
    }

    if(pos) puts("Yes"); else puts("No");
  }
  return 0;
}

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

const ll MX = 1e18;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    bool ng = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(ng || (MX + 1) / ans < a || ans * a > MX){
            ng = true;
        }
        ans *= a;
    }
    if(ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define endl "\n"
#define mod 1000000007

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    string str;
    cin>>str;
    ll r[n+2],g[n+2],b[n+2];
    r[n]=g[n]=b[n]=0;
    for(int i=n-1;i>=0;i--){
        r[i]=g[i]=b[i]=0;
        if(str[i]=='R') r[i]=1;
        else if(str[i]=='G') g[i]=1;
        else b[i]=1;
        r[i]+=r[i+1];
        g[i]+=g[i+1];
        b[i]+=b[i+1];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(str[i]==str[j]) continue;
            if(str[i]=='R' && str[j]=='B') ans+=g[j+1];
            else if(str[i]=='R' && str[j]=='G') ans+=b[j+1];
            else if(str[i]=='B' && str[j]=='R') ans+=g[j+1];
            else if(str[i]=='B' && str[j]=='G') ans+=r[j+1];
            else if(str[i]=='G' && str[j]=='R') ans+=b[j+1];
            else if(str[i]=='G' && str[j]=='B') ans+=r[j+1];
            int l=j-i;
            int k=j+l;
            if(k<n && str[k]!=str[i] && str[k]!=str[j]) ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3668
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()

ap = [0 for i in range(N)]
for i in range(N):
    co = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        co += 1
    ap[i] = co

for i in range(1,N):
    if ap[i] != ap[i-1]:
        print(0)
        exit()

po = lcm_list(a) * int(math.pow(2,ap[0]-1))

p = -(-(M // po) // 2)

print(p)





Measured memory_bytes: 85228
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
    string a, b;
    cin >> a;
    cin >> b;

    if(a == b){
        cout << "EQUAL" << endl;
    } else if (a.size() > b.size()){
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        if (a > b) {
            cout << "GREATER" << endl;
        } else {
            cout << "LESS" << endl;
        }
    }
}


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


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().ToCharArray();

        var ret = 0;
        var tmp = ' ';
        for (var i = 0; i < n; i++)
        {
            if (s[i] != tmp)
            {
                ret++;
                tmp = s[i];
            }
        }

        Console.Write(ret);
    }
}

Measured memory_bytes: 11488
MOD=10**9+7

def modpow(a,n):
    r=1
    while n > 0:
        if n%2==1:
            r = r*a%MOD
        a = a*a % MOD
        n = n//2
    return r

N=int(input())
a10N=modpow(10,N)
a9N=modpow(9,N)
a8N=modpow(8,N)
ans=a10N-(a8N+2*(a9N-a8N))
ans%=MOD
print(ans)

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long                           //del this if TLE or MLE
#define ll long long
#define pr pair<int,int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fow(i,a,b,c) for(int i=a;i<=b;i+=c)
#define bck(i,a,b,c) for(int i=a;i>=b;i-=c)
#define F first
#define S second
#define loop int tests;cin>>tests;while(tests--)

const int N=1e4+5;
const int mod=1e9+7;

int dp[N][101][2];

string k;
int d;

int DP(int pos,int rem,int small)
{
	if(pos==k.length()) 
		return (!rem);
	int &rep=dp[pos][rem][small];
	if(rep!=-1)
		return rep;
	rep=0;
	int upperlimit=9;
	if(!small)
		upperlimit=k[pos]-'0';
	fow(i,0,upperlimit,1)
	{
		rep=(rep+DP(pos+1,(rem+i)%d,max(small,(int)(i<upperlimit))))%mod;
	}
	return rep;
}

signed main()
{
	fastio;
//	freopen("SMTH.inp","r",stdin);
//	freopen("SMTH.out","w",stdout);
	cin>>k>>d;
	memset(dp,-1,sizeof(dp));
	cout<<(DP(0,0,0)+mod-1)%mod<<"\n";
}



Measured memory_bytes: 16896
n = int(input())
a = list(map(int, input().split()))

k = 0
tmp = abs(a[n - 1])

for i in range(n - 1):
    if abs(a[i]) < tmp:
        tmp = abs(a[i])

    if a[i] < 0:
        a[i] *= -1
        a[i + 1] *= -1

    k += a[i]

if a[n - 1] < 0:
    if abs(a[n - 1]) == tmp:
        k += a[n - 1]
    else:
        k += abs(a[n - 1])
        k -= tmp * 2
else:
    k += a[n - 1]

print(k)

Measured memory_bytes: 14496
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n;
    cin >> n;
    
    double ans = 0;
    double a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    
    for(int i=0; i<n; i++)
    {
        ans += 1 / a[i];
        //cout << ans << endl;
    }
    
    
    printf("%.10f\n", (double)1/ans);
    
    return 0;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int max_num = 0, max_point = 0;
        for (int i = 0; i < N; i++) {
            int A = NextInt();
            int B = NextInt();
            if (max_num < A) { max_num = A;max_point = B; }
        }
        Console.WriteLine(max_num + max_point);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 17460
n, k = map(int, input().split())
h = []
ans = 1000000000

for i in range(n):
    h.append(int(input()))
h.sort()

for i in range(n):
    if i + k - 1 >= n:
        break
    ans = min(h[i + k - 1] - h[i], ans)

print(ans)

Measured memory_bytes: 7384
void main(){
	string s1, s2;
	s1 = readln().chomp().dup().reverse();
	s2 = readln().chomp();
	if(s1 == s2)writeln("YES");
	else writeln("NO");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
 */
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
template<class T> bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end())
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//output
#define out(a) cout << a << endl
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl;
#define outp(v) rep(i, SZ(v)) cout << v[i].F << " " << v[i].S << endl
#define outc(s, t) cout << fixed << setprecision(10) << (double)(t - s) / CLOCKS_PER_SEC << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
//algorithm (have library)
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0, while r < n





bool comp(pair<int, pii> a, pair<int, pii> b) {
    //if (a.S.F != b.S.F) return a.S.F > b.S.F;
    //return a.S.S > b.S.S;
    return a.S.F > b.S.F;
}
bool comp2(pair<int, pii> a, pair<int, pii> b) {
    //if (a.S.F != b.S.F) return a.S.F > b.S.F;
    //return a.S.S > b.S.S;
    return a.S.S < b.S.S;
}
int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    
    int ddy[4] = {0, -1, 0, 1};
    int ddx[4] = {-1, 0, 1, 0};
    
    int n;
    while (cin >> n && n) {
        if (n == 1) {
            cout << 1 << " " << 1 << endl;
            continue;
        }
    
        int x[200], y[200];
        x[0] = 0, y[0] = 0;
        
        rep3(i, 1, n) {
            int id, d; cin >> id >> d;
            
            x[i] = x[id] + ddx[d];
            y[i] = y[id] + ddy[d];
            
        }
        int l = inf, r = 0, u = 0, b = inf;
        rep(i, n) {
            chmin(l, x[i]); chmax(r, x[i]);
            chmin(b, y[i]); chmax(u, y[i]);
        }
        cout << r - l + 1 << " " << u - b + 1 << endl;
    }
    
    
    
    
}
//cast caution






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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    const int digit = 60;
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<int> countBit(digit, 0);
    REP(i, N)
    {
        cin >> A[i];
        REP(j, digit)
        {
            if (((A[i] >> j) & 1) == 1) countBit[j]++;
        }  
    }

    vector<ll> res(digit);
    res[0] = 1;
    for (int i = 1; i < digit; ++i) res[i] = (res[i - 1] * 2) % MOD;

    ll ans = 0;
    REP(i, digit)
    {
        ans += res[i] * (((N - countBit[i]) * countBit[i]) % MOD);
        ans = ans % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import math
N,P = map(int,input().split())
A = list(map(int,input().split()))
Odd = 0
Even = 0
for i in range(N):
  if A[i] % 2 == 0:
    Even += 1
  else:
    Odd += 1
T = 2**Even
S = 0
if P == 0:
  for i in range(Odd//2+1):
    S += math.factorial(Odd)//((math.factorial(Odd-2*i))*math.factorial(2*i))
  print(S*T)
else:
  for j in range(Odd//2):
    S += math.factorial(Odd)//((math.factorial(Odd-2*j-1))*math.factorial(2*j+1))
  print(S*T)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N, P;
		long ans = 0;

		N = Integer.parseInt(sc.next());
		P = Integer.parseInt(sc.next());

		int[] A = new int[N];
		int oCount = 0;
		int eCount = 0;

		for(int i = 0; i < N; i++){
			A[i] = Integer.parseInt(sc.next());
		}

		for(int i = 0; i < N; i++){
			if(A[i] % 2 != 0){
				oCount++;
			}else{
				eCount++;
			}
		}

		if(P == 0){
			if(oCount >= 2){
				int o = oCount - (oCount % 2);
				while(o > 0){
					ans += comb(oCount, o);
					o -= 2;
				}
			}
			ans += 1;
		}else{
			int o = oCount - ((oCount+1) % 2);
			while(o > 0){
				ans += comb(oCount, o);
				o -= 2;
			}
		}

		ans *= Math.pow(2, eCount);

		System.out.println(ans);

	}

	public static int comb(int n, int r){
		if(r == 0 || r == n) return 1;
		else return comb(n-1, r-1) + comb(n-1, r);
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n, w;
	cin >> n >> w;
	vector<int> value(n), weight(n);
	for (int i = 0; i < n; i++) cin >> value[i] >> weight[i];

	vector<vector<int>> dp(n, vector<int>(w + 1));
	dp[0][0] = 0;
	for (int i = 0; i <= w; i++) {
		if (weight[0] <= i) dp[0][i] = value[0];
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= w; j++) {
			dp[i][j] = dp[i - 1][j];
			if (0 <= j - weight[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[i]] + value[i]);
		}
	}

	cout << dp[n - 1][w] << endl;
}


Measured memory_bytes: 6760
N = gets.to_i
arr = gets.split.map(&:to_i).sort
t_arr = arr.each_slice(arr.count/2).to_a
if t_arr[0].count != t_arr[1].count
  puts 0
else
  puts [*(t_arr[0].last)..(t_arr[1].first)].count - 1
end

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main() {
  string S;
  cin>>S;
  if(S=="0"||S=="9"){
    cout<<"Yes"<<endl;
  }
  else{
    
  int suma = 0;
  while(S.size()>0){
    int y = ctoi(S.at(S.size()-1));
    suma += y;
    S.pop_back();
  }
  if(suma%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	int sum = 1 + 2 + 3 + 4 + 5;
	cout << sum - (x1 + x2 + x3 + x4 + x5) << endl;
}


Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(long int i=0;i<(n);i++)
int N, P, Q;
vector<int> C;
vector<long long> D;//Dは、i日目だけ自炊したときの、全て食堂にした場合との差分
int main()
{
	cin >> N >> P >> Q;
	int a;
	long long sum = 0;
	rep(i, N)
	{
		cin >> a;
		C.push_back(a);
		sum += a;
		D.push_back(-C[i] + P * (Q -i));
	}
	sort(D.rbegin(), D.rend());
	long long Dans=0;//全部食堂の場合との差分の最大値 初期値は自炊0の場合
	//以下自炊1以上
	long long satismax=0;
	for(int make=1;make< N + 1;make++)
	{
		satismax +=D[make-1] +2*((long long)make-1)*P;
		Dans = max(Dans, satismax);
	}
	cout <<sum+Dans << endl;
	return 0;
}



Measured memory_bytes: 8940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define PER(i, a, b) for(int i = a; i >= b; i--)
#define LL long long
#define lowbit(x) x &(-x)

inline int read() {
    int x = 0, flag = 1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') flag = - 1;
        ch = getchar();
    }
    while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * flag;
}
const int N = 311;
int a[N], n, ans;
int main() {   
    n = read();
    REP(i, 1, n << 1) a[i] = read();
    sort(a + 1, a + n * 2 + 1);
    for(int i = 1; i < n * 2; i += 2) ans += a[i];
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int n;
      cin >> n;
      n %= 10;
      
      if(n == 3)
        cout << "bon";
      else if(n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon";
      else
        cout << "hon";
    }
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a =10000,b=5000,c=1000;
    int n,y;
    bool flag=false;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            for(int k=0;k<=n;k++)
            {
                if(i+j+k == n && (i*a+j*b+k*c) ==y)
                {
                    flag =true;
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    break;
                }else if(i+j+k>n)
                break;
            }
            if(flag)
            break;
            
        }
        if(flag)
        break;
    }
    if(!flag)
    cout<<"-1 -1 -1"<<endl;
     return 0;
}

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

signed main() {
  int N;
  cin >> N;
  vector<string>A(N);
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  
  int C = 1;
  for(int i = 0; i < N-1; i++){
    if(A.at(i) != A.at(i+1)){
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 9584
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int m, d;
    cin >> m >> d;
    int cnt = 0;

    for (int q = 4; q <= m; q++){
        for (int p = 22; p <= d; p++){
            if (p%10 == 1 || p/10 < 2) continue;
            if ((p%10) * (p/10) == q) cnt++;
        }
    }


    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int left(char ch){
	if(ch=='q'||ch=='w'||ch=='e'||ch=='r'||ch=='t'||ch=='a'||ch=='s'||ch=='d'||ch=='f'||ch=='g'
		||ch=='z'||ch=='x'||ch=='c'||ch=='v'||ch=='b'){
			return 1;
	}
	else
		return 0;
}

int main(){

	string str;
	while(cin>>str&&!(str=="#")){
		int lf=left(str[0]);
		int cnt=0;
		for(int i = 1; i < str.size(); i++){
			int res=left(str[i]);
			if(res^lf){
				lf=res;
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=100+10,mod=1e9+7;
int Begin[maxn],Next[maxn<<1],to[maxn<<1],e=1,pre[maxn],low[maxn],fac[maxn<<1],ifac[maxn<<1];
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		y>>=1;
		x=(ll)x*x%mod;
	}
	return res;
}
inline int C(int n,int m){
	if(n<0 || m<0 || n<m) return 0;
	return (ll)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline void init(int n){
	fac[0]=1;
	REP(i,1,n) fac[i]=(ll)i*fac[i-1]%mod;
	ifac[n]=ksm(fac[n],mod-2);
	DREP(i,n,1) ifac[i-1]=(ll)i*ifac[i]%mod;
}
inline void add_edge(int x,int y){
	to[++e]=y;
	Next[e]=Begin[x];
	Begin[x]=e;
}
int dfs_clock,stk[maxn<<1],top,n,m,k,bccno[maxn],bcc_cnt,ans;
void dfs(int x,int ff){
	pre[x]=low[x]=++dfs_clock;
	for(int i=Begin[x];i;i=Next[i]) if(to[i]!=ff){
		if(!pre[to[i]]){
			stk[++top]=i;
			dfs(to[i],x);
			if(low[to[i]]>=pre[x]){
				++bcc_cnt;
				int cur1=0,cur2=0;
				while(top){
					int u=stk[top--];
					if(bccno[to[u]]!=bcc_cnt) bccno[to[u]]=bcc_cnt,++cur1;
					if(bccno[to[u^1]]!=bcc_cnt) bccno[to[u^1]]=bcc_cnt,++cur1;
					++cur2;
					if(u==i) break;
				}
				if(cur2==1) ans=(ll)ans*k%mod;
				else if(cur1==cur2){
					int res=0;
					REP(j,1,cur1) res=(res+ksm(k,__gcd(j,jend)))%mod;
					res=(ll)res*ksm(cur1,mod-2)%mod;
					ans=(ll)ans*res%mod;
				}
				else ans=(ll)ans*C(cur2+k-1,k-1)%mod;
			}
			chkmin(low[x],low[to[i]]);
		}
		else if(pre[to[i]]<=pre[x]){
			stk[++top]=i;
			chkmin(low[x],pre[to[i]]);
		}
	}
}
int main(){
	n=read(),m=read(),k=read();
	init(m+k);
	REP(i,1,m){
		int x=read(),y=read();
		add_edge(x,y),add_edge(y,x);
	}
	ans=1;
	REP(i,1,n) if(!pre[i]) dfs(i,0);
	printf("%d\n",ans);
	return 0;
}

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

N = int(input())
A = list(map(int, input().split()))

A.sort()

inf = int(2e9)

m = inf
check = 0
for i in range(N):
    check1 = gcd(A[0], A[i])
    if check1 < m:
        m = check1
        check = i

# A[0]以外
check2 = A[1]
for i in range(1,N):
    check2 = gcd(check2, A[i])

ans = check2

# check以外
if check != 0:
    check3 = A[0]
    for i in range(N):
        if i == check:
            continue
        check3 = gcd(check3, A[i])
    ans = max(check2, check3)

print(ans)

Measured memory_bytes: 14052