akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str,str1;
    string st = "es";
    string stt= "s";
    cin>>str;
  int  x=str.size();
    //cout<< x;
    if(str[x-1]=='s')
    {
        str1=str + st;
        cout<<str1<< "\n";
    }
    else
    {
        str1= str+stt;
        cout<<str1<< "\n";
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> point(n);
  vector<pair<int,int>> cpoint(m);
  rep(i,n){
    int x,y;
    cin >> x >> y;
    point[i]={x,y};
  }
  rep(i,m){
    int x,y;
    cin >> x >> y;
    cpoint[i]={x,y};
  }
  rep(i,n){
    int dis = 1 << 30;
    int res = -1;
    rep(j,m){
      if (abs(cpoint[j].first-point[i].first) + abs(cpoint[j].second-point[i].second) < dis){
        dis = abs(cpoint[j].first-point[i].first) + abs(cpoint[j].second-point[i].second);
        //cout << dis << endl;
        res = j+1;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
from collections import Counter

N = int(input())
arr = input()
west_side = Counter()
east_side = Counter(arr)
costs = []

for i in range(N):
    leader = arr[i]
    east_side[leader] -= 1

    costs.append(west_side['W'] + east_side['E'])
    west_side[leader] += 1

print(min(costs))


Measured memory_bytes: 15820
import Data.List
import Data.Char
import Data.Functor
import Control.Monad
import qualified Data.ByteString.Char8 as B

main :: IO()
main = do
  (n:_) <- getInts
  forM_ [1..n] $ \_ -> do
    xs <- getInts
    putStrLn $ if f xs then "YES" else "NO"

f :: [Int] -> Bool
f xs = (a*a)+(b*b)==(c*c)
  where (a:b:c:_) = sort xs

getInts :: IO[Int]
getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

Measured memory_bytes: 4020
#include <iostream>

using namespace std;

typedef long long int ll;

const int MAX_N = 100;

int main () {
    int n;
    ll B[MAX_N];
    ll ans = 0;

    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans += B[i];
        } else if (i == n - 1) {
            ans += B[i - 1];
        } else {
            ans += min(B[i - 1], B[i]);
        }
    }

    cout << ans << endl;
}


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

int main(void)
{
    int n, k;
    double p = 0;
    cin >> n >> k;

    for (int c = 1; c <= n; c++) {
        int c_ = c;
        for (int x = 0; x <= 17; x++) {
            if (c_ >= k) {
                p += 1.0 / n * pow(0.5, x);
                break;
            }
            c_ *= 2;
        }
    }
    cout << setprecision(12) << p << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int m, d; cin >> m >> d;
    int ans = 0;
    loop1 (m, mi) loop1 (d, di) {
        int d1 = di % 10, d10 = di / 10;
        if (d1 >= 2 && d10 >= 2 && d1 * d10 == mi) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
  int t[100001]={0},n,l,r,sum=0,T,max;
  cin>>n>>T;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    t[l]++;
    t[r]--;
  }
  max=0;
  for(int i=0;i<=T;i++){
    sum+=t[i];
    if(sum>max)max=sum;
  }
  cout<<max<<endl;
  
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

#define popc(x) __builtin_popcount(x)

void test(){
  map<int,int> mem;
  mem[0] = 0;
  mem[1] = 1;
  mem[2] = 1;
  auto f = [&](auto&& f,int x)->int{
    if(mem.count(x))return mem[x];
    return mem[x] = f(f,x%popc(x))+1;
  };
  int lim = 1000000;
  for(int i=0;i<lim;++i){
    //cout<<i<<" : "<<f(f,i)<<endl;
    if(f(f,i)>10)cout<<i<<endl;
  }
}

map<ll,ll> mem;
ll f(ll x){
  if(mem.count(x))return mem[x];
  return mem[x] = f(x%popc(x))+1;
}

signed main(){

  //test();return 0;

  ll n;
  string s;
  cin>>n>>s;

  mem[0] = 0;
  mem[1] = 1;
  mem[2] = 1;

  reverse(begin(s),end(s));
  ll mod = 0;
  rep(i,n)if(s[i]=='1')mod++;
  if(mod==0){
    rep(i,n)cout<<1<<endl;
    return 0;
  }
  
  if(mod==1){
    if(s[0]=='1'){
      rep(i,n-1)cout<<2<<endl;
      cout<<0<<endl;
      return 0;
    }else{
      reverse(begin(s),end(s));
      rep(i,n-1){
        if(s[i]=='1')cout<<0<<endl;
        else cout<<1<<endl;
      }
      cout<<2<<endl;
      return 0;
    }
  }

  ll moda = mod+1;
  ll modb = mod-1;
  vector<ll> pa(n),pb(n);
  pa[0] = pb[0] = 1;
  rep(i,n-1){
    pa[i+1] = (pa[i]*2)%moda;
    pb[i+1] = (pb[i]*2)%modb;
  }
  ll ma=0,mb=0;

  rep(i,n)if(s[i]=='1'){
    ma += pa[i];
    mb += pb[i];
    ma %= moda;
    mb %= modb;
  }

  vector<ll> ans(n);
  rep(i,n){
    if(s[i]=='1'){
      ll x = (mb+modb-pb[i])%modb;
      ans[i] = f(x)+1;
    }else{
      ll x = (ma+pa[i])%moda;
      ans[i] = f(x)+1;
    }
  }

  reverse(begin(ans),end(ans));
  for(auto x:ans)cout<<x<<endl;

}

Measured memory_bytes: 9340
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 400005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

ll n;
struct seg
{
    ll s[N*3];
    ll lazy[N*3];
    void build()
    {
        for(ll i=1;i<N*3;i++)
        {
            s[i]=n;
            lazy[i]=-1;
        }
    }
    void lazyDown(ll node,ll l,ll r)
    {
        if(lazy[node]!=-1)
        {
            lazy[node*2]=lazy[node];
            lazy[node*2+1]=lazy[node];
            s[node*2]=s[node*2+1]=lazy[node];
            lazy[node]=-1;
        }
        return;
    }
    ll query(ll node,ll l,ll r,ll p)
    {
        if(p<l||r<p) return n;
        if(l==r)
        {
            return s[node];
        }
        lazyDown(node,l,r);
        return min(query(node*2,l,(l+r)/2,p),query(node*2+1,(l+r)/2+1,r,p));
    }
    void update(ll node,ll l,ll r,ll b,ll e,ll R)
    {
        if(e<l||r<b)
            return;
        if(b<=l&&r<=e)
        {
            s[node]=R;
            lazy[node]=R;
            return;
        }
        lazyDown(node,l,r);
        update(node*2,l,(l+r)/2,b,e,R);
        update(node*2+1,(l+r)/2+1,r,b,e,R);
    }
};
seg row,col;

main()
{
    ll q;
    cin>>n>>q;
    row.build();
    col.build();
    ll ans=(n-2)*(n-2);
    while(q--)
    {
        ll t;
        cin>>t;
        ll x;
        cin>>x;

        if(t==1)
        {
            ll now=col.query(1,1,n,x);
            if(now>=3)
            {
                ans-=now-2;
            }
            if(now>1&&row.query(1,1,n,now-1)>x)
            {
                row.update(1,1,n,1,now-1,x);
            }
        }
        else
        {
            ll now=row.query(1,1,n,x);
            if(now>=3)
            {
                ans-=now-2;
            }
            if(now>1&&col.query(1,1,n,now-1)>x)
            {
                col.update(1,1,n,1,now-1,x);
            }
        }
    }
    cout<< ans;

}


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

const int MAXN = 505;
char blue[MAXN][MAXN];
char red[MAXN][MAXN];

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
		{
			char hj;
			cin >> hj;
			red[i][j] = hj;
			blue[i][j] = hj;
		}

	for (int i = 0; i < h; i+=2)
		for (int j = 1; j < w-1; j++)
			red[i][j] = '#';

	for (int i = 1; i < h; i+=2)
		for (int j = 1; j < w-1; j++)
			blue[i][j] = '#';

	for (int i = 0; i < h; i++)
	{
		blue[i][0] = '#';
		red[i][w-1] = '#';
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cout << blue[i][j];
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cout << red[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	int N,L;
	cin>>N>>L;
	vector<string> S(N);
	rep(i,N)cin>>S[i];
	sort(all(S));
	rep(i,N)cout<<S[i];
	cout<<endl;
}

Measured memory_bytes: 256
# coding: utf8

def read_int():
    return int(input())
 
 
def read_int_n():
    return list(map(int, input().split()))
 
 
def read_str():
    return input()
 
 
def read_str_n():
    return list(map(int, input().split()))

def main():
    a,b,c = read_int_n()
    if a-b > c:
        print(0)
    else:
        print(c - a + b)

main()

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

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C);
    for (int i = 0; i < A; i++) cin >> P[i];
    for (int i = 0; i < B; i++) cin >> Q[i];
    for (int i = 0; i < C; i++) cin >> R[i];
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    sort(R.begin(), R.end());
    vector<ll> eatpq;
    for (int i = 0; i < X; i++) eatpq.push_back(P[A-1-i]);
    for (int i = 0; i < Y; i++) eatpq.push_back(Q[B-1-i]);
    sort(eatpq.begin(), eatpq.end());
    ll ans = 0;
    ll now = 0;
    for (int i = 0; i < X+Y; i++) now += eatpq[i];
    ans = now;
    for (int i = 0; i < min(C, X+Y); i++) {
        now = now - eatpq[i] + R[C-1-i];
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

ll dx[] = { 1, 0 };
ll dy[] = { 0, 1 };

int main()
{
	ll H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (ll i = 0; i < H; i++)
	{
		cin >> a[i];
	}
	queue<pair<ll, ll>> location;
	location.push(make_pair(0, 0));
	while (!location.empty())
	{
		pair<ll, ll> place = location.front();
		location.pop();
		ll x = place.first, y = place.second;
		a[y][x] = '.';
		for (ll i = 0; i < 2; i++)
		{
			if (x + dx[i] < W && y + dy[i] < H)
			{
				if (a[y + dy[i]][x + dx[i]] == '#')
				{
					location.push(make_pair(x + dx[i], y + dy[i]));
					break;
				}
			}
		}
	}
	for (ll i = 0; i < H; i++)
	{
		for (ll j = 0; j < W; j++)
		{
			if (a[i][j] == '#')
			{
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(map(int, input()))
z = []
o = []
zj = 0
oj = 0
for i in range(len(s)):
    if i % 2 == 0:
        z.append(0)
        o.append(1)
        if s[i] == 0:
            oj += 1
        else:
            zj += 1
    else:
        z.append(1)
        o.append(0)
        if s[i] == 0:
            zj += 1
        else:
            oj += 1
print(min(zj, oj))

Measured memory_bytes: 5504
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

const ll NMAX=100100;
const ll KMAX=110;
vll dp(KMAX,vl(NMAX,0));

int main(){
    map<ll,ll> mp;
    ll N,K;
    cin>>N>>K;
    REP2(i,1,N+1){
        ll j=N/i;
        mp[N/i]+=N/j-i+1;
        i=N/j;
    }

    ll m=mp.size();

    vl w(m);
    ll cnt=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        w[m-cnt-1]=itr->second;
        cnt++;
    }

    dp[0][0]=1;
    REP(i,K){
        vl sdp(NMAX+10,0);
        REP(j,w.size()){
            sdp[j+1]=(sdp[j]+dp[i][j])%MOD;
        }
        REP(j,w.size()){
            dp[i+1][j]=(w[j]*sdp[m-j])%MOD;
        }
    }

    ll ans=0;
    REP(i,NMAX){
        ans+=dp[K][i];
        ans%=MOD;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 94612
#include<stdio.h>
int main(void){
    char a[1200];
    int i,n=0;
    while(1){
        scanf("%c",&a[n]);
        if(a[n]=='\n'){
            break;
        }
        n++;
    }
    for(i=0;i<=n;i++){
        if(a[i]>=0x41&&a[i]<=0x5A){
            a[i]+=32;
        }else if(a[i]>=0x61&&a[i]<=0x7A){
            a[i]-=32;
        }
        printf("%c",a[i]);
    }
    return 0;
}


Measured memory_bytes: 2088
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T, vector<T>, greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16, mod2 = 998244353;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

string s;
int n;
string a;
int a1;
vector<string>cnt;
vector<int>cnt2;
signed main() {
	cin >> s;
	s.push_back('R');
	n = s.size();
	rep(i, n) {
		if (i == 0) {
			a.push_back(s[i]);
			a1++;
		}
		else {
			if (s[i - 1] == 'L' && s[i] == 'R') {
				cnt.push_back(a);
				cnt2.push_back(a1);
				a = "R";
				a1 = 1;
			}
			else {
				a.push_back(s[i]);
				if (s[i] == 'R') a1++;
			}
		}
	}
	rep(i, cnt.size()) {
		a = cnt[i];
		a1 = cnt2[i];
		int R = a1, L = a.size() - a1;
		int b1 = a1;
		rep(i, a1 - 1) cout << 0 << " ";
		if (a.size() - a1 > a1) b1 = a.size() - a1;
		if (b1 & 1) {
			if (abs(R - L) < 2) {
				cout << R << " " << L << " ";
			}
			else {
				if (R < L) cout << a.size() / 2 << " " << a.size() / 2 + a.size() % 2 << " ";
				else cout << a.size() / 2 + a.size() % 2 << " " << a.size() / 2 << " ";
			}
		}
		else {
			if (abs(R - L) < 2) {
				cout << L << " " << R << " ";
			}
			else {
				if (R < L) cout << a.size() / 2 + a.size() % 2 << " " << a.size() / 2 << " ";
				else cout << a.size() / 2 << " " << a.size() / 2 + a.size() % 2 << " ";
			}
		}
		rep(i, a.size() - a1 - 1) cout << 0 << " ";
	}
	cend;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

int main() {

	//dp[i][j]...i番目までの子でn個を分け合う組み合わせ
	//dp[i][j]...dp[i-1][j] 0個 + dp[i-1][j-1] 1個... + dp[i-1][j-ai] ai個
	//sum[i][j]...dp[i][0]+dp[i][1] + ... + dp[i][j]
	//dp[i][j] = sum[i-1][j] - sum[i-1][j-ai-1]

	int n, k;
	cin >> n >> k;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];

	vector<vector<ll>> dp(n, vector<ll>(k + 1, 0));
	vector<vector<ll>> sums(n, vector<ll>(k + 1, 0));
	for (int i = 0; i <= as[0]; i++) {
		dp[0][i] = 1;
		sums[0][i] = i + 1;
	}
	for (int i = as[0]+1; i <= k; i++) {
		sums[0][i] = sums[0][i-1];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[i][j] = sums[i - 1][j];
			if (j - as[i] - 1>= 0) {
				dp[i][j] += mod - sums[i - 1][j - as[i] -1];
			}
			dp[i][j] %= mod;
		}
		sums[i][0] = dp[i][0];
		for (int j = 0; j < k; j++) {
			sums[i][j + 1] = sums[i][j] + dp[i][j + 1];
			sums[i][j + 1] %= mod;
		}
	}
	cout << dp[n - 1][k] << endl;
	return 0;
}
	

Measured memory_bytes: 157552
#include <stdio.h>
int main(){
  int n , i,j;
  scanf("%d", &n);
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(i*j==n){
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){cin >> a[i];}
    int max = 0;
    int smax = 0;
    int maxnum = 0;

    for(int j=0;j<n;j++){
        if(max <= a[j]){
            maxnum = j;
            smax = max;
            max = a[j];
        }
        else if(smax < a[j]){
            smax = a[j];
        }
    }

    for(int k=0;k<n;k++){
        if(k != maxnum){cout << max << endl;}
        else{cout << smax << endl;}
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string a, b;
    cin >> a >> b;
    reverse(b.begin(), b.end());
    cout << (a == b ? "YES" : "NO") << endl;
}


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

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

    vector<int> h(n+1, 0);
    for (int i = 0; i < m; i++) {
        h[a[i]]++;
        h[b[i]]++;
    }

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

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

long H,W;

int main(){
    cin>>H>>W;
    
    if(H==1||W==1){
        cout<<1<<endl;
    }else if(H%2==0 || W%2==0){
        cout<<H*W/2<<endl;
    }else{
        cout<<H*W/2+1<<endl;
    }
}

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

// int main(){
//     string s;
//     cin >> s;
//     int n = s.size();
//     bool stkai = true;
//     for(int i =0; i < n/2; i++){
//         if(s.at(0) != s.at(n - 1 - i)) stkai = false;
//     }
//     for(int i =0; i < n/2; i++){
//         if(!(s.at(i) == s.at(n/2 - i -1) && s.at(n- 1 - i) == s.at(n/2 + 1 + i))){
//             stkai = false;
//         }
//     }
//     if(stkai) cout << "Yes" <<  endl;
//     else  cout << "No" << endl;
// }

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

bool iskaibun(string s){
    string t = s;
    reverse(t.begin(), t.end());
    if(t == s) return true;
    else return false;
}

int main(){
    string s;
    cin >> s;
    int m = s.size();
    m /= 2;
    string a = s.substr(0, m);
    if(iskaibun(s)&&iskaibun(a)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int main() {
    string S;
    cin >> S;

    if((S.at(2) == S.at(3)) && (S.at(4) == S.at(5))){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
return 0;
}

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

int main(){
    string s;
    cin >> s;
    int ans1 = 0;
    for(int i=0;i<s.size();i++){
        ans1 += s[i] - '0';
    }

    int ans2 = s[0]-'1' +(s.size()-1)*9;
    cout << max(ans1,ans2) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int x;
  int ans = 1;
  cin>>x;
  for(int i=2; i*i<=x; i++) {
    int p=2;
    while(pow(i,p)<=x) p++;
    ans = max(ans, (int)pow(i,p-1));
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        String s = sc.next();
        char[] code = s.toCharArray();
        String ans = "Good";
        for(int i = 0; i< code.length-1;i++){
            if(code[i]==code[i+1]){
                ans ="Bad";
            }
        }
        //System.out.println((s + s).contains(s2) ? "Yes" : "No");
        System.out.println(ans);

    }
}

Measured memory_bytes: 22996
import heapq
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()

i = 0
while True:
  if K**i > N:
    break
  i += 1
print(i)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    map<string, ll> m;
    string s;
    REP(i, N) {
        cin >> s;
        sort(ALL(s));
        m[s]++;
    }

    ll ans = 0;
    for (auto p : m) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    ll  t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;

    ll y1 = (a1-b1)*t1;
    ll y2 = (a2-b2)*t2;

    if (y1 > 0)
    {
        y1 *= -1LL;
        y2 *= -1LL;
    }

    // cout <<y1 << ' ' << y2 << ' ' << y1+y2 << endl;
    if (y1 +y2 < 0) 
    {
        cout << 0 << endl;
        return 0;
    }
    // cout << "**" << endl;
    if (y1 + y2 == 0)
    {
        cout << "infinity" << endl;
        return 0;
    }
    ll d = y1+y2;
    ll cnt = y1/d*(-2LL) + 1LL;
    // cout << "******" << endl;
    // cout << y1 << " " << d << endl;
    if (y1%d == 0) --cnt;
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    LL N,M;
    cin >> N >> M;
    LL ans=0;
    if(N>=M/2){
        ans=M/2;
    }
    else{
        ans+=N;
        M=M-N*2;
        ans+=M/4;
    }
    cout << ans;
}

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

int main(){
	ll N, K;
	cin >> N >> K;
	if(K % 2 == 0){
		ll m = K/2;
		ll a = N/m;
		if(a % 2 == 0){
			cout << 2*(a/2)*(a/2)*(a/2) << endl;
		}else{
			cout << (a/2)*(a/2)*(a/2) + ((a+1)/2)*((a+1)/2)*((a+1)/2) << endl;
		}
	}else{
		ll a = N/K;
		cout << a*a*a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	inputs := scanNums(N)
	res := true
	for i := 0; i < len(inputs)-1; i++ {
		if inputs[i] == inputs[i+1] {

		} else if inputs[i] <= inputs[i+1]-1 {
			inputs[i+1] = inputs[i+1] - 1
		} else {
			res = false
		}
	}
	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0};
const int dy[8]={0,1,0,-1};
int H, W;
char A[1000][1000];
bool used[1000][1000];
queue<pair<int, int> > q;

int main() {
  cin >> H >> W;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cin >> A[i][j];
      if(A[i][j] == '#') {
        q.push({i, j});
        used[i][j] = true;
      }
    }
  }
  int ans = -1;
  while(!q.empty()) {
    ans++;
    int len = q.size();
    for(int i = 0; i < len; ++i) {
      pair<int, int> p = q.front(); q.pop();
      for(int j = 0; j < 4; ++j) {
        int nx = p.first + dx[j];
        int ny = p.second + dy[j];
        if(nx < 0 || ny < 0 || nx >= H || ny >= W) continue;
        if(used[nx][ny]) continue;
        q.push({ nx, ny });
        used[nx][ny] = true;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10384
n=int(input())
a=list(map(int,input().split()))
a.sort()
k=max(a)

num_list=set()
prime_list=set()

from collections import Counter
dic=Counter(a)
a=set(a)

for i in dic:
  if dic[i]>=2:
    dic[i]=0
  if i not in num_list:
    for j in range(i*2,k+1,i):
      if j in a:
        dic[j]=0
        num_list.add(j)

print(sum(dic.values()))

      
  

Measured memory_bytes: 55212
#include<iostream>
using namespace std;
int main(){
  int n,tmp=0,ans=0;
  string s,t;
  cin>>n>>s;
  for(int i=1;i<n;i++,tmp=0){
    t=s.substr(i,n-i);
    s.erase(s.begin()+i,s.end());
    for(int j='a';j<='z';j++)tmp+=((int)s.find(j)!=-1&&(int)t.find(j)!=-1);
    ans=max(ans,tmp);
    s+=t;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  int i;
  long long sum = 0;
  for(i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  if(sum>=h) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3768
s = input().strip()

i = int(s[:2])
j = int(s[2:])

if 1 <= i <= 12:
    if 1 <= j <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= j <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
 using namespace __gnu_pbds;
 using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;

const int N = 5e3 + 10;

long double a[N],p[N];

clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int main()
{
  FIO;
   

  int n,last;
  cin>>n;

  int mark=-2,ans=0;
  bool flag=0;

  stack<int> s;

  forn(i,n)
  {
    cin>>last;
    s.push(last);
  }
  last=s.top();
  s.pop();

  while(!s.empty())
  {
    int cur=s.top();
    s.pop();

    if(cur>last)
    {
      last=cur;
      if(mark==-2)
        mark=1;
      else if(mark==-1)
      {
        mark=-2;
        ans++;
      }
    }
    else if(cur==last)
    {
      last=cur;
    }
    else //cur<last
    {
      last=cur;
      if(mark==-2)
      {
        mark=-1;
      }
      else if(mark==1)
      {
        mark=-2;
        ans++;
      }
    }
  }
  cout<<ans+1;
  return 0;
}

Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn not(b: bool) -> bool {
    if b {
        false
    } else {
        true
    }
}

fn fact(n: u64) -> u64 {
    if n == 0 {
        1
    } else {
        (n * fact(n - 1)) % 1000000007
    }
}

fn main() {
    let ab: Vec<i32> = read_vec();
    let a = ab[0];
    let b = ab[1];
    if b == 1 {
        println!("0");
    } else {
        println!("{}", (b - 2) / (a - 1) + 1);
    }
}


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

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x/gcd(x,y)*y;}

int main(void){
  int n, ans, t;
  
  cin >> n;
  ans = 1;
  for (int i=0; i<n; i++){
    cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3136
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    now = x
    now2 = x
    while True:
        f1 = now in p
        f2 = now2 in p

        if f1 and f2:
            now += 1
            now2 -= 1
            continue
        if f1 and not f2:
            ans = now2
            break
        if f2 and not f1:
            ans = now
            break
        if not f1 and not f2:
            ans = now2
            break
        # if now in p:
        #     if now2 in p:
        #         now += 1
        #         now2 -= 1
        #     else:
        #         print()
        # if now2 in p:
        #     if now in p:
        #         now += 1
        #         now2 -= 1
        #
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 9184
n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
p = [list(map(int, input().split()))+ [i] for i in range(q)]
l.extend(p)
l = sorted(l,key= lambda x:x[1])
ka = [0] * n
ans = []
for i in l:
  if len(i) == 2:
    ka[i[0]-1] += 1
  else:
    ans.append([i[2],sum(ka[i[0]-1:i[1]])])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int x;
  fscanf(stdin, "%d ", &x);
  puts(x==0 ? "1" : "0");
  return 0;
}


Measured memory_bytes: 3664
import Data.List

main = do
    s <- getLine
    putStrLn $ resovle s

resovle:: String -> String
resovle s 
  | not $ elem 'a' s = "No"
  | not $ elem 'b' s = "No"
  | not $ elem 'c' s = "No"
  | otherwise = "Yes"

Measured memory_bytes: 380
#include<stdio.h>
typedef long long ll;
int main(void)
{
  ll a,b,k;
  scanf("%lld %lld %lld",&a,&b,&k);

  if(b-a+1<2*k){
    for(ll i=a;i<=b;i++){
      printf("%lld\n",i);
    }
  }else{
    for(ll i=a;i<a+k;i++){
      printf("%lld\n",i);
    }
    for(ll i=b-k+1;i<=b;i++){
      printf("%lld\n",i);
    }

  }


  return 0;
}


Measured memory_bytes: 1728
use proconio::input;

fn main() {
    input! {
        n: isize
    }

    for a in 1..=3500 {
        for b in 1..=3500 {
            let denom = 4 * a * b - n * a - n * b;
            if denom == 0 {
                continue;
            }
            let numer = n * a * b;
            if numer % denom != 0 {
                continue;
            }
            
            let c = numer / denom;
            if c <= 0 {
                continue;
            }
            println!("{} {} {}", a, b, c);
            return;
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n, 0);
  vector<int> vec2(n, 0);
  
  for(int i = 0; i < n; i++){ 
    cin >> vec.at(i);
    vec2.at(i) = vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  if(vec.at(0) == vec.at(1)){
    for(int i = 0; i < n; i++)cout << vec.at(0) << endl;
  }
  else{
    for(int i = 0; i< n; i++){
      if(vec2.at(i) == vec.at(0)) cout << vec.at(1) <<endl;
      else cout << vec.at(0) << endl;
    }
    
  }
}

Measured memory_bytes: 3200
#include <stdio.h>
int main(){
  int i, N, sum=0, l, r;
  scanf("%d", &N);
  for (i=0; i<N; i++){
    scanf("%d%d", &l,&r);
    sum = sum + r - l + 1;
  }
  printf("%d", sum);
return 0;
}

Measured memory_bytes: 128
#素因数分解
def prime_factorize(x0):
    tmp_l = [1]
    if x0 == 1:
        return tmp_l
    if x0%2 == 0:
        tmp_l.append(2)
        while x0 % 2 == 0:
            x0 //=2
    if x0 > 2:
        i = 3
        while 1:
            if i > pow(x0,1/2):
                if x0 == 1:
                    break
                tmp_l.append(x0)
                break
            if x0 % i == 0:
                tmp_l.append(i)
                while x0 % i == 0:
                    x0 //= i   
            i+=2
    return tmp_l

#最大公約数
def gcd(x0, y0):
    if x0<y0:
        tmp0 = x0
        x0 = y0
        y0 = tmp0
    if y0 == 0:
        return x0
    else:
        return gcd(y0, x0 % y0)
        
a,b=map(int,input().split())

g = gcd(a,b)
print(len(prime_factorize(g)))

Measured memory_bytes: 3064
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;


template<typename T>
void ep_(const std::string& name, const T& val) {
    std::cerr << name << ": " << val << " ";
}

#define EP(val) ep_( #val, val )

int main()
{
    int64_t N, C;
    std::cin >> N >> C;

    struct S {
        int64_t x;
        int64_t v;
    };

    std::vector<S> sr;
    for (size_t i = 0; i < N; ++i) {
        S s;
        std::cin >> s.x >> s.v;
        sr.push_back(s);
    }


    std::sort(std::begin(sr), std::end(sr),
              [](const auto& a, const auto& b) {
                  return a.x < b.x;
              });

    auto sl = sr;
    std::reverse(std::begin(sl), std::end(sl));

    // 時計回り、反時計回りにi個食べた中でのベストエネルギ
    std::vector<int64_t> rmax, lmax;
    rmax.push_back(0);
    lmax.push_back(0);
    {
        int64_t rm, lm, re, le, rpos, lpos;
        rm = lm = re = le = rpos = 0;
        lpos = C;

        for (size_t i = 0; i < N; ++i) {
            re = re + sr[i].v - (sr[i].x - rpos);
            rm = std::max(rm, re);
            rmax.push_back(rm);
            rpos = sr[i].x;

            le = le + sl[i].v - (lpos - sl[i].x);
            lm = std::max(lm, le);
            lmax.push_back(lm);
            lpos = sl[i].x;
        }
    }

    int64_t rlmax, lrmax;
    {
        int64_t re, le, rpos, lpos;
        rlmax = lrmax = re = le = rpos = 0;
        lpos = C;

        for (size_t i = 0; i < N; ++i) {
            // i+1個目食べるかどうか判定

            // 時計回りに進んだパターン
            re = re + sr[i].v - (sr[i].x - rpos);
            // {もう食べない, いまの食べる, 今の食べて反時計回りに最大N-(i+1)個食べる}の中のベスト
            rlmax = std::max({rlmax, re, re + lmax[N-i-1] - sr[i].x});
            rpos = sr[i].x;

            // 反時計回りに進んだパターン
            le = le + sl[i].v - (lpos - sl[i].x);
            // {もう食べない, いまの食べる, 今の食べて時計回りに最大N-(i+1)個食べる}の中のベスト
            lrmax = std::max({lrmax, le, le + rmax[N-i-1] - (C - sl[i].x)});
            lpos = sl[i].x;
        }
    }

    std::cout << std::max(lrmax, rlmax) << std::endl;

    return 0;
}


Measured memory_bytes: 6256
import collections
import math

N = int(input())
a = list(map(int,input().split()))
a_counter = collections.Counter(a)

res = 0

for v in a_counter: # 全通り
    res += a_counter[v]*(a_counter[v]-1)//2

for v in a:
    befor = a_counter[v]*(a_counter[v]-1)//2
    after = (a_counter[v]-1)*(a_counter[v]-2)//2
    print(res-befor+after)



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

int32_t main()
{

    int n,cnt=0;
    cin>>n;


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

       if(n%i==0){
        cnt+=(n/i)-1;
       }
       else{
        cnt+=n/i;
       }

    }
    cout<<cnt<<endl;



    return 0;
}


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

int main()
{
    #define int long long
  fast
  int n,k;
  cin>>n>>k;
  
  bool vis[n] = {false};
  int dis[n] = {0};
  //int comp[n] = {0};

  vector<int>arr(n);
  for(int i = 0; i<n; i++) cin>>arr[i];
  int index = 0;
  int cycleSize = 0;
  int lastK = 0;
  for(int i = 1; i<=k; i++)
  {
    if(!vis[index])
    {
        //cout<<"index: "<<index<<endl;
      vis[index] = true;
      dis[index] = i;
      if(i<k) index = arr[index]-1;
    }
    else
    {
        //cout<<"conflict at: "<<index<<endl;
      cycleSize = i - dis[index];
      lastK = i;
      break;
    }
  }
  if(cycleSize == 0) cout<<arr[index];
  else
  {
    int jump = (k - lastK) % cycleSize;
    while(jump--)
    {
      index = arr[index] -1;
    }
    cout<<arr[index];
  }
  return 0;
}
  
      
    
  
  
  

Measured memory_bytes: 6636
from numpy import *

N = int(input())
P = list(map(int, input().split()))

l = zeros(N+1, dtype=int)

l[0] = P[0]
j = 0
for i in range(1, N):
    if P[i] < l[j]:
        l[j+1] = P[i]
        j += 1
    else:
        pass


count = 0
for i in range(N):
    if l[i] == 0:
        break
    count += 1

print(count)


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

namespace AtCoder.Contests.ABC169
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            //var a = NextLong();
            //var b = (long)(double.Parse(Next())*100);

            var a = decimal.Parse(Next());
            var b = decimal.Parse(Next());

            Console.WriteLine(Math.Floor(a * b));
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27616