akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll A,B,N;
    cin >> N>>A>>B;

  ll X[N];
  FOR(i,0,N-1){
    cin>>X[i];
  }
  ll ans=0;

  FOR(i,1,N-1){
    ans=ans+min(B,A*(X[i]-X[i-1]));
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    s = [x-1 for x in s]
    answer = 'x' * N
    head_flag = False
    for i in range(M):
        if list(answer)[s[i]] == 'x':
            answer = answer[:s[i]] + str(c[i]) + answer[s[i]+1:]
        else:
            if str(c[i]) != answer[s[i]]:
                print(-1)
                return
        if s[i] == 0 and c[i]==0:
            head_flag = True
    answer = ''.join(answer)
    answer = answer.replace('x', '0')
    answer = int(answer)
    answer = str(answer)
    if len(answer) != N and head_flag ==True:
        print(-1)
    elif len(answer) < N:
        answer = '1' + '0' * (N - len(answer) - 1) + answer
        print(answer)
    elif len(answer) == N:
        print(answer)
    else:
        print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string a[30000];
bool my_cmp(string a,string b)
{
	return a<b;
}
int main()
{
	string s;
    	int n,l,count=0,i,j;
    	cin>>s;
    	l=s.length();
    	scanf("%d",&n);
    	for(i=1;i<=min(n,l);i++)
    	{
    		for(j=0;j<l-i+1;j++)
    		{
    			a[count++]=s.substr(j,i);
    		}
    	}
    	sort(a,a+count,my_cmp);
    	unique(a,a+count);
    	cout<<a[n-1]<<endl;
    	return 0;
}

Measured memory_bytes: 1664
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>s) {
		cout<<(s=="AAA"||s=="BBB" ? "No":"Yes")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
local n = io.read("*n")
local x = {}
for i = 1, n do
  x[i] = io.read("*n")
end
local r = 1000000007
local mmi, mma = math.min, math.max
for i = 1, 100 do
  local c = 0
  for j = 1, n do
    c = c + (x[j] - i) * (x[j] - i)
  end
  r = mmi(r, c)
end
print(r)


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main{
	static long[]l=new long[51];
	static long[]b=new long[51];
	
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),w=s.nextInt()-1;
		int[]a=IntStream.range(0,n).map(i->s.nextInt()).sorted().toArray();
		
		System.out.println(
				IntStream.range(0,n-w).map(i->a[i+w]-a[i])
				.min().getAsInt()
				);
	}
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    rep(i, n) s[i] = 'x';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
    }
    inline T queryf(T& x,T& y){
        return x+y;
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};

ll powmod(ll n,ll k){
    ll ret = 1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int n;
    cin>>n;
    int x[n],y[n];
    vector<int> xs,ys;
    rep(i,n){
        cin>>x[i]>>y[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    rep(i,n){
        x[i]=lower_bound(xs.begin(), xs.end(),x[i])-xs.begin();
        y[i]=lower_bound(ys.begin(), ys.end(),y[i])-ys.begin();
    }
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    vector<int> lu(n),ld(n),ru(n),rd(n);
    SegmentTree<int> sg(n,0);
    sort(ord.begin(),ord.end(),[&](int i, int j){
        return x[i]<x[j];
    });
    for(auto i : ord){
        lu[i]=sg.get(0,y[i]);
        ld[i]=sg.get(y[i],n);
        sg.update(y[i],1);
    }
    rep(i,n)sg.update(i,0);
    reverse(ord.begin(),ord.end());
    for(auto i : ord){
        ru[i]=sg.get(0,y[i]);
        rd[i]=sg.get(y[i],n);
        sg.update(y[i],1);
    }
    ll ans = 0;
    rep(i,n){
        ans+=powmod(2,n);
        ans+=mod-powmod(2,lu[i]+ld[i]);
        ans+=mod-powmod(2,ru[i]+rd[i]);
        ans+=mod-powmod(2,lu[i]+ru[i]);
        ans+=mod-powmod(2,ld[i]+rd[i]);
        ans+=powmod(2,lu[i]);
        ans+=powmod(2,ld[i]);
        ans+=powmod(2,ru[i]);
        ans+=powmod(2,rd[i]);
        ans+=mod-1;
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 9580
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 28/Mar/20 05:33:34 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int x;
	cin >> x;
	int ans = 1000 * (x / 500);

	x = x - (x / 500) * 500;
	ans += 5 * (x / 5);
	pr (ans);
	return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;

    unordered_map<int, int> mp;
    for (int i = 0; i < m; i ++) {
        int a, b;
        cin >> a >> b;
        mp[a] ++;
        mp[b] ++;
    }

    for (int i = 1; i < n + 1; i ++) {
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M, K = map(int, readline().split())
    G = [[] for i in range(N)]
    INF = 10**18
    for i in range(M):
        a, b, c = map(int, readline().split())
        if c == 0:
            c = -INF
        G[a-1].append((b-1, c))
        G[b-1].append((a-1, c))
    def calc(K, U, l):
        if not l:
            X = [-INF]*(K+1)
            S0 = [-INF]*(K+1)
            S1 = [-INF]*(K+1)
            S0[0] = S1[1] = 0
            for i in range(1, K):
                e = U[i]
                for j in range(K-1, -1, -1):
                    S1[j+1] = max(S0[j], S1[j] + e)
                    S0[j] = max(S0[j], S1[j])
            for i in range(K+1):
                X[i] = max(S0[i], S1[i])
        else:
            X = calc(K-1, U[1:], 0) + [-INF]
            S0 = [-INF]*K
            S1 = [-INF]*K
            S0[0] = 0; S1[1] = U[1]
            for i in range(2, K):
                e = U[i]
                for j in range(K-2, -1, -1):
                    S1[j+1] = max(S0[j], S1[j] + e)
                    S0[j] = max(S0[j], S1[j])
            e = U[0]
            for i in range(K):
                X[i+1] = max(X[i+1], S0[i], S1[i] + e)
        return X
    used = [0]*N
    sg = 0
    dp = [-INF]*(N+1)
    dp[0] = 0
    for i in range(N):
        if used[i]:
            continue
        if len(G[i]) == 0:
            used[i] = 1
            for i in range(N-1, -1, -1):
                dp[i+1] = max(dp[i+1], dp[i])
            continue
        if len(G[i]) == 1:
            used[i] = 2
            v, c = G[i][0]
            r = [i]
            u = [0, c]
            while len(G[v]) == 2:
                r.append(v)
                used[v] = 2
                w1, w2 = G[v]
                if used[w1[0]]:
                    v, c = w2
                    u.append(c)
                else:
                    v, c = w1
                    u.append(c)
            r.append(v)
            used[v] = 2
            L = len(r)
            s = calc(L, u, 0)
            for i in range(N-L, -1, -1):
                for j in range(1, L+1):
                    dp[i+j] = max(dp[i+j], dp[i] + s[j])
    for i in range(N):
        if used[i]:
            continue
        r = []
        u = []
        v = i
        while 1:
            r.append(v)
            used[v] = 3
            w1, w2 = G[v]
            if used[w1[0]] and used[w2[0]]:
                break
            if used[w1[0]]:
                v, c = w2
                u.append(c)
            else:
                v, c = w1
                u.append(c)
        if G[i][0][0] == r[-1]:
            c = G[i][0][1]
        else:
            c = G[i][1][1]
        u = [c] + u
        L = len(r)
        s = calc(L, u, 1)
        for i in range(N-L, -1, -1):
            for j in range(1, L+1):
                dp[i+j] = max(dp[i+j], dp[i] + s[j])
    if dp[K] < -10**9:
        write("Impossible\n")
    else:
        write("%d\n" % dp[K])
solve()


Measured memory_bytes: 6664
import sys
from collections import deque

read = sys.stdin.read

H, W = map(int, input().split())
S = tuple(map(str, read().split()))
udlr = ((1, 0), (-1, 0), (0, 1), (0, -1))

visited = [[False] * W for i in range(H)]
answer = 0
for i in range(H):
    for j in range(W):
        if visited[i][j] or S[i][j] == '.':
            continue

        visited[i][j] = True
        queue = deque([(i, j)])
        black = 1
        white = 0

        while queue:
            x, y = queue.popleft()
            if S[x][y] == '#':
                switch = 'Black'
            else:
                switch = 'White'

            for di, dj in udlr:
                new_i = x + di
                new_j = y + dj
                if 0 <= new_i < H and 0 <= new_j < W:
                    if visited[new_i][new_j]:
                        continue

                    if switch == 'Black':
                        if S[new_i][new_j] == '.':
                            white += 1
                            queue.append((new_i, new_j))
                            visited[new_i][new_j] = True
                    else:
                        if S[new_i][new_j] == '#':
                            black += 1
                            queue.append((new_i, new_j))
                            visited[new_i][new_j] = True
            if switch == 'Black':
                switch = 'White'
            else:
                switch = 'Black'
        answer += black * white

print(answer)


Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

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

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL A,B; cin >> A >> B;
    cout << A*B / gcd(A,B) << endl;

}


Measured memory_bytes: 256
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector
cdef inline vector[int] readint(int n) nogil:
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef vector[int] readInt(int n):
    return readint(n)

cdef inline void printlongn(vector[long] l, int n):
    for i in range(n): printf("%ld\\n", l[i])

cpdef void printLongN(vector[long] l, int n):
    printlongn(l, n)
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
    cdef cppclass fenwick_tree[T]:
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)

cdef class FenwickTree:
    cdef fenwick_tree[long long] *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new fenwick_tree[long long](n)
    cpdef void add(self, int p, long long x):
        self._thisptr.add(p, x)
    cpdef long long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import readInt, FenwickTree, printLongN

n, q = readInt(2)
bit = FenwickTree(n)
*map(bit.add, range(n), readInt(n)),
res = []
for i in range(q):
    t, u, v = readInt(3)
    if t: res.append(bit.sum(u, v))
    else: bit.add(u, v)
printLongN(res, len(res))

Measured memory_bytes: 65240
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
S = read_str()

r = 0
g = 0
b = 0
for s in S:
    if s == 'R':
        r += 1
        continue
    if s == 'G':
        g += 1
        continue
    if s == 'B':
        b += 1
        continue

def solve():
    ans = r * g * b
    for d in range(1, N):
        for i in range(0, N - 2 * d):
            if S[i] != S[i + d] and S[i] != S[i + 2 * d] and S[i + d] != S[i + 2 * d]:
                ans -= 1
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    int n;
    cin>>n;
    int arr[n+1]={};
    for(int i=1;i<n;i++) {
        int x;
        cin>>x;
        arr[x]++;
    }
    for(int i=1;i<=n;i++) {
        cout<<arr[i]<<"\n";
    }
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


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

int main() {
  string s;
  stack<long> S;
  while (cin >> s) {
    if (s == "+") {
      int x1 = S.top(); S.pop();
      int x2 = S.top(); S.pop();
      S.push(x1 + x2);
    } else if (s == "-") {
      int x1 = S.top(); S.pop();
      int x2 = S.top(); S.pop();
      S.push(x2 - x1);
    } else if (s == "*") {
      int x1 = S.top(); S.pop();
      int x2 = S.top(); S.pop();
      S.push(x1 * x2);
    } else {
      S.push(stol(s));
    }
  }
  cout << S.top() << endl;
}


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

using namespace std;

typedef long long ll;

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

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a * n, b) << endl;


}


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

# Kが偶数の場合, 全てKの倍数または全てK//2に倍数の両方考える必要あり
num = [0]*(K+1)  # 1以上N以下の整数で余りが0~K-1の個数をカウントする
for i in range(1, N+1):
    num[i % K] += 1  # i % K の取りうる値は0~K-1

ans = 0
for a in range(K+1):  # aに関して全探索を行う
    b = (K-a) % K
    c = (K-a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]

print(ans)


Measured memory_bytes: 4596
INF=float('inf')

n=int(input())
P=list(map(float,input().split()))#0

dp=[[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0]=1    
for j in range(n+1):
  for i in range(1,n+1):
    if i<j:
      continue
    if j==0:
      dp[i][j]=(1-P[i-1])*dp[i-1][j]
    else:
      dp[i][j]=P[i-1]*(dp[i-1][j-1])+(1-P[i-1])*(dp[i-1][j])

ans=0
for i in range((n+1)//2,n+1):
  ans+=dp[n][i]
    
print(ans)

Measured memory_bytes: 224020
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int parent[110];
int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
bool unionSet(int x, int y) {
  x = root(x); y = root(y);
  if (x == y) { return false; }
  if (parent[x] > parent[y]) { swap(x, y); }
  parent[x] += parent[y];
  parent[y] = x;
  return true;
}

struct Edge {
  int from;
  int to;
  int cost;
  Edge() {;}
  Edge(int f, int t, int c) : from(f), to(t), cost(c) {;}
  bool operator<(const Edge &rhs) const { return cost < rhs.cost; }
};

Edge edges[100000];

int main() {
  int n, m;
  while (scanf("%d %d", &n, &m), n|m) {
    REP(i, m) {
      int f, t, c;
      scanf("%d %d %d", &f, &t, &c);
      edges[i] = Edge(f, t, c);
    }
    sort(edges, edges + m);
    int ans = 1 << 30;
    REP(i, m) {
      MEMSET(parent, -1);
      if (i != 0 && edges[i].cost == edges[i - 1].cost) { continue; }
      int sum = 0;
      FOR(j, i, m) {
        if (edges[j].cost - edges[i].cost >= ans) { break; }
        if (unionSet(edges[j].from, edges[j].to)) {
          sum++;
          if (sum == n - 1) {
            ans = min(ans, edges[j].cost - edges[i].cost);
            break;
          }
        }
        if (j == m - 1 && sum != n - 1) { goto end; }
      }
    }
end:;
    if (ans == (1 << 30)) { ans = -1; }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 936
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int mod = 1e9 + 7;

int main()
{
	int k, a, b;
	cin >>  k >> a >> b;
	if (a%k==0 || b%k==0 || a/k!=b/k)
	{
		cout << "OK";
	}
	else
	{
		cout << "NG";
	}
	return 0;
}

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

using namespace std;

#define ll long long

int findMax(int x, vector< list<int> > &edges, vector<int> &dp)
{
	if(dp[x]!=-1)
		return dp[x];
	if(edges[x].size() == 0)
		dp[x] = 0;
	else
	{
		for(list<int>::iterator it = edges[x].begin(); it != edges[x].end(); it++)
			dp[x] = max(dp[x], findMax(*it, edges, dp) + 1);
	}
	return dp[x];
}

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

	int n, m, i, x, y;
	cin>>n>>m;
	vector< list<int> > edges(n);
	vector<int> dp(n, -1); // maximum length of node i from an end node
	for(i = 0; i < m; i++)
	{
		cin>>x>>y;
		edges[x-1].push_back(y-1);
	}
	for(i = 0; i < n; i++)
	{
		if( dp[i] == -1 && edges[i].size() != 0)
		{
			for(list<int>::iterator it = edges[i].begin(); it != edges[i].end(); it++)
			{
				dp[i] = max(dp[i], findMax(*it, edges, dp) + 1);
			}
		}
	}
	int val = -1;
	for(i = 0; i < n; i++)
		val = max(val, dp[i]);
	cout<<val<<endl;

	return 0;
}


Measured memory_bytes: 8064
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfInt()
    val map = mutableMapOf<Int, Int>()
    val sum = IntArray(N + 1)
    for (n in 0 until N) {
        sum[n + 1] = (sum[n] + A[n]) % M
    }
    var ans = 0L
    for (n in 0 until sum.size) {
        val count = map.get(sum[n]) ?: 0
        ans += count
        map.put(sum[n], count + 1)
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 57984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC081_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int oneCount = 0;
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] == '1')
                {
                    oneCount++;
                }
            }
            Console.WriteLine(oneCount);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c = s.charAt(0);
    
    if(Character.isUpperCase(c)) {
      System.out.println('A');
    } else {
      System.out.println('a');
    }

  }

}

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

void solve(){
	string S;
	cin >> S;

	int k = 0;
	while(k < S.length()){
		if(S.substr(k, 11) == "dreameraser"){
			k += 11;
		}else if(S.substr(k, 10) == "dreamerase"){
			k += 10;
		}else if(S.substr(k, 7) == "dreamer"){
			k += 7;
		}else if(S.substr(k, 5) == "dream"){
			k += 5;
		}else if(S.substr(k, 6) == "eraser"){
			k += 6;
		}else if(S.substr(k, 5) == "erase"){
			k += 5;
		}else{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
	return;
}

int main(){
	solve();
	return 0;
}

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

using namespace std;

int main()
{

    // I/O
    int N;
    cin >> N;
    vector<long long> a(3 * N);
    for (int i = 0; i < 3 * N; i++)
        cin >> a[i];

    // 累積和を取る
    vector<long long> S(2 * N + 1, 0);
    priority_queue<long long, vector<long long>, greater<long long>> qs;
    for (int i = 0; i < N; i++)
    {
        S[i + 1] = S[i] + a[i];
        qs.push(a[i]);
    }
    for (int i = N; i < 2 * N; i++)
    {
        long long e1 = qs.top();
        if (a[i] > e1)
        {
            S[i + 1] = S[i] - e1 + a[i];
            qs.pop();
            qs.push(a[i]);
        }
        else
        {
            S[i + 1] = S[i];
        }
    }

    vector<long long> T(2 * N + 1, 0);
    priority_queue<long long> qt;
    for (int i = 0; i < N; i++)
    {
        T[i + 1] = T[i] + a[3 * N - 1 - i];
        qt.push(a[3 * N - 1 - i]);
    }
    for (int i = N; i < 2 * N; i++)
    {
        long long e2 = qt.top();
        if (a[3 * N - 1 - i] < e2)
        {
            T[i + 1] = T[i] - e2 + a[3 * N - 1 - i];
            qt.pop();
            qt.push(a[3 * N - 1 - i]);
        }
        else
        {
            T[i + 1] = T[i];
        }
    }

    long long ans = -(1LL << 60);
    for (int i = N; i <= 2 * N; i++)
    {
        ans = max(ans, S[i] - T[3 * N - i]);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;  cin >> N;
  int maxheight = 0;
  int ans = 0;
  for(int i=0;i<N;i++){
    int H;
    cin >> H;
    if(maxheight <= H){
      ans ++;
      maxheight = H;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n;
  cin >> n;
  ll ans = 1;
  while(ans <= n) ans*= 2;
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

bool dp[100005];

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	for (int i = 1; i <= k; i++) {
		for (int x : a) {
			if (i >= x && !dp[i-x]) {
				dp[i] = true;
				break;
			}
		}
	}
	
	cout << (dp[k]? "First" : "Second") << "\n";
}


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

using namespace std;

int main(){
  string str;
  int K;
  int str_size;
  
  cin >> K;
  cin >> str;
  
  str_size = str.length();
  
  if(str_size <= K){
    cout << str;
    return 0;
  }else{
  	cout << str.substr(0,K) << "...";
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif




void solve() {
    int N;
    ll X;
    cin >> N >> X;
    int mm = 100000000;
    rep(i, N) {
        int m;
        cin >> m;
        X -= m;
        mm = min(mm, m);
    }
    cout << (N + X / mm) << '\n';
}


int main() {
    solve();
    return 0;
}


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

class ORDER {
public:
	int N;
	void GROUP() {
		cin >> N;
		if (N % 3 == 0) {
			cout << N / 3 << endl;
		}
		else {
			while (N % 3 != 0) {
				N++;
			}
			cout << N / 3 - 1 << endl;
		}
	}
};

int main() {
	ORDER x;
	x.GROUP();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
using namespace std;
ll ans;
ll N,K;
ll A[200001];
ll sum[200001];
bool DP[101];
int main() {
	cin >> N;
	DP[0] = true;
	rep(i, 0, 101) {
		if (i >= 4)DP[i] = DP[i - 4];
		if (i >= 7)DP[i] = max(DP[i-4],DP[i - 7]);
	}
	if (DP[N])cout << "Yes" << endl;
	else cout << "No" << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

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

    int n, m; cin >> n >> m;
    vi e(m);
    REP(i, m) cin >> e[i];
    vi used(n+1);
    vi ans;
    RREP(i, m) {
        if (used[e[i]]) continue;
        ans.push_back(e[i]);
        used[e[i]] = 1;
    }
    FOR(i, 1, n+1) {
        if (!used[i]) ans.push_back(i);
    }
    REP(i, n) {
        cout << ans[i];
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 5088
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    map<char, queue<char>> s;
    rep(i, sa.length()) s['a'].push(sa[i]);
    rep(i, sb.length()) s['b'].push(sb[i]);
    rep(i, sc.length()) s['c'].push(sc[i]);
    char next = 'a', prev = 'a';
    while(true){
        if(s[next].size() == 0){
            cout << (char)toupper(next) << endl;
            return 0;
        }

        prev = next;
        next = s[next].front();
        s[prev].pop();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

const int mod = 1e9 + 7;
const int inv2 = mod + 1 >> 1;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) { int z = 1;
  for (; y; y >>= 1, x = Mul(x, x)) { if (y & 1) z = Mul(z, x); } return z; }
inline int Inv(int x) { return Pow(x, mod - 2); }
inline int Fix(li x) { x %= mod; if (x < 0) x += mod; return (int)x; }
inline int Fix(int x) { x %= mod; if (x < 0) x += mod; return x; }

// ----------------------------------------

const int maxn = 2e5;

int n, m, V, P;
int A[maxn];

bool Check(int i) {
  if (n - i <= P) return true;

  int h_start = n - (P - 1);
  if (h_start <= i) --h_start;
  int l_end = h_start - 1;
  if (l_end == i) --l_end;
  int lim = A[i] + m;

  li rest = (li)(P - 1) * m;
  for (int j = 0; j <= l_end; ++j) {
    if (j == i) continue;
    if (A[j] > lim) return false;
    rest += min(m, lim - A[j]);
  }
  return rest >= (li)m * (V - 1);
}

int main(void) {
  scanf("%d%d%d%d", &n, &m, &V, &P);
  for (int i = 0; i < n; ++i) {
    scanf("%d", A + i);
  }
  sort(A, A + n);
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = l + r >> 1;
    if (Check(mid - 1)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d\n", n - l);
  return 0;
}


Measured memory_bytes: 2132
#include<stdio.h>

int main()
{	
	int a[3],cnt=0;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	int i,j;
	for(i=0;i<3;i++)
		for(j=i+1;j<3;j++)
		{
			if(a[i]>a[j])
			{
				int temp;
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	if((a[2]-a[1])%2)
	{
		a[0]++;
		a[1]++;
		cnt++;
		cnt+=(a[2]-a[1])/2;
		a[1]=a[2];
	}
	else
	{
		cnt+=(a[2]-a[1])/2;
		a[1]=a[2];
	}
	if((a[2]-a[0])%2)
	{
		a[2]++;
		a[1]++;
		cnt++;
		cnt+=(a[2]-a[0])/2;
	}
	else
		cnt+=(a[2]-a[0])/2;
	
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 128
import math

a,b = map(int, input().split())
 
def gcd(a, b):
  while b:
      a, b = b, a % b
  return a
 
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

g = gcd(a,b)
fac = prime(g)
print(len(fac)+1)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    vec ac(n);
    vec wa(n);
    rep(i,m){
        int p;
        string s;
        cin>>p>>s;
        p--;
        if(s=="AC"){
            ac[p]++;
        }
        else{
            if(ac[p]==0){
                wa[p]++;
            }
        }
    }
    int f=0,g=0;
    rep(i,n){
        if(ac[i]!=0) f++;

        if(ac[i]!=0) g+=wa[i];
    }
    cout<<f<<" "<<g<<endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N;
    cin >> N;
    int b[N+1], cnt[N+1];
    rep2(i, 1, N+1){
        cin >> b[i];
        cnt[i] = i - b[i];
    }
    rep2(i, 1, N+1){
        if(cnt[i] < 0){
            cout << -1 << endl;
            exit(0);
        }
    }
    vector<int> vec;
    rep(i, N){
        int j = N-i;
        while(true){
            if(j == 0){
                cout << -1 << endl;
                exit(0);
            }
            elif(cnt[j] == 0){
                vec.push_back(j);
                break;
            }
            else j--;
        }
        rep2(k, j, N-i){
            cnt[k] = cnt[k+1]-1;
        }
    }
    rep3(i, N){
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
using namespace std;

int dr[] = {0, 0, -1, +1, -1, -1, +1, +1};
int dc[] = {-1, +1, 0, 0, -1, +1, -1, +1};

int main(){
    string a , b;
    cin >> a >> b;
    int ans = 0;
    for(int i = 0; i < (int)a.size(); i++)
        if(a[i] != b[i])
            ans++;
    cout << ans << endl;
}



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

using ll = long long;

const int MAX = 1e+5 + 10;

ll dp[100 + 5][MAX];
pair<int, ll> w[100 + 5];

int main() {

    int n, max_w;

    cin >> n >> max_w;

    for(int i = 1; i <= n; ++i) {
        cin >> w[i].first >> w[i].second;
    }

    for(int i = 1; i <= n; ++i) {

        for(int j = 1; j <= max_w; ++j) {

            if(j < w[i].first) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }

            dp[i][j] = max(dp[i - 1][j - w[i].first] + w[i].second, dp[i - 1][j]);
        }
    }

/*
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= max_w; ++j)
            printf("%3d ", dp[i][j]);
        cout << endl;
    }
*/

    cout << dp[n][max_w] << endl;

    return 0;

}

Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<(n);++i)
int main(){
	int n;long a,b;scanf("%d %ld %ld",&n,&a,&b);
	vector<int> x(n);long ans=0;
	scanf("%d",&x[0]);
	FOR(i,1,n){
		scanf("%d",&x[i]);
		ans+=min(a*(x[i]-x[i-1]),b);
	}
	printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  int i,arr[n],sum=0;
  for(i=0;i<n;i++){
    scanf("%d ",&arr[i]);
    sum = sum+arr[i];
  }
  int av1 = sum/n;
  int av2 = sum/n +1;
  int cost1=0,cost2=0;
  for(i=0;i<n;i++){
    cost1 = cost1+(arr[i]-av1)*(arr[i]-av1);
    cost2 = cost2+(arr[i]-av2)*(arr[i]-av2);
  }
  if(cost1<cost2) printf("%d\n",cost1);
  else printf("%d\n",cost2);
  return 0;
}

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

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

	if (N > 10)
	{
		cout << R;
		return 0;
	}
	else
	{
		cout << R + 100 * (10 - N);
		return 0;
	}

	return 0;
}

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
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;
}

int main(){
    int r, D, x2000; cin >> r >> D >> x2000;
    for (int i = 1; i <= 10; i++) {
        x2000 = r * x2000 - D;
        cout << x2000 << endl;
    }
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
i=0
tmp=[]
while True:
    if (A*i)%B == C:
        print('YES')
        break
    elif (A*i)%B in tmp:
        print('NO')
        break
    else :
        tmp.append((A*i)%B)
        i+=1


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int N;
	int mina = 1000, maxa = 0;
	int a;
	cin >> N;
	rep(i, N) {
		cin >> a;
		mina = min(mina, a);
		maxa = max(maxa, a);
	}
	cout << maxa - mina << endl;
	return 0;
}

Measured memory_bytes: 256