akhauriyash/Code-Regression huggingface dataset:
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			var n = firstLine[0];
			var m = firstLine[1];
			var x = firstLine[2];

			var books = new List<int[]>();
			for(var i = 0; i < n; i++)
			{
				books.Add(ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
			}

			var minCost = int.MaxValue;

			for(var i = 1; i < (1 << n); i++)
			{
				var understandings = new int[m];
				var cost = 0;
				for(var j = 0; j < n; j++)
				{
					if(((i >> j) & 1) == 1)
					{
						for(var k = 0; k < m; k++)
						{
							understandings[k] += books[j][k + 1];
						}
						cost += books[j][0];
					}
				}

				if(understandings.All(value => value >= x))
				{
					minCost = Min(minCost, cost);
				}
			}

			WriteLine(minCost != int.MaxValue ? minCost : -1);
		}
	}
}


Measured memory_bytes: 20060
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    ll x;
    cin >> x;
    int t = x % 11;
    ll ans;
    if (t == 0) {
        ans = 2*(x/11);
    }
    else if (t > 6) {
        ans = 2*(x/11) + 2;
    }
    else {
        ans = 2*(x/11) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int64_t a, b, c;
    cin >> a >> b >> c;
    long double rtab, rtc;
    long double A, B, C;
    A = (long double)a;
    B = (long double)b;
    C = (long double)c;
    rtab = sqrtl(A*B);
//    rtc = sqrtl(C);
    if ((A+B+2*rtab) < C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, A[100001], sum=1, judge=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];

        if(A[i]==0) judge = 1;
    }

    if(judge==1){
        cout << 0 << endl;
        return 0;
    }

    for(i=1; i<=N; i++){
        ld b = (ld)1e18/sum;
        if(A[i] > b){
            cout << -1 << endl;
            return 0;
        }

        else sum *= A[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#define INF 300000
#define NIL NULL
#define WHITE 'W'
#define BLACK 'B'

void prim(int,int**);

int main()
{
  int n,**w,i,j;
  scanf("%d",&n);
  
  w = malloc(sizeof(int*)*n);
  
  for(i=0;i<n;i++)
    {
      w[i]=malloc(sizeof(int)*n);
    }
  
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&w[i][j]);
	}
    }
  prim(n,w);
  
  return 0;
}
void prim(int n,int **w)
{
  int *d,*pi,mincost,u,i,v;
  char *color;
  
  d = malloc(sizeof(int)*n);
  pi = malloc(sizeof(int)*n);
  color = malloc(sizeof(char)*n);
  
  for(i=0;i<n;i++)
    {
      d[i] = INF;
      pi[i] = NIL;
      color[i] = WHITE;
    }
  d[0]=0;

  while(1)
    {
      mincost = INF;
      for(i=0;i<n;i++)
	{
	  if(color[i]!=BLACK && d[i]<mincost){
	    mincost=d[i];
	    u=i;
	  }
	}
      if(mincost == INF) break;
      color[u]=BLACK;

       for(v=0;v<n;v++) 
       	{
	  if(w[u][v]==-1)continue;
       	  if(color[v]!=BLACK && w[u][v] < d[v]){ 
	    pi[v] = u;
	    d[v]=w[u][v];
	  }
	}
    }
  v=0;
  for(i=0;i<n;i++){
    v+=d[i];
  }
  printf("%d\n",v);
}



Measured memory_bytes: 2112
#include<stdio.h>

int H, W, N, K;
int ans_map[50][50];

void check4s(int h, int w, int num) {
	int p;
	int c = 0;
	
	printf("? %d %d %d %d\n", h, w, h, w);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h][w] = p;
	c += p;
	if(c == num) return;
	
	printf("? %d %d %d %d\n", h, w+1, h, w+1);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h][w+1] = p;
	c += p;
	if(c == num) return;
	
	printf("? %d %d %d %d\n", h+1, w, h+1, w);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h+1][w] = p;
	c += p;
	if(c == num) return;
	
	ans_map[h+1][w+1] = 1;
}

void check4h(int h, int w, int num) {
	int i;
	int p;
	int c = 0;
	
	for(i=0;i<3;i++) {
		printf("? %d %d %d %d\n", h, w+i, h, w+i);
		fflush(stdout);
		scanf("%d", &p);
		ans_map[h][w+i] = p;
		c += p;
		if(c == num) return;
	}
	
	ans_map[h][w+3] = 1;
}

void check4v(int h, int w, int num) {
	int i;
	int p;
	int c = 0;
	
	for(i=0;i<3;i++) {
		printf("? %d %d %d %d\n", h+i, w, h+i, w);
		fflush(stdout);
		scanf("%d", &p);
		ans_map[h+i][w] = p;
		c += p;
		if(c == num) return;
	}
	
	ans_map[h+3][w] = 1;
}

void check25(int h, int w, int num) {
	int i, j;
	int p;
	int c = 0;
	
	for(i=0;i<2;i++) {
		for(j=0;j<2;j++) {
			printf("? %d %d %d %d\n", h+i*2, w+j*2, h+i*2+1, w+j*2+1);
			fflush(stdout);
			scanf("%d", &p);
			if(p > 0) {
				c += p;
				check4s(h+i*2, w+j*2, p);
				if(c == num) return;
			}
		}
	}
	
	printf("? %d %d %d %d\n", h+4, w, h+4, w+3);
	fflush(stdout);
	scanf("%d", &p);
	if(p > 0) {
		c += p;
		check4h(h+4, w, p);
		if(c == num) return;
	}
	
	printf("? %d %d %d %d\n", h, w+4, h+3, w+4);
	fflush(stdout);
	scanf("%d", &p);
	if(p > 0) {
		c += p;
		check4v(h, w+4, p);
		if(c == num) return;
	}
	
	ans_map[h+4][w+4] = 1;
}

int main() {
	int i, j;
	int p;
	int c = 0;
	long ans = 0;
	long pow = 1;
	
	scanf("%d %d %d %d", &H, &W, &N, &K);
	/*
	for(i=0;i<10;i++) {
		for(j=0;j<10;j++) {
			if(c == N) break;
			printf("? %d %d %d %d\n", i*5, j*5, i*5+4, j*5+4);
			fflush(stdout);
			scanf("%d", &p);
			if(p > 0) {
				c += p;
				check25(i*5, j*5, p);
			}
		}
	}*/
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			printf("? %d %d %d %d\n", i, j, i, j);
			fflush(stdout);
			scanf("%d", &p);
			ans_map[i][j] = p;
		}
	}
	
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(ans_map[i][j]) ans += pow;
			pow *= 2;
			ans %= K;
			pow %= K;
		}
	}
	
	printf("! %ld\n", ans);
	
	return 0;
}

Measured memory_bytes: 596
import math

def main():
    n,k=list(map(int,input().split(' ')))
    ans = 0
    for i in range(1,min(n+1,k)):
        ans +=(1/2)**(-(math.log2(k/i)//-1))
    if n >= k:
        ans += (n-k+1)
    print(ans/n)

main()

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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;

int n, k;
int a[2020];

int l[2020], r[2020];

ll fac(int k) {
  ll ans = k+1;
  ans *= k;
  ans /= 2;
  
  ans %= MOD;
  return ans;
}

int main() {
  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n) {
    l[i] = 0;
    r[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[j] < a[i]) {
        l[i]++;
      }
    }
    for (int j = i+1; j < n; j++) {
      if (a[j] < a[i]) {
        r[i]++;
      }
    }
  }

  ll fack = fac(k);
  ll fackm = fac(k-1);

  ll ans;
  for (int i = 0; i < n; i++) {
    ans += l[i] * fackm;
    ans %= MOD;
    ans += r[i] * fack;
    ans %= MOD;
  }

/*
  ll ans = 0;
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < n; i++) {
      ans += l[i] * (k - j - 1);
      ans %= MOD;
      ans += r[i] * (k - j);
      ans %= MOD;
    }
  }*/

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

typedef struct{
  double x,y;
}Point;

void print(Point p){
  printf("%.8f %.8f\n",p.x,p.y);
}

void plot(int n,Point p1,Point p2){
  Point s,t,u;
  double th = 60.0*(acos(-1)/180.0);
  if(n==0)return;
  s.x=(2.0*p1.x+1.0*p2.x)/3.0;
  s.y=(2.0*p1.y+1.0*p2.y)/3.0;
  t.x=(1.0*p1.x+2.0*p2.x)/3.0;
  t.y=(1.0*p1.y+2.0*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  plot(n-1,p1,s);
  print(s);
  plot(n-1,s,u);
  print(u);
  plot(n-1,u,t);
  print(t);
  plot(n-1,t,p2);
}

int main(){
  Point p1,p2;
  int n;
  scanf("%d",&n);

  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;
  print(p1);
  plot(n,p1,p2);
  print(p2);

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,sum=0;
    cin>>n;
    vector<int> s(n);
    rep(i,0,n){
        cin>>s[i];
        sum+=s[i];
    }
    sort(s.begin(),s.end());
    if(sum%10){cout<<sum<<endl;return 0;}
    else{
        rep(i,0,n){
            int tmp=sum;
            tmp-=s[i];
            if(tmp%10 != 0){
                cout<<tmp<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> VI;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int swap_count = 0;
		VI E(n);
		for ( int i = 0; i < n; i++ ) cin >> E[i];
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 1; j < n-i; j++ )
			{
				if ( E[j-1] > E[j] )
				{
					swap( E[j-1], E[j] );
					swap_count ++;
				}
			}
		}
		cout << swap_count << endl;
	}

	return 0;
}

Measured memory_bytes: 0
def comb(n,k):
    nCk = 1
    MOD = 10**9+7
    # X
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    # Y
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk


# n = int(input())
n, m = map(int, input().split())
# k = list(map(int, input().split()))
ans = 0

if n >= 2:
    ans += comb(n, 2)

if m >= 2:
    ans += comb(m, 2)

print(ans)

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

using namespace std;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;

  for(int i=0;;i+=a+b){
    if(i<=c && c<=i+a){
      cout << i+c%60-i%60 << endl;
      break;
    }
    //if(60<i && 60%(a+b)==0){
    if(100000<i){
      cout << -1 << endl;
      break;
    }
    if(i/60 != (i+a+b)/60)c+=60;
  }
  
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;

int main(){
   int n;   cin >> n;
   ll a[n+1],b[n+1];
   b[0] = 0;
   for(int i=1;i<=n;i++){
       cin >> a[i];
       b[i] =(b[i-1]+a[i])%MOD;
    }

    for(int i=1;i<=n;i++){
        if(b[n]-b[i]<0) b[n]+=MOD;
        ans += a[i]*(b[n]-b[i]);
        ans = ans % MOD;
    }
    
    

    cout << ans%MOD << endl;
}

Measured memory_bytes: 6708
H,W=map(int,input().split())
M=[['.' for _ in range(W+2)] for _ in range(H+2)]
flag=True
for i in range(H):
    s=input()
    for j in range(W):
        M[i+1][j+1]=s[j]
for i in range(H):
    for j in range(W):
        if M[i+1][j+1]=='#':
            if M[i][j+1]=='.' and M[i+2][j+1]=='.' and M[i+1][j]=='.' and M[i+1][j+2]=='.':
                flag=False
if flag==True:
    print('Yes')
else:
    print('No')

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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll x[n]; rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1){
        ans += min(a*(x[i+1]-x[i]),b);
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll a, b, c, n;
	string s, t;
	cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int i,n,a,b;
	for(;scanf("%d",&n),n;puts(i==n?"Yes":"No")){
		vector<pair<int,int> >v;
		for(i=0;i<n;i++)scanf("%d%d",&a,&b),v.push_back(make_pair(b,a));
		sort(v.begin(),v.end());
		for(a=i=0;i<n;i++)if(a+=v[i].second,a>v[i].first)break;
	}
}

Measured memory_bytes: 1020
import bisect
import sys
sys.setrecursionlimit(1000000)

input = sys.stdin.readline

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

tree = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    tree[u - 1].append(v - 1)
    tree[v - 1].append(u - 1)

ans = [0] * n
visited = [0] * n
visited[0] = 1
l = []

def dfs(i):
    s = a[i]
    pi = -1
    pv = -1
    if len(l) == 0 or s > l[-1]:
        l.append(s)
    else:
        pi = bisect.bisect_left(l, s)
        pv = l[pi]
        l[pi] = s
    ans[i] = len(l)

    for ni in tree[i]:
        if not visited[ni]:
            visited[ni] = 1
            dfs(ni)
            
    if pi == -1:
        l.pop()
    else:
        l[pi] = pv


dfs(0)

for i in ans:
    print(i)


Measured memory_bytes: 354984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;


ll fact(ll x){
    ll ans = 0;
    ll p = 5;
    while(p<x){
        ans += (x/p)/2;
        p*=5; 
    }
    return ans;
}

int main(){
    ll n;
    cin  >> n;
    ll ans = fact(n);
    if(n%2 == 1) ans = 0;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 16 22:15:18 2019

@author: Yamazaki Kenichi
"""

N, M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
mod = 10**9 + 7

A = [[1 for j in range(M+1)]]
A += [[0 for j in range(M+1)]]
#A += [[0 for j in range(M+1)] for i in range(N)]
A += [[1 for j in range(M+1)]]
for i in range(N):
#    print(i,j)
    tmp2 = 0
    for j in range(M):
#        print(i,j)
        if T[j] == S[i]:
            tmp = A[-1][j-1] % mod
#            A[i+1][j] = A[-1][j-1] % mod
        else:
            tmp = tmp2 % mod
#            A[i+1][j] = A[i+1][j-1] % mod
        tmp2 = tmp
        A[-1][j] += tmp
#        A[-1][j] += A[i+1][j]
        A[-1][j] %= mod
#        print(A)
ans = A[-1][-2] % mod
print(ans)

Measured memory_bytes: 43868
function Main(input){
   input = input.split(' ');
   X = 2;
   N = input.map(input=>parseInt(input,10));
   if(N % X ==0){
      console.log(N[0]);
      }else{
      var ans = N[0] * X;
      console.log(ans);
      }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(1, N+2):
    a.append(2 * a[i-1] + 3)
    p.append(2 * p[i-1] + 1)

def calc(N, X): #レベルNバーガーの下からX層に含まれるパティの枚数
    if N == 0: #全てパティ
        if X == 0:
            return 0
        else:
            return 1
    if X == 1:
        return 0
    # print (N - 1)
    if 1 < X <= 1 + a[N - 1]:
        # print ('A')
        return calc(N - 1, X - 1)
    if X == 2 + a[N - 1]:
        # print ('B')
        return p[N - 1] + 1
    if 2 + a[N - 1] < X <= 2 + 2 * a[N - 1]:
        # print ('C')
        return p[N - 1] + 1 + calc(N - 1, max(X - 2 - a[N - 1], 0))
    if X == 3 + 2 * a[N - 1]:
        # print ('D')
        return p[N]

print (calc(N, X))

Measured memory_bytes: 3064
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int[] w=new int[n+1];
    int[] e=new int[n+1];
    for(int i=0;i<n;i++){
      w[i+1]=(s.charAt(i)=='W'?1:0)+w[i];
    }
    for(int i=n;i>0;i--){
      e[i-1]=(s.charAt(i-1)=='E'?1:0)+e[i];
    }
    int min=Integer.MAX_VALUE;
    for(int i=0;i<=n;i++){
      min=Math.min(e[i]+w[i],min);
    }
    System.out.println(min);
  }
}

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

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  bool ans = true;
  for(int i = A; i < max(C, D); i++) {
    if(S[i] == '#' && S[i+1] == '#') {
      ans = false;
      break;
    }
  }
  if(ans) {
    if(D < C) {
      ans = false;
      for(int i = B - 2; i <= D - 2; i++) {
        if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') {
          ans = true;
          break;
        }
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(int argc, char* argv[])
{
  string value;
  int sum;
  while(1)
  {
    sum=0;
    cin >> value;
    if(value=="0")break;
    for(int i=0;i<value.size();i++)
    {
      sum+=value[i]-'0';
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int a, b, k;
    cin >> a >> b >> k;
    
    for(int i = a; i <= min(a + k - 1, b); i++) cout << i << "\n";
    for(int i = max(b - k + 1, min(a + k - 1, b) + 1); i <= b; i++) cout << i << endl;
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


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

using namespace std;

int main(int argc, char *argv[])
{
    int i;
    int n, m;
    int ans_num = 0;
    int ans_pena = 0;

    cin >> n >> m;
    vector<int> penalty(n);
    for (i = 0; i < m; i++) {
        int p;
        string s;

        cin >> p >> s;
        if (penalty[p] == -1) {
            continue;
        }
        if (s == "AC") {
            ans_num++;
            ans_pena += penalty[p];
            penalty[p] = -1;
        } else if (s == "WA") {
            penalty[p]++;
        }
    }

    cout << ans_num << " " << ans_pena << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int inf=1e9+7;
int m;
string last="@";
vector<string> used;
bool find(string t)
{
	for(int i=0;i<(int)used.size();i++)
	if(used[i]==t) return true;
	return false;
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>m;
	while(m--)
	{
		string s;
		cin>>s;
		if(find(s) || (last[0]!='@' && s[0]!=last[(int)last.size()-1]))
		{
			cout<<"No"<<endl;
			return 0;
		}
		used.push_back(s);
		last=s;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int memo[1000][26];

int toIndex(char c){
    return c - 'A';
}

int main(){
    std::string D;
    std::cin >> D;
    std::string Z(D.begin(), D.end());
    
    memo[0][toIndex(D[0])] += 1;
    FOR(i, 1, D.size()){
        REP(j, 26){
            memo[i][j] = memo[i-1][j];
        }
        if(i-8 >= 0){
            memo[i][toIndex(D[i-8])] -= 1;
        }
        memo[i][toIndex(D[i])] += 1;

        if(memo[i][toIndex('A')] == 2 &&
           memo[i][toIndex('D')] == 1 &&
           memo[i][toIndex('I')] == 1 &&
           memo[i][toIndex('N')] == 2 &&
           memo[i][toIndex('U')] == 1 &&
           memo[i][toIndex('Y')] == 1){
            Z.replace(i-7, 8, "AIZUNYAN");
        }
    }

    std::cout << Z << std::endl;
}

Measured memory_bytes: 1288
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

uint[10^^5] AS;
long[10^^5] BS;

void main()
{
    auto nk = readln.split;
    auto N = nk[0].to!int;
    auto K = nk[1].to!uint;

    foreach (i; 0..N) {
        auto ab = readln.split;
        AS[i] = ab[0].to!uint;
        BS[i] = ab[1].to!long;
    }

    long r_max;
    foreach (i; 0..32) {
        uint m;
        if (!(K&(1<<i))) {
            if (i == 31) {
                m = K;
            } else {
                continue;
            }
        } else {
            m = K&(~(1<<i)) | ((1<<i)-1);
        }
        long r;
        foreach (j; 0..N) {
            if ((AS[j]|m) == m) r += BS[j];
        }
        r_max = max(r_max, r);
    }

    writeln(r_max);
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
int main(){
  std::string s;
  std::cin >> s;
  if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
    std::cout << "Yes\n";
  else std::cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>


void q_sort(int numbers[], int left, int right)
{
  int pivot, l_hold, r_hold;

  l_hold = left;
  r_hold = right;
  pivot = numbers[left];
  while (left < right)
    {
      while ((numbers[right] >= pivot) && (left < right))
	right--;
      if (left != right)
        {
	  numbers[left] = numbers[right];
	  left++;
        }
      while ((numbers[left] <= pivot) && (left < right))
	left++;
      if (left != right)
        {
	  numbers[right] = numbers[left];
	  right--;
        }
    }
  numbers[left] = pivot;
  pivot = left;
  left = l_hold;
  right = r_hold;
  if (left < pivot)
    q_sort(numbers, left, pivot-1);
  if (right > pivot)
    q_sort(numbers, pivot+1, right);
}


int main(void)
{
  int n,m,i,ans=0;
  scanf("%d%d",&n,&m);
  int x[m],sub[m-1];
  for(i=0;i<m;i++)
    {
      scanf("%d",&x[i]);
    }
  q_sort(x,0,m-1);
  for(i=0;i<m-1;i++)
    {
      sub[i] = abs(x[i] - x[i+1]);
    }
  q_sort(sub,0,m-2);
  for(i=0;i<m-n;i++)
    {
      ans += sub[i];
    }
  printf("%d\n",ans);
  return 0;
}
  

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

int main() {
    int N; cin >> N;
    map<int, int> m;
    vector<ll> v;
    for (int i = 0; i < N; i++){
        int a; cin >> a;
        m[a]++;
        if(m[a]==2){
            m[a] = 0;
            v.push_back(a);
        }
    }

    if(v.size()<2){
        cout << 0 << endl;
        return 0;
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] * v[1] << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int month = Integer.parseInt(s.substring(5,7));
        if(month<=4){
            System.out.println("Heisei");
        }else{
            System.out.println("TBD");
        }
        sc.close();
    }
    
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin>>S;
    int cnt=0;
    int len=S.length();
    sort(S.begin(),S.end());
    for(int i=0;i<len;i++)
    {
        if(S[i]==S[i+1])
        {
            cnt++;
        }
    }
    if(len-cnt==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int a[3];
               cin>>a[0]>>a[1]>>a[2];
               sort(a,a+3);
               if(a[0]==5 && a[1]==5 && a[2]==7)
                    cout<<"YES";
               else
                    cout<<"NO";
       }
}


Measured memory_bytes: 3700
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, a[N], ans;
main() {
  file("lala");
  ios;
  cin >> n >> k;
  fo(i, 1, n, 1) cin >> a[i];
  sort(a + 1, a + n + 1);
  fo(i, 1, k, 1) ans += a[i];
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll cnt[100003]={0};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll n;
   cin>>n;
   ll a[n],i,j,k,ans=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       cnt[a[i]]++;
       ans+=a[i];
       
   }
   int q;
   cin>>q;
   while(q--)
   {
       int x,y;
       cin>>x>>y;
       ans+=cnt[x]*(y-x);
       cnt[y]+=cnt[x];
       cnt[x]=0;
       cout<<ans<<endl;
   }
}

Measured memory_bytes: 5148
import math

a, b, h, m = map(float, input().split())

theta = 2*math.pi*abs((h/12+m/60/12)-m/60)
if theta > math.pi:
    theta = 2*math.pi - theta

cos_theta = math.cos(theta)
c = math.sqrt(a**2 + b**2 - 2*a*b*cos_theta)
print(c)

Measured memory_bytes: 9432
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    string s; cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s;
    return 0;
}



Measured memory_bytes: 3600
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        System.out.println((n * m) % 2 == 1 ? "Odd" : "Even");
    }
}

Measured memory_bytes: 23764
import java.util.*;
import java.io.*;
public class Main {
    
    public static void main(String[] args) {
        MyScanner ms = new MyScanner();
        long N = ms.nextLong();
        long K = ms.nextLong();
        long divisor = N/K;
        N-=(divisor*K);
        long min = N;
        min = Math.min(min, Math.abs(N-K));
        System.out.println(min);
    }
   static  int gcd (int a, int b) {
        return b != 0 ? gcd (b, a % b) : a;
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
    
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
    
     }
}

Measured memory_bytes: 21460
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");

    }


    public static void main(String[] args) {

        solve();

        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


    class Counter extends HashMap<Integer, Integer> {
        public int get(int k) {
            return containsKey(k) ? super.get(k) : 0;
        }

        public void add(int k, int v) {
            put(k, get(k) + v);
        }
    }



    static class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

//    static class Node {
//        int key;
//        int data;
//        Node next;
//        Node prev;
//
//        Node(int key, int data) {
//            this.key = key;
//            this.data = data;
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class Trie {
        void add(String word) {

        }

        boolean search(String w) {
            return false;
        }
    }

    static class Node1 {
        public int val;
        public List<Node1> children;

        public Node1() {
        }

        public Node1(int _val, List<Node1> _children) {
            val = _val;
            children = _children;
        }
    }

    ;

    static class TrieNode {

    }

    static class KvNode implements Comparable<KvNode> {
        String key;
        int freq;

        public KvNode(String key, int freq) {
            this.key = key;
            this.freq = freq;
        }

        @Override
        public int compareTo(KvNode o) {
            if (this.key.equals(o.key)) {
                return 0;
            }
            return Integer.compare(o.freq, this.freq);
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}


Measured memory_bytes: 21716
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for i in range(m)]
for a,b in ab:
    ma=10**10
    tp=0
    for i in range(m):
        if ma>abs(a-cd[i][0])+abs(b-cd[i][1]):
            ma=abs(a-cd[i][0])+abs(b-cd[i][1])
            tp=i+1
    print(tp)

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

long long A, B, C, K;

int main(){
	cin >> A >> B >> C >> K;

	long long maxi = max(A, max(B, C));

	if(maxi == A){
		for(long long i = 0; i < K; i++){
			maxi *= 2;
		}
		cout << maxi + B + C << endl;
	}else if (maxi == B){
		for(long long i = 0; i < K; i++){
			maxi *= 2;
		}
		cout << maxi + A + C << endl;
	}else {
		for(long long i = 0; i < K; i++){
			maxi *= 2;
		}
		cout << maxi + A + B << endl;
	}
}

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

int main() {

	string s;
	cin >> s;

	string fr = "", ls = "";
	fr.append(s, 0, 2);
	ls.append(s, 2, 4);

	int f = stoi(fr);
	int l = stoi(ls);

	bool f_mm = (f>0 && f<=12) ? 1 : 0;
	bool l_mm = (l>0 && l<=12) ? 1 : 0;

	// cout << f_mm << ' ' << l_mm;

	if(f_mm && !l_mm) cout << "MMYY";
	else if(!f_mm && l_mm) cout << "YYMM";
	else if(f_mm && l_mm) cout << "AMBIGUOUS";
	else cout << "NA";


	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(1000):
    tg = str(i + 1000)[1:]
    if tg[0] not in s:
        continue
    else:
        x2 = s[s.index(tg[0]) + 1:]
        if tg[1] not in x2:
            continue
        else:
            x3 = x2[x2.index(tg[1]) + 1:]
            if tg[2] not in x3:
                continue
            else:
                ans += 1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n,x;
	cin>>n>>x;
	ll a[n];
	ll s=0;
	ll c=0;
	for(ll i=0; i<n; i++){
		cin>>a[i];
		s+=a[i];
	}
	c=n;
	x-=s;
	sort(a,a+n);
	c+=x/a[0];
	cout<<c;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N, R, p, c;
    while (cin >> N >> R && N) {
        vector <int> A(N,0);
        for (int i = 0; i < N; ++i) A[i] = N - i;
        for (int i = 0; i < R; ++i) {
            cin >> p >> c;
            rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
        }
        cout << A[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
int main(void){
  int n,k,x,i,ans=0;
  scanf("%d%d",&n,&k);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    ans+=((x*2<k)? x:k-x)*2;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdlib.h>  
using namespace std;
int main()
{
	bool arr[26];
	for(int i=0;i<26;i++)
		arr[i]=false;
	string s;
	cin>>s;
	for(long int i=0;i<s.length();i++)
	{
		arr[s[i]-'a']=true;
	}
	int j=0;
	char c='a';
	while(j<26)
	{
		if(arr[j]==false)
		{
			char d=c+j;
			cout<<d<<endl;
			return 0;
		}
		j++;
	}
	cout<<"None\n";
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  bool judge[31] = {};
  for(int i = 0 , a ; i < 28 ; i++ ) cin >> a , judge[a] = true;
  for(int i = 1 ; i < 31 ; i++ ) if(!judge[i]) cout << i << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
  int N, M;  cin >> N >> M;
  if (N == M) yes;
  else no;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

bool comp(const int &a,const int &b){
    int A = a%10,B=b%10;
    if(A == 0) A+=10;
    if(B == 0) B+=10;
    if(abs(10-A) > abs(10-B) )return true;
    return false;
}

int main(){
    vector<int> v(5);
    rep(i,5) cin >> v[i];
    sort(v.begin(),v.end(),comp);
    reverse(v.begin(),v.end());
    //for(auto e: v)cout << e << endl;

    int ans = 0;
    rep(i,4){
        if(v[i]%10 != 0){
            ans +=((v[i]/10)+1) * 10;
        }else
        ans += v[i];
    }
    ans += v[4];
    cout<< ans << endl;
    return 0;
}

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

int main() {
 string s1 , s2 , s3 ;
 cin >> s1 >> s2 >> s3 ;
  
  int x = (int)s1.at(0)-32;
  cout << (char)x;
  
  x = (int)s2.at(0)-32;
  cout << (char)x;
  
  x = (int)s3.at(0)-32;
  cout << (char)x;

}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

set<ll> factors(ll n){
  set<ll> r;
  for (ll i = 2; i * i <= n; i++){
    if (n % i == 0) r.insert(i);
    while (n % i == 0) {
      n /= i;
    }
  }
  r.insert(n);
  r.insert(1);
  return r;
}

void solve(){ 
  ll a, b;
  cin >> a >> b;
  
  auto p1 = factors(a);
  auto p2 = factors(b);
  int ans = 0;
  for (auto x: p1){
    if (p2.find(x) != p2.end()) ans++;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1000

1 

def f(n):
  if n // 10 == 0:
      return 1
  else:
      return n // 10 * f(n//10)

*/

Measured memory_bytes: 256
n_and_m = input()

n, m = map(int, n_and_m.split())

homeworks = input()
homeworks = homeworks.split()

do_homework = 0
for num in homeworks:
    do_homework = do_homework + int(num)

if do_homework > n:
    print(-1)

else:
    print(n - do_homework)

Measured memory_bytes: 9672
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String A = stdIn.next();
		char c[] = A.toCharArray();
		if(c[0]>=0x41 && 0x5a >= c[0]) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
		stdIn.close();
	}
}


Measured memory_bytes: 35628
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

class UnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.size_dict = {i:1 for i in range(n)}
        self.fuben = n * (n-1) / 2

    def merge(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        if rooti == rootj:
          return
        self.parents[rooti] = rootj
        sj = self.size_dict[rootj]
        si = self.size_dict[rooti]
        self.fuben -= sj*(n-sj)/2
        self.fuben -= si*(n-si)/2
        self.fuben += (sj+si)*(n-(sj+si))/2
        self.size_dict[rootj] += self.size_dict[rooti]
        self.size_dict[rooti] = 0

    def issame(self, i, j):
        rooti = self.findroot(i)
        rootj = self.findroot(j)
        return rooti == rootj

    def findroot(self, i, followed_indices=None):

        if i == self.parents[i]:
            return i
        else:
            root = self.findroot(self.parents[i])
            self.parents[i] = root # 経路圧縮
            return root
          
n, m = LI()
edge_list = []
for i in range(m):
  a, b = LI()
  edge_list.append((a-1, b-1))
  
ans = []

uf = UnionFind(n)
import collections

for e in edge_list[::-1]:
  ans.append(int(uf.fuben))
  uf.merge(e[0], e[1])

for a in ans[::-1]:
  print(a)


Measured memory_bytes: 46960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

vector<ll> A;
vector<ll> F;
ll N;
ll K;

bool check(ll test){
  ll need = 0;
  ll temp;
  REP(i, 0, N){
    // temp = (A[i] * F[i] - test);
    // if (temp <= 0){
    //   need += 0;
    // }
    // else{
    //   if (temp % F[i] == 0)
    //     need += temp / F[i];
    //   else
    //     need += temp / F[i] + 1;
    // }
    need += max(0LL, (F[i] * A[i] - test + F[i] - 1) / F[i]);
  }
  // cout << "test: " << test << endl;
  // cout << (need<=K) << endl;
  return need <= K;
}

ll binary_search (ll m, ll n, ll test) {
  // cout << "binary_search(" << m << ", " << n << ", " << test << ")" << endl;
  ll ret;
  if (n-m <= 1){
    if (check(m))
      return m;
    else
      return n;
  }

  if (check(test)) {
    ret = binary_search(m, test, (m+test)/2);
  }
  else{
    ret = binary_search(test, n, (test+n)/2);
  }

  return ret;
}

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

  ll temp;
  REP(i, 0, N){
    cin >> temp;
    A.push_back(temp);
    // mp.insert(temp);
  }
  REP(i, 0, N){
    cin >> temp;
    F.push_back(temp);
  }

  // main
  sort(A.begin(), A.end()); // 0, 1, 2, 3, ...
  sort(F.begin(), F.end(), greater<ll>()); // 3, 2, 1, 0, ...

  ll M = 0;
  REP(i, 0, N){
    M = max(M, (ll)(A[i] * F[i]));
  }
  ll ans = binary_search(0, M, M/2);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int r, g, b;
  cin >> r >> g >> b;
  cout << ((r*100+g*10+b)%4 ? "NO" : "YES") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

string solve(string& os, string& es){
    string ans;
    for(int i = 0; i < es.size(); i++){
        ans.push_back(os[i]);
        ans.push_back(es[i]);
    }
    if(os.size() > es.size()){
        ans.push_back(os[os.size() - 1]);
    }
    return ans;
}


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

    string os, es;
    cin >> os >> es;
    cout << solve(os, es) << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			int N = in.nextInt();
			int K = in.nextInt();
			if(N == 0 && K == 0) break;
			int [] S = new int [K];
			boolean judge = true;
			for(int i = 0; i < K; i++){
				S[i] = in.nextInt();
			}
			for(int i = 0; i < N; i++){
				for(int m = 0; m < K; m++){
					S[m] -= in.nextInt();
					if(S[m] < 0) judge = false;
				}
			}
			if(judge)System.out.println("Yes");
			else System.out.println("No");
		}
	}
}

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

#define int long long

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

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n + 1), f(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] <= a[i - 1]) f[i] += f[i - 1];
    ans = max(ans, f[i]);
  }
  cout << ans - 1 << '\n';
}


Measured memory_bytes: 4692
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int minX = 0, maxX = W, minY = 0, maxY = H;
    for (int i = 0; i < N; ++i)
    {
        int xi, yi, ai;
        cin >> xi >> yi >> ai;
        if (ai == 1) minX = max(xi, minX);
        else if (ai == 2) maxX = min(xi, maxX);
        else if (ai == 3) minY = max(yi, minY);
        else if (ai == 4) maxY = min(yi, maxY);
    }
    if (minX > maxX || minY > maxY)
        cout << 0 << endl;
    else
        cout << (maxX - minX) * (maxY - minY) << endl;

    return 0;
}

Measured memory_bytes: 256