akhauriyash/Code-Regression huggingface dataset:
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 2e9
#define ll long long
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(), v.end()

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char b; cin >> b;
    if (b == 'A') cout << 'T' << endl;
    if (b == 'T') cout << 'A' << endl;
    if (b == 'C') cout << 'G' << endl;
    if (b == 'G') cout << 'C' << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if( m < 5 ) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
static const int MAXN = 8;

int n, m;
bool g[MAXN][MAXN] = {{ false }};
int p[MAXN];

inline bool check()
{
    if (p[0] != 0) return false;
    for (int i = 1; i < n; ++i) if (!g[p[i - 1]][p[i]]) return false;
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    int u, v;
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &u, &v); --u, --v;
        g[u][v] = g[v][u] = true;
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) p[i] = i;
    do if (check()) ++ans; while (std::next_permutation(p, p + n));

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


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m, s = LI()
    uvab = LIR(m)
    cd = LIR(n)
    dp = [[inf] * 2501 for i in range(n)]
    edg = [[] for i in range(n)]
    for u, v, a, b in uvab:
        edg[u - 1].append((v - 1, a, b))
        edg[v - 1].append((u - 1, a, b))
    for i, (c, d) in enumerate(cd):
        edg[i].append((i, -c, d))
    if s >= 2501:
        s = 2500
    q = [(0, 0, s)]
    dp[0][s] = 0
    time = 0
    while q:
        time, p, score = heappop(q)
        for e, a, b in edg[p]:
            timebuf = time
            if 0 <= score - a <= 2500:
                timebuf += b
                if dp[e][score - a] > timebuf:
                    dp[e][score - a] = timebuf
                    heappush(q, (timebuf, e, score - a))
                    for i in range(score - a, -1, -1):
                        if dp[e][i] > timebuf:
                            dp[e][i] = timebuf
                        else:
                            break
    
    for i in range(1, n):
        print(min(dp[i]))

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 101648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    string s;
    cin >> s;
    ll ans = 0;
    F0R(i,s.length()){
      if(s[i] == '0') ans++;
      else ans--;
    }

    cout << s.length() - abs(ans) << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

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

    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    #endif // _DEBUG

    int n;
    cin>>n;
    unordered_map<string, int> mp;
    while (n--) {
        string s;
        cin>>s;
        mp[s]++;
    }
    auto ptr = max_element(mp.begin(), mp.end(),
        [] (const pair<string, int> &p1, const pair<string, int> &p2) {
            return p1.second < p2.second;
        }
    );
    vector<string> v;
    for (auto i : mp) {
        if (i.second == ptr->second) v.push_back(i.first);
    }
    sort(v.begin(), v.end());
    for (auto i : v) cout<<i<<"\n";

    return 0;
}


Measured memory_bytes: 25412
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    char x,y;
    cin >> x >> y;
    if(x > y){
        cout << '>' << endl;
    }else if(x < y){
        cout << '<' << endl;
    }else{
        cout << '=' << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007
typedef long long ll;
int main() { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t,a[1000000],n,i,j,c=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            c+=a[i]*a[j];
        }
    }
    cout<<c<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
const int INF=1001001001;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
 
int H,W;
char fld[222][222];
int lim[222][222];
int dist[222][222];
 
signed main(){
    int sy,sx,gy,gx;
 
    cin>>H>>W;
 
    queue<pint>que;
    fill_n(*lim,222*222,INF);
 
    rep(i,H)rep(j,W){
        cin>>fld[i][j];
        if(fld[i][j]=='@'){
            sy=i;sx=j;
        }
        if(fld[i][j]=='%'){
            gy=i;gx=j;
        }
        if(fld[i][j]=='$'){
            lim[i][j]=0;
            que.push(pint(i,j));
        }
    }
    while(que.size()){
        int y,x;
        tie(y,x)=que.front();
        que.pop();
 
        rep(i,4){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]=='#'||lim[ny][nx]!=INF)continue;
            lim[ny][nx]=lim[y][x]+1;
            que.push(pint(ny,nx));
        }
    }
 
    fill_n(*dist,222*222,INF);
    dist[sy][sx]=0;
    que.push(pint(sy,sx));
    while(que.size()){
        int y,x;
        tie(y,x)=que.front();
        que.pop();
 
        rep(i,4){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny<0||ny>=H||nx<0||nx>=W||dist[ny][nx]!=INF||fld[ny][nx]=='#'||lim[ny][nx]<=dist[y][x]+1)continue;
            dist[ny][nx]=dist[y][x]+1;
            que.push(pint(ny,nx));
        }
    }
 
    if(dist[gy][gx]!=INF){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4456
a, b, c, d, e, f, g = map(int, raw_input().split())
if a > 0 and d > 0 and e > 0:
    ans1 = b + a / 2 * 2 + d / 2 * 2 + e / 2 * 2
    ans2 = b + 3 + (a-1) / 2 * 2 + (d-1) / 2 * 2 + (e-1) / 2 * 2
    print max(ans1, ans2)
else:
    print b + a / 2 * 2 + d / 2 * 2 + e / 2 * 2



Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    int sa=0,sb=0;
    for(auto i:a)sa+=i;
    for(auto i:b)sb+=i;
    bool can=true;
    int diff=sb-sa;
    int cnta=0,cntb=0;
    int d;
    if(diff<0)can=false;
    //最大でdiff回操作が行える
    for(int i=0;i<n;i++){
        d=b[i]-a[i];
        if(d>0){
            a[i]=b[i]+(a[i]%2!=b[i]%2);
            cnta+=(d+1)/2;
        }
        else{
            b[i]=a[i];
            cntb-=d;
        }
    }
    /* for(int i=0;i<n;i++)cout<<a[i]<<' ';
    cout<<endl;
    for(int i=0;i<n;i++)cout<<b[i]<<' ';
    cout<<endl;
    cout<<diff<<' '<<cnta<<' '<<cntb<<endl; */
    if(diff>=cnta&&diff>=cntb)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#include <iomanip>
 #include <iostream>
 using namespace std;
 int main(){
 int N;
 double ans = 0.0, A;
cin >> N;
 for(int i = 1; i <= N; ++i){
 cin >> A;
  ans += 1.0 / A;
 }
 ans = 1.0 / ans;
 cout << setprecision(16) << ans << endl;
 }

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	string s[3];
	REP(i, 3) cin >> s[i];
	int64 res = 0;
	REP(i, N){
		map<char, int> cnt;
		REP(j, 3){
			cnt[s[j][i]]++;
		}
		int maxi = 0;
		for(auto x : cnt){
			maxi = max(maxi, x.sc);
		}
		res += 3-maxi;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string S;
    map<string,int> m;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        m.insert(pair<string,int>(S,0));
    }
    cout << m.size();
    return 0;
}


Measured memory_bytes: 19260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k,s;
	cin >> k >> s;
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int z=s-i-j;
			if(z>=0 && z<=k)
			{
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 200001;

int w[N], b[N];

int main()
{
	fio;
	int n;
	string s;
	cin >> n >> s;
	for(int i=1; i<=n; i++)
	{
		w[i] = w[i-1];
		b[i] = b[i-1];
		if(s[i-1] == '.')
			w[i]++;
		else
			b[i]++;
	}
	int ans = INF;
	for(int i=0; i<=n; i++)
		ans = min(ans, b[i] + w[n] - w[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n, m;
  cin >> n;
  vector<pair<lld, lld>> ps;
  m = n;
  for (lld i = 2; i * i <= n; i++) {
    if (n % i != 0) {
      continue;
    }
    lld num = 0;
    while (n % i == 0) {
      n /= i;
      num++;
    }
    ps.push_back(make_pair(i, num));
  }
  if (n != 1) {
    ps.push_back(make_pair(n, 1));
  }

  lld s = ps.size(), o = 0;;
  for (lld i = 0; i < s; i++) {
    lld j = 1;
    while (1) {
      ps[i].second -= j;
      if (ps[i].second < 0) {
        break;
      }
      j++;
    }
    o += j - 1;
  }

  cout << o << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>

//returns 1 instead of true
//also 0 - false
inline int isPrime(const int& n){
    if(n == 2){
        return 1;
    }

    if(!(n & 1)){
        return 0;
    }

    float root = std::sqrt(n);
    for(int div = 3; div <= root; div += 2){
        if(!(n % div)){
            return 0;
        }
    }
    return 1;
}

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

    std::vector<int> vec(n);
    for(auto& e : vec){
        std::cin >> e;
    }

    int numOfPrime = 0;
    for(const auto& e : vec){
        numOfPrime += isPrime(e);
    }

    std::cout << numOfPrime << '\n';
}


Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

signed main(){
    string S;
    cin>>S;
    
    if(S=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int m,n,k,g=0;
    cin>>m>>n>>k;
    //memset(a,0,sizeof(a));
    map<int,int>a;
    for(int i = 0; i < k; i++)
    {
        if(m+i > n)
        {
            g = 1;
            break;
        }
        else
        {
            cout<<m+i<<endl;
            a[m+i] = -1;
        }
    }

    for(int i = k-1; i >= 0; i--)
    {
        if(g==1)
        {
            break;
        }
        else
        {
            if(-1 != a[n-i])
            {
                cout<<n-i<<endl;

            }

        }
    }

}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $m);

$divs = [];
for ($i = 1; $i <= sqrt($m); ++$i) {
    if ($m % $i == 0) {
        $divs[] = $i;
        $divs[] = $m / $i;
    }
}

$max = 1;
foreach ($divs as $div) {
    if ($m >= $n * $div) {
        $max = max($max, $div);
    }
}

echo $max;


Measured memory_bytes: 16068
#abc056 b
a,b,c=map(int,input().split())
num=[]
i=1
n=a
while True:
    n=a*i
    x=n%b
    if x not in num:
        num.append(x)
    else:
        break
    i+=1

if c in num:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include<cstring>

using namespace std;

int main()
{
    string word[]={"SAT","SUN","MON","TUE", "WED", "THU", "FRI"};
    string s;
    cin>>s;
    for(int i=0;i<7;i++)
    {
        if(s==word[i]&&i==0)
            cout<<1<<endl;
        else if(s==word[i])
            cout<<6-i+2<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
a, b, c, d = [int(i) for i in input().split()]
ac = a-c if a-c>=0 else c-a
ab = a-b if a-b>=0 else b-a
bc = b-c if b-c>=0 else c-b
if ac<=d:
  print('Yes')
elif ab<=d and bc<=d:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int n,i,j;
    scanf("%d",&n);
    
    char s[51][51];
    int a[51][27]={0};
    
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
        
        
        for(j=0;s[i][j]!='\0';j++){
            a[i][s[i][j]-'a']++;
        }
    }
    
    int b[27];
    for(j=0;j<26;j++){
        b[j]=a[0][j];
        for(i=1;i<n;i++){
            if(a[i][j]<b[j]){
                b[j]=a[i][j];
            }
        }
    }
    
   for(i=0;i<26;i++){
        for(j=0;j<b[i];j++){
            putchar('a'+i);
        }
    }
    
    putchar('\n');
    
    return 0;
   
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k, s;
  cin >> n >> k >> s;
  n -= k;
  while (k--) cout << s << ' ';
  if (s == (int)1e9)
    while (n--) cout << (s - 1) << ' ';
  else
    while (n--) cout << (s + 1) << ' ';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

const int mod = 1'000'000'007;
vector<int> h;

struct dp_t {
  long long alternating;
  long long other;
};

long long power(long long n, long long k, long long m) {
  if (m < 0) m = -m;
  n %= m;
  long long ret = 1;
  while (k) {
    if (k & 1) ret = (ret * n % m);
    n = (n * n % m);
    k >>= 1;
  }
  return ret;
}


dp_t solve(int L, int R, int base) {
  dp_t res = { 0, 0 };
  if (L == R) {
    int count = h[L] - base;
    res.alternating = power(2, count - 1, mod);
    return res;
  }
  int splitbase = *min_element(h.begin() + L, h.begin() + R + 1);
  int last = L;
  long long alternate = 1;
  long long all = 1;
  for (int i = L; i <= R; i++) {
    if (h[i] == splitbase) {
      last = i + 1;
      all *= 2;
      all %= mod;
    }
    else if (i + 1 > R || h[i + 1] == splitbase) {
      dp_t sub = solve(last, i, splitbase);
      alternate *= sub.alternating * 2;
      alternate %= mod;
      all *= (sub.alternating * 4 + sub.other) % mod;
      all %= mod;
    }
  }

  res.other = (all - alternate * 2) % mod;
  alternate *= power(2, splitbase - base - 1, mod);
  alternate %= mod;
  res.alternating = alternate;
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  h.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  dp_t ans = solve(0, n-1, 0);
  long long val = (ans.alternating * 2 + ans.other) % mod;
  val += mod;
  val %= mod;
  printf("%lld\n", val);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 

int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

int32_t main()
{
	fast;
	int n;
	cin>>n;
	int x=(n/1.08);
	int y=x*1.08;
	int z=(x+1)*1.08;
	// cout<<y<<endl;
	if(y==n)
	{
		cout<<x<<endl;
	}
	else if(z==n)
	{
		cout<<(x+1)<<endl;
	}
	else
	{
		cout<<":("<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    vector<vector<pair<int,int>>> vec(n);
    rep(i,n) {
        int m;
        cin>>m;
        while(m--) {
            int x,y;
            cin>>x>>y;
            x--;
            vec[i].emplace_back(x,y);
        }
    }
    
    int ans=0;
    for(int bit=0; bit<(1<<n); bit++) {
        int now=0;
        bool ok=true;
        rep(i,n) {
            if(!(bit&(1<<i))) continue;
            int add=1;
            for(auto p:vec[i]) {
                if((p.second==1 && !(bit&(1<<p.first))) || (p.second==0 && (bit&(1<<p.first)))) {
                    add=0;
                    ok=false;
                }
            }
            now+=add;
        }
        if(ok) ans=max(ans,now);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int b1,b2,b3;
    cin>>b1>>b2>>b3;
    if((b3==1)||(b1==1 &&b2==1)){
        cout<<"Open"<<endl;
    }
     
    else{
        cout<<"Close"<<endl;
    }
}


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);

            var a = new bool[n + 1];
            for(var i = 0; i < m; i++){
                var t = int.Parse(Console.ReadLine());
                a[t] = true;
            }

            long[] dp = new long[n + 1];
            dp[0] = 1;
            dp[1] = a[1] ? 0 : 1;

            for(var i = 2; i <= n; i++){
                if(!a[i - 1]){
                    dp[i] += dp[i - 1]; 
                }
                if(!a[i - 2]){
                    dp[i] += dp[i - 2];
                }
                dp[i] %= 1000000007;

            }
            Console.WriteLine(dp[n]);
        }
    }
}


Measured memory_bytes: 13664
def GCD(x,y):
    if x==0:
        return y 
    elif y==0:
        return x
    elif x>y:
        return GCD_ordered(x,y)
    else:
        return GCD_ordered(y,x)

def GCD_ordered(x,y):
    z=x%y
    if z!=0:
        return GCD_ordered(y,z)
    if z ==0:
        return y




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

tmp_forward=A[0]
tmp_backward=A[-1]
gcd_forward=[0,tmp_forward]
gcd_backward=[0,tmp_backward]

for i in range(1,N):
    tmp_forward = GCD(tmp_forward,A[i])
    gcd_forward.append(tmp_forward)
    
    tmp_backward = GCD(tmp_backward,A[-i-1])
    gcd_backward.append(tmp_backward)
#     print("forward",tmp_forward)
#     print("backward",tmp_backward)

# print("forward",gcd_forward)
# print("backward",gcd_backward)

ans=0

for i in range(0,N):
    tmp_gcd = GCD(gcd_forward[i],gcd_backward[(N-1)-i])
#     print(tmp_gcd)
    if ans < tmp_gcd:
        ans = tmp_gcd
      
print(ans)

Measured memory_bytes: 14076
#include <bits/stdc++.h>
#define int long long
#define FLASH                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int n, m;
vector<string> A;
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
int dist[30][30];
bool valid(int x, int y)
{
    return (x >= 1 && x <= n && y >= 1 && y <= m);
}
bool visited[30][30];
int ans;
void bfs(pair<int, int> source)
{
    queue<pair<int, int>> q;
    q.push(source);
    dist[source.first][source.second] = 0;
    visited[source.first][source.second] = true;
    while (!q.empty())
    {
        pair<int, int> v = q.front();
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            int row = v.first + dx[i];
            int col = v.second + dy[i];
            if (valid(row, col) && A[row - 1][col - 1] == '.' && visited[row][col] == false) // '.' = Win ynejem yet7arek
            {
                visited[row][col] = true;
                dist[row][col] = dist[v.first][v.second] + 1;
                ans = max(dist[row][col], ans);
                q.push(make_pair(row, col));
            }
        }
    }
}

signed main()
{
    // Matrix v1=x*y and v2=y*x
    cin >> n >> m;
    int h = n, w = m;
    // vector<string> v(h);
    A.resize(h);
    // vector<vector<char>> v2(w);
    // cout << "a";
    for (int i = 0; i < h; i++)
        cin >> A[i];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            visited[i][j] = false;
            dist[i][j] = INT_MAX;
        }
    int res = 0;
    rep(i, 1, h + 1)
        rep(j, 1, w + 1)
    {
        if (A[i-1][j-1] == '.')
        {
            bfs({i, j});
            memset(visited, false, sizeof visited);
            res = max(ans, res);
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/extc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int64_t, int64_t>> points(n);
  for (auto&& [x, y] : points) cin >> x >> y;
  int64_t ans = -1;
  auto go = [&](int cx, int cy) -> void {
    sort(begin(points), end(points), [&](auto p, auto q) {
      return cx * p.first + cy * p.second < cx * q.first + cy * q.second;
    });
    auto [x0, y0] = points.front();
    auto [x1, y1] = points.back();
    ans = max(ans, abs(x1 - x0) + abs(y1 - y0));
  };

  go(1, 1);
  go(1, -1);

  cout << ans << '\n';
}


Measured memory_bytes: 6344
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

void make_lunlun(vector<ll>& res, int k){
    int count = 0;
    vector<ll> tmp;
    for(int i = 1; i < 10; i++){
        tmp.push_back(i);
        res.push_back(i);
        count++;
    }

    while(count < k + 10){
        vector<ll> new_tmp;
        for(auto x: tmp){
            if(x % 10 == 9){
                ll newX = x * 10 + 8;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;

                newX = x * 10 + 9;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;
            }
            else if(x % 10 == 0){
                ll newX = x * 10;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;

                newX = x * 10 + 1;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;
            }
            else{
                for(int i = -1; i <= 1; i++){
                    ll newX = x * 10 + x % 10 + i;
                    res.push_back(newX);
                    new_tmp.push_back(newX);
                    count++;
                }
            }
            if(count >= k + 10){
                break;
            }
        }
        tmp.clear();
        for(auto x: new_tmp){
            tmp.push_back(x);
        }
    }
}


int main(){
    ll k;
    cin >> k;
    vector<ll> res;
    make_lunlun(res, k);

    cout << res[k-1] << endl;

    return 0;
}

Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N; cin >>N;
  int ans=0;
  rep(i,1,(N+1)/2) {
    int j=N-i;
    if (i!=j) {
      ans++;
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3636
/**
 * C - Base -2 Number
 * https://atcoder.jp/contests/abc105/tasks/abc105_c
 **/
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    string ans = "";
    while (N!=0) {
        int r = N % 2;
        if(r<0) r+=2;

        N = (N-r)/(-2);

        ans += (char)('0'+r);
    }
    reverse(ans.begin(), ans.end());
    if(ans=="") ans = "0";
    cout << ans << endl;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x  = root; // root of T

    Node *z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else x = x->right;
    }
    z->parent = y;

    if(y == NIL){
        root = z;
    } else if(z->key < y->key){
        y->left = z;
    } else {
        y->right = z;
    }
}
Node* find(Node *x, int k){
    while(x != NIL && k != x->key){
        if(k < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return x;
}
void inorder(Node *u){
    if( u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "find"){
            scanf("%d", &x);
            Node *z = find(root, x);
            if(z == NIL){
                printf("no\n");
            } else {
                printf("yes\n");
            }
        }
    }

    return 0;
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int note10000 = -1, note5000 = -1, note1000 = -1;
    for (int i=0; i<=N; i++) {      //範囲に注意
        for (int j=0; i+j<=N; j++) {
            int k = N - i -j;
            int tot = 10000*i + 5000*j + 1000*k;
            if (tot == Y) {
                note10000 = i;
                note5000  = j; 
                note1000  = k;
            }
        }
    }
    cout << note10000 << " " << note5000 << " " << note1000 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N, M; cin >> N >> M;
  ll result ; 
  if (N==1&&M==1) result = 1;
  else if (N==1) result = M-2;
  else if (M==1) result = N-2;
  else result = (N-2)*(M-2);
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		
		Scanner scan = new Scanner(System.in);
		ArrayList<PriorityQueue<Integer>> pque = new ArrayList<>();
		
		int n = scan.nextInt();
		for(int i=0; i<n; i++) {
			pque.add(new PriorityQueue<Integer>(Comparator.reverseOrder()));
		}
		
		int count = scan.nextInt();
		
		for(int i=0; i<count; i++) {
			int query = scan.nextInt();
			int a = scan.nextInt();

			switch(query) {
			
			case 0:
				int b = scan.nextInt();
				pque.get(a).offer(b);
				break;
				
			case 1:
				if(!pque.get(a).isEmpty())
				System.out.println(pque.get(a).peek());
				break;
				
			case 2:
				if(!pque.get(a).isEmpty())
				pque.get(a).poll();
				break;
			}
		}
	}
}


Measured memory_bytes: 168844
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    for (ll i=0;i<n;i++)cin >> a[i];
    ll dp[n+10];
    fill(dp,dp+n,INF);
    dp[0]=0;
    for (ll i=1;i<n;i++){
        chmin(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if (i>1){
            chmin(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

#define lli long long int

lli min(lli a,lli b){
	if(a>=b) return b;
	else return a;
}

lli abs2(lli a){
	if(a>=0)return a;
	else return -a;
}

using namespace std;

int main(){

	int n;
	vector<lli> a;

	cin>>n;

	for(int i=0;i<n;i++){
		lli tmp;
		cin>>tmp;
		a.push_back(tmp);
	}

	sort(a.begin(),a.end());

	lli ans=0;
	lli max = a.at(n-1);
	lli center = max/2;
	for(int i=0;i<n;i++){
		if( abs2(center-ans) >= abs2(center-a.at(i))){
			if(a.at(i) != max){
				ans = a.at(i);
			}
		}
	}

	cout<<max<<" "<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1528
import fractions
import heapq
import itertools


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


A, B = map(int, input().split())

cd = []
max_cd = fractions.gcd(A, B)

if max_cd == 1:
    cd.append(1)
else:
    heapq.heappush(cd, 1)

    f = [k[0] for k in factorize(max_cd)]
    for v in f:
        heapq.heappush(cd, v)

l = []

for i in range(0, len(cd)):
    c = heapq.heappop(cd)
    if not l:
        l.append(c)
    else:
        join = True
        for j in range(0, len(l)):
            k = l[j]
            if fractions.gcd(c, k) != 1:
                join = False
                break
        if join:
            l.append(c)

print(len(l))


Measured memory_bytes: 5152
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int a, b; cin >> a >> b;
  if ((a + b) % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
//  ll s = in();
//  ll x1 = 1e9, x2 = 1;
//  ll y2 = dup(s,x1), y1 = x1*y2-s;
//  vl ans;
//  ans.pb(0); ans.pb(0);
//  ans.pb(x1); ans.pb(y1);
//  ans.pb(x2); ans.pb(y2);
//  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


const int MAX_N = 1e5;
int N, M;
ll A[MAX_N];

int main() {
  cin >> N >> M;
  rep(i, N) cin >> A[i];

  ll ans = 0;
  ll sum = 0;
  map<int, int> mp;
  mp[0]++;
  for (int i = 0; i < N; ++i) {
    sum += A[i];
    if (mp.find(sum%M) != mp.end()) {
      ans += mp[sum%M];
    }
    mp[sum%M]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3968
a = [[0]*3 for _ in range(3)]
f = [[0]*3 for _ in range(3)]

for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
ans = "No"

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                f[j][k] = 1
    
for l in range(3):
    if f[l][0] == 1 and f[l][1] == 1 and f[l][2] == 1:
        ans = "Yes"
    elif f[0][l] == 1 and f[2][l] == 1 and f[1][l] == 1:
        ans = "Yes"
    elif f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
        ans = "Yes"
    elif f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
        ans = "Yes"
        
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL a[200005];
LL prefix[200005];

unordered_map<LL, LL> m;
LL n, k;

LL mod(LL x) {
    return ((x % k) + k) % k;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    prefix[0] = 0;
    for (int i = 1; i <= n; i++) {
        prefix[i] = prefix[i - 1] + a[i];
    }
    LL ans = 0;
    m[0] = 1;
    for (int i = 1; i <= n; i++) {
        ans += m[mod(prefix[i] - i)];
        if (i >= k - 1) {
            m[mod(prefix[i - k + 1] - (i - k + 1))]--;
        }
        // printf("ans = %lld\n", ans);
        m[mod(prefix[i] - i)]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14580
n = int(input())
a = list(map(int, input().split()))
ai = max(a)
diff = float("inf")
for aj in set(a):
    if abs(ai / 2 - aj) < diff:
        ans = [ai, aj]
        diff = abs(ai / 2 - aj)
print(' '.join(map(str, ans)))


Measured memory_bytes: 15692
// inputに入力データ全体が入る
function Main(input) {
  const inputLines = input.split("\n");
  const line0 = inputLines[0];

  var n = parseInt(line0, 10);
  var result = "";

  const dogs = 1000000000000001;
  const abcs = "abcdefghijklmnopqrstuvwxyz";

  while (0 < n) {
    var m = n % 26;
    if (m === 0) {
      m = 26;
    }
    result = abcs.substr(m - 1, 1) + result;
    n = (n - m) / 26;
  }

  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//Main("123456789");


Measured memory_bytes: 29636
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

//const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s;
  std::cin>>s;

  if(s[0]=='S')std::cout<<"Cloudy";
  else if(s[0]=='C')std::cout<<"Rainy";
  else std::cout<<"Sunny";

  return 0;
}


Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin>>n;
    cout<<((n+1)/2)/(1.0*n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

vector<int> Divisor(int n){
  vector<int> res;
  for(int i = 1; i*i <= n; i++){
    if(n%i == 0){
      res.push_back(i);
      if(i*i != n) res.push_back(n/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N);
  vector<int> AA(1e6+1, 0);
  REP(i, N){
    cin >> A[i];
    AA[A[i]]++;
  }

  int ans = 0;
  REP(i, N){
    vector<int> D = Divisor(A[i]);
    bool flag = true;
    for(int j : D){
      // if(j == 1) continue;
      if(AA[j] > 0){
        if(j == A[i] && AA[j] == 1) continue;
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define N 1000006
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int mod = 998244353;
struct custom_hash {
	   static uint64_t splitmix64(uint64_t x) {
	   	x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		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);
	}
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
int cnt[N], h[N], g[N], s[N], mu[N], x[N], p[N], ret, ans, sum, inv2, maxn = N - 5;
int main(){
	int i, j, n, m;
	inv2 = ksm(2, mod - 2, mod);
	mu[1] = 1;
	for(i = 2; i <= maxn; i++){
		if(!x[i]) x[i] = p[++ret] = i, mu[i] = -1;
		for(j = 1; j <= ret; j++){
			LL t = z * i * p[j];
			if(t > maxn) break;
			x[t] = p[j];
			if(i % p[j] == 0) break;
			mu[t] = -mu[i];
		}
	}
	n = read();
	for(i = 1; i <= n; i++){
		j = read();
		cnt[j]++;
		sum = (sum + j) % mod;
	}
	for(i = 1; i <= maxn; i++){
		for(j = 1; j <= maxn / i; j++){
			h[i] = (h[i] + z * j * cnt[i * j] % mod) % mod;
			g[i * j] = (g[i * j] + z * i * mu[i] % mod) % mod;
		}
	}
	for(i = 1; i <= maxn; i++) ans = (ans + z * h[i] * h[i] % mod * i % mod * g[i] % mod) % mod;
	ans = (ans - sum) % mod;
	ans = z * ans * inv2 % mod;
	printf("%d", (ans + mod) % mod);
	return 0;
}


Measured memory_bytes: 23808
N,C=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
DP=[[0]*(C+1) for i in range(N+1)]
DP[0][0]=1
mod=10**9+7
X=[[0] for i in range(401)]
for i in range(401):
  for j in range(401):
    X[i].append((X[i][j]+pow(j,i,mod))%mod)
for i in range(N):
  for j in range(C+1):
    for k in range(j+1):
      DP[i+1][j]=(DP[i][j-k]*(X[k][B[i]+1]-X[k][A[i]])+DP[i+1][j])%mod
print(DP[N][C])

Measured memory_bytes: 76444