akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=2e5+10;
int n,m,a[N],ans,b[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
inline bool chck(int x)
{
	for(RG int i=1;i<=m;i++) b[i]= a[i]>=x;
	for(RG int i=0;i<n;i++)
	{
		if(b[n-i]==b[n-i-1]) return b[n-i];
		if(b[n+i]==b[n+i+1]) return b[n+i];
	}
	return b[1];
}
int main()
{
//	freopen("Median Pyramid Hard.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n); m=n*2-1;
	for(RG int i=1;i<=m;i++) read(a[i]);
	int l=1, r=m;
	while(l<=r)
	{
		int mid=l+(r-l)/2;
		if(chck(mid)) ans=mid, l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;

const int N = 1000005;
ll a[N];

ll prime[N];
bool vis[N];
void seive()
{
    for(ll i=0;i<=N;i++)
    {
        prime[i]=i;
    }
    prime[0]=0; prime[1]=1;
    for(ll i=2;i*i<=N;i++)
    {
        if(prime[i])
        {
            for(ll j=i*i;j<=N;j+=i)
            {
                prime[j]=i;
            }
        }
    }
}

bool check(ll x)
{
    vector <bool> ths(x+1,0);
    while(x!=1)
    {
        if(vis[prime[x]]==1 && x!=1 && ths[prime[x]]==0)
        {
            return false;
        }
        ths[prime[x]]=1;
        vis[prime[x]]=1;
        x = (x/prime[x]);
    }
    return true;
}

int main() {
  ll n;
  cin>>n;
  ll g; ll ans=1;
  seive();
  for(ll i=0;i<n;i++)
  {
      ll x; cin>>x;
      if(ans==1)
      {
          if(!check(x)) ans=0;
      }
      if(i==0) g = x;
      else g = gcd(g,x);
  }
  if(ans==1) cout<<"pairwise coprime"<<endl;
  else{
    if(g==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
  }
}


Measured memory_bytes: 12576
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */   /* ABC075 D 解説読後 */
const UNI = 100000;
class Int {
  num = [0, 0, 0, 0];
  setValue(v: number): Int {
    for (let i = 0; i < 4; i++) {
      this.num[i] = v % UNI;
      v = (v / UNI) | 0;
    }
    return this;
  }
  less(that: Int): Boolean {
    for (let i = 3; i >= 0; i--) {
      if (this.num[i] < that.num[i]) {
        return true;
      } else if (this.num[i] > that.num[i]) {
        return false;
      }
    }
    return false;
  }
  sub(that: Int): Int {
    let ret = new Int();
    let car = 0;
    for (let i = 0; i < 4; i++) {
      ret.num[i] = this.num[i] - that.num[i] - car;
      if (ret.num[i] < 0){
        car = 1;
        ret.num[i] += UNI;
      } else {
        car = 0;
      }
    }
    return ret;
  }
  mul(that: Int): Int {
    let ret = new Int();
    let car = 0;
    for (let i = 0; i < 4; i++) {
      ret.num[i] += car;
      for (let j = 0; j < 4; j++) {
        ret.num[i+j] += this.num[i] * that.num[j];
      }
      car = (ret.num[i] / UNI) | 0;
      ret.num[i] %= UNI;
    }
    return ret;
  }
  toString(): string {
    let s = '';
    for (let i = 3; i >= 0; i--) {
      if (s.length === 0) {
        if (this.num[i] > 0) {
          s = this.num[i].toString();
        }
      } else {
        let n = '0000' + this.num[i].toString();
        s += n.substring(n.length - 5);
      }
    }
    return s.length === 0 ? '0' : s;
  }
}
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  let s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  const lines = buf.trim().split("\n");
  const getVals = (p) => lines[p].split(' ').map( (x) => parseInt(x) )
  const [n, k] = getVals(0);
  let rects: {x: number, y: number}[] = [];
  for (let i = 0; i < n; i++) {
    const [x, y] = getVals(i+1);
    rects[i] = {x, y};
  }
  let ans: Int | null = null;
  for (let i1 = 0; i1 < n; i1++) {
    for (let i2 = i1+1; i2 < n; i2++) {
      let y1 = rects[i1].y;
      let y2 = rects[i2].y;
      if (y1 === y2) { continue; }
      if (y2 < y1) {
        [y1, y2] = [y2, y1];
      }
      for (let j1 = 0; j1 < n; j1++) {
        for (let j2 = j1+1; j2 < n; j2++) {
	      let x1 = rects[j1].x;
          let x2 = rects[j2].x;
          if (x1 === x2) { continue; }
          if (x2 < x1) {
            [x1, x2] = [x2, x1];
          }
          let cnt = 0;
          for (let p = 0; p < n; p++) {
            const r = rects[p];
            if (r.x < x1 || x2 < r.x) { continue; }
            if (r.y < y1 || y2 < r.y) { continue; }
            cnt++;
          }
          if (cnt >= k) {
            let Y1 = (new Int()).setValue(y1);
            let Y2 = (new Int()).setValue(y2);
            let X1 = (new Int()).setValue(x1);
            let X2 = (new Int()).setValue(x2);
            const s = Y2.sub(Y1).mul(X2.sub(X1));
            if (ans === null || s.less(ans)) {
              ans = s;
            } 
          }
        } // j2
      } // j1
    } // i2
  } // i1
  console.log(ans.toString());
});

Measured memory_bytes: 12468
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int A = sc.nextInt();
            int B = sc.nextInt();
            int T = sc.nextInt();
        sc.close();

        int ans = (T/A) * B;
        System.out.println(ans);

    }
}


Measured memory_bytes: 23636
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n);
	}
    }

    static void solve(int n){
	int[][] f = new int[n][n];
	int x, y;
	x = n/2+1;
	y = n/2;
	f[x][y] = 1;
	//テ」ツつケテ」ツつソテ」ツδシテ」ツδ暗・ツ慊ーテァツつケテ」ツ?ェテ」ツ??

	x = x+1;
	y = y+1;

	int i=2;
	while(i<=n*n){
	    //System.out.println(x+" "+y);
	    if(check(x, y, n)&&empty(x, y, f)){
		f[x][y] = i;
		i++;
		x += 1;
		y += 1;
	    }
	    else{
		if(x<0) x = n-1;
		else if(x>=n) x = 0;
		if(y>=n) y = 0;
		else if(y<0) y = n-1;
     		if(!empty(x, y, f)){
		    x += 1;
		    y -= 1;
		}
	    }
	}

	int a, b;
	for(a=0; a<n; a++){
	    for(b=0; b<n; b++){
		System.out.printf("%4d",f[a][b]);
	    }
	    System.out.println();
	}
    }

    static boolean check(int x, int y, int n){
	boolean a = x<n && x>=0;
	boolean b = y<n && y>=0;
	return a&&b;
    }

    static boolean empty(int x, int y, int[][] f){
	return f[x][y]==0;
    }
}

Measured memory_bytes: 20088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[110];
bool num[27];bool now[27];
int n;int ans;int qwq;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++) scanf("%c",&a[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		  num[a[j]-'a']=true;
		for(int j=i+1;j<=n;j++)
		  if(num[a[j]-'a']==true&&!now[a[j]-'a']) qwq++,now[a[j]-'a']=true;
		ans=max(ans,qwq);
		qwq=0;
		memset(num,0,sizeof(num));
		memset(now,0,sizeof(now));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        long n = stdIn.nextLong();

        long count = 0L;

        for(int i = 0;i < n;i++){
            count+=i;
        }
        
 
        System.out.println(count);

        
    }

}

Measured memory_bytes: 23764
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	char c='T';
	for(int i=0;i<n;i++){
		char d;
		scanf(" %c",&d);
		if(c=='T'&&d=='F')c='F';
		else c='T';
	}
	printf("%c\n",c);
}


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

using namespace std;

int N, v[110];

int main(void) {
    cin >> N;
    int ts = 0;
    for(int i = 0; i < N; i++) cin >> v[i];

    for(int i = 0; i < N; i++) {
        for(int j = N - 1; j >= i + 1; j--) {
			if(v[j] < v[j - 1]) {
				swap(v[j], v[j - 1]); ts += 1;
			}
		}
    }
    for(int i = 0; i < N; i++) {
        if(i == N - 1) {
            cout << v[i] << endl;
        } else {
            cout << v[i] << " ";
        }
    }
    cout << ts << endl;
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll X,t;
	cin>>X>>t;
	cout<<max(X-t,0ll)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200200;
char s[N];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	LL ans=0;
	int cnt=0;
	char st='C';
	for(int i=n-1;i>=0;i--){
		switch(s[i]){
			case 'A':{
				if(st=='C'){
					ans+=cnt;
					st='C';
				}else{
					cnt=0;
					st='C';
				}
				break;
			}
			case 'B':{
				if(st=='B'){
					cnt++;
					st='C';
				}else{
					cnt=0;
					st='C';
				}
				break;
			}
			case 'C':{
				if(st=='C'){
					st='B';
				}else{
					cnt=0;
					st='B';
				}
				break;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef pair<int, int> P;

int n, m;
vector<P> v[200];

double solve(){
  double res = 0;
  double dp[201][201];
  vector<int> area[200];
  vector<int> hv[200];
  
  fill(dp[0], dp[201], 0);  

  for(int i=0;i<n;i++){
    int a = 0;
    int h = 0;
    area[i].push_back(0);
    hv[i].push_back(0);
    for(int j=0;j<v[i].size();j++){
      a += v[i][j].first * v[i][j].second;
      area[i].push_back(a);

      h += v[i][j].second;
      hv[i].push_back(h);
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<=m;j++){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }

    for(int j=0;j<v[i].size();j++){
      for(int k=0;k<=area[i][j+1]-area[i][j];k++){
        for(int l=0;l+area[i][j]+k<=m;l++){
          dp[i+1][l+area[i][j]+k] = max(dp[i+1][l+area[i][j]+k], dp[i][l] + hv[i][j] + (double)k / (double)v[i][j].first);
        }
      }
    }
    
    /*
    for(int j=0;j<v[i].size();j++){
      for(int k=0;k<=m;k++){
        if(k + area[i][j+1] <= m){
          dp[i+1][k+area[i][j+1]] = max(dp[i+1][k+area[i][j+1]], dp[i][k] + hv[i][j+1]);
        } else if(k + area[i][j] <= m){
          //cout << dp[i+1][m] << " -> ";
          dp[i+1][m] = max(dp[i+1][m], dp[i][k] + hv[i][j] + (double)(m - k - area[i][j]) / (double)v[i][j].first);
        //cout << dp[i+1][m] << endl;
        } else break;
      }
    }
    */
  }

  return dp[n][m];
}

int main(){
  int k, x, y;
  while(cin >> n >> m){
    for(int i=0;i<n;i++){
      v[i].clear();
      cin >> k;
      for(int j=0;j<k;j++){
        cin >> x >> y;
        v[i].push_back(P(x, y));
      }
    }
    printf("%.6f\n", solve());
  }
}

Measured memory_bytes: 1628
import sys
import math
input  = sys.stdin.readline
 
a,b,x = map(int,input().split())
y = (2*x)/(a*b)
if y > a:
  b = b - x/(a**2)
  y = a/2
  print(math.degrees(math.acos(y/math.sqrt(y**2+b**2))))
else:
  print(math.degrees(math.acos(y/math.sqrt(y**2+b**2))))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1; i<=(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    ll N; cin >> N;
    ll ans=1LL << 62;
    for (ll i=1; i*i<=N; i++){
        if(N%i==0){
            ans=min(ans,(i-1)+(N/i-1));
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x) make_pair(x)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int w, a, b;
  cin >> w >> a >> b;
  if (a > b) {
    swap(a, b);
  }
  D(max(0, b - a - w));
  return 0;
}



Measured memory_bytes: 256
N = int(input())
W = []
W.append(input())
for i in range(N-1):
    nw = input()
    if nw in W:
        print("No")
        break
    if nw[0] == W[-1][-1]:
        W.append(nw)
        continue
    else:
        print("No")
        break
else:
    print("Yes")


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

int dp[101][4][4][4];
//グローバルに置くと0で初期化してくれる

int main(){
    int N;
    cin >> N;
    //長さ0の文字列は1
    dp[0][3][3][3] = 1;

    rep(len,N){
        //最後から1文字目
        rep(i,4){
            //2文字目
            rep(j,4){
                //3文字目
                rep(k,4){
                    if(dp[len][i][j][k] == 0)continue;
                //新しく追加
                rep(a,4){
                    //だめな5つの条件をカット
                    if(a == 2 &&i == 1&&j == 0)continue;
                    if(a == 2 &&i == 0&&j == 1)continue;
                    if(a == 1 &&i == 2&&j == 0)continue;
                    if(a == 2 &&i == 1&&k == 0)continue;
                    if(a == 2 &&j == 1&&k == 0)continue;

                    //S = ....k j i
                    //nextSS = ..j i a
                    dp[len+1][a][i][j] += dp[len][i][j][k];
                    dp[len+1][a][i][j] %= mod;
                }
            }
        }
    }
    }
    int ans = 0;
 
	//長さNの全部の答えを纏める
	//最後から1文字目の文字
	for (int c1 = 0; c1 < 4; c1++)
	{
		//最後から2文字目の文字
		for (int c2 = 0; c2 < 4; c2++)
		{
			//最後から3文字目の文字
			for (int c3 = 0; c3 < 4; c3++)
			{
				ans += dp[N][c1][c2][c3];
				ans %= mod;
			}
		}
	}

    cout << ans << endl;

    return 0;
}

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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	string s; cin >> s;
	ll sum = 0;
	for(char c : s) sum += (c - '0');
	cout << (sum % 9 == 0 ? "Yes\n" : "No\n");


	return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;
void Main()
{
   int N;
   cin >> N;
   vector<int> D(N);
   FORV(d, D)
   {
      cin >> d;
   }
   sort(D.begin(), D.end());
   int half = N / 2;
   if (D[half - 1] == D[half])
   {
      cout << 0 << endl;
      return;
   }
   cout << D[half] - D[half - 1] << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

ll f(ll b, ll n) {
    return n<b ? n : f(b, n/b)+n%b;
}

int main(void) {
    ll n, s;
    cin >> n;
    cin >> s;
    ll ans1=INF, ans2=INF;
    
    if(n<s) {
        printf("-1\n");
        return 0;
    }else if(n==s) {
        printf("%lld\n", n+1);
        return 0;
    }
    
    ll b;
    for(b=2; b*b<=n; b++) {
        if(f(b, n)==s) {
            ans1=b;
            break;
        }
    }
    
    ll p;
    for(p=1; p*p<=n; p++) {
        b=(n-s)/p+1;
        if((n-s)%p==0 && f(b, n)==s) {
            ans2=b;
        }
    }
    ll ans=min(ans1, ans2);
    if(ans==INF) ans=-1;
    prin(ans);
}

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

using namespace std;

int main()
{
    multiset<int> s;
    int temp;
    for(int i=0;i<6;i++)
    {
        cin >> temp;
        s.insert(temp);
    }
    bool good=1;
    for(int i=1;i<=4;i++)
    {
        if(s.count(i)==0||s.count(i)>2) good=0;
    }
    if(good) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int counts = 0;
	rep(i,3){
		if(s[i] == 'R') counts++;
	}
		if(counts == 0){
			cout << 0 << endl;
			return 0;
		}
		else if(counts == 1){
			cout << 1 << endl;
			return 0;
		}
		else if(counts == 2){
			if(s[1] == 'R'){
				cout << 2 << endl;
			}
			else{
				cout << 1 << endl;
			}
			return 0;
		}
		else if(counts == 3){
			cout << 3 << endl;
		}
}

Measured memory_bytes: 3580
import numpy as np

def ForbiddenList():

    NumA = list(map(int,input().split()))

    NumB = list(map(int,input().split()))

    if len(NumB) != 0:
        result = list(range(min(NumB)-1, max(NumB)+2, 1))

        for data in NumB:
            result.remove(data)

        idx = np.abs(np.asarray(result) - NumA[0]).argmin()

        print(result[idx])

    else:
        print(NumA[0])
    

if __name__ == '__main__':
    ForbiddenList()

Measured memory_bytes: 27228
#include <iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
using namespace std;



int main()
{
	int s;
	int count = 0;
	cin >> s;
	int a[1000100];
	a[1] = s;
	for (int i = 2;;i++)
	{
		if (a[i - 1] % 2 == 0)
		{
			a[i] = a[i - 1] / 2;
		}
		else
		{
			a[i] = 3 * a[i - 1] + 1;
		}

		for (int j = 1; j < i; j++)
		{
			if (a[j] == a[i])
			{
				cout << i;
				count++;
				break;
			}
		}

		if (count == 1)
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, sub, ans;
  while(cin >> n) {
    vector<int> p(n);
    sub = 0; ans = 0;
    for(int i = 0 ; i < n ; i++) {
      cin >> p[i];
    }
    sort(p.begin(), p.end());
    for(int i = 0 ; i < n ; i++) {
      sub += p[i];
      ans += sub;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, p = map(int, input().split())
s =list(str(input()))
s = [int(c) for c in s]
s.reverse()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if s[i]%p == 0:
            ans += n-1-i+1
    print(ans)
    exit()


#print(s)

#s = [0] + s
#from itertools import accumulate
#cum =list(accumulate(s))
#cum = [c%p for c in cum]

def power(a, n, mod):
  bi=str(format(n,"b")) #2進数
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res

temp = 0
cum = [0]*n
for i in range(n):
    temp += s[i]*power(10, i, p)
    temp = temp%p
    cum[i] = temp
cum = [0]+cum

#print(cum)

d = {}
ans = 0
for i in range(n+1):
  if cum[i] not in d:
    d[cum[i]] = 1
  else:
    ans += d[cum[i]]
    d[cum[i]] += 1
print(ans)


Measured memory_bytes: 61680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
  	int n;
  	cin>>n;
  	int a[n+1],i;
  	long long sum= 0;
  	int num  = 1e9;
  	for(i=0;i<n;i++)
  	{
  		cin>>a[i];
  		sum+=a[i];
  		if(a[i]%10!=0)
  		{
  			num = min(num,a[i]);
  		}
  	}
  	if(sum%10==0&&num!=1e9)sum = sum-num;
  	if(sum%10==0)cout<<"0";
  	else cout<<sum;
  	return 0;
} 

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 1;
	for (int i = 0; i < n-1; i++) {
		if (a[i] != a[i + 1]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 9540
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/03 21:01:41 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
string	s;
	cin >> s;

	if (s.at(1) == 'B')
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
using namespace std;
#define MAXN 100001
int dp[MAXN*3];
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N*3;++i){
		cin>>dp[i];
	}
	//dp[i]对应与本次选择i%3(A,B,C)的最大值，等于前面不选择i%3的最大值加上选择i%3的值
	for(int i=3;i<N*3;i++){
		if(i%3==0){
			dp[i]=dp[i]+max(dp[i-2],dp[i-1]);
		}else if(i%3==1){
			dp[i]=dp[i]+max(dp[i-4],dp[i-2]);
		}else{
			dp[i]=dp[i]+max(dp[i-4],dp[i-5]);
		}
	}
	int x;
	if(dp[3*N-1]>=dp[3*N-2]){
		x=dp[3*N-1];
	}else{
		x=dp[3*N-2];
	}
   cout<<(x>dp[3*N-3]?x:dp[3*N-3]);
   return 0;
} 

Measured memory_bytes: 1408
/// IN THE NAME OF GUITAR
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define lc                          id << 1
#define rc                          lc | 1

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
 
const ll MAXN = 2e5 + 20;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll ans = 0, n;

ll F(ll x, ll k) {
	if (x % k == 0) return x / k;
	ll y = (x + k - 1) / k;
	return F(x - y * ((x % k + y - 1) / y), k);
}

int main() {
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		ll x, k; scanf("%lld%lld", &x, &k);
		ans ^= F(x, k);
	}
	if (ans) printf("Takahashi\n");
	else printf("Aoki\n");
    return 0;
}
 

Measured memory_bytes: 3764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

int lhs[100];
int rhs[100];
int par[100];
int find(int x) {
  return par[x] == x ? x : (par[x] = find(par[x]));
}
bool merge(int x, int y) {
  x = find(x);
  y = find(y);
  if(x==y) return false;
  par[x] = y;
  return true;
}

void solve() {
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) cin >> lhs[i] >> rhs[i];
  int ret = 0;
  for(int i = 0; i < m; i++) {
    for(int a = 1; a <= n; a++) par[a] = a;
    int cmps = n;
    for(int j = 0; j < m; j++) {
      if(j == i) continue;
      cmps -= merge(lhs[j], rhs[j]);
    }
    ret += cmps > 1;
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main(){
    int N;
    scanf("%d", &N);
    int cc = N*100/108;
    if ((int)(cc*(1.08)) == N) printf("%d\n", cc);
    else if ((int)((cc+1)*(1.08)) == N) printf("%d\n", cc+1);
    else printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
X=list(map(int,input().split()))
X.sort()

if m==1 or n>=m :
    print(0)
else :

    sa=[]
    for i in range(m-1):
        sa.append(X[i+1]-X[i])


    sa.sort(reverse=1)


    jo=[]
    for i in range(n-1):
        jo.append(sa[i])


    print(X[m-1]-X[0]-sum(jo))


Measured memory_bytes: 13960
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x, y = map(int, input().split())
list_x = make_divisors(x)
list_y = make_divisors(y)
#listの一致するところをとってくる
list_xy = set(list_x) & set(list_y)

a = 0
for i in list_xy:
    if is_prime(i) == True:
        a = a + 1
    else:
        continue
print(a+1)

Measured memory_bytes: 41572
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  int ans=INF,check=0;
  string S;
  cin >> S;
  int L=S.length();
  rep(i,L-2){
    check=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    check=abs(check-753);
    if(check<ans) ans=check;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization
    
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 
from fractions import gcd

a,b = [int(i) for i in readline().split()]
#a = [int(i) for i in readline().split()]

g = gcd(a,b)

if g == 1:
    print(1)
else:
    l = prime_factorize(g)
    print(len(l)+1)





Measured memory_bytes: 5688
// IN THE NAME OF RIGHT
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll k,n,a[200000+10],dp[200000+10];
ll mi=INT_MAX;

int main(){
cin>>k>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
dp[0]=k-a[0]-(k-a[n-1]);
mi=dp[0];
for(int i=1;i<n;i++){
dp[i]=k-(a[i]-a[i-1]);
mi=min(mi,dp[i]);
}
cout<<mi<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX = 100000;
const ll inf = 5e18;

int main() {
	fastio;
	ll n;
    cin>>n;
    vi ans(n);
    f(i,1,n){
        ll x;
        cin >> x;
        ans[x-1]++;
    }
    f(i,0,n){
        cout << ans[i] << endl;
    }
return 0;
}

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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  int n;
  bool locked=true;
  cin >> n;
  set<string> names;
  REP(i,n){
    string tmp;
    cin >> tmp;
    names.insert(tmp);
  }
  cin >> n;
  REP(i,n){
    string tmp;
    cin >> tmp;
    if(names.find(tmp)==names.end())
      cout << "Unknown " << tmp << endl;
    else{
      if(locked) cout << "Opened by " << tmp << endl;
      else cout << "Closed by " << tmp << endl;
      locked=!locked;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int A,B,C,a,b,c;
	cin>>A>>B>>C;
	if(A%2==1 || B%2==1 || C%2==1){
			cout<<0<<endl;
			return 0;
	}
	FOR(i,1,100000000){
		if(i%2==1){
		a=(B+C)/2;
		b=(A+C)/2;
		c=(B+A)/2;
		if(a%2==1 || b%2==1 || c%2==1){
			cout<<i<<endl;
			return 0;
		}}
		else{
			A=(b+c)/2;
			B=(a+c)/2;
			C=(b+a)/2;
		if(A%2==1 || B%2==1 || C%2==1){
			cout<<i<<endl;
			return 0;
		}}
	}
	cout<<-1<<endl;
	return 0;
}






















Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
ans = 0
for x in product(["","+"], repeat = len(s) - 1):
    tmp = ""
    for i in range(len(s)-1):
        tmp += s[i] + x[i]
    tmp += s[-1]
    ans += eval(tmp)
print(ans)

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
    int n, r;
    cin >> n >> r;
    if(n < 10)
    {
        cout << r + 100 * (10 - n) << endl;
    }
    else
    {
        cout << r <<endl;
    }
    return 0;
}



Measured memory_bytes: 256
n, k ,s = map(int, input().split())
ans = []

if s<10**9:
    for i in range(n):
        if i <= k-1:
            ans.append(s)
        else:
            ans.append(s+1)
elif s==10**9:
    for j in range(n):
        if j <= k-1:
            ans.append(s)
        else:
            ans.append(1)
ans = map(str, ans)
print(' '.join(ans))


Measured memory_bytes: 14104
N, K, C = map(int, input().split())
S = input()

F = {}
i = 0
c = 1
while i < N and c <= K:
    if S[i] == 'x':
        i += 1
        continue
    F[c] = i + 1
    i += C + 1
    c += 1

L = {}
i = N - 1
c = K
while i >= 0 and c >= 1:
    if S[i] == 'x':
        i -= 1
        continue
    L[c] = i + 1
    i -= C + 1
    c -= 1

for i in range(1, K + 1):
    if F[i] == L[i]:
        print(F[i])


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

int main() {
  string s;
  int k=0, u=0, p=0, c=0;
  
  cin >> s;
  for(int i = 0 ; i < s.size() ; i++) {
    if(s[i] == 'K') k++;
    if(s[i] == 'U') u++;
    if(s[i] == 'P') p++;
    if(s[i] == 'C') c++;
  }
  cout << min(min(k,u),min(p,c)) << endl;
  return 0;
}

Measured memory_bytes: 0
def main():
    input1 = input().split()
    N = int(input1[0])
    K = int(input1[1])
    d = [0]*K
    count = [0]*N
    for i in range(K):
        input2 = input()
        d[i] = int(input2)
        input3 = input().split()
        for j in range(d[i]):
            count[(int(input3[j]))-1] += 1

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

if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

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

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

void solve()
{
  ll i,j,k,l,m,n;
  cin>>n>>m;
  if(4*n<m)
    cout<<"No";
  else
    if(2*n>m)
      cout<<"No";
  else
    if(m%2==0)
      cout<<"Yes";
  else
    if(m%2!=0)
      cout<<"No";
}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
}
//pr12

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  double x[n][d];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  double num = 0, ans = 0;
  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      for(int k = 0; k < d; k++) {
        num +=  pow(x[i][k] - x[j][k], 2);
      }
      if(ceil(sqrt(num)) == floor(sqrt(num))) ans++;
      num = 0;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
T = []
for i in range(n):
  m1 = list(map(int,input().split()))
  T.append(m1)

l = []
for x in range(m) :
  m2 = int(input())
  l.append(m2)

  
for i in range(n):
  R = [x*y for (x,y) in zip(l,T[i])]
  R1 = sum(R)
  print(R1)
  


Measured memory_bytes: 6024
#include <bits/stdc++.h>
#define int64_t int

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    int dp[n+1][3];
    memset(dp, 0, sizeof(dp));
    for(int i=1;i<=n;i++){
        dp[i][0]=max(a[i-1][0]+dp[i-1][1], a[i-1][0]+dp[i-1][2]);
        dp[i][1]=max(a[i-1][1]+dp[i-1][0], a[i-1][1]+dp[i-1][2]);
        dp[i][2]=max(a[i-1][2]+dp[i-1][1], a[i-1][2]+dp[i-1][0]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}


Measured memory_bytes: 2560
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[], int fs[]){
  T i;
  int sz = 0;
  if(N%2==0){
    fac[sz] = 2;
    fs[sz] = 1;
    N /= 2;
    while(N%2==0){
      N /= 2;
      fs[sz]++;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      fs[sz] = 1;
      N /= i;
      while(N%i==0){
        N /= i;
        fs[sz]++;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    fs[sz] = 1;
    sz++;
  }
  return sz;
}
long long N;
int fs;
long long f[100];
int fn[100];
int main(){
  int i;
  int j;
  int res = 0;
  rd(N);
  fs =Factor_L(N, f, fn);
  for(i=(0);i<(fs);i++){
    for(j=1;fn[i]>=j;j++){
      fn[i] -= j;
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// ll N;
// int fs; ll f[100]; int fn[100];
// {
//   int i, j, res = 0;
//   rd(N);
//   fs = Factor(N, f, fn);
//   rep(i,fs){
//     for(j=1;fn[i]>=j;j++){
//       fn[i] -= j;
//       res++;
//     }
//   }
//   wt(res);
// }


Measured memory_bytes: 3632
#include <iostream>

#define MAX_H 100
#define MAX_W 100

int H, W;
char field[MAX_H][MAX_W];

void dfs(int h, int w, char fruit) {
    field[h][w] = 'x';
    if (0<=w+1 && w+1<W && 0<=h && h<H && field[h][w+1] == fruit) dfs(h, w+1, fruit);
    if (0<=w-1 && w-1<W && 0<=h && h<H && field[h][w-1] == fruit) dfs(h, w-1, fruit);
    if (0<=w && w<W && 0<=h+1 && h+1<H && field[h+1][w] == fruit) dfs(h+1, w, fruit);
    if (0<=w && w<W && 0<=h-1 && h-1<H && field[h-1][w] == fruit) dfs(h-1, w, fruit);
}

void solve() {
    int res=0;
    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            if (field[h][w] != 'x') {
                dfs(h, w, field[h][w]);
                res++;
            }
        }
    }
    std::cout << res << std::endl;
}

int main() {
    while (true) {
        std::cin >> H >> W;
        if (!H && !W) break;

        for (int h=0; h<H; h++) {
            for (int w=0; w<W; w++) {
                std::cin >> field[h][w];
            }
        }
        solve();
    }

    return 0;
}



Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

void solve(long long N){
  while(N>0){N-=1000;}
  cout<<-N<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3760
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll n;
vector<pair<ll,ll>> p;

ld max_d(ld x,ld y){
    ld res=-1;
    rep(i,n) 
    res=max(res,(x-p[i].first)*(x-p[i].first)+(y-p[i].second)*(y-p[i].second));
    return res;
}

ld f(ld x){
    ld l=-1000000,r=1000000;
    ld tl,tr;
    rep(_,160){
        tl=(2*l+r)/3;
        tr=(l+2*r)/3;
        if(max_d(x,tl)>=max_d(x,tr)) l=tl;
        else r=tr;
    }
    return max_d(x,l);
}

int main(){
    cout<<fixed<<setprecision(15);
    cin>>n;
    p.assign(n,mk(0,0));
    rep(i,n){
        ll x,y; cin>>x>>y;
        p[i]=mk(x,y);
    }
    ld l=-1000000,r=1000000;
    ld tl,tr;
    rep(_,160){
        tl=(2*l+r)/3;
        tr=(l+2*r)/3;
        if(f(tl)>=f(tr)) l=tl;
        else r=tr;
    }
    cout<<sqrt(f(l))<<endl;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	static class State{
		int tx,ty,kx,ky, cost;
		State(int tx,int ty,int kx, int ky, int cost){
			this.tx=tx;
			this.ty=ty;
			this.kx=kx;
			this.ky=ky;
			this.cost=cost;
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int w=sc.nextInt();
				int h=sc.nextInt();
				if(w+h==0) break;
				int stx=sc.nextInt();
				int sty=sc.nextInt();
				int skx=sc.nextInt();
				int sky=sc.nextInt();
				int[][] field=new int[51][51];
				
				for(int i=1; i<=h; i++) {
					for(int j=1; j<=w; j++) {
						field[i][j]=sc.nextInt();
					}
				}
				
				Queue<State> q=new LinkedList<>();
				boolean[][][][] minstep=new boolean[51][51][51][51];
				int INF=100000000;
				int[] tdx= {1, 0, -1, 0};
				int[] tdy= {0, 1, 0, -1};
				int[] kdx= {-1, 0, 1, 0};
				int[] kdy= {0, -1, 0, 1};
				q.add(new State(stx, sty, skx, sky, 0));
				int ans=INF;
				
				while(!q.isEmpty()) {
					State state=q.poll();
					if(minstep[state.ty][state.tx][state.ky][state.kx]) continue;
					if(state.cost>=100) {
						ans=INF;
						break;
					}
					
					minstep[state.ty][state.tx][state.ky][state.kx]=true;
					if(state.tx==state.kx&&state.ty==state.ky) {
						ans=state.cost;
						break;
					}
					for(int i=0; i<4; i++) {
						int ntx=state.tx, nty=state.ty, nkx=state.kx, nky=state.ky;
						if(state.tx+tdx[i]>=1 && state.tx+tdx[i]<=w && state.ty+tdy[i]>=1 && state.ty+tdy[i]<=h && field[state.ty+tdy[i]][state.tx+tdx[i]]==0) {
							ntx=state.tx+tdx[i];
							nty=state.ty+tdy[i];
						}
						if(state.kx+kdx[i]>=1 && state.kx+kdx[i]<=w && state.ky+kdy[i]>=1 && state.ky+kdy[i]<=h && field[state.ky+kdy[i]][state.kx+kdx[i]]==0) {
							nkx=state.kx+kdx[i];
							nky=state.ky+kdy[i];
						}
						q.add(new State(ntx, nty, nkx, nky, state.cost+1));
					}
				}
				System.out.println(ans==INF? "NA":ans);
				q.clear();
			}
		}
	}
}


Measured memory_bytes: 336292
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

void solve()
{
  int grp[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
  int x,y;
  cin >> x >> y;

  if(grp[x-1] == grp[y-1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}


Measured memory_bytes: 256
s=int(input())
x1,x2,x3,y1,y2,y3=[0,0,0,0,0,0]
x1=10**9
x2=1
y2=(s+10**9-1)//10**9
y1=(-s%(10**9))%(10**9)
print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int a;
	int b;
}ss[200010];
int cmp(node x,node y){
	if(x.b==y.b) return x.a<y.a;
	else return x.b<y.b;
}
int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			scanf("%d%d",&ss[i].a,&ss[i].b);
		}
		sort(ss,ss+n,cmp);
		int flag=1;
		int sum=0;
		for(int i=0;i<n;i++){
			sum+=ss[i].a;
			if(sum>ss[i].b){
				flag=0;
				break;
			}
		}
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,m,sa[110],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>sa[i];
		ans+=sa[i];
	}
	cin>>m;
	while(m--)
	{
		int p,x;
		cin>>p>>x;
		cout<<ans-sa[p]+x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256