akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<string> v;
    for (int i=1;i<=n;i++) {
        string s;
        cin >> s;
        sort (s.begin(),s.end());
        v.pb(s);
    }
    sort (v.begin(),v.end());
    v.pb("*");
    LL ans=0,cnt=0;
    for (int i=0;i<v.size()-1;i++) {
        //cout << v[i] << endl;
        if (v[i]==v[i+1]) cnt++;
        else {
            cnt++;
            ans+=(cnt)*(cnt-1)/2;
            cnt=0;
        }
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

ll a, b;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> a >> b;
    ll c = __gcd(a, b);
    ll ans = 0;
    for (ll i = 2; i * i <= c; ++i) {
        if (c % i == 0) {
            ++ans;
            c /= i;
            while (c % i == 0) c /= i;
        }
    }
    if (c != 1) ++ans;
    cout << ans + 1 << '\n';
    return 0;
}


Measured memory_bytes: 256
def fib(n: int, meolist: dict):
    if n == 0 or n == 1:
        meolist[n] = 1
        return 1
    elif n in meolist.keys():
        return meolist[n]
    
    meolist[n] = fib(n - 1, meolist) + fib(n - 2, meolist)
    return meolist[n]

if __name__ == '__main__':
    n = int(input())
    meolist = {}
    print(fib(n, meolist))


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    
    return 0;
}

Measured memory_bytes: 3652
# 優先度付きキュー
from heapq import heappush, heappop

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

jobs = {}
for _ in range(N):
    A, B = map(int, input().split())
    if A in jobs:
        jobs[A].append(B)
    else:
        jobs[A] = [B]

result = 0
candidates = []
for a in range(1, M + 1):
    if a in jobs:
        for b in jobs[a]:
            heappush(candidates, -b)
    else:
        if len(candidates) == 0:
            continue
    result += -heappop(candidates)
print(result)


Measured memory_bytes: 26072
#include<iostream>
#include<vector>

using namespace std;

int main(){
int n;cin>>n;
double x;
  string u;
  double ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>x>>u;
    double sum=x;
    if(u=="BTC")
       sum=sum*380000;
    ans+=sum;
  }
  cout<<ans<<endl;
}
       
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double n, m, d;
  cin >> n >> m >> d;
  cout << fixed << setprecision(10);
  if(d == 0) cout << 1.0 * (m - 1.0) / n << endl;
  else cout << 2.0 * (n - d) / n * (m - 1.0) / n << endl;
}

Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline

L = [int(v) for v in list(input().strip())]

for v in itertools.product(["+", "-"], repeat = 3):
    s = ""
    for i in range(len(L) - 1):
        s += "{}{}".format(L[i], v[i])
        
    s += str(L[-1])
    if eval(s) == 7:
        print(s + "=7")
        sys.exit()

Measured memory_bytes: 3064
n,k = map(int,input().split())
lis = list(map(int,input().split()))
dp = [10 ** 10 for i in range(n+k)]
dp[0] = 0
for i in range(n):
  for j in range(1,k+1):
    if i + j < n:
      dp[i+j] = min(dp[i+j],dp[i] + abs(lis[i+j]-lis[i]))
print(dp[n-1])


Measured memory_bytes: 56672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    float n,t,a,i;
    cin>>n>>t>>a;
    vector<float>v;
    for(i=0;i<n;i++)
    {
        float x;
        cin>>x;
        float l=t-(x*0.006);
        v.push_back(l);
    }
    float m=100000;
    for(i=0;i<v.size();i++)
    {
        m=min(m,abs(v[i]-a));
    }
    float d=100000;
    for(i=0;i<v.size();i++)
    {
        d=min(d,abs(v[i]-a));
        if(d==m)
        {
            cout<<i+1;
            return 0;
        }
    }

}


Measured memory_bytes: 3728
/*版权所有，拷贝必究！*/
/*若想获得，请联系许希泉*/
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
const int INF = 0x3f3f3f3f;
int maxn=5000005;
using namespace std;
struct node{

};
bool is_pal(string a)
{
    string s=a;
    reverse(s.begin(),s.end());
    if(s==a)
    return true;
    else
    return false;
}
bool is_prime(int n)
{
    if(n==1)
	return false;
    if(n==2||n==3)
	return true;
    if(n%6!=1&&n%6!=5)
	return false;
    for(register int i=5;i*i<=n;i+=6)
    if(n%i==0||n%(i+2)==0)
	return false;
    return true;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	string s1,s2,s;
    int n,t,m,x,y,p,mut=1,sum=0,maxv=0,minv=1E5;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
    for(int j=0;j<2;j++)
    {
    	cin>>a[i][j];
	}
	for(int i=0;i<n-2;i++)
    {
    	if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
    	{
    		cout<<"Yes";
    		return 0;
		}
	}
	cout<<"No";
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	char x,y;
	cin>>x>>y;
	if(x==y)cout<<"="<<endl;
	else cout<<((x<y)?'<':'>')<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;


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

	if(s[0]=='S') cout << "Cloudy" << endl;
	if(s[0]=='R') cout << "Sunny" << endl;
	if(s[0]=='C') cout << "Rainy" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// 各点到当前工厂的距离
int d[1024][1024];
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
int factory[16][2];
typedef pair<int, int> P;
 
 
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const int & sx 起点x
// Parameter: const int & sy 起点y
// Parameter: const int & gx 终点x
// Parameter: const int & gy 终点y
//************************************
int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
	//memset(d, -1, sizeof(d));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			d[j][i] = -1;
		}
	}
	queue<P> que;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size())
	{
		const P p = que.front(); que.pop();
		// 如果是终点就结束
		if (p.first == gx && p.second == gy)
		{
			break;
		}
 
		// 四方向漫游
		for (int i = 0; i < 4; ++i)
		{
			int nx = p.first + direction[i][0];
			int ny = p.second + direction[i][1];
			// 是否可以移动，并且该点没有访问过
			if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
 
	return d[gx][gy];
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	cin >> h >> w >> n;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> map[j][i];
		}
	}
 
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (map[j][i] == 'S')
			{
				factory[0][0] = j;
				factory[0][1] = i;
				map[j][i] = '.';
			}
			else if (isdigit(map[j][i]))
			{
				int index = map[j][i] - '0';
				factory[index][0] = j;
				factory[index][1] = i;
			}
		}
	}
 
	int step = 0;
	for (int i = 0; i < n; ++i)
	{
		// 按顺序吃遍中华
		step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
	}
	
	cout << step << endl;
 
	return 0;
}


Measured memory_bytes: 8036
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define int long long
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

void add_mod(int &a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
}
void sub_mod(int &a, int b) {
	a -= b;
	if(a < 0)
		a += mod;
}

int32_t main() {
	int n, k;
	cin >> n >> k;
	vector<int> dp(k+2);
	dp[0] = 1;
	while(n--) {
		int up;
		cin >> up;
		vector<int> fake(k+2);
		for(int used = k; used >= 0; used--) {
			int L = used+1, R = min(used+up, k)+1;
			add_mod(fake[L], dp[used]);
			sub_mod(fake[R], dp[used]);
		}
		int prefix = 0;
		for(int i = 0; i <= k; i++) {
			add_mod(prefix, fake[i]);
			add_mod(dp[i], prefix);
		}
	}
	cout << dp[k] << endl;

}


Measured memory_bytes: 1792
#

import sys
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    if N>=2 and M>=2:
        print((N*(N-1))//2+(M*(M-1)//2))
    elif N>=2:
        print((N*(N-1))//2)
    elif M>=2:
        print((M*(M-1)//2))
    else:
        print(0)
            
    
if __name__=="__main__":
    main()


Measured memory_bytes: 61864
"""

https://atcoder.jp/contests/arc086/tasks/arc086_c

対消滅する可能性があるのは同じ深さの点に置かれたビー玉だけ
→1つも残らない or 1つだけ残るである

すなわち、ある深さに関して、そのうち1つ残るのがいくつあるかを数えればよい

1つだけ置く場合→絶対のこる
2つ置く場合→絶対消える
3つ置く場合→3つのLCAが等しくなければ残る

木dpみたいにする？
dp[0] = 一つも含んでいない場合の通り数
dp[1] = 1つ含んでいる場合の通り数

dp[0] = すべての場合 - dp[1]
dp[1] = 1つだけ1を持っている場合

で、子から親に伝播させていく…？
マージテクで計算量削減か？
3sだからそうっぽいな…
3つ以上のマージ書くのだるすぎん？

またはマージの順番をどっかにメモっておく

maxd-d = indexでやる
最長のやつにマージする

dp[maxd-d][1] = 1つだけ元深さdが残っている場合の数
c = 子の数

計算量は？
サイズは高々1しか増えないので可能っぽい
2倍処理がまずい

もっと簡潔に？
単一のdだけで考えよう
2倍処理なんてしない
最後に各dに関してかければいい
→するとマージの際に2番目の大きさだけでなんとかなる

必要のないマージをしない
両方に関係ないdは操作しない
むしろばらつきは深い部分にだけ存在するか
浅い部分は共通。よって-xで管理すればいいか

"""

import sys
mod = 10**9 + 7
sys.setrecursionlimit(200000)

from collections import deque
def NC_Dij(lis,start):

    ret = [float("inf")] * len(lis)
    ret[start] = 0
    
    q = deque([start])
    plis = [i for i in range(len(lis))]

    while len(q) > 0:
        now = q.popleft()

        for nex in lis[now]:

            if ret[nex] > ret[now] + 1:
                ret[nex] = ret[now] + 1
                plis[nex] = now
                q.append(nex)

    return ret,plis

def inverse(a): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)


def dfs(v):

    if len(lis[v]) == 0:
        ret = [ [1,1] ]
        return ret

    else:

        retlis = []
        for nex in lis[v]:
            nret = dfs(nex)
            retlis.append( [len(nret),nret] )
        retlis.sort()

        #1つしかない場合マージしない
        if len(retlis) == 1:
            retlis[-1][1].append([1,1])
            return retlis[-1][1]

        #2つ以上の場合最大のやつにマージする
        for revd in range(retlis[-2][0]):

            zmul = 1
            amul = 1
            for i in range(len(retlis)-1,-1,-1):
                if revd < retlis[i][0]:
                    zmul *= retlis[i][1][-1-revd][0]
                    amul *= sum(retlis[i][1][-1-revd])
                    zmul %= mod
                    amul %= mod
                else:
                    break

            nsum = 0
            for i in range(len(retlis)-1,-1,-1):
                if revd < retlis[i][0]:
                    nsum += zmul * inverse(retlis[i][1][-1-revd][0]) * retlis[i][1][-1-revd][1]
                    nsum %= mod
                else:
                    break

            retlis[-1][1][-1-revd][1] = nsum
            retlis[-1][1][-1-revd][0] = (amul-nsum) % mod

        retlis[-1][1].append([1,1])
        return retlis[-1][1]

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

lis = [ [] for i in range(N+1) ]

for i in range(N):

    #lis[i+1].append(p[i])
    lis[p[i]].append(i+1)

dlis,plis = NC_Dij(lis,0)
maxd = max(dlis)

dn = [0] * (maxd+1)
for i in dlis:
    dn[i] += 1

ans = dfs(0)
#print (dn,ans)
A = 0
for i in range(maxd+1):
    A += ans[-1-i][1] * pow(2,N+1-dn[i],mod)
    A %= mod
print (A)


Measured memory_bytes: 402788
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList = input.map(x => parseInt(x, 10));
    // 人数
    const N = numList[0];
 
    // １番小さい数を見つける
    var min = Number.MAX_SAFE_INTEGER;
    for (var i = 1; i < 6; i++) {
        var num = numList[i];
        min = Math.min(min, num);
    }

    // ボトルネックになる箇所で何回輸送する必要があるかを考える
    const maxTransportCount = Math.ceil(N / min);

    console.log(4 + maxTransportCount);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n;
LL a[25][25] = {0};
LL sum[1 << 16] = {0};
LL dp[1 << 16] = {0};

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(LL s = 0;s < (1 << n);s ++){
		for(LL i = 1;i <= n;i ++){
			for(LL j = 1;j <= n;j ++){
				if((s & (1 << (i - 1))) && (s & (1 << (j - 1)))) sum[s] += a[i][j];
			}
		}
		sum[s] >>= 1;
	}
	for(LL s = 0;s < (1 << n);s ++){
		for(LL t = s;t;t = (t - 1) & s){
			dp[s] = max(dp[s],dp[s ^ t] + sum[t]);
		}
	}
	printf("%lld\n",dp[(1 << n) - 1]);
	return 0;
}

Measured memory_bytes: 1280
N, M = gets.chomp.split().map(&:to_i)
SWITCHES = M.times.map { gets.split().map(&:to_i) }
FLAGS = gets.chomp.split().map(&:to_i)

def all_on?(comb)
  m = -1
  SWITCHES.all? do |a, *s|
    ct = 0
    s.each do |s|
      ct += 1 if comb[s-1]
    end
    m += 1  
    ct % 2 == FLAGS[m]
  end
end

ans = 0

[true, false].repeated_permutation(N).each do |comb|
  ans += 1 if all_on?(comb)
end

puts ans

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s,t;cin>>s>>t;
    reverse(s.begin(),s.end());
    if(s==t)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>
#include <cassert>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int h = a[0];
    bool p = 0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            p = !p;
        }else{
            bool q = (a[i]-h)%2;
            if(q){
                if(p){
                    if(h+i==n||h+i-1==n){
                        cout << "First" << endl;
                        return 0;
                    }else if(h+i-1>n){
                        int k = h-2+i-n+1;
                        cerr << "test 1" << " "  << k << endl;
                        if(k%2==1){
                            cout << "Second" << endl;
                        }else{
                            cout << "First" << endl;
                        }
                        return 0;
                    }
                }
            }else{
                if(!p){
                    if(h+i==n||h+i+1==n){
                        cout << "First" << endl;
                        return 0;
                    }else if(h+i>n){
                        int k = h-1+i-n+1;
                        cerr << "test 2" << " " << k << endl;
                        if(k%2==1){
                            cout << "Second" << endl;
                        }else{
                            cout << "First" << endl;
                        }
                        return 0;
                    }
                }
            }
            h = a[i];
            p = 0;
        }
    }
    if(((a[n-1]%2==0)^p)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

vector<ll> use,in;
int main() {
	ll n;
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		in.push_back(a);
	}
	sort(ALL(in));
	REP(i, in.size() - 1) {
		if (in[i] == in[i + 1]) {
			use.push_back(in[i]);
			i++;
		}
	}
	sort(ALL(use),greater<ll>());
	if (use.size() < 2) cout << 0 << endl;
	else cout << use[0] * use[1] << endl;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
struct info{
	int light,heavy,weight;
	info(int a,int b,int c){
		light = a;
		heavy = b;
		weight = c;
	}
};
vector<info>arr;
int p[100005];
long long dist[100005];

int u_find(int a){
	if(p[a]==0) return a;
	int temp = u_find(p[a]);
	dist[a]+=dist[p[a]];
	return p[a] = temp;
}
void merge(int a,int b,int w){
    if(u_find(a)==u_find(b)) return;
	long long da = dist[a];
	long long db = dist[b];
	a = u_find(a);
	b = u_find(b);
	p[a] = b;
	dist[a] = db+w-da;
}

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int l,h,w;
		cin>>l>>h>>w;
		info a = info(l,h,w);
		arr.push_back(a);
		merge(l,h,w);
	}
	
	for(int i=0; i<m; i++){
		int l = arr[i].light;
		int h = arr[i].heavy;
		int w = arr[i].weight;
		if(u_find(l)!=u_find(h)) continue;
		if(dist[l]-dist[h]!=w){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 7484
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
int main(){
    ll n, x, ans = 0;
    cin >> n;
    vector<ll> A, B, C;
    RAP(i, n){
        cin >> x;
        A.push_back(x);
    }
    RAP(i, n){
        cin >> x;
        B.push_back(x);
    }
    RAP(i, n){
        cin >> x;
        C.push_back(x);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll idx_a, idx_c;
    RAP(i, n){
        auto itr_a = lower_bound(A.begin(), A.end(),B[i]);
        auto itr_c = upper_bound(C.begin(), C.end(),B[i]);
        idx_a = distance(A.begin(), itr_a);
        idx_c = distance(itr_c, C.end());

        ans += idx_a*idx_c;
        //cout << idx_a << " " << idx_c << " " <<ans << endl;

    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n,d;
    int x,y;
    int count=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(sqrt(pow(x,2)+pow(y,2))<=d){
            count++;
        }
    }
    cout<<count;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  vector<int> count(4);
  for(int i =0;i < n;i++){
    cin >> s;
    if(s == "AC")
      count[0]++;
    else if(s == "WA")
      count[1]++;
    else if(s == "TLE")
      count[2]++;
    else if(s == "RE")
      count[3]++;
  }
  
  
  
  cout << "AC x " << count[0] << endl << "WA x " << count[1] << endl << "TLE x " << count[2] << endl << "RE x " << count[3] << endl;
    
}


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

// 未完成
int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<char>> v(h, vector<char>(w));
  rep(i, h)
  {
    rep(j, w)
    {
      cin >> v[i][j];
    }
  }
  rep(i, h)
  {
    rep(j, w)
    {
      if (v[i][j] == '#')
      {
        cout << '#';
        continue;
      }
      int ans = 0;
      for (int y = -1; y <= 1; y++)
      {
        for (int x = -1; x <= 1; x++)
        {
          if (x + j < w && 0 <= x + j && y + i < h && 0 <= y + i && v[y + i][x + j] == '#')
          {
            ans++;
          }
        }
      }
      cout << ans;
    }
    cout << endl;
  }
}


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

A.sort(reverse=True)

ans = 0

b = 0
tmp = 0


for i in range(len(A)):
    if ans == 0:
        if A[i] == tmp:
            if b > 0:
                ans = A[i] * b
            else:
                b = A[i]
                tmp = 0

        else:
            tmp = A[i]


print(ans)


Measured memory_bytes: 14244
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
edge = {}
edge[0, 1] = min(A[0], A[1])
edge[1, 0] = min(A[0], A[1])
ans = A[0]
max_edge_list = [(0, 1), (1, 0)]
idx = 0
for i in range(2, N):
    x, y = max_edge_list[idx]
    ans += edge[(x, y)]
    #del edge[(x, y)]
    edge[x, i] = A[i]
    edge[i, y] = A[i]
    max_edge_list.append((x, i))
    max_edge_list.append((i, y))
    #max_edge_list.pop(0)
    idx += 1
print(ans)

Measured memory_bytes: 194720
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  map<string, int> mp;
  mp["AC"] = 0;
  mp["WA"] = 0;
  mp["TLE"] = 0;
  mp["RE"] = 0;
  int N;
  cin >> N;
  rep(i,N) {
    string temp;
    cin >> temp;
    mp[temp]++;
  }
  cout << "AC" << " " << "x" << " " << mp["AC"] << endl;
  cout << "WA" << " " << "x" << " " << mp["WA"] << endl;
  cout << "TLE" << " " << "x" << " " << mp["TLE"] << endl;
  cout << "RE" << " " << "x" << " " << mp["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void) {
  int x,y,n,m,i;
  
  scanf("%d %d",&x,&y);
  
  if(x <= y){
    n = x;
    m = y;
  }else{
    n = y;
    m = x;
  }
  
  for(i=0;i<m;i++)
    printf("%d",n);
  
  
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, A, B):
    C = [[abs(a-b) for a, b in zip(ar, br)] for ar, br in zip(A, B)]

    memo = [[set() for _ in range(W)] for __ in range(H)]
    memo[0][0].add(C[0][0])
    for i in range(H):
        for j in range(W):
            c = C[i][j]
            if i > 0:
                for d in memo[i-1][j]:
                    memo[i][j].add(abs(d + c))
                    memo[i][j].add(abs(d - c))
            if j > 0:
                for d in memo[i][j-1]:
                    memo[i][j].add(abs(d + c))
                    memo[i][j].add(abs(d - c))


    return min(map(abs, memo[H-1][W-1]))




def main():
    H, W = read_int_n()
    A = [read_int_n() for _ in range(H)]
    B = [read_int_n() for _ in range(H)]
    print(slv(H, W, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 550668
S = input()
K = int(input())

if len(set(S)) == 1:
    print(len(S)*K//2)
    exit()

b = [1]
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        b[-1] += 1
    else:
        b.append(1)

ans = 0
for i in b:
    ans += i//2
ans *= K

if S[0] == S[-1] and b[0]%2 == b[-1]%2 == 1:
    ans += K - 1
print(ans)

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

int main(){
    int a,b,c,d,e,f,g,k;
    cin >> a >> b >> c >> d >> e >> k;
    f=min(a,min(b,min(c,min(d,e))));
    g=max(a,max(b,max(c,max(d,e))));
    if (k<g-f) cout << ":(";
    else cout << "Yay!";
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "YES";
const string NO = "NO";

int main(){
    int n;
    cin >> n;
    vi p(n), t(n);
    rep(i, n) cin >> p[i];
    int count = 0;
    rep(i, n) {
        if (p[i] != i + 1) ++count;
    }
    if (count == 0 || count == 2) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	int i, n, sum, elmNum[ 10 ] = { 0, 5, 3, 3, 3, 3, 3, 4, 3, 4 };
	char ch[ 10 ][ 6 ] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

	scanf( "%d%*c", &n );

	for ( i = 0; i < n; i++ ) {
		while ( 1 ) {
			scanf( "%c", &key );

			if ( key == '\n' )
				break;
			else if ( key == '0' )
				continue;

			for ( sum = 0; scanf( "%c", &tmp ), tmp != '0'; sum++ ) ;
			putchar( ch[ key - '0' ][ sum % elmNum[ key - '0' ] ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] abc = br.readLine().split(" ");
		int a = Integer.parseInt(abc[0]);
		int b = Integer.parseInt(abc[1]);
		int c = Integer.parseInt(abc[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);
 */


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();


		if(s[0] != 'A'){
			System.out.println("WA");
			System.exit(0);
		}
		if(s[1] == 'C' || s[s.length-1] == 'C'){
			System.out.println("WA");
			System.exit(0);
		}

		int k = s[1];
		int j = s[s.length-1];

		if(k<91||j<91){
			System.out.println("WA");
			System.exit(0);
		}

		boolean isCExist = false;
		for(int x = 2;x < s.length-1;x++){
			int asc = s[x];

			if(asc == 67){
				if(isCExist){
					System.out.println("WA");
					System.exit(0);
				}
				else isCExist = true;
			}
			else if(asc < 91){
				System.out.println("WA");
				System.exit(0);
			}

		}

		if(isCExist)System.out.println("AC");
		else System.out.println("WA");
	}


}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+20;
const ll mod=1e9+7;
char s[N],t[N];
int fail[N],suf[N];
void getfail(int *fail,char *s)
{
	fail[0]=-1;
	int i=0,j=-1;
	while(s[i])
	{
		if(j==-1||s[i]==s[j])
		{
			fail[i+1]=j+1;
			i++,j++;
		}
		else
			j=fail[j];
	}
}
int main()
{
	while(scanf("%s",s)!=EOF)
	{
	
		ll ans=0;
		int len=strlen(s);
		for(int i=0;s[i];i++)
			t[i]=s[len-i-1];
		t[len]='\0';
		getfail(fail,s);
		getfail(suf,t);
		int m;
	//	cout<<fail[len]<<endl;
		if(fail[len]==0||len%(len-fail[len]))
			m=1;
		else
			m=2;
		bool flag=true;
		for(int i=1;s[i];i++)
		{
			if(s[i]!=s[i-1])
				flag=false;
		}	
		if(flag)
			m=len;
		if(m==1||flag)
			ans=1;
		else
		{
			for(int i=0;i<len-1;i++)
			{
				int k=len-i-1;
			//	cout<<i<<' '<<k<<endl;
				if((fail[i+1]==0||(i+1)%((i+1)-fail[i+1])) &&(suf[k]==0||(k)%(k-suf[k])))
					ans++;
			}
		}	
		cout<<m<<endl<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 10368
import java.util.Arrays;
import java.util.Scanner;

/**
 * https://abc061.contest.atcoder.jp/tasks/abc061_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long K = Long.parseLong(sc.next());
		Item[] items = new Item[N];
		for(int i=0; i<N; i++){
			items[i] = new Item(Long.parseLong(sc.next()),Long.parseLong(sc.next()));
		}
		sc.close();
		
		Arrays.sort(items, (o1, o2) -> (int)o1.a - (int)o2.a );

		long current = 0;
		int index = 0;
		while(index<N && current+items[index].b<K){
			current = current+items[index].b;
			index++;
		}

		System.out.println(items[index].a);
		
	}
	
	static class Item{
		long a;
		long b;
		Item(long a, long b){
			this.a = a;
			this.b = b;
		}
	}

}

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

using namespace std;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    int ans = t/a ;
    t -= ans * a;
    ans *= b;
    cout << ans;
    /*
    float rem = (float)t + 0.5;
    float one = (float)a / (float)b;
    int bis = floor(rem/one);
    ans += bis;
    cout << ans;*/
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    priority_queue<int> que;
    CIN(N);CIN(K);
    int ins = 0;
    REP(a,N){
        CIN(b);
        if(a == 0){
            ins  = b;
        }else{
            que.push(b-ins);
            ins = b;
        }
    }
    REP(a,K-1){
        que.pop();
    }
    LL ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    COUT(ans + K);
    return 0;
}



Measured memory_bytes: 3532
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		// 県、年でソート
		PriorityQueue<City> city = new PriorityQueue<>(m, new Comparator<City>() {

			@Override
			public int compare(City o1, City o2) {
				if ( o1.pref != o2.pref ) {		// 県でソート
					return o1.pref - o2.pref;
				} else {						// 同じ県の時は年でソート
					return o1.year - o2.year;
				}
			}
		});
		for ( int id = 1; id <= m; id++ ) {
			city.add(new City(id, in.nextInt(), in.nextInt()));
		}

		// 県ごとに年でナンバー付けしてidでソート
		String citycode[] = new String[m + 1];
		int p = 0;
		int num = 0;
		while ( city.size() > 0 ) {
			City c = city.poll();
			// 新出の県の場合
			if ( p != c.pref ) {
				p = c.pref;
				num = 1;
			} else {
				num++;
			}

			c.num = num;
			citycode[c.id] = String.format("%06d", c.pref) + String.format("%06d", c.num);
			// System.out.println("id:" + c.id + " pref:" + c.pref + " year:" + c.year);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for ( int i = 1; i<=m; i++ ) {
			pw.println(citycode[i]);
		}
		pw.flush();
		in.close();
	}
}

class City {

	int	id		= 0;
	int	pref	= 0;
	int	year	= 0;
	int	num		= 0;

	public City(int id, int pref, int year) {
		this.id = id;
		this.pref = pref;
		this.year = year;
	}
}


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

#define ll long long int

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(n + 1), a(n);
  for(int i = 0; i < n; i++) {
      cin >> a[i];
      cnt[a[i]]++;
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
      ans += (cnt[i]) * (cnt[i] - 1) / 2;
  }
  for(int i = 0; i < n; i++) {
      ll curr = ans;
      curr -= (cnt[a[i]]) * (cnt[a[i]] - 1) / 2;
      curr += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
      cout << curr << endl;
  }
}

Measured memory_bytes: 5760
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  /**
   * Main method.
   */
  public static void main(String[] args) throws IOException {
    Scanner s = new Scanner(System.in);
    
    Map<String, Integer> map = new HashMap<>();
    
    final int N = s.nextInt();   
    for (int i = 0; i < N; i++) {
    	String str = s.next();
    	if (map.containsKey(str)) {
    		map.put(str, map.get(str)+1);
    	} else {
    		map.put(str, 1);
    	}
    }
    
    final int M = s.nextInt();
    for (int i = 0; i < M; i++) {
    	String str = s.next();
    	if (map.containsKey(str)) {
    		map.put(str, map.get(str)-1);
    	} else {
    		map.put(str, -1);
    	}
    }
    
    int max = -9999;
    for (String str : map.keySet()) {
    	max = Math.max(max, map.get(str));
    }
     
    System.out.println(max < 0 ? "0" : max);
 
  }
}


Measured memory_bytes: 21844
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        o: Chars,
        e: Chars,
    };
    let mut s = vec![];
    let mut i = 0;
    let mut i_o = 0;
    let mut i_e = 0;
    while i_o < o.len() || i_e < e.len() {
        if i % 2 == 0 {
            if i_o < o.len() {
                s.push(o[i_o]);
            }
            i_o += 1;
        } else {
            if i_e < e.len() {
                s.push(e[i_e]);
            }
            i_e += 1;
        }
        i += 1;
    }
    let ans = s.iter().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef struct E{
  int to,cost;
}edge;
const int MAX_V=200100;
const int Inf=1e9;
vector<vector<edge> >E(MAX_V);
int d[MAX_V];
void dijkstra(int s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  fill_n(d,MAX_V,Inf);
  d[s] = 0;
  que.push(pair<int,int>(0,s));
  while(!que.empty()){
    pair<int,int> p=que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    for(int j=0;j<E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to]>d[v]+t.cost){
	d[t.to]=d[v]+t.cost;
	que.push(pair<int,int>(d[t.to],t.to));
      }
    }
  }
}

int main(){
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    edge e;
    int a,b;cin>>a>>b;
    e.to=b;e.cost=1;
    E[a].pb(e);
    e.to=a;
    E[b].pb(e);
  }
  dijkstra(1);
  if(d[n]<=2)
    cout<<"POSSIBLE"<<endl;
  else
    cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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

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

    long long k, a, b;
    cin >> k >> a >> b;

    long long ans = k + 1;
    
    if(k >= a + 1)
    {
        k -= a + 1;
        long long curr = b;
        
        curr += (b - a) * (k / 2) + k % 2;
        ans = max(ans, curr);
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	int ans=n*(n-1)/2+m*(m-1)/2;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main()
{
    long long H;
    cin >> H;
    int count = 1;
    long long atk = 0;
    while (H != 1)
    {
        H = H / 2;
        count++;
    }
    for (int i = 0; i < count;i++){
        atk = atk + pow(2, i);
    }
    cout << atk << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);

  int ans = 1;
  for(ll x = 2; x * x <= g; x++) {
    if(g == 1) break;
    bool counted = false;
    while(g % x == 0) {
      g /= x;
      if(!counted) {
        ans++;
        counted = true;
      }
    }
  }
  if(g > 1) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
long long a,b;
using namespace std;
int main(){
//	freopen("agc.in","r",stdin);
	scanf("%lld%lld",&a,&b);long long ans=0;
	if (a<0&&b<0&&a>=b) {ans+=2;ans+=abs(a-b);}
	if (a<0&&b<0&&a<b) {ans+=abs(a-b);}
	if (a<0&&b>0) {ans=1;ans+=abs(b+a);}
	if (a>0&&b<0) {ans=1;ans+=abs(b+a);}
	if (a>0&&b>0&&a<=b) {ans+=abs(b-a);}
	if (a>0&&b>0&&a>b) {ans=2;ans+=abs(b-a);}
	if (!a||!b) {
		if (a>b) ans+=abs(b-a)+1;else ans+=abs(b-a);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    int max=d.at(N-1);
    vector<int>::iterator position;
    int count=0;
    for(int i=1; i<=max; i++){
        position=lower_bound(d.begin(),d.end(),i);
        int idx=distance(d.begin(),position);
        if(idx==N/2){
            count++;
        }
    }
    cout << count << endl;
}

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

void dfs(string s, int N) {
    if (s.size() == N) {
        cout << s << endl;
        return;
    }
    
    char c = 'a';
    for (char &i : s) c = max(c, i);
    
    for (char i = 'a'; i <= c + 1; ++i) dfs(s + i, N);
}

int main(void){
    int N;
    cin >> N;
    
    dfs("a", N);
}


Measured memory_bytes: 1536
import std.stdio;
import std.string;

void main() {
	auto l = readln().chomp();
	size_t c;
	size_t t;
	for (size_t i; i < l.length; ++i) {
		if (l[i] == 'W') {
			t += i - c;
			++c;
		}
	}
	t.write;
}


Measured memory_bytes: 2684
import itertools
N = int(input())
Pls = list(map(int,input().split()))
Qls = list(map(int,input().split()))

lis = [i for i in range(1,N+1)]
permutations_lis = itertools.permutations(lis)
i = 0
for case in permutations_lis:
    i += 1
    if list(case) == Pls:
        a = i
    if list(case) == Qls:
        b = i

print(abs(a-b))

Measured memory_bytes: 73468
#include<stdio.h>
int main()
{
    int a,b,c,temp;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        temp=a;
        a=b;
        b=temp;
    }
    if(a>c){
        temp=a;
        a=c;
        c=temp;
    }
    if(b>c){
        temp=b;
        b=c;
        c=temp;
    }
    int cost = 0;
    // after sort 1 5 7
    cost += (b-a);
    cost += (c-b);
    printf("%d\n",cost);
    return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
H = list(map(int, (input().split())))
ans = [1] * N
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        ans[A-1] = 0
    if H[B-1] <= H[A-1]:
        ans[B-1] = 0
print(sum(ans))

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

ll a,b,c,k,ans;

int main()
{
    cin>>a>>b>>c>>k;
    ans= k&1? b-a:a-b;
    if(abs(ans)> 1000000000000000000)cout<<"Unfair\n";
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
H, W, K=map(int,input().split())
F = [input() for _ in range(H)]
ans = 0
for i in range(2**H):
  for j in range(2**W):
    cnt = 0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
          continue
        cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define frr(i,s,n) for(int i=s;i<=n;i++)
#define fr(i,s,n) for(int i=s;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

lli dp[1001][1001];
int a[1001][1001];

lli solve(int i,int j,int n,int m)
{
	if(i>n || j>m)
		return 0;

	if(i == n && j == m)
		return 1;

	if(dp[i][j] != -1)
		return dp[i][j];

	if(a[i][j] == 0)
		return 0;

	return dp[i][j] = ((solve(i+1,j,n,m)%mod) + (solve(i,j+1,n,m)%mod))%mod;
}
void loop()
{
	memset(dp,-1,sizeof(dp));
	int n,m;
	cin>>n>>m;
	//int a[n+1][m+1];
	char ch;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>ch;
			if(ch == '.')
				a[i][j] = 1;
			else
				a[i][j] = 0;
		}
	}
	cout<<solve(1,1,n,m)<<"\n";
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	//fast;
    int t=1;
    //cin>>t;
    while(t--)
    	loop();
}


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

int gcd(int a, int b) {
  while (b) {
    int c = a % b;
    a = b;
    b = c;
  }
  return b;
}

int main() {
  int N, K, g = 0, ma = 0;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) {
    int t; scanf("%d", &t);
    g = __gcd(g, t);
    ma = max(ma, t);
  }
  if (K % g == 0 && K <= ma) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


s = input()
max_count = 0
now_count = 0
target = ["A", "C", "G", "T"]
for c in s:
        if(c in target):
                now_count += 1
        else:
                max_count = max(max_count, now_count)
                now_count = 0
print(max(max_count, now_count))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  vector<char> data;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '0'){
      data.push_back('0');
    }else if(s.at(i) == '1'){
      data.push_back('1');
    }else if(s.at(i) == 'B' && data.size() == 0){
    }else{
      data.pop_back();
    }
  }
  for(int i=0; i<data.size(); i++){
    cout << data.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 768