akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;



signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0ll) << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;
   string C;
   cin >> C;

   int red = count(C.begin(), C.end(), 'R');

   int fix = count(C.begin(), C.begin()+red, 'W');

   cout << fix << '\n';

   return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define loop(i,n)for(i=0;i<n;i++)
#define INF 1000000000
using ll = long long int;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;


#define MAX 100005
#define MOD 1000000007

long long binpow(long long a, long long b)
{
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
    int n;
    cin>>n;
    ll ans = binpow(10,n);
    ans-=(2*binpow(9,n));
    ans%=MOD;
    if(ans<0)ans+=MOD;
    ans+=binpow(8,n);
    ans%=MOD;
    cout<<ans<<endl;
        return 0;
}


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

vector<int> p, q;
int main() {
    int n, a;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        p.push_back(a);
    }
    for(int i = 0; i < n; i++) {
        cin >> a;
        q.push_back(a);
    }
    for(int i = 0; i < n; i++) {
        if(p[i] != q[i]) {
            if(p[i] > q[i])
                swap(p, q);
            break;
        }
    }
    int c = 0;
    while(p != q) {
        c++;
        next_permutation(p.begin(), p.end());
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define take freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define speed ios_base::sync_with_stdio(false);
#define int long long
#define endl "\n"
#define maxi 10000007
#define rof(i,a,b) for(int i=a;i<b;i++)
int32_t main()
{
    speed
    //take
    string s;
    cin>>s;
    int n=s.size();
    char prev=s[0];
    int ans=0;
    int count=0;
    if(prev=='R')
    {
        ans++;
        count++;
    }
    
    for(int i=1;i<n;i++)
    {
        if(prev=='R'&&count)
        {
            if(s[i]=='R')
            {
                count++;
                ans=max(ans,count);
            }
            else
            {
                ans=max(ans,count);
                count=0;
                prev=s[i];
            } 
            
        }
         else
            {
                if(s[i]=='R')
                {
                    count++;
                    prev=s[i];
                    ans=max(ans,count);
                }
                
            }
    }
    cout<<ans;
    
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=k;i++)
	ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, -1)
INF = 100100100100
dp_table = [INF]*(N+1)
dp_table[0] = -1
dp_table[1] = 0

for i in range(2, N+1): # 各足場i(2~N)を緩和.
  for k in range(1,K+1): # 各足場i(2~N)について高々K通りの遷移.
    if i-k <=0: break #足場i-kからの遷移をみるが足場の最小は1. だから, 0以下になったらbreak.
    dp_table[i] = min(dp_table[i], dp_table[i-k] + abs(h[i]-h[i-k]))
print(dp_table[N])

Measured memory_bytes: 52448
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  int ret = 0, maxH = 0;
  REP(i, N) {
    int H;
    cin >> H;
    if(H >= maxH) {
      ret++;
      maxH = H;
    }
  }
  cout << ret << endl;
}

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

using namespace std;

int main() {
    short n, m, h, c = 1;
    cin >> n >> m;
    while (--n) {
        cin >> h;
        if (h >= m) {
            m = h;
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A; cin >> A;
    string SA = to_string(A);
    string SB; cin >> SB;
    ll keta[3];
    keta[0] = SB[0] - '0';
    keta[1] = SB[2] - '0';
    keta[2] = SB[3] - '0';
    ll ans = A*keta[0] + (A/10)*keta[1] + (A/100)*keta[2];
    ll shimo2 = A % 100;
    ll shimo1 = A % 10;
    ll temp = shimo1*keta[1]*10 + shimo2*keta[2];
    ans += temp/100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
S=list(input())
K=int(input())
N=len(S)

L=[]
for i in range(K):
    for j in range(N-i):
        if S[j:j+i+1] not in L:
            L.append(S[j:j+i+1])

L.sort()
ans=""
for l in L[K-1]:
    ans+=l
print(ans)

Measured memory_bytes: 10616
class Node:
    def __init__(self):
        self.left=[0]
        self.right=[0]
    def createleft(self,inp,A):
        cnt=0
        for cn in range(len(inp)):
            c=inp[cn]
            if c=='(':
                cnt+=1
            elif c==')':
                cnt-=1
            elif cnt==0:
                self.left=[A[int(c)-1]]
            elif c==' ' and cnt==1:
                leftnode=Node()
                inpl=inp[1:cn]
                inpr=inp[cn+1:len(inp)-1]
                leftnode.createleft(inpl,A)
                leftnode.createright(inpr,A)
                self.left=leftnode
        
    def createright(self,inp,A):
        cnt=0
        for cn in range(len(inp)):
            c=inp[cn]
            if c=='(':
                cnt+=1
            elif c==')':
                cnt-=1
            elif cnt==0:
                self.right=[A[int(c)-1]]
            elif c==' ' and cnt==1:
            	rightnode=Node()
                inpl=inp[1:cn]
                inpr=inp[cn+1:len(inp)-1]
                rightnode.createleft(inpl,A)
                rightnode.createright(inpr,A)
                self.right=rightnode
    def possible(self):
        lp=self.left
        rp=self.right
        if isinstance(self.left,Node):
            lp=self.left.possible()
        if  isinstance(self.right,Node):
            rp=self.right.possible()
        return [l & r for l in lp for r in rp]+[l | r for l in lp for r in rp]+[l ^ r for l in lp for r in rp]
 
 
 
while(1):
    inp=raw_input()
    if inp=='END': break
    n=int(raw_input())
    A=[]
    for i in range(n):
        bn=int(''.join(raw_input().split()),2)
        A.append(bn)
    cnt=0
    root=Node()
    #create tree
    cnt=0
    for cn in range(len(inp)):
        c=inp[cn]
        if c=='(':
            cnt+=1
        elif c==')':
            cnt-=1
        elif c==' ' and cnt==1:
            inpl=inp[1:cn]
            inpr=inp[cn+1:len(inp)-1]
            root.createleft(inpl,A)
            root.createright(inpr,A)
    #count
    poss=root.possible()
    ans=poss.count(15)
    print ans

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

int main(){
	int r,g,b;
	cin>>r>>g>>b;
	
	if((100*r+10*g+b)%4==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
 
int main(){
    int a,b,c,x,y,s,t,r;
    cin >> a >> b >> c >> x >> y;
   	if(x >= y){
    	s = (2*c*y + (x-y)*a);
    } 
    else{
     	s = (2*c*x + (y-x)*b);
    }
    t = (a*x + b*y);
    r = c*max(x,y)*2;
    cout << min({s,t,r}) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------    
    string s;cin>>s;
    ll a=0,b=0,c=0;
    for(ll i=0;i<s.lg;i++){
        if(s[i]=='a')a++;
        else if(s[i]=='b')b++;
        else c++;
    }
    if(mmax(mmax(a,b),c)-mmin(mmin(a,b),c)<2){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------










































Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int r, c;
	cin >> r >> c;
	vector<vector<int>> table(r + 1, vector<int>(c + 1));
	for (int i = 0; i < r; i++) {
		int sum = 0;
		for (int j = 0; j < c; j++) {
			cin >> table[i][j];
			sum += table[i][j];
		}
		table[i][c] = sum;
	}

	for (int i = 0; i < c + 1; i++) {
		int sum = 0;
		for (int j = 0; j < r; j++) {
			sum += table[j][i];
		}
		table[r][i] = sum;
	}

	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			if (j == c) cout << table[i][j] << endl;
			else cout << table[i][j] << " ";
		}
	}
}


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

class Adjl{
private:
	int u;
	int k;
	int *v;
public:
	Adjl(int u, int k);
	~Adjl(){ delete[] v; }
	void setV(int vk);
	void printAdjm(int n);
};

Adjl::Adjl(int u, int k)
{
	this->u = u;
	this->k = 0;
	v = new int[k];
}

void Adjl::setV(int vk)
{
	v[k] = vk;
	k++;
}

void Adjl::printAdjm(int n)
{
	int j = 0;
	for (int i = 1; i <= n; i++) {
		if (j < k && v[j] == i) {
			cout << "1";
			j++;
		}
		else {
			cout << "0";
		}
		if (i < n) cout << " ";
		else cout << endl;
	}
}

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		Adjl *adjl = new Adjl(u, k);
		for (int j = 0; j < k; j++) {
			int vk;
			cin >> vk;
			adjl->setV(vk);
		}
		adjl->printAdjm(n);
		delete adjl;
	}

	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	ll n;
	
	cin >> n;
	
	ll tm = 100;
	
	for(int i = 1; i <= 3761; ++i) {
		if(tm >= n) {
			cout << i-1;
			return;
		}
		
		tm = tm + (tm/100);
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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

int main(){
    int x;
    cin>>x;
    int ans;
    
    for(int i=0;i<1e6;i++){
      int sum=0;
      ans=x+i;
      for(int j=2;j<x;j++){
          if(ans%j!=0) continue;
          sum++;
      }
      if(sum==0){
          cout<<ans<<endl;
          return 0;
      }
    }
}

Measured memory_bytes: 256
N, W=[int(i) for i in input().split()]
wv=[[int(i) for i in input().split()] for _ in range(N)]


dp=[[0]*(W+1) for _ in range(N)]

for i in range(N):
    for w in range(W+1):
        if i==0:
            if wv[i][0]<=w:
                dp[i][w]=wv[i][1]
        else:
            if w>=wv[i][0]:
                dp[i][w]=max(dp[i-1][w-wv[i][0]]+wv[i][1],dp[i-1][w])
            else:
                dp[i][w]=dp[i-1][w]

print(max(dp[-1])) 



Measured memory_bytes: 119788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

ll dp[101][100010]={};

int main(void){
    ll N,W;
    cin>>N>>W;
    ll w[101],v[101];
    for(int i=0;i<N;i++) cin>>w[i]>>v[i];
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]<0) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
        }
    }
    ll ans=0;
    for(int i=0;i<=W;i++){
        ans=max(ans,dp[N][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81704
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner s=new Scanner(System.in);
    int
    a=s.nextInt(),
    b=s.nextInt(),
    c=s.nextInt();
    
    System.out.println(Math.min(a+b+1,c)+b);
    
  }
}
    

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int ans = 0;
  for (auto &c : s) {
    if (c == '+') ans++;
    else ans--;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 998244353;
using mint = Fp<MOD>;
mint dp[3001][3002];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[0][0]=1;
    rep(i,c-a) dp[i+1][0]=dp[i][0]*b;
    rep(i,d-b) dp[0][i+1]=dp[0][i]*a;
    rep(i,c-a)rep(j,d-b) dp[i+1][j+1]=dp[i+1][j]*(a+i+1)+dp[i][j+1]*(b+j+1)-dp[i][j]*(a+i)*(b+j);
    cout<<dp[c-a][d-b];
}

Measured memory_bytes: 73872
import numpy as np


k, q = map(int, input().split())
d = np.array(list(map(int, input().split()))).astype(np.int64)
queries = [tuple(map(int, input().split())) for _ in range(q)]

for n, x, m in queries:
    d_mod = d % m
    quotient, rem = divmod(n - 1, k)
    rem_d_mod = d_mod[:rem]
    print(quotient * np.count_nonzero(d_mod) + np.count_nonzero(rem_d_mod)
          - (x % m + quotient * d_mod.sum() + rem_d_mod.sum()) // m)


Measured memory_bytes: 15072
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    const int INF = 1<<28;
    LL N, W;
    cin >> N >> W;
    vector<LL> w(N);
    vector<LL> v(N);
    REP(i, N){
        cin >> w[i] >> v[i];
    }
    LL base = w[0];
    REP(i, N)w[i] -= base;
    vector<vector<LL> > dp(N+1, vector<LL>(3*N+1, -INF));
    dp[0][0] = 0;
    REP(i, N){
        vector<vector<LL> > next(N+1, vector<LL>(3*N+1, -INF));
        REP(j, i+1){
            REP(k, 3*N+1){
                if(dp[j][k]==-INF)continue;
                // do not use
                next[j][k] = max(next[j][k], dp[j][k]);
                // use
                LL weight = k + w[i];
                LL value = dp[j][k] + v[i];
                if(base*(j+1) + weight <= W){
                    next[j+1][weight] = max(next[j+1][weight], value);
                }
            }
        }
        dp = next;
    }
    LL res = 0;
    REP(i, N+1)REP(j, 3*N+1)res = max(res, dp[i][j]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 788
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vector<int> x[100001], y[100001];
set<int> st[100001];
bool used[100001];

int main(){
    int N;
    cin >> N;
    //cin >> N;
    for(int i = 0; i < N; i++) {
        int x_, y_;
        cin >> x_ >> y_;
        x[x_].push_back(y_);
        y[y_].push_back(x_);
    }
    UnionFind uf(100001);
    for(int i = 1; i <= 100000; i++){
        for(int j = 1; j < x[i].size(); j++){
            uf.unionSet(x[i][0], x[i][j]);
        }
    }
    
    for(int i = 1; i <= 100000; i++){
        if(uf.size(i) > 0){
            int r = uf.root(i);
            for(int j = 0; j < y[i].size(); j++){
                st[r].insert(y[i][j]);
            }
        }
    }

    long ans = 0;
    for(int i = 1; i <= 100000; i++){
        int r = uf.root(i);
        if(uf.size(r) > 0){
            if(used[r]) continue;
            long s = uf.size(i);
            long t = st[r].size();
            ans += s*t;
            used[r] = true;
        }
    }   
    cout << ans-N << endl;
}

Measured memory_bytes: 15616
"use strict";
    
const main = arg => {
    const N = arg.split("\n")[0].split(" ")[0];
    const M = arg.split("\n")[0].split(" ")[1];
    const C = parseInt(arg.split("\n")[0].split(" ")[2]);
    
    const B = arg.split("\n")[1].split(" ").map(n=>parseInt(n));
    const A = arg.split("\n").slice(2);
    
    let cnt = 0;
    
    for(let i=0; i<N; i++) {
        let temp = 0;
        A[i].split(" ").forEach((val,idx)=>temp += val*B[idx]);
        
        if(temp + C > 0) {
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
N=int(input())
A=list(map(int,input().split()))

m=1000
n=0
flag=0
for i in range(N-1):
  if flag==1:
    m += n*A[i]
    n = 0
    flag = 0
  
  if A[i+1]>A[i]:
    buy = m//A[i]
    n += buy
    m -= buy*A[i]
    flag=1

if flag == 1:
  m += n*A[-1]
  n = 0
  flag = 0
  
print(m)

Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3872
N = int(input())

if (N%2 == 1):
    print(0)
elif N == 0:
    print(0)
else:
    N //= 2
    res = 0
    div_coef = 1
    while True:
        tmp_add = N // (5 ** div_coef)
        res += int(tmp_add)
        div_coef += 1
        # print(int(tmp_add))
        if tmp_add < 1:
            break
    # print(N)
    print(int(res))


Measured memory_bytes: 8984
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){

    scanf("%d %d",&n,&k);
    if(n==0 && k==0)break;

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j] = (i==j?0:INF);

    for(i=0;i<k;i++){
      scanf("%d",&x);
      
      if(x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }
    }
  }  
  return 0;
}

void warshall_floyd(void){
  int i,j;

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      }
    }
}

int min(int x,int y){
  return (x<y)?x:y;
}

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

int main() {
  int N, X;
  cin >> N;
  X = N;
  
  int sum;
  while (N) {
    sum += N % 10;
    N /= 10;
  }
  
  X %= sum;
  if (!X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		  Scanner cin=new Scanner(System.in);
		  List<Integer> list=new ArrayList<>();
		  int n=cin.nextInt(),res=0;
		  for(int i=0;i<n;i++)list.add(cin.nextInt());
		  
		  for(int i=0;i<n;i++) {
			  int x=list.get(i),limit=(int)(Math.sqrt(x)),j;
			  
			  for(j=limit;j>1;j--) {
				  if(x%j==0)break;
			  }
			  
			  if(j==1)res++;
			  
		  }
		  
		  System.out.println(res);
		  
	}

}



Measured memory_bytes: 41732
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int n;
	string s, t;
	cin >>n>> s >> t;
	for (int i = 0; i < n; i++) {
		
			cout << s.at(i);
		
			cout << t.at(i);
		
	}


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	string str;
	cin >> n >> str;

	map<char, ll> mp;
	for(auto el: str) mp[el]++;
	ll ans = mp['R'] * mp['G'] * mp['B'];

	for(int i = 1; i * 2 + 1 <= n; i++)
		for(int j = 0; j + i * 2 + 1 <= n; j++)
			if(str[j] != str[j + i] && str[j] != str[j + i * 2] && str[j + i] != str[j + i * 2])
				ans--;
	cout << ans << '\n';
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 1e18;


ll n,m,x;
ll g[13][13];

ll best = inf;
ll c[13];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m>>x;
    for (int i=0; i<n; i++) {
	cin>>c[i];
	for (int j=0; j<m; j++) {
	    cin>>g[i][j];
	}
    }

    for (int mask=0; mask<1<<n; mask++) {
	ll tot = 0;
	vector<ll> skill(m);
	for (int j=0; j<n; j++) {
	    if (mask>>j&1) {
		tot += c[j];
		for (int i=0; i<m; i++) {
		    skill[i] += g[j][i];
		}
	    }
	}
	bool ok = true;
	for (int i=0; i<m; i++) {
	    if (skill[i]<x) ok=false;
	}
	if (ok) best=min(best,tot);
    }

    if (best==inf) best=-1;
    cout<<best<<endl;
    
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A[];
        A=new int[N];
        for(int i=0;i<N;i++) A[i]=sc.nextInt();
        for(int i=N-1;i>=0;i--){
            System.out.print(A[i]);
            if(i!=0) System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26168
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=0
for i in range(K):
  for j in range(N+1):
    B[j]=0
  for j in range(N):
    B[max(0,j-A[j])]+=1
    B[min(N,j+A[j]+1)]-=1
  C=0
  for j in range(N):
    C+=B[j]
    A[j]=C
  if set(A)==set([N]):
    break
print(*A)

Measured memory_bytes: 108964
#include <iostream>

using namespace std;

typedef long long ull;

ull M = 1e9 + 7;

ull pow(int a, int b)
{
    ull res = 1;
    ull base = a;
    while(b)
    {
        if(b & 0x1) res = (res * base) % M;
        base = (base * base) % M;
        b >>= 1;
    }
    return res % M;
}

ull C(int a, int b)
{
    if(b > a) return 0;
    ull x = 1, y = 1;
    for(int i = a - b + 1; i <= a; i++) x = x * i % M;
    for(int i = 1; i <= b; i++) y = y * i % M;
    return x * pow(y, M - 2) % M;
}

ull lucas(int a, int b)
{
    if(b == 0) return 1;
    return C(a % M, b % M) * lucas(a / M, b / M) % M;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    // ans = 2^n - 1 - C(n, a) - C(n, b)
    cout << (pow(2, n) - 1 -(lucas(n, a) + lucas(n, b)) % M + M) % M << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

bool toStr(int n){
    string str;
    int len = static_cast<int>(log10(n));
    int K = 1;
    int b = -1;
    rep(i,len) K*=10;
    rep(i,len + 1){
        if(n / K == 0) str+= '0';
        else str+= ('0' + n / K);
        if(b == -1){
            b = n / K;
        }else{
            if(b + 1 != n / K) return false;
            b++;
        }
        n%=K; K/=10;
    }
    return true;
}


int main(){
    int n, ans = -1;
    int a[1001];
    cin >> n;
    rep(i,n){ cin >> a[i]; }
    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            if(toStr(a[i] * a[j])) ans = max(ans, a[i] * a[j]);
        }
    }
    cout << ans << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n >> m;
    vl mark(n + 10, -1);
    vector<set<ll>> next(n + 10);
    mark[0] = 0;

    MREP() {
        cin >> a >> b;
        next[a - 1].insert(b);
        next[b - 1].insert(a);
    }

    queue<ll> q;
    ll from = 1;
    bool first = true;
    set<ll> nextes;

    while (first || !q.empty()) {
        if (first) {
            first = false;
        } else {
            from = q.front();
            q.pop();
        }

        nextes = next[from - 1];
        for (ll item : nextes) {
            if (mark[item - 1] == -1) {
                mark[item - 1] = from;
                q.push(item);
            }
        }
    }

    NREP() {
        if (i == 0) continue;
        if (mark[i] == -1) {
            END("No")
        }
    }

    MSG("Yes")
    NREP() {
        if (i == 0) continue;
        MSG(mark[i])
    }
}


Measured memory_bytes: 32996
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;


int main ()
{
    int h,w;
    cin>>h>>w;
    string s[h];
    for (int i=0;i<h;i++)
    {
        cin>>s[i];
    }
    for (int i=0;i<h;i++)
    {
        cout<<s[i]<<endl<<s[i]<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  ll x,k,d;
  cin >> x >> k >> d;

  bool f = false;
  if(x < 0){
    f = true;
    x = -x;
  }
  ll mv = x / d;
  ll ans;
  if(mv <= k){
    k -= mv;

    if(k % 2 == 0){
      ans = abs(x - d*mv);
    }else{
      ans = abs(x - d*(mv+1));
    }

  }else{
    ans = abs(x - d*k);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;

ll dp[64][100];
void solve(){
	rep(i, 64){
		dp[i][0] = 1;
	}
	dp[6][0] = dp[9][0] = dp[18][0] = 0;
	rep(i, N - 3){
		rep(j, 64){
			int c1 = j / 16;
			int c2 = (j % 16) / 4;
			int c3 = j % 4;
			int taboo = -1;
			if((c2 == 0 and c3 == 1) or (c3 == 0 and c2 == 1) or c1 == 0 and (c2 == 1 or c3 == 1))
				taboo = 2;
			else if(c2 == 0 and c3 == 2)
				taboo = 1;
			rep(k, 64){
				int nc1 = k / 16;
				int nc2 = (k % 16) / 4;
				int nc3 = k % 4;
				if(nc1 == c2 and nc2 == c3 and nc3 != taboo){
					dp[k][i + 1] += dp[j][i];
					dp[k][i + 1] %= MOD;
				}
			}
		}
	}
	ll ans = 0;
	rep(i, 64){
		ans += dp[i][N - 3];
		ans %= MOD;
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)
int main()
{
    ll n;
    cin>>n;
vll v;
ll answer=0;
  inc(i,0,n)
  {
     ll x;
     cin>>x;
     v.pb(x);
  }
  sortall(v);
  ll count=0;
  ll point=0;
  while(n>0)
  {
      if(count==0)
      {
          n=n-1;
      }
      if(count==1)
      {
          n=n-1;
          answer+=v[v.size()-1-point];
          point++;
      }
      if(count>1)
      {
          if(n>=2)
          {
              answer+=2*v[v.size()-1-point];
              point++;
              n=n-2;
          }
          else
          {
              answer+=v[v.size()-1-point];
              point++;
              n=n-1;
          }
          
      }
      count++;
  }
  cout<<answer;
   return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int MOD = 1000000007;
int comb[100040][40];

int main() {
  int N,M;cin>>N>>M;

  // N=1の場合
  if (N==1) {
    OUT(1);
    return 0;
  }

  // 素因数カウント
  VECINT cnt;
  for (int i=2;i<=(int)sqrt(M);i++) {
    int tmp=0;
    while (M%i==0) {
      tmp++;
      M/=i;
    }
    if (tmp>0) cnt.push_back(tmp);
  }
  if (M!=1) cnt.push_back(1);

  // comb初期化
  for (int i=0;i<N+40;i++) {
    comb[i][0] = 1;
    if (i<40) comb[i][i] = 1;
  }
  for (int j=1;j<N+40;j++) {
    for (int k=1;k<min(j,40);k++) {
      comb[j][k] = comb[j-1][k-1]+comb[j-1][k];
      comb[j][k] %= MOD;
    }
  }

  ll ans = 1;
  REP(i,cnt.size()) {
    // cnt[i]+N-1のコンビネーションを計算
    ans *= comb[cnt[i]+N-1][cnt[i]];
    ans %= MOD;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 15872
n = int(input())
v = list(map(int,input().split()))
#print(v)

sv = sorted(v)
#print(sv)
#sv.pop(0)

#sv[0] = (sv[0]+sv.pop(1))/2
#print(sv)

for _ in range(n-1):
    sv[0] = (sv[0]+sv.pop(1))/2
    #print(sv)


print(sv[0])

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
	char inputs[4];
	int counts[4] = {0};

	for(int i = 0; i < 4; ++i){
		cin >> inputs[i];
	}

	for(int i = 0; i < 3; ++i){
		for(int j = i+1; j < 4; ++j){
			if(inputs[i] == inputs[j]){
				counts[i] += 1;
				counts[j] += 1;
			}
		}
	}

	bool flag = false;
	for(int i = 0; i < 4; ++i){
		if(counts[i] == 1){
			//nothing
		}else{
			flag = true;
		}
	}

	if(flag){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans


def solve():
    N, M, K = list(map(int, input().split()))
    uf = UnionFindVerSize(N)
    candidates = [-1 for _ in range(N)]

    for _ in range(M):
        a, b = list(map(int, input().split()))
        a, b = a-1, b-1
        uf.unite(a, b)
        candidates[a] -= 1
        candidates[b] -= 1

    for _ in range(K):
        c, d = list(map(int, input().split()))
        c, d = c-1, d-1
        if uf.is_same_group(c, d):
            candidates[c] -= 1
            candidates[d] -= 1

    for i in range(N):
        candidates[i] += uf.get_size(i)

    print(*candidates)




if __name__ == "__main__":
    solve()


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
ll A[maxn],B[maxn],all;
int n;
vector<int> od;
bool less2(pii a,pii b)
{
	if(a.first!=b.first)return a.first>b.first;
	return a.second<b.second;
}
ll base[66];
void insert(ll val)
{
	for(int i=59;i>=0;i--)
	{
		if(val>>i&1)
		{
			if(!base[i])
			{
				base[i]=val;
				return;
			}
			val^=base[i];
		}
	}
}
ll getmax()
{
	ll res=0;
	for(int i=59;i>=0;i--)
	{
		if(!(res>>i&1))
		{
			res^=base[i];
		}
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&A[i]);
		all^=A[i];
	}
//	cout<<all<<endl;
	ll sum1=0;
	for(int i=0;i<60;i++)
	{
		if(!(all>>i&1))od.push_back(i);
		else sum1+=(1ll<<i);
	}
//	for(int i=0;i<od.size();i++)
//	{
//		cout<<od[i]; 
//	}
//	cout<<endl;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<od.size();j++)
		{
			ll bit=(A[i]>>od[j])&1;
			B[i]|=(bit<<j);
		}
		insert(B[i]);
	}
	ll res=getmax();
	ll ans=0;
	for(int i=0;i<od.size();i++)
	{
		ll bit=(res>>i)&1;
		ans|=(bit<<od[i]);
	}
	printf("%lld\n",ans*2+sum1);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 307, Q = 300, mod = 998244353;
int K, m, p[N], dp[N][N][2 * N], pr[N][N][2 * N], ps[N][N][N];
string s;

void add(int & x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

int get(int i, int c, int l, int r, int f) {
	if (l > r || c + Q < 0) return 0;
	if (f) return (pr[i][r][c + Q] - ((l > 0) ? pr[i][l - 1][c + Q] : 0) + mod) % mod;
	if (c < 0) return 0;
	return (ps[i][r][c] - ((l > 0) ? ps[i][l - 1][c] : 0) + mod) % mod;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> s >> K;
	s += '0';
	int n = s.size(), cur = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') {
			p[++m] = cur;
		}	else cur++;
	}
	K = min(K, p[m]);
	dp[0][0][0] = 1;
	for (int i = 0; i <= m; i++) {
		for (int j = p[i]; j <= cur; j++) {
			if (i > 0) {
				for (int k = 0; k <= K; k++) {
					dp[i][j][k] = get(i - 1, k + (p[i] - p[i - 1]) - j, 0, j - (p[i] - p[i - 1]), 1);
					add(dp[i][j][k], get(i - 1, k, j - (p[i] - p[i - 1]) + 1, j, 0));
				}
			}
			for (int c = -Q; c <= Q; c++) {
				pr[i][j][c + Q] = (j > 0) ? pr[i][j - 1][c + Q] : 0;
				if (j + c >= 0 && j + c <= Q) add(pr[i][j][c + Q], dp[i][j][j + c]);
				if (c >= 0) {
					ps[i][j][c] = (j > 0) ? ps[i][j - 1][c] : 0;
					add(ps[i][j][c], dp[i][j][c]);
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i <= cur; i++)
		for (int j = 0; j <= K; j++)
			add(res, dp[m][i][j]);
	cout << res;
}


Measured memory_bytes: 138724
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const long long mod = 1000000007;

int main(void){
    int n, a[100005];
    int cnt[100005];
    fill(cnt, cnt+100005, 0);
    cin >> n;
    int cnt_ng=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] != 0){
            cnt[a[i]+1]++;
            cnt[a[i]-1]++;
            cnt[a[i]]++;
        }else{
            cnt[a[i]+1]++;
            cnt_ng++;
            cnt[a[i]]++;
        }
    }
    int m=cnt_ng;
    for(int i=0; i<100005; i++){
        m = max(m,cnt[i]);
    }
    cout << m << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#! env/bin/local python3
# -*- coding: utf-8 -*-

k, n = [int(i) for i in input().split()]
distances = [int(d) for d in input().split()]
sections = [distances[i+1] - distances[i] for i in range(n-1)]
sections.append(distances[0] - (distances[-1] - k))

print(k - max(sections))

Measured memory_bytes: 26420