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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	int n;
	string s;

	cin >> n;
	FOR(i, 1, n) {
		cin >> s;
		int count = 0;
		int now = 0;
		FOR(t, 0, s.size() - 1) {
			if (s[t] == '0') {
				if (now == 1) {
					switch (count % 5) {
					case 0:
						cout << " ";
						break;
					case 1:
						cout << ".";
						break;
					case 2:
						cout << ",";
						break;
					case 3:
						cout << "!";
						break;
					case 4:
						cout << "?";
						break;
					}
				}
				else if (now == 7) {
					switch (count % 4) {
					case 0:
						cout << "s";
						break;
					case 1:
						cout << "p";
						break;
					case 2:
						cout << "q";
						break;
					case 3:
						cout << "r";
						break;
					}
				}
				else if (now == 9) {
					switch (count % 4) {
					case 0:
						cout << "z";
						break;
					case 1:
						cout << "w";
						break;
					case 2:
						cout << "x";
						break;
					case 3:
						cout << "y";
						break;
					}
				}
				else if (now == 2) {
					switch (count % 3) {
					case 0:
						cout << "c";
						break;
					case 1:
						cout << "a";
						break;
					case 2:
						cout << "b";
						break;
					}
				}
				else if (now == 3) {
					switch (count % 3) {
					case 0:
						cout << "f";
						break;
					case 1:
						cout << "d";
						break;
					case 2:
						cout << "e";
						break;
					}
				}
				else if (now == 4) {
					switch (count % 3) {
					case 0:
						cout << "i";
						break;
					case 1:
						cout << "g";
						break;
					case 2:
						cout << "h";
						break;
					}
				}
				else if (now == 5) {
					switch (count % 3) {
					case 0:
						cout << "l";
						break;
					case 1:
						cout << "j";
						break;
					case 2:
						cout << "k";
						break;
					}
				}
				else if (now == 6) {
					switch (count % 3) {
					case 0:
						cout << "o";
						break;
					case 1:
						cout << "m";
						break;
					case 2:
						cout << "n";
						break;
					}
				}
				else if (now == 8) {
					switch (count % 3) {
					case 0:
						cout << "v";
						break;
					case 1:
						cout << "t";
						break;
					case 2:
						cout << "u";
						break;
					}
				}

				now = 0;
				count = 0;
			}
			else {
				now = s[t] - '0';
				count++;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, l; cin >> n >> l;
    int sum = l*n+(n+1)*n/2-n;
    int ans = sum-l;
    rep(i,n) {
        if (abs(sum-ans) > abs(l+i)) {
            ans = sum-(l+i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())

ans = 0
for n in range(N + 1):
    # 無理
    if n <= K:
        continue

    if K == 0:
        ans += N
        continue

    # 倍数分
    ans += (N // n) * (n - K)
    # あまり分
    if K <= (N % n):
        ans += (N % n) - K + 1


print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int a[25];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d",&a[i]);
	}
	int ans = 0;
	for(int i = 2;i < n; ++i)
	{
		vector<int> v;
		v.push_back(a[i - 1]);
		v.push_back(a[i]);
		v.push_back(a[i + 1]);
		sort(v.begin(),v.end());
		if(v[1] == a[i])
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    if (n % 2 == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        bool success = true;
        for (int i = 0; i < n / 2; i++)
        {
            if (s[i] != s[i + n / 2])
            {
                success = false;
                break;
            }
        }
        cout << (success ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
if n==1:
    print(0)
    exit()
d=dict()
for i in range(2,int(n**0.5)+1):
    while n%i==0:
        n//=i
        if i in d:
            d[i]+=1
        else:
            d[i]=1
if n!=1:
    d[n]=1
#print(d)
p=0
for i in d.values():
    e=0
    j=1
    while True:
        e+=j
        p+=1
        #print(i,e,p)
        j+=1
        if e>i:
            p-=1
            break
print(p)

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

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

    vector<int> vecLen(n);
    for(int i=0; i<n; i++)
        cin >> vecLen.at(i);

    sort(vecLen.begin(), vecLen.end());
    
    int res = 0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            int maxLen = vecLen[i] + vecLen[j];
            int bound = lower_bound(vecLen.begin(), vecLen.end(), maxLen) - vecLen.begin();
            int start = j + 1;

            res += bound - start;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
    }
    template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
        return false;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll q;
        cin>>q;
        priority_queue<ll> L;
        priority_queue<ll,vl,greater<ll>> R;
        ll bsum=0;
        ll lsum=0;
        ll rsum=0;
        rep(i,q){
            ll x;
            cin>>x;
            if(x==1){
                ll a,b;
                cin>>a>>b;
                bsum+=b;
                if(Size(L)>Size(R)){
                    ll ma=L.top();
                    if(a>=ma){
                        R.push(a);
                        rsum+=a;
                    }else{
                        lsum-=ma;
                        L.pop();
                        R.push(ma);
                        rsum+=ma;
                        L.push(a);
                        lsum+=a;
                    }
                }else{
                    if(L.empty()){
                        L.push(a);
                        lsum+=a;
                        continue;
                    }
                    ll mi=R.top();
                    if(a<=mi){
                        L.push(a);
                        lsum+=a;
                    }else{
                        rsum-=mi;
                        R.pop();
                        R.push(a);
                        rsum+=a;
                        L.push(mi);
                        lsum+=mi;
                    }
                }
            }else{
                ll n=L.top();
                ll ans=bsum+Size(L)*n-lsum+rsum-n*Size(R);
                cout<<n<<' '<<ans<<endl;
            }
        }
    }

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

int main(){
	int n;
	string s;
	cin >> n >> s;

	for(int i=0; i<s.size(); ++i){
		s[i] = 'A'+(s[i]-'A'+n)%26;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
Slist = [0 for x in range(0,N)]
L = list()
R = list()
number = 0

for x in range(0,N-1):
    if S[x] is 'A' and S[x+1] is 'C':
        number += 1
    Slist[x+1] = number

for x in range(0,Q):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

for x in range(0,Q):
    answer = Slist[R[x]-1] - Slist[L[x]-1]
    print(answer)

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

int main(){
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++){
        cout<<s<<endl;
    }
    for(int i=0;i<n-k;i++){
        if(s==1e9) cout<<1<<endl;
        else cout<<1000000000<<endl;
    }
}

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

int main(){
	char A[11], B[11], C[11];
	scanf("%s %s %s", A, B, C);
	
	int lenA=0, lenB=0, lenC=0;
	lenA = strlen(A);
	lenB = strlen(B);
	lenC = strlen(C);
	
	if(A[lenA-1] == B[0] && B[lenB-1] == C[0] ){
		printf("YES");
	} else {
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 1728
#include<cstdio>

using namespace std;

int memo[11][1024];

int main(){
	int sw[1024];
	for(int i=0;i<1024;i++){
		sw[i]=0;
		if(i&1)		sw[i]^=3;
		for(int j=1;j<9;j++)	if(i&(1<<j))	sw[i]^=(7<<(j-1));
		if(i&512)	sw[i]^=768;
	}

	int t;	scanf("%d",&t);
	while(t--){
		int cell[10]={};
		for(int i=0;i<10;i++){
			cell[i]=0;
			for(int j=0,tmp;j<10;j++)	scanf("%d",&tmp),cell[i]|=(tmp<<(9-j));
		}

		for(int i=0;i<1024;i++)	memo[0][i]=0;
		for(int r=1;r<=10;r++){
			for(int i=0;i<1024;i++){
				memo[r][i]=-1;
				for(int b=0;b<1024;b++){
					if(memo[r-1][b]==-1)	continue;
					if((cell[r-1]^memo[r-1][b]^sw[b]^i)==0)	memo[r][i]=b;
				}
			}
		}

		int ans[10];
		for(int i=0,j=memo[10-i][0];i<10;i++,j=memo[10-i][j])	ans[i]=j;
		for(int i=9;i>=0;i--){
			for(int k=9;k>=0;k--)	printf("%s%d",(k==9?"":" "),(bool)(ans[i]&(1<<k)));
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 812
import numpy as np
 
N = int(input())
Vi = np.array(list(map(int,input().split())))
for i in range(N):
    if len(Vi)>2:
        Vi = np.sort(Vi)
        Vi = np.concatenate(([Vi[:2].mean()],Vi[2:]))
    else:
        Vi = Vi.mean()
        break
print(Vi)

Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+19;
int gcd(int a,int b) {
    return b==0?a:gcd(b,a%b);
}
int a[maxn],b[maxn];
int main() {

    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 1,x;i<=n;++i)
    {
        scanf("%d",&x);
        a[x]++;
    }
    int kk = 1;
    for(int i = 0;i<=n;++i){
        if(a[i])b[kk++] = a[i];
    }
    sort(b+1,b+kk,greater<int>());
    int ans = 0;
    for(int i = k+1;i<kk;++i)
        ans+=b[i];
        cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
    int K,N;
    cin >> K >> N;
    int house[N];
    rep(i,N) cin >> house[i];
    int minm = 10000000;
    rep(i,N){
        if(i!=0){
            int temp = house[N-1]-house[i]+K-house[N-1]+house[i-1];
            if(temp < minm) minm = temp;
        }
        else{
            int temp = house[N-1]-house[i];
            if(temp < minm) minm = temp;
        }
    }
    rep(i,N){
        if(i!=N-1){
            int temp = house[i]+K-house[i+1];
            if(temp < minm) minm = temp;
        }
        else{
            int temp = house[N-1]-house[0];
            if(temp < minm) minm = temp;
        }
    }
    cout << minm << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    long long a, b, c, d;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    long long product = c * d;
    long long c_multiple_num;
    long long d_multiple_num;
    if ( a % c == 0 ) {
        c_multiple_num = b / c - a / c + 1;
    }
    else {
        c_multiple_num = b / c - a / c;
    }
    if ( a % d == 0 ) {
        d_multiple_num = b / d - a / d + 1;
    }
    else {
        d_multiple_num = b / d - a / d;
    }


    /* swap to c > d */
    long long temp;
    if ( c < d ) {
        temp = c;
        c = d;
        d = temp;
    }

    /* Least common multiple */
    long long rest = c % d;
    while ( rest != 0 ) {
        c = d;
        d = rest;
        rest = c % d;
    }
    long long lcm = product / d;

    long long common_multiple_num;
    if ( a % lcm == 0 ) {
        common_multiple_num = b / lcm - a / lcm + 1;
    }
    else {
        common_multiple_num = b / lcm - a / lcm;
    }

    printf("%lld\n", (b - a + 1) - (c_multiple_num + d_multiple_num - common_multiple_num));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main()
{
	int N = 0;
	std::cin >> N;
	int H[25];
	for (int i = 0; i < N; i++) { std::cin >> H[i]; }
	int max = H[0];
	int counter = 1;
	for (int i = 1; i < N; i++) {
		if (H[i] >= max) {
			max = H[i];
			counter++;
		}
	}

	std::cout<<counter;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
 long long n,d,sum=0;
 cin>>n>>d;
 for(long long i=1;i<=n;i++)
 {
  long long x,y;
  cin>>x>>y;
  if(x*x+y*y<=d*d)sum++;
 }
 cout<<sum<<endl;
 return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool is_over(ll target, ll now) {
    assert(target == -1 || target == 1);
    if (target == 1) {
        return now >= 1;
    } else {
        return now <= -1;
    }
}

ll calc_to(ll target, ll now_sum, ll now) {
    if (is_over(target, now_sum + now)) {
        return now;
    } else {
        ll to = target - now_sum;
        assert(now_sum + to == target);
        return to;
    }
}


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

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    ll ans = INF;
    {
        ll sum = 0;
        // +-+-
        vector<ll> tos(n, 0);
        rep(i, n) {
            ll target = i % 2 == 0 ? 1 : -1;
            ll to = calc_to(target, sum, numbers[i]);
            tos[i] = to;
            sum += to;
        }

        ll diff = 0;
        rep(i, n) diff += abs(numbers[i] - tos[i]);
        cmin(ans, diff);
    }
    {
        ll sum = 0;
        // +-+-
        vector<ll> tos(n, 0);
        rep(i, n) {
            ll target = i % 2 == 1 ? 1 : -1;
            ll to = calc_to(target, sum, numbers[i]);
            tos[i] = to;
            sum += to;
        }

        ll diff = 0;
        rep(i, n) diff += abs(numbers[i] - tos[i]);
        cmin(ans, diff);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1804
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
  string s;
  cin >> s;
  if (s=="RRR") puts("3");
  else if ((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R')) puts("2");
  else if (s[0]=='R'||s[1]=='R'||s[2]=='R') puts("1");
  else puts("0");
  

  return 0;
}





Measured memory_bytes: 3624
n,m=map(int,input().split())

edge=[0]*(n+1)

for _ in range(m):
    a,b=map(int,input().split())
    a,b=min(a,b),max(a,b)
    edge[a]+=1
    edge[b]-=1

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

for i in range(1,n):
    if edge[i]%2==1:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 75120
n, k = map(int, input().split())
a = list(map(int, input().split()))
#dp[i] - TRUE if the first player wins if there are i stones remaining
dp = [False] * (k + 1)
for stones in range(k + 1):
    for x in a:
        if stones >= x and not dp[stones - x]:
            dp[stones] = True
print('First' if dp[k] else 'Second')

Measured memory_bytes: 43292
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int a[N];
int main()
{
    int n, x;
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    a[n+1] = 2e9;
    sort(a+1, a+1+n);
    for(int i = 1; i < n; i++)
    {
        if(x>=a[i])
        {
            x -= a[i];
        }
        else
        {
            printf("%d\n", i-1);
            return 0;
        }
    }
    printf("%d\n", n-1+(x==a[n]));
    return 0;
}


Measured memory_bytes: 256
import copy

n = int( input() )

a = []
for i in range(n):
    a.append(int(input()))

max_num = max(a)
semi_max = 0
if a.count(max_num) == 1:
    tmp = copy.copy(a)
    tmp.remove(max_num)
    semi_max = max(tmp)
    for i in range(n):
        if a[i] == max_num:
            print(semi_max)
        else:
            print(max_num)
else:
    for i in range(n):
        print(max_num)

Measured memory_bytes: 70232
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,k,a[109];
ll dp[109][100009],v[109];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(dp[i-1][j]==-1)continue;
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(j+a[i]<=k)dp[i][a[i]+j]=max(dp[i][a[i]+j],dp[i-1][j]+v[i]);
        }
    }
    ll mx=0;
    for(int i=0;i<=k;i++)
    {
        mx=max(mx,dp[n][i]);
      //  cout<<mx<<" "<<dp[n][i]<<"\n";
    }
    cout<<mx;
}


Measured memory_bytes: 85376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, m;
    cin >> n >> m;
    int road[n], a, b;
    for(int i=0; i<n; i++) road[i]=0;
    for(int i=0; i<m; i++){
      cin >> a >> b;
      road[a-1]++;
      road[b-1]++;
    }
    for(int i=0; i<n; i++)
      cout << road[i] << endl;
}

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

const int mod=1e9+7;
using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

template<typename T> class BiCoef
{
 public:
    vector<T> fact,ifact,inv;
    BiCoef(int N):fact(N+1),ifact(N+1),inv(N+1){
        fact[0]=ifact[N]=inv[0]=1;
        for(int i=1;i<=N;i++) fact[i]=fact[i-1]*i;
        ifact[N]/=fact[N];
        for(int i=N-1;i>=0;i--) ifact[i]=ifact[i+1]*(i+1);
        for(int i=1;i<=N;i++) inv[i]=ifact[i]*fact[i-1];
    }
    T comb(int n,int k){
        if(n<0 or k<0 or n<k) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main()
{
   int N,M; cin>>N>>M;
   string s; cin>>s;
   vector<int> _l(M),_r(M);
   for(int i=0;i<M;i++) cin>>_l[i]>>_r[i];

   vector<int> l,r;
   l.push_back(_l[0]);
   r.push_back(_r[0]);
   for(int i=1;i<N;i++){
      if(_r[i]>r.back()){
         l.push_back(_l[i]);
         r.push_back(_r[i]);
      }
   }
   M=l.size();
   // for(int i=0;i<M;i++) cout<<l[i]<<' '<<r[i]<<endl;
   for(int i=0;i<M;i++) l[i]--;

   vector<int> cnt(N+1);
   for(int i=0;i<N;i++) cnt[i+1]=cnt[i]+(s[i]=='1');

   BiCoef<mint> bc(100010);
   vector<vector<mint>> dp(M,vector<mint>(N+1));
   dp[0][cnt[r[0]]-cnt[l[0]]]=1;
   for(int i=0;i+1<M;i++) for(int j=0;j<=r[i]-l[i];j++){
      if(r[i]<=l[i+1]){
         dp[i+1][cnt[r[i+1]]-cnt[l[i+1]]]+=dp[i][j]*bc.comb(r[i]-l[i],j);
      }else{
         for(int k=0;k<=min(j,r[i]-l[i+1]);k++) if(j-k<=l[i+1]-l[i]){
            dp[i+1][k+cnt[r[i+1]]-cnt[r[i]]]+=dp[i][j]*bc.comb(l[i+1]-l[i],j-k);
         }
      }
   }
   mint ans=0;
   for(int j=0;j<=r[M-1]-l[M-1];j++) ans+=dp[M-1][j]*bc.comb(r[M-1]-l[M-1],j);
   cout<<ans.value()<<endl;
   return 0;
}


Measured memory_bytes: 35712
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = input[0];
        int m = input[1];
        string output = n == m ? "Yes" : "No";
        Console.WriteLine(output);
    }
}

Measured memory_bytes: 13268
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       M:usize,
    }

    let mut s = vec![];
    for _ in 0..N {
        input! {
            x:i64,
            y:i64,
            z:i64,
        }
        s.push(vec![x, y, z]);
    }

    let mut ans: i64 = 0;
    for i in 0..1 << 3 {
        let mut tmp = vec![];
        for k in 0..N {
            let mut q = 0_i64;
            for j in 0..3 {
                let mut p = 1_i64;
                if i >> j & 1 == 1 {
                    p = -1;
                }
                q += p * s[k][j];
            }
            tmp.push(q);
        }
        tmp.sort();
        tmp.reverse();
        ans = max(ans, tmp.iter().take(M).sum());
    }

    echo!(ans);
}


Measured memory_bytes: 2248
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 998244353

using namespace std;

ll powa(ll a, ll b, ll c)
{
    if(b == 0)  
        return 1;
    a%=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a,res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   map<ll,ll> ma;
   ll arr[n];
   for(ll i=0;i<n;i++)
   {
       ll temp;
       cin>>temp;
       arr[i] = temp;
       ma[temp]++;
       
   }
   
   if(arr[0]!=0)
   {
       cout<<0;
       return 0;
   }
   
   if(ma.begin()->first > 0)
   {
       cout<<0;
       return 0;
   }
   
   if(ma[0]>1)
   {
       cout<<0;
       return 0;
   }
   for(ll i=1;i<n;i++)
   {
       if(ma[i] != 0 && ma[i-1] == 0)
       {
           cout<<0;
           return 0;
       }
   }
   
   ma.erase(0);
   ll prev = 1;
   ll ans = 1;
   for(ll i=1;i<n;i++)
   {
       ll curr = ma[i];
       if(curr == 0)
            break;
       ans*=powa(prev,curr,MOD);
       prev = curr;
       ans%=MOD;
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;

using namespace std;
template <typename T>
ostream & operator << (ostream& cout,vector<T> vec)
{
	cout<<"{";
	for(int i=0;i<vec.size();i++)
	{
		cout<<vec[i];
		if(i!=(int)vec.size()-1) cout<<',';
	}
	cout<<"}";
	return cout;
}

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

template <typename T>
T operator * (vector <T> v1,vector <T> v2)
{
	assert(v1.size()==v2.size());
	int n=v1.size();
	T res=0;
	for(int i=0;i<n;i++)
	{
		res+=v1[i]*v2[i];
	}
	return res;
}

template <typename T1,typename T2>
pair<T1,T2> operator - (pair<T1,T2> x)
{
	return make_pair(-x.first,-x.second);
}

template <typename T>
vector<vector<T> > operator ~ (vector<vector <T> > vec)
{
	vector <vector<T> > v;
	int n=vec.size(),m=vec[0].size();
	v.resize(m);
	for(int i=0;i<m;i++)
	{
		v[i].resize(n);
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			v[i][j]=vec[j][i];
		}
	}
	return v;
}

struct XorSpace
{
	vector <ll> b;
	void clear()
	{
		b.clear();
	}
	void normalize(ll &v)
	{
		for(auto &x:b) chmin(v,v^x);
	}
	void add(ll x)
	{
		normalize(x);
		if(x) b.push_back(x);
	}
	bool query(ll x)
	{
		normalize(x);
		return (x==0);
	}
};

XorSpace xs;
void solve()
{
	int n;
	string s;
	ll a[205];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>s;
	xs.clear();
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='0') xs.add(a[i]);
		else
		{
			if(xs.query(a[i])) continue;
			cout<<1<<endl;
			return;
		}
	}
	cout<<0<<endl;
}

int main()
{
//	freopen("input.txt","r",stdin);
	int T;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a = I()
s = S()

print(s if a >= 3200 else 'red')


Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#include<math.h>

int main(void){
    char A[101], B[101];
    char temp[101];
    scanf("%s", A);
    scanf("%s", B);
    if(strlen(A) < strlen(B)) {
        printf("LESS\n");
        return 0;
    }
    else if(strlen(A) > strlen(B)) {
        printf("GREATER\n");
    }
    else {
        if(strcmp(A, B) > 0) {
            printf("GREATER\n");
        }
        else if(strcmp(A, B) ==0) {
            printf("EQUAL\n");
        }
        else{
            printf("LESS\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define n 100000
#define q 50000
int main()
{
  int S[n],T[q],es,et,i,j=0,left,right,mid,C=0;
  scanf("%d",&es);
  for(i=0;i<es;i++)
    scanf("%d",&S[i]);
  scanf("%d",&et);
  for(i=0;i<et;i++)
    scanf("%d",&T[i]);

  
  for(i=0;i<et;i++)
    {
      //if(i!=0) printf("^%d^",T[i-1]);
      left=0;
      right=es;
      while(1)
	{
	  if(left>right)
	    {
	      break;
	    }
	  mid=(left+right)/2;
	  //printf("%d ",mid);
	  if(S[mid]==T[i])
	    {
	      //printf("%d\n",T[i]);
	      C++;
	      break;
	    }
	  if(left==right) break;
	  if(S[mid]>T[i])
	    {
	      right=mid;
	      continue;
	    }
	  else if(S[mid]<T[i])
	    {
	      left=mid+1;
	      continue;
	    }
	}
    }
  printf("%d",C);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2316
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 1e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int func(int x)
{
    int res = 0;
    while(x)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

void work()
{
    int n; read(n);
    int ans = n;
    for(int i = 1; i < n; i++)
    {
        Min(ans, func(i) + func(n - i));
    }
    cout <<ans <<endl;
}


//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 888
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskC {
    int n;
    int[] a, sa;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      a = new int[n];
      for (int i = 0; i < n; ++i) {
        a[i] = in.nextInt();
      }
      sa = Arrays.copyOf(a, n);
      Arrays.sort(sa);
      int ans = 0;
      for (int i = 0; i < n; ++i) {
        if ((Arrays.binarySearch(sa, a[i]) - i) % 2 != 0) {
          ++ans;
        }
      }
      ans /= 2;
      out.println(ans);
    }

  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 21056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B;
    cin >> A >> B;
    int ans = -100;
    ans = max(ans, A + B);
    ans = max(ans, A - B);
    ans = max(ans, A * B);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;
const long long INF = 5 * 1e9;

int n, t;
int a[MAXN], b[MAXN];
vector<int> v, vz;
long long dp[MAXN][35];
long long mn[35];
int ans = 0;

long long f(int idx, long long tm) {
  return tm + 1ll * a[idx] * tm + b[idx];
}

bool cmp(const int& a, const int& b) {
  return f(b, f(a, 1) + 1) < f(a, f(b, 1) + 1);
}

int main() { 

  scanf("%d %d", &n, &t);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }

  for (int i = 0; i < n; i++) {
    if (a[i] != 0) {
      v.push_back(i);  
    } else {
      vz.push_back(b[i]);
    }
  }
  sort(all(v), cmp);
  sort(all(vz));

  for (int i = 0; i <= 30; i++) {
    mn[i] = INF;
  }
  mn[0] = 0;

  for (int i = 0; i < sz(v); i++) {
    for (int j = 30; j >= 1; j--) {
      dp[i][j] = INF;
      if (mn[j - 1] != INF) {
        long long tm = f(v[i], mn[j - 1] + 1);
        if (tm <= t) {
          dp[i][j] = tm;
        }
      }
      mn[j] = min(mn[j], dp[i][j]);
    }
  }

  for (int i = 0; i <= 30; i++) {
    if (mn[i] != INF) {
      // cerr << i << " " << mn[i] << endl;
      ans = max(ans, i);
      long long tm = mn[i];
      for (int j = 0; j < sz(vz); j++) {
        tm = tm + 1 + vz[j];
        if (tm <= t) {
          ans = max(ans, i + j + 1);
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 57972
//Name: Sale Reult
//Level: 1
//Category: やるだけ
//Note:

#include <iostream>
#include <map>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    map<int,long long> res;
    vector<int> ord;
    for(int i = 0; i < N; ++i) {
        int id, v, c;
        cin >> id >> v >> c;
        res[id] += ((long long)v)*c;
        ord.push_back(id);
    }

    bool exist = false;
    for(int id : ord) {
        if(res[id] >= 1000000) {
            cout << id << endl;
            res[id] = 0;
            exist = true;
        }
    }
    if(!exist) cout << "NA" << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1292
n,M=map(int,input().split())
i=2
c_list=[]
m=M
while i**2<=M:
    count=0
    while m%i==0:
        m=m//i
        count=count+1
    if not count==0:
        c_list.append(count)
    i=i+1
if not m==1:
    c_list.append(1)
def comb(x,y):
    a=1
    for i in range(x-y+1,x+1):
        a=a*i
    b=1
    for i in range(1,y+1):
        b=b*i
    return a//b
if M==1:
    print(1)
else:
    INF=10**9+7
    Sum=1
    for i in c_list:
        Sum=Sum*comb(i+n-1,i)
        Sum=Sum%INF
    print(Sum)


Measured memory_bytes: 38640
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

var mod int64 = 1000000007

func modPow2(num int64) int64 {
	if num == 0 {
		return 1
	}

	var rtn int64
	rtn = 1
	var i int64
	for i = 0; i < num; i++ {
		rtn = (rtn << 1) % mod
	}
	return rtn
}

func main() {
	N := getStdinInt64()
	hash1 := make(map[string]int64)
	hash2 := make(map[string]string)
	var zero int64 = 0
	var i int64
	for i = 0; i < N; i++ {
		list := getStdinIntArr64()
		A := list[0]
		B := list[1]
		if A == 0 && B == 0 {
			zero++
		} else if B == 0 {
			hash1["1/0"]++
			hash2["1/0"] = "0/1"
		} else if A == 0 {
			hash1["0/1"]++
			hash2["0/1"] = "1/0"
		} else {
			rat1 := big.NewRat(A, B)
			rat2 := big.NewRat(-B, A)
			hash1[fmt.Sprint(rat1)]++
			hash2[fmt.Sprint(rat1)] = fmt.Sprint(rat2)
		}
	}

	var ans int64 = 1
	for idx, val1 := range hash1 {
		if val1 == -1 {
			continue
		}
		var val2 int64 = hash1[hash2[idx]]	// 仲の悪い相方
		var tmp1 int64 = (modPow2(val1) - 1) % mod
		var tmp2 int64 = (modPow2(val2) - 1) % mod
		var tmp3 int64 = 1
		hash1[idx] = -1			// 重複を避ける
		hash1[hash2[idx]] = -1
		ans = (ans * (tmp1 + tmp2 + tmp3)) % mod
	}
	ans = (ans + zero + mod - 1) % mod
	fmt.Printf("%d", ans)

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinInt64() int64 {
	sc.Scan()
	rtn, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}


Measured memory_bytes: 109456
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;
 
int main(){
    fast;
    string s, t;    
    cin >> s >> t;
    ll ans = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] != t[i])
            ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3792
// A - Expired?

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

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	string ans;

	if (B <= A) ans = "delicious";
	else if (B <= A + X) ans = "safe";
	else ans = "dangerous";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import copy
d=int(input())
c0=input().split()
cl=[]
csum=0
for i in range(26):
  c1=int(c0[i])
  cl.append(c1)
  csum+=c1
  
def search(cdl,al0,leftd):
  addmax=0
  max26=[]
  al=al0[0]
  for j in range(26):
    cdl[j]+=1
  for j in range(26):
    a1=al[j]
    add1=a1+(cdl[j])*cl[j]
    if leftd==1:
      if addmax<add1:
        addmax=add1
        max26=[j]
    else:
      cdl2=copy.deepcopy(cdl)
      cdl2[j]=0
      rept,rel=search(cdl2,al0[1:],leftd-1)
      if rept+add1>addmax:
        addmax=rept+add1
        max26=rel
        max26.append(j)
  return (addmax,max26)
    
als=[]
for i in range(d):
  a0=input().split()
  als1=[]
  for k in range(26):
    als1.append(int(a0[k]))
  als.append(als1)
  
cd=[0 for i in range(26)]
for i in range(121):
  reall,ans=search(cd,als[i*3:i*3+3],3)
  print(ans[2]+1)
  print(ans[1]+1)
  print(ans[0]+1)
  for j in range(26):
    if j==ans[2]:
      cd[j]=0
    elif j==ans[1]:
      cd[j]=1
    elif j==ans[0]:
      cd[j]=2
    else:
      cd[j]+=3
    
reall9,ans9=search(cd,als[363:],2)
print(ans9[1]+1)
print(ans9[0]+1)

Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,cntR=0,cntG=0,cntB=0,cnt=0;
  string s;
  cin >> n >> s;
  for(int i=0;i<n;i++){
    if(s[i]=='R')cntR++;
    if(s[i]=='B')cntB++;
    if(s[i]=='G')cntG++;
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int k=2*j-i;
      if(i>=j or k<=j or k>=n)continue;
      if(s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i])cnt++;
    }
  }
  cout << cntR*cntB*cntG-cnt << endl;
}


Measured memory_bytes: 3580
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;
    int n;  cin >> n;
    vector<double> a(n);    for(int x=0;x<n;x++)    cin >> a[x];
    sort(rall(a));

    while(a.size() != 1){
        double fi = a[a.size() -1] ; a.pop_back();
        double se = a[a.size() -1] ; a.pop_back();
        double ans = (fi + se) / (double) 2;
        a.pb(ans);
    }

    cout << fixed << setprecision(12) ;

    cout << a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=50+10;
int vis[maxn];
int a[maxn];
int x[maxn][maxn],y[maxn][maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        for(int j=1;j<=a[i];j++)
            scanf("%d%d",&x[i][j],&y[i][j]);
    }
    int len=(1<<(n))-1;
    //cout<<len<<endl;
    int ans=0;
    for(int i=0;i<=len;i++)
    {
        int k=i;
        int cnt=0;
        for(int j=1;j<=n;j++)
        {
            vis[j]=k%2;
            k/=2;
            if(vis[j]==1)
                cnt++;
        }

        /*for(int j=1;j<=n;j++)
            cout<<vis[j]<<" ";
        cout<<endl;*/

        bool flag=true;
        for(int s=1;s<=n;s++)
        {
            if(vis[s]==0) continue;
            for(int j=1;j<=a[s];j++)
            {
                int id=x[s][j];
                int sf=y[s][j];
                //cout<<"id,sf:"<<id<<" "<<sf<<endl;
                if(vis[id]!=sf)
                {
                    flag=false;
                    break;
                }
            }
            if(flag==false)
                break;
        }
        if(flag)
            ans=max(ans,cnt);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256