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

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

  if(N<10){
    cout<<N<<endl;
    return 0;
  }
  if(10<=N && N<100){
    cout<<9<<endl;
    return 0;
  }
  if(100<=N && N<1000){
    cout<<9+N-99<<endl;
    return 0;
  }
  if(1000<=N && N<10000){
    cout<<909<<endl;
    return 0;
  }
  if(10000<=N && N<100000){
    cout<<909+N-9999<<endl;
    return 0;
  }
  if(N=100000){
    cout<<90909<<endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>

int main() {

	int N, M;
	std::cin >> N >> M;

	std::vector<int> height(N+1);

	for (int i = 1; i < N+1; i++) {
		std::cin >> height[i];
	}

	std::vector<std::unordered_set<int>> accessible(N+1);

	for (int i = 0; i < M; i++) {
		int a, b;
		std::cin >> a >> b;
		accessible[a].insert(b);
		accessible[b].insert(a);
	}


	int count = 0;
	for (int i = 1; i < N+1; i++) {
		for (int j : accessible[i]) {
			if (height[i] <= height[j]) {
				count--;
				break;
			}
		}
		count++;
	}


	std::cout << count << std::endl;
}



Measured memory_bytes: 16612
#include <cstdio>
#include <stack>
using namespace std;
int main(){
	int n;
	stack<int> car;
	while(scanf("%d",&n)!=EOF) {
		if(n!=0) car.push(n);
		else{
			printf("%d\n",car.top());
			car.pop();
		}
	}	
	return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
long long res=0,n;
string s[200001];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>s[i];
    sort(s+1,s+n+1);
    for (int i=1;i<=n;i++)
    if (s[i]!=s[i-1]) res++;
    cout<<res;
    
}

Measured memory_bytes: 9952
#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>;
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
  return 0;
}

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

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  int total = 2 * n - 1;

  if (x == 1 || x == total) {
    cout << "No" << endl;
    return 0;
  }

  int cur = n;
  int start = 1;
  while (cur != x) {
    ++start;
    ++cur;
    if (cur == 2 * n)
      cur = 1;
  }

  cout << "Yes" << endl;
  for (int i = start; i <= total; ++i)
    cout << i << ' ';
  for (int i = 1; i < start; ++i)
    cout << i << ' ';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::vector<ulli> A(N);
  N_TIMES (n, N) {
    std::cin >> A[n];
  }
  
  std::map<ulli, unsigned> hash;
  N_TIMES (n, N) {
    auto itr = hash.find(A[n]);
    if (itr == hash.end()) {
      hash.emplace(A[n], 1);
    } else {
      unsigned count = itr->second;
      hash.erase(itr);
      hash.emplace(A[n], count + 1);
    }
  }
  
  for (auto itr = hash.begin(); itr != hash.end(); ++itr) {
    std::cerr << itr->first << ": " << itr->second << std::endl;
  }
  
  std::vector<ulli> B;
  for (auto itr = hash.rbegin(); itr != hash.rend(); ++itr) {
    for (unsigned i = 0; i < (itr->second >> 1); ++i) {
      B.push_back(itr->first);
    }
  }
  
  std::sort(B.begin(), B.end(), std::greater<ulli>());
  
  ulli S = (B.size() < 2) ? 0 : B[0] * B[1];
  std::cout << S << std::endl;
  
  return 0;
}

Measured memory_bytes: 7296
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(N):
  if b[i] >= a[i]:
    b[i] -= a[i]
    res += a[i]
  else:
    res += b[i]
    b[i] = 0
  res += min(a[i + 1], b[i])
  a[i + 1] = max(0, a[i + 1] - b[i])
print(res)

Measured memory_bytes: 73572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll n,k;
	string s;
	cin >> n >> s >> k;
	char ok = s[k-1];
	FOR(i,0,n){
		cout << (s[i]==ok?ok:'*') << (i==n-1?"\n":"");
	}

}

Measured memory_bytes: 256
from itertools import accumulate
n=int(input())
List=list(map(int,input().split()))
List=list(accumulate(List))
ans=float('inf')
# print(List)
for i in range(n):
    ans=min({ans,abs(List[i]-abs(List[n-1]-List[i]))})
print(int(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100001],b[100000];
int main(){
	int n,m,i,ans=0;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>a[i];
	}
	sort(a+1,a+m+1);
	for(i=1;i<m;i++){
		b[i]=a[i+1]-a[i];
	}
	sort(b+1,b+m);
	for(i=1;i<=m-n;i++){
		ans+=b[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,m;
int a[10];
const string MINUSINF = "-";
string dp[10100];

void input(){
    cin >> n >> m;
    for(int i=0;i<m;i++) cin >> a[i];
}

void chmax(string &a, string b){
    if(a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()){
        if(a < b) a = b;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int num[10] = {2,5,5,4,5,6,3,7,6};
    for(int i=0;i<10100;++i) dp[i] = MINUSINF;
    dp[0] = "";
    for(int i=0;i<=n;++i){
        if(dp[i] == MINUSINF) continue;
        for(int j=0;j<m;++j) chmax(dp[i+num[a[j]-1]], dp[i] + to_string(a[j]));
    }
    cout << dp[n] << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll a, b, t;

int main() {
	cin >> a >> b;
	if (a*b<=0) cout << "Zero" << ln;
	else if (a<0 && (abs(a-b)+1)%2==1) cout << "Negative" << ln;
	else cout << "Positive" << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0; i<n; i++){
		if(a[i]==a[i+1]){
			cout<<"NO";
			return 0;
		}
	}		
	cout<<"YES";
}

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

signed main() {
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	for (int i = 0; i < n; ++i) {
		pair<int, int> x;
		cin >> x.first >> x.second;
		v.push_back({ x.first + x.second,x.first - x.second });
	}
	int nowat = 0;
	sort(v.begin(), v.end());
	int ans = 0;
	int t = -1e10;
	for (int i = 0; i < n; ++i) {
		if (t <= v[i].second) {
			++ans;
			t = v[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;
vector<ll> weights;
vector<bool> visited;
vector<ll> dp;
void dfs(vector<ll> adj[], vector<ll> &v, ll last){
    // ll last = v.back();    
    // O(n2)method
    // if(visited[last] != true){
    //     visited[last] = true;        
    //     // We need to do DP search for only last element of array
    //     ll index = last;        
    //     for (ll j=0;j<v.size()-1;j++){
    //         ll new_index = v[j];
    //         if(weights[index] > weights[new_index] && dp[index] < dp[new_index] + 1){
    //             dp[index] = dp[new_index] + 1;
    //         }            
    //     }               
    // }    
    
    // O(nlogn) method
    bool pop_flag = false;
    ll prev_weight;
    visited[last] = true;

    ll insert_index = lower_bound(v.begin(), v.end(), weights[last]) - v.begin();
    if(insert_index == v.size()){
        v.pb(weights[last]);
        pop_flag = true;
    }else{
        prev_weight = v[insert_index];
        v[insert_index] = weights[last];
    }
    
    dp[last] = v.size();

    for(ll i=0;i<adj[last].size();i++){        
        ll next = adj[last][i];        
        if(visited[next] == true)continue;
        // v.pb(next);        
        dfs(adj, v, next);
        // v.pop_back();
    }
    // roll back as each tree path in itself is an independet array.
    if(pop_flag)v.pop_back();
    else v[insert_index] = prev_weight;
    return;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n;
    weights.resize(n+1, 0);
    visited.resize(n+1, false);
    dp.resize(n+1, 1);
    vector<ll> adj[n+1];    
    for(i=1;i<=n;i++){
        cin>>weights[i];
    }
    // n-1 edges
    for(i=1;i<n;i++){
        cin>>x>>y;
        adj[x].pb(y);        
        adj[y].pb(x);
    }        
    vector<ll> v;
    // v.pb(1);
    dfs(adj, v, 1);
    for(i=1;i<=n;i++){
        cout<<dp[i]<<"\n";
    }
}    
    

Measured memory_bytes: 34508
import sys
from itertools import permutations

N = int(sys.stdin.readline())
prev, prev_delay = None, None
out = []
for _ in range(5):
    x = int(sys.stdin.readline())
    if prev is None or prev >= x:
        d = N // x
        r = N % x
        prev = x
        prev_delay = d + (1 if r > 0 else 0)
    else:
        prev = x
    out.append(prev_delay)

ret = out[0]
max_delay = ret
for x in out[1:]:
    ret += max(0, x - max_delay) + 1
    if x > max_delay:
        max_delay = x
print(ret)

Measured memory_bytes: 3064
from collections import Counter

def read():
    N = int(input())
    A = list(map(int, input().split()))
    return N, A

def nC2(n):
    if n < 2:
        return 0
    return n * (n-1) // 2

def solve(N, A):
    counter = Counter(A)
    nc2_sum = sum([nC2(n) for _, n in counter.items()])
    for k in range(N):
        n = counter[A[k]]
        u = nc2_sum - nC2(n) + nC2(n-1)
        print(u)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 26772
# coding: utf-8

n = int(input())
a = list(map(int, input().split()))

# aの要素は1以上であるため、前方からの総和の数列sについて
# 同一の数値がでてきたとき、和が0になる連続する部分数列がある
# 例
# A = [1, 3, -4, 2, 2, -2]
# S = [1, 4, 0, 2, 4, 2]
# S_3:5 = S_5 - S_2 =(Sum(A_1:5) - Sum(A_1:2)) = 0
#


ans = 0
s = 0
# 総和順列の値について、値と個数の辞書を用意する
l ={0:1}


for i in a:
    # 数列の現在位置までの総和をカウント
    s += i
    if s in l:
        ans += l[s]
        l[s] += 1
    else:
        l[s] = 1

print(ans)

Measured memory_bytes: 39540
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CountMedian | diff CountMedian.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CountMedian.cpp && ./a.out

/*

 5/31/2020

 5:21-6:01 AC

 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N];
int N;

LL f(LL good, LL bad) {
  while(abs(good-bad)>1) {
    LL m=(good+bad)/2;
    LL a=0,b=0,c=0;
    REP(i,N) {
      if(B[i]<m) ++a;
      else if(A[i]>m) ++b;
      else ++c;
    }
    LL l1=a,r1=N-b,l2=N/2-(1-(N%2)),r2=N/2+1;
    bool res=l2>=l1&&r2<=r1;
    //dump(m,res,a,b,c,l1,r1,l2,r2);
    (res?good:bad)=m;
  }
  return good;
}
void solve() {
  if(N%2==0) REP(i,N)A[i]*=2,B[i]*=2;
  vector<LL> xs(A,A+N),ys(B,B+N);
  sort(ALL(xs)),sort(ALL(ys));
  LL med1=xs[N/2],med2=ys[N/2];
  if(N%2==0) med1=(med1+xs[N/2-1])/2,med2=(med2+ys[N/2-1])/2;
  //LL mina=*min_element(A,A+N),maxb=*max_element(B,B+N);
  LL lb=med1,hb=med2;
  //LL lb=f(med1, mina-1),hb=f(med2, maxb+1);
  //dump(med1,med2,lb,hb);
  cout<<hb-lb+1<<endl;
}

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

  cin>>N;
  REP(i,N) cin>>A[i]>>B[i];
  solve();

  return 0;
}


Measured memory_bytes: 9540
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> march(5, 0);
    rep(i, n) {
        string s; cin >> s;
        if (s[0] == 'M') march[0]++;
        else if (s[0] == 'A') march[1]++;
        else if (s[0] == 'R') march[2]++;
        else if (s[0] == 'C') march[3]++;
        else if (s[0] == 'H') march[4]++;
    }
    ll ans = 0;
    for(int i = 1; i < 32; i++) {
        ll count = 1;
        if(bitset<5>(i).count() == 3) {
            for(int j = 0; j < 5; j++) {
                if(i & 1 << j) count *= march[j];
            }
            ans += count;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;

int main() {
    string a;
    cin >> a;
    ll count_r=0,count_l=0;
    bool check=true;
    vl ans(a.size());
    for (ll i=0;i<a.size();++i){
        ans[i]=0;
    }
    for (ll i=0;i<a.size();++i){
        if (check){
            if (a[i]=='R'){
                ++count_r;
            }else{
                check=false;
                ans[i-1]+=count_r/2+count_r%2;
                ans[i]+=count_r/2;
                count_r=0;
            }
        }else if(a[i]=='R'){
            ++count_r;
            check=true;
        }
    }
    check=true;
    for (ll i=0;i<a.size();++i){
        if (check){
            if (a[a.size()-i-1]=='L'){
                ++count_l;
            }else{
                check=false;
                ans[a.size()-i]+=count_l/2+count_l%2;
                ans[a.size()-i-1]+=count_l/2;
                count_l=0;
            }
        }else if(a[a.size()-i-1]=='L'){
            ++count_l;
            check=true;
        }
    }
    for (ll i=0;i<a.size();++i){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}



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

ll solve()
{
    ll N,ans,m2;
    ans = 0;
    cin >> N;
    m2 = 0;
    /*
    for (ll m = 2; m <= N; ++m) {
        if (N > m * m) continue;
        if (N / m == N % m) {
            m2 = N / m;
            cout << N << " = " << m << " * " << m2 << " + " << m2 << endl;
            //break;
        }
    }
    if (m2 == 0) {
        return 0;
    }
    */
    m2 = (ll)pow(N, 0.5)+1;

    for (ll m = 1; m <= m2; ++m) {
        if (N % m == 0) {
            ll b = N / m - 1;
            if (b != 0) {
                if (N / b == N % b) {
                    ans += b;
                }
            }
        }
    }
    return ans;
}

int main()
{
    cout << solve() << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <deque>
#include <stdlib.h>

using namespace std;



int main(){
    deque<int>A;
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int req;
        cin >> req;
        if (req==0){
            int d, x;
            cin >> d >> x;
            if (d==0){
                A.push_front(x);
            }else{
                A.push_back(x);
            }
            
        }else if(req==1){
            int p;
            cin >> p;
            cout << A[p] << endl;
        }else{
            int d;
            cin >> d;
            if (d==0){
                A.pop_front();
            }else{
                A.pop_back();
            }
        }
    }

}



Measured memory_bytes: 4640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;cin>>n;vector<int>a(n);for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    if(a[i]%2==1 && i%2==0)c++;
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3612
// Problem : E - Double Factorial
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N;
	cin>>N;
	if(N%2!=0)
	{
		cout<<0<<nl;
		return 0;
	}
	ll k=10,ans=0;	
	while(k<=N)
	{
		ans+=N/k;
		k*=5;
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3592
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

long long int gcd(long long int a, long long int b)
{
	if (b == 0)
	{
		return a;
	}
	return gcd(b, a%b);
}

vector <long long int> prime;
void eratos(void)
{
	bool isprime[1000001];
	memset(isprime, true, sizeof(isprime));
	isprime[1] = false;
	for (int i = 2; i <= 1000000; i++)
	{
		if (isprime[i])
		{
			prime.push_back(i);
			for (int j = 2 * i; j <= 1000000; j += i)
			{
				isprime[j] = false;
			}
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long int a, b, g;

	cin >> a >> b;
	g = gcd(a, b);
	eratos();

	int res = 1;
	for (int i = 0; i < prime.size(); i++)
	{
		if (g == 1)
		{
			break;
		}
		if (g%prime[i] == 0)
		{
			res++;
			while (1)
			{
				if (g%prime[i] != 0)
				{
					break;
				}
				g /= prime[i];
			}
		}
	}
	if (g != 1)
	{
		res++;
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
int mini = A * X + B * Y;

int maxXY = max(X,Y), yen;
rep(ab, 0, maxXY+1){
	yen = 2 * C * ab;
	if (X > ab) yen += A * (X - ab);
	if (Y > ab) yen += B * (Y - ab);
	mini = min(mini, yen);
	
}
cout << mini << "\n";

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 998244353;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    ll n, k;
    cin >> n >> k;
    vector<int> a = inp(n);

    // dp[i][j] := i番目の点から 2^j 個次の点を格納する
    vector<vector<int>> dp(n, vector<int>(62, -1));

    rep(i, n) {
        dp[i][0] = a[i] - 1;
    }
    rep(j, 61) {
        rep(i, n) {
            dp[i][j + 1] = dp[dp[i][j]][j];
        }
    }
    
    ll ans = 0;
    ll mask = 1;
    ll cnt = 0;
    while (mask <= k) {
        if (mask & k) ans = dp[ans][cnt];
        mask <<= 1;
        ++cnt;
    }

    Cout(ans + 1);

    return 0;
}


Measured memory_bytes: 58708
import numpy as np
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))


directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def serch(x, count):
    #print("top", x, count)

    for d in directions:
        nx = d+x
        # print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)

    return count


N = int(input())
s = list(input())


def chk(init_tf):
    tf = [-1]*(N)

    tf[0:2] = init_tf
    for i in range(2, N):
        if tf[i-1] == 1:
            if s[i-1] == "o":
                # d[i]=d[i-2]
                tf[i] = tf[i-2]
            else:
                tf[i] = (tf[i-2]+1) % 2

        if tf[i-1] == 0:
            if s[i-1] == "o":
                tf[i] = (tf[i-2]+1) % 2
            else:
                tf[i] = tf[i-2]
    """ 
    print(tf)
    print(s)
     """

    for i in range(N):
        
        r=(i+1)%(N)
     #   print(i,r)
        if tf[i] == 1:
            if s[i]=="o":
                if tf[i-1] !=tf[r]:
                    return False       
            else:
                if tf[i-1] == tf[r]:
                    return False

        elif tf[i] == 0:
            if s[i] == "x":
                if tf[i-1] != tf[r]:
                    return False
            else:
                if tf[i-1] == tf[r]:
                    return False

    return ["S" if x == 1 else "W" for x in tf]


for i in range(2):
    for j in range(2):
        res=chk((i,j))
        if res:
            print("".join(res))
            sys.exit()

print(-1)




Measured memory_bytes: 15016
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    D = string_to_int(inputs[0])
    sum_good = 0

    for i, d in enumerate(D):
        for j in range(i + 1, len(D)):
            sum_good += D[i] * D[j]
    return sum_good


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3060
#include<stdio.h>
#include <string.h>
#include <stdlib.h>


int sift(int l, int r);

int main(){

	int *a, *b;
	char buf[256];
	int i, j, k, n, sumb, ret, ch;
	char *s, *t;
	int ball=0;
	int binb=1;
	
	if(fgets(buf, 256, stdin) == NULL){
		
		return 1;
		
	}
	
	n=atoi(buf);
	
	//printf("n=%d\n", n);
	
	a=(int *)malloc(sizeof(int)*n);
	b=(int *)malloc(sizeof(int)*n);
	
	//s=(char *)malloc(sizeof(char)*2*n);
	
//	if(fgets(s, 2*n, stdin) == NULL){
//		
//		return 1;
//		
//	}
	
	for(j=0; j < n; j++){
		
		ret=scanf("%d", &a[j]);
		
		
	}
	
	//printf("n=%d\n", n);
	//printf("s=%s\n", s);
	
	//i=0;
	
//	while((ch = getchar()) != EOF){
//		
//			if(ch != 32 && ch != 10){a[i++]=(ch-48);}
//		//printf("ch=%d\n", ch);
//		//printf("a[%d]=%d\n", i-1, a[i-1]);
//		
//	}
	
	//t=strtok(s, " ");
	//printf("t=%s\n", t);
	//a[i++]=atoi(t);

//	while(t != NULL){
//		//printf("t=%s\n", t);
//		a[i++]=atoi(t);
//		t=strtok(NULL, " ");
//		
//		
//	}
	
	for(i=0; i < n; i++){
		
		b[i]=0;
		
	}
	
	//printf("n=%d\n", n);
	
	for(j=n-1; j >= 0; j--){
		
		//printf("j=%d, n/2=%d\n", j, n/2);
		
		if(j > (n/2 - 1)){b[j]=a[j];}
		else{
			
			sumb=0;
			
			for(k = (n/(j+1)); k > 1; k--){
				
				sumb=sumb+b[k*(j+1)-1];
				//printf("j=%d, k=%d, sumb=%d\n", j, k, sumb);
			}
			//printf("j=%d, k=%d, sumb=%d\n", j, k, sumb);
			if(sumb % 2 == a[j]){b[j]=0;}
			else{b[j]=1;}
			
		}
		
	}
	
	//printf("n1=%d\n", n);
	
	for(i=0; i < n; i++){
		
		ball=ball+b[i];
		//printf("b[%d]=%d\n", i, b[i]);
		
	}
	
	//printf("ball=%d\n", ball);
	printf("%d\n", ball);
	
	for(i=0; i < n; i++){
		
		if(b[i] == 1){
		
		if(binb == ball){printf("%d\n", i+1);}
		else{
			printf("%d ", i+1);
			binb++;
		}
			
		}
		
	}
	
	free(a);
	free(b);
	
	
}

Measured memory_bytes: 2432
package main

import (
	"fmt"
	"math"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var a, b, n float64
	fmt.Scan(&a, &b, &n)

	x := float64(min(int(b-1), int(n)))
	fmt.Println(int(math.Floor(a*x/b)) - int(a)*int(math.Floor(x/b)))
}


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

int main()
{
	int a,b,x1,x2;
	float f1,f2;
	cin>>a>>b;
	
	for(int i=1;i<=10000;i++)
	{
		f1=i*0.08;
		f2=i*0.1;
		if((int)f1-f1<=0.5)
			x1=f1;
		else
			x1=f1,x1++;
		
		if((int)f2-f2<=0.5)
			x2=f2;
		else
			x2=f2,x2++;
		
		if(x1==a && x2==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::cmp::max;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let hs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let mut max_h: usize = 0;
  let mut temp: usize = 0;
  for i in 1..n {
    if hs[i-1] >= hs[i] {
      temp += 1;
    } else {
      max_h = max(max_h, temp);
      temp = 0;
    }
  }
  max_h = max(max_h, temp);
  println!("{}", max_h);
}

Measured memory_bytes: 8444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int H  =scn.nextInt(), W = scn.nextInt();
		int N = scn.nextInt();
		
		int D = Math.max(H, W);
		System.out.println((N-1)/D + 1);
	}

}


Measured memory_bytes: 21844
number_of_rows, number_of_columns = list(map(int, input().split(" ")))
rows = [list(map(int, input().split(" "))) for i in range(number_of_rows)]

for j in range(number_of_rows):
    for k in range(number_of_columns ):
        if k == number_of_columns - 1:
            print(rows[j][k],end=" ")
            print(sum(rows[j]))
            rows[j].append(sum(rows[j]))
        else:
            print(rows[j][k],end=" ")
ans = []

for l in range(number_of_columns + 1):
    plus = 0
    for m in range(number_of_rows):
        plus += rows[m][l]
    ans.append(plus)
for n in range(number_of_columns + 1):
    if n == number_of_columns:
        print(ans[n])
    else:
        print(ans[n],end=" ")


Measured memory_bytes: 6220
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <ctype.h>

#define LENGTH 1000000

int countDigit(char *s){
  int i;
  for(i=0;isdigit(s[i]);i++);
  return i;
}

int main(int argc, char *argv[])
 // argc は実行時引数の個数 +1
// argv[0] はプログラム名, argv[1] から順に実行時引数
{
  int n;
  int i;
  int j;
  int k;
  int l;
  int cnt;
  int tmp;
  
    char x[1000000]={0};
      char y[1000000]={0};
 
    while(scanf("%d",&n),n)
      {
        cnt=0;
        scanf("%s",x);
	
        while(n--)

	  {
            cnt=0;
            for(k=0;x[k]!='\0';k++)
	      {
		
                for(l=1;x[k]==x[k+l-1];l++);
                tmp=l-1;
                l--;
		
                if(l>99)
		  {
                    y[cnt++]=l/100+'0';
                    l%=100;
                    y[cnt++]=l/10+'0';
                    l%=10;
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
	
		else if(l<=9)

		  {
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
			else 

		  {
                    y[cnt++]=l/10+'0';
                    l%=10;
                    y[cnt++]=l+'0';
                    y[cnt++]=x[k];
                }
                k=k+tmp-1;
            }
            for(k=0;k<1000000;k++)

	      {
                x[k]=y[k];
                y[k]=0;
            }
        }
    printf("%s\n",x);
    }
    return 0;
}



Measured memory_bytes: 3684
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, k, s;
    cin >> n >> k >> s;
    int r = s + 1;
    if (s==1000000000)
        r = 23553;
    rep(i, k) cout << s << ' ';
    repk(i, k, n) cout << r << ' ';
    cout << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
int main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double ans,t;
	t=0.5*m+30*h-6*m;
	if(t<0)
	t=-t;
	ans=sqrt(a*a+b*b-2*a*b*cos(t*3.1415926536/180));
	cout<<fixed<<setprecision(20)<<ans;
	return 0;
}

Measured memory_bytes: 4052
s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0 for _ in range(lt + 1)] for _ in range(ls + 1)]
# dp[si][ti] = si文字目までとti文字目までのLCS長

for si in range(ls):
    for ti in range(lt):
        if s[si] == t[ti]:
            dp[si + 1][ti + 1] = max(dp[si + 1][ti + 1], dp[si][ti] + 1)

        dp[si + 1][ti + 1] = max(dp[si + 1][ti + 1], dp[si + 1][ti])
        dp[si + 1][ti + 1] = max(dp[si + 1][ti + 1], dp[si][ti + 1])

ans = ''
si = ls
ti = lt
while si > 0 and ti > 0:
    if dp[si][ti] == dp[si - 1][ti]:
        si -= 1
    elif dp[si][ti] == dp[si][ti - 1]:
        ti -= 1
    else:
        ans = s[si - 1] + ans
        si -= 1
        ti -= 1
print(ans)


Measured memory_bytes: 121308
#include "bits/stdc++.h"

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

LL GCDr(LL m, LL n) {
  return n ? GCDr(n, m % n) : m;
}
LL GCD(LL m, LL n) {

  if (m < n) {
    swap(m, n);
  }

  while (n != 0) {
    LL n_new = m % n;
    m = n;
    n = n_new;
  }
  return m;
}

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}

vector<LL> CD(LL A) {
  vector<LL> S;
  LL i = 1;
  while (i * i <= A) {
    if (A % i == 0) {
      //cerr << i << endl;;
      //cerr << gcd/i << endl;;
      S.push_back(i);
      S.push_back(A / i);
    }
    i++;
  }
  return S;
}

vector<pair<LL, LL>> soinsu_bunkai(LL A) 
{
  vector<pair<LL, LL>> result;
  for (LL i = 2; i * i <= A; ++i) {
    if (A % i != 0) {
      continue;
    }
    result.push_back(make_pair(i, 0));
    while (A % i == 0) {
      A /= i;
      result.back().second++;
    }
  }
  if (A != 1) {
    result.push_back(make_pair(A, 1));
  }

  return result;
}


void func() {
  LL A, B;
  cin >> A >> B;
  // A,Bの共通する約数は最大公約数の約数
  LL gcd = GCDr(A, B);
  auto S = soinsu_bunkai(gcd);
  for (auto s : S) {
     //cerr << s.first << " " <<s.second <<  endl;
  }
  LL cnt = S.size();
  cout << cnt + 1;

}


void func_() {
  LL A, B;
  cin >> A >> B;
  
  LL i = 1;
  set<LL> SA;
  set<LL> SB;
  while (i * i <= A) {
    if (A % i == 0) {
      //cerr << i << endl;
      //cerr << N/i << endl;
      SA.insert(i);
      SA.insert(A / i);
    }
    i++;
  }

  i = 1;
  while (i * i <= B) {
    if (B % i == 0) {
      //cerr << i << endl;
      //cerr << N/i << endl;
      SB.insert(i);
      SB.insert(B / i);
    }
    i++;
  }
  set<LL> S;
  set_intersection(ALL(SA), ALL(SB), std::inserter(S, S.end()));

  LL cnt = 0;
  for (auto s : S) {
    //cerr << s << endl;
    if (isPrime(s)) {
      cnt++;
      //cerr << s << endl;
    }
  }
  cout << cnt + 1;

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(a) cout << #a << " := " << (a) << endl
#define all(a) (a).begin(), (a).end()
using namespace std;
void solve();
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
}

const int INF = (int) 1e18 + 7;

int get_ans(int n, int c, vector<pair<int, int>> a){
    int res = 0;
    vector<int> conter(n + 1); int cur = 0;
    for (int i = n - 1; i >= 0; --i){
        cur += a[i].second;
        conter[i] = max(conter[i + 1], cur - (c - a[i].first))
                ;
    }
    cur = 0;
    for (int i = 0; i < n; ++i){
        cur += a[i].second;
        res = max(res, cur - a[i].first + conter[i + 1] - (i != n - 1) * a[i].first);
    }
    return max(res, conter[0]);
}


void solve(){
    int n, c; cin >> n >> c;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
    int res1 = get_ans(n, c, a);
    for (int i = 0; i < n; ++i) a[i].first = c - a[i].first; reverse(all(a));
    int res2 = get_ans(n, c, a);
    cout << max(res1, res2);


}

Measured memory_bytes: 4224
list=["a","b",'c','d',"e","f","g",'h',"i","j",'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s=input()
ans=0
for i in list:
	if i not in s:
		print(i)
		ans=i
		break
if ans==0:
	print("None")

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(2e6)+10;
const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

void solve () {
    ll ans = 0;
    int n;cin>>n;
    // Contribution of The Nodes.
    for (int i=1;i<=n;i++) {
        ans += i * 1ll * (n-i+1);
    }
    for (int i=1;i<n;i++) {
        int u,v;cin>>u>>v;
        int a = max(u,v);
        int b = min(u,v);
        ans -= b * 1ll * (n-a+1);
    }
    cout<<ans<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<ll> s(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld", &s[i]);
    }

    ll ans=0;   // A=n-1

    for(i=1; i<=(n-1)/2; i++) {
        ll sum=0;
        int curr0=0, curr1=n-1;
        int k;
        for(k=1; k<=(n-1)/i; k++) {
            int curr0_prev = curr0;
            curr0 = curr0 + i;
            curr1 = curr1 - i;
            if(curr0_prev==curr1 || curr0==curr1 || curr1<=i) {
                break;
            }
            sum+=s[curr0]+s[curr1];
            ans = MAX(ans, sum);
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1152