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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> note;
    long long sum = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        note[a]++;
        sum += a;
    }

    int q_count;
    cin >> q_count;
    int b[q_count], c[q_count];
    for(int i = 0; i < q_count; i++) {
        cin >> b[i] >> c[i];
    }
    for(int i = 0; i < q_count; i++) {
        note[c[i]] += note[b[i]];
        sum += (c[i]-b[i]) * note[b[i]];
        note[b[i]] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 8624
# -*- coding: utf-8 -*-
from math import factorial as fact
def comb(n,r):
    return fact(n) // (fact(r)*fact(n-r))

n,a,b = map(int, input().split())
vl = list(map(int, input().split()))
vl.sort(reverse=True)

res_avg = sum(vl[:a])/a
res_cnt = 0
last_v = vl[a-1]

cnt_all = 0
for v in vl:
    if v==last_v:
        cnt_all += 1

for m in range(a,b+1):
    if sum(vl[:m])/m == res_avg:
        cnt_in = 0
        for i in range(m):
            if last_v==vl[i]:
                cnt_in += 1
        res_cnt += comb(cnt_all, cnt_in)

print("{:6f}".format(res_avg))
print(res_cnt)


Measured memory_bytes: 3064
#include<stdio.h>
int binarySearch(int,int S[],int);
int main(){
    int n,S[100000];
    int q,T[50000];
    int i,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
       scanf("%d",&S[i]); 
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&T[i]);
        count+=binarySearch(n,S,T[i]);
    }
    printf("%d\n",count);
    return 0;
}

int binarySearch(int n,int S[],int key){
    int left,right,mid;
    left=0;
    right=n;
    while(left<right){
        mid=(left+right)/2;
        if(key==S[mid]){
        return 1;
        }
        if(key>S[mid]){
        left=mid+1;
        }
        else if(key<S[mid]){
        right=mid;
        }
    }
    return 0;
}


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

typedef long long ll;
using namespace std;

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

	ll a,b,c,k; cin >> a >> b >> c >> k;

	cout << (k%2==1?b-a:a-b) << endl;	

	return 0;

}


Measured memory_bytes: 256
#118 b
n,m=map(int,input().split())
a=[]
for i in range(n):
    x=list(map(int,input().split()))
    a.append(x)
ans=dict()
cnt=0
for i in a:
    for j in range(1,len(i)):
        z=i[j]
        if z not in ans:
            ans[z]=1
        else:
            ans[z]+=1
for x in ans.values():
    if x==n:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <stack>
#include <string>

using namespace std;

int main()
{
    stack<int> st;
    string str;
    int x,y;
    cin>>str;
    while(cin){
        switch(str[0]){
        case '+':
            y=st.top();
            st.pop();
            x=st.top();
            st.pop();
            st.push(x+y);
            break;
        case '-':
            y=st.top();
            st.pop();
            x=st.top();
            st.pop();
            st.push(x-y);
            break;
        case '*':
            y=st.top();
            st.pop();
            x=st.top();
            st.pop();
            st.push(x*y);
            break;
        default:
            st.push(atoi(str.c_str()));
        }
        cin>>str;
    }
    cout<<st.top()<<endl;
}

Measured memory_bytes: 1196
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[[] for _ in range(N)]
    for i in range(N):
        A[i]=deque(list(map(lambda x: int(x)-1,input().split())))
    days=1
    c=0
    pre=[]
    tmp=[]
    for i in range(N):
        if A[i] and A[A[i][0]][0]==i:
            tmp.append(i)
            tmp.append(A[i][0])
    tmp=list(set(tmp))
    for i in tmp:
        A[i].popleft()
        c+=1
    pre=tmp
    if c<N*(N-1):
        while c<N*(N-1):
            tmp=[]
            for i in pre:
                if A[i] and A[A[i][0]][0]==i:
                    tmp.append(i)
                    tmp.append(A[i][0])
            tmp=list(set(tmp))
            for i in tmp:
                A[i].popleft()
                c+=1
            pre=tmp
            days+=1
            if days>N*(N-1)//2:
                print(-1)
                exit()
    print(days)
                
            
        
    
        
        

    

        
if __name__ == '__main__':
    main()


Measured memory_bytes: 71004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
pii point[200005];
int bit[200005];
ll mod = 998244353, upleft[200005], upright[200005], downleft[200005], downright[200005];
vector<int> y;
int query(int index)
{
	int res = 0;
	for (; index > 0; index -= index & -index)
		res += bit[index];
	return res;
}
void update(int index)
{
	for (; index <= y.size(); index += index & -index)
		++bit[index];
}
ll modpow(ll power)
{
	ll base = 2, res = 1;
	while (power) {
		if (power & 1)
			res = res * base % mod;
		base = base * base % mod;
		power /= 2;
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> point[i].first >> point[i].second;
		y.push_back(point[i].second);
	}
	sort(y.begin(), y.end());
	for (int i = 0; i < n; ++i)
		point[i].second = lower_bound(y.begin(), y.end(), point[i].second) - y.begin() + 1;
	sort(point, point + n);
	for (int i = 0; i < n; ++i) {
		downleft[i] = query(point[i].second);
		upleft[i] = i - downleft[i];
		update(point[i].second);
	}
	memset(bit, 0, sizeof(bit));
	for (int i = n - 1; i >= 0; --i) {
		downright[i] = query(point[i].second);
		upright[i] = n - i - 1 - downright[i];
		update(point[i].second);
	}
	ll ans = n * (((modpow(n) - 1) + mod) % mod) % mod;
	for (int i = 0; i < n; ++i) {
		ll ul = (modpow(upleft[i]) - 1 + mod) % mod, ur = (modpow(upright[i]) - 1 + mod) % mod, 
		dl = (modpow(downleft[i]) - 1 + mod) % mod, dr = (modpow(downright[i]) - 1 + mod) % mod;
		ans = (ans - ul - ur - dl - dr - ul * ur % mod - ul * dl % mod - ur * dr % mod - dr * dl % mod + 10 * mod) % mod;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  string v;
  cin >> N >> v;
  vector<int> e(N+1, 0);
  vector<int> w(N+1, 0);
  REP(i, N) {
    if (v[i] == 'W') {
      w[i+1] = w[i] + 1;
      e[i+1] = e[i];
    } else {
      e[i+1] = e[i] + 1;
      w[i+1] = w[i];
    }
  }

  int ans = N;
  
  for(int i = 1; i <= N; i++) {
    if (i == 0) {
      ans = min(ans, e[N] - e[i]);
    } else if (i == N) {
      ans = min(ans, w[N-1]);
    } else {
      ans = min(ans, w[i-1] + (e[N] - e[i]));
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3076
public class Main {


  private static void solve() {
    int[] a = na(5);
    int k = ni();
    for (int i = 0; i < 5; i ++) {
      for (int j = 0; j < 5; j ++) {
        if (Math.abs(a[i] - a[j]) > k) {
          System.out.println(":(");
          return;
        }
      }
    }
    System.out.println("Yay!");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <algorithm>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	map <char, char> mp;
	int n = s.length();
	for (int i = 0; i < n; ++i) {
		mp[s[i]] = t[i];
	}
	//cout << "done" << endl;

	for (char i = 'a'; i <= 'z'; i++) {
		for (char j = 'a'; j <= 'z'; ++j) {
			if (mp.count(i) == 0 || mp.count(j) == 0 || i == j)
				continue;
			if (mp[i] == mp[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	//cout << "done" << endl;


	for (int i = 0; i < n; ++i) {
		s[i] = mp[s[i]];
	}
	cout << (s == t ? "Yes" : "No") << endl;
	//cout << "done" << endl;

	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N;
	string ans = "Yes";
	cin >> N;
	vector<int> t(N + 1), x(N + 1), y(N + 1);

	t[0] = x[0] = y[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> t[i] >> x[i] >> y[i];

		int time = t[i] - t[i - 1];
		int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);

		if (dist <= time && (dist - time) % 2 == 0)
		{
			// Yes
		}
		else
		{
			ans = "No";
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  
  int a,b,c,d,p;

  cin >> a >> b >> c >> d >> p;

  if(p>c){
    b += d*(p-c);
  }

  a = a*p < b ? a*p : b;

  cout << a << endl;

  return 0;

}

Measured memory_bytes: 3088
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),p=0,c=0,r=0;
		for(int i=0;i<n;++i) {
			int a=s.nextInt();
			if(p<a)
				c=0;
			else
				++c;
			p=a;
			r=Math.max(r,c);
		}
		System.out.println(r);
	}
}


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

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

  string S;
  cin >> S;

  int left_black = 0, right_white = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '.'){
      right_white++;
    }
  }
  int ans = 1e9;
  for(int white_end_idx = 0; white_end_idx <= S.size(); white_end_idx++){
    ans = min(ans, left_black + right_white);
    if(white_end_idx < S.size()){
      if(S[white_end_idx] == '#'){
	left_black++;
      }else{
	right_white--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 832
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const LL mod = 1000000007ll;

LL N,K;
LL A[200000];

LL ans = 0;

LL S[200001];//累積和
//S[0] = 0
//S[i] = A[0] ~ A[i-1]の和　(i>=1)
//と決める
//A[0] = S[1] - S[0]
//......
//A[i] = S[i+1] - S[i]
//......
//A[N-1] = S[N] - S[N-1]

//A[i] + A[i+1] + A[i+2] + .... + A[j-2] + A[j-1] = S[j] - S[i]
//A[i] ~ A[j-1]は要素数j-i

//j>iの時
//(S[j]-S[i])%K==(j-i) 
//つまり
//(S[j]−j)%K==(S[i]−i)%K かつ (j−i)<K
//となるようなi,jの組の数を求める
void solve(){
	S[0] = 0;
	for(int i=1;i<=N;i++) S[i] = (S[i-1] + A[i-1])%K;
	for(int i=0;i<=N;i++) S[i] = (S[i] + (K-i%K))%K;

	//現在見ているインデックスがiだとしたとき、
	map<LL,LL> mp;//S[i-(K-1)]~S[i]のうち、Kで割ったあまりがS[i]である数の個数をmp[S[i]]とおく
	queue<LL> q;//S[i-(K-1)]~S[i]を格納する
	for(int i=0;i<=N;i++){
		ans += mp[S[i]];
		mp[S[i]]++;
		q.push(S[i]);
		while(q.size()>=K){
			mp[q.front()]--;//q.front()はS[i-(K-1)]~S[i]から外れてしまうので減らす
			q.pop();
		}
	}
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> A[i];
		A[i] = A[i]%K;
	}
 
	solve();

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

Measured memory_bytes: 17536
#include<cstdio>
#include<algorithm>
using namespace std;

int n, t, s, a, b;
int dp[3001];

int main() {
  scanf("%d%d%d", &n, &t, &s);
  for (int i = 0; i <= n; i++) dp[i + 1] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    for (int j = t; j >= b; j--) if (!(j > s && s > j - b)) dp[j] = max(dp[j], dp[j - b] + a);
  }
  int ans = 0;
  for (int i = 0; i <= t; i++) ans = max(ans, dp[i]);
  printf("%d\n", ans);
}



Measured memory_bytes: 2760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
		ll x,k,d;
		cin>>x>>k>>d;
		x=abs(x);
		ll move=x/d;
		if(move>=k){

			cout<<x-k*d<<endl;
			return 0;
		}

		k-=move;
		x-=move*d;

		if(abs(x-d)< x){

			x=x-d;
			k--;
		}

		if(k%2==0)
			cout<<abs(x)<<endl;
		else
		{
			if(abs(x+d)< abs(x-d))
				cout<<abs(x+d)<<endl;
			else
			{
				cout<<abs(x-d)<<endl;
			}
		}
	
	return 0;
}

Measured memory_bytes: 3544
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <tuple>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N,M,K;
char inp[300005];
int psum[300005];
int ans = 1e9;
int main(){
	scanf("%d",&N);
	scanf("%s",inp+1);
	for(int i=1;i<=N;i++){
		psum[i]=psum[i-1] +(inp[i]=='.');
	}
	for (int i = 1;i<=N+1;i++){
		int ret = (i-1 - psum[i-1]) + (psum[N]-psum[i-1]);
		ans = min(ans,ret);
	}
	printf("%d",ans);
}

Measured memory_bytes: 1280
K=gets.to_i
if K.even?
    puts "-1"
    exit
end

c=1
n=7
loop do
    break if n%K==0 
    c+=1
    n=(n*10+7)%K
    if n==7 || c == K+1
        puts "-1"
        exit
    end
end
puts c


Measured memory_bytes: 14188
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<long, long> pl;
typedef vector<long, long> vll;
typedef map<int, int> mi;
typedef map<long, long> ml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef tuple<double, int, int> dii;
typedef tuple<int, int, int> iii;
typedef priority_queue<int, vi, greater<int>> min_pq;
 
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, b) for(int i = 0; i < b; ++i)
#define ROF(i, b, a) for(int i = b; i >= a; --i)
#define PER(i, b) for (int i = b; i >= 0; --i)
#define trav(x, a) for(auto x: a)
#define TC(test_case) while(test_case--)
 
#define mp make_pair
#define mtp make_tuple
#define pb push_back
#define eb emplace_back
#define rsz resize
#define pf push_front
#define F first
#define S second

#define ar array
#define LSOne(S) ((S) & -(S))
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define MxN 1005
#define INF 1e9
#define EPS 1e-9
enum {UNVISITED = -1, VISITED = -2};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c, b*d))) << "\n";
    return 0;
}

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

using namespace std;

const int N = 6;

int n, m, k;
int a[N][N], b[N][N];

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        string str; cin >> str;
        for (int j = 0; j < m; j++) {
            a[i][j] = str[j] == '#';
        }
    }
    int res = 0;
    for (int mask = 0; mask < (1 << (n + m)); mask++) {
        int cnt = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                b[i][j] = a[i][j];
        for (int i = 0; i < n; i++) if (mask >> i & 1) {
            for (int j = 0; j < m; j++)
                b[i][j] = 2;
        }
        for (int j = 0; j < m; j++) if (mask >> (n + j) & 1) {
            for (int i = 0; i < n; i++)
                b[i][j] = 2;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++)
                cnt += b[i][j] == 1;
        }
        res += cnt == k;
    }
    cout << res;
}


Measured memory_bytes: 3628
s = input()
s = s[::-1]
t = ["dream", "dreamer", "erase", "eraser"]

i = 0
while i < len(s) - 7 + 1:
    for j in t:
        if s[i:i + len(j)] == j[::-1]:
            i += len(j)
            break
    else:
        print("NO")
        break
else:
    for j in t:
        if s[i:] == j[::-1] or s[i:] == "":
            print("YES")
            break
    else:
        print("NO")


Measured memory_bytes: 9108
inputLine = input().split(' ')
N = int(inputLine[0])
A = int(inputLine[1])
B = int(inputLine[2])

if (B - A) % 2 == 1:
  returnNum = int(min((N - B), (A - 1)))
  print(int(returnNum + 1 + (B - A - 1) // 2))
else:
  print(int((B - A) // 2))


Measured memory_bytes: 3060
/*
 * Problem Description: Shortest Path - All Pairs Shortest Path
 * Category: Graph/Floyd
 * Author: Khan
 * Date: 23th October, 2017
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd()
{
    for (int k = 0; k < n; ++k)
    {
        for (int i = 0; i < n; ++i)
        {
            if(d[i][k] == INFTY)
                continue;
            for (int j = 0; j < n; ++j)
            {
                 if(d[k][j] == INFTY)
                    continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int e, u, v, c;
    cin >> n >> e;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            d[i][j] = ((i == j) ? 0 : INFTY);
    
    for (int i = 0; i < e; ++i)
    {
        cin >> u >> v >> c;
        d[u][v] = c;
    }

    floyd();

    bool negative = false;
    for (int i = 0; i < n; ++i)
    {
        if(d[i][i] < 0)
            negative = true;
    }

    if(negative)
    {
        cout << "NEGATIVE CYCLE" << endl;
    }
    else
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if(j)
                    cout << " ";
                if(d[i][j] == INFTY)
                    cout << "INF";
                else
                    cout << d[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new List<int>();
        Search(9, "", ref list);
        list = list.OrderBy(f => f).ToList();
        int ans = 0;
        for (int i = 0; i < list.Count(); i++)
        {
            if (list[i] <= n) ans++;
            else break;
        }
        Console.WriteLine(ans);
    }
    static void Search(int n, string s, ref List<int> list)
    {
        if (n + 1 == s.Length) return;
        else if (s.Distinct().Count() == 3) list.Add(int.Parse(s));
        Search(n, "3" + s, ref list);
        Search(n, "5" + s, ref list);
        Search(n, "7" + s, ref list);
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};
mint operator "" _m(unsigned long long n) { return n; }

// c[gcd(i, j)] += a[i] * b[j]
vector<mint> zeta(vector<mint> f) {
  const int n = f.size();
  for (int i = 1; i < n; i++) {
    for (int j = i * 2; j < n; j += i) {
      f[i] += f[j];
    }
  }
  return f;
}

vector<mint> moebius(vector<mint> f) {
  const int n = f.size();
  for (int i = n - 1; i >= 1; i--) {
    for (int j = i * 2; j < n; j += i) {
      f[i] -= f[j];
    }
  }
  return f;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  constexpr int U = 1e6;
  vector<mint> inv(U + 1);
  inv[1] = 1;
  for (int i = 2; i <= U; i++) {
    inv[i] = inv[MOD % i] * (MOD - MOD / i);
  }
  int N; cin >> N;
  vector<mint> f(U + 1);
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    f[A[i]] += A[i];
  }
  f = zeta(f);
  for (int i = 1; i <= U; i++) {
    f[i] *= f[i];
  }
  f = moebius(f);
  mint ans = 0;
  for (int i = 1; i <= U; i++) {
    ans += f[i] * inv[i];
  }
  rep(i, N) {
    ans -= mint(A[i]);
  }
  ans *= inv[2];
  cout << ans << endl;
}


Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int wake = 60 * sc.nextInt() + sc.nextInt();
        int sleep = 60 * sc.nextInt() + sc.nextInt();
        int M = sc.nextInt();
        int awaking = wake < sleep ? sleep - wake : 3600 - wake + sleep;
        System.out.println(awaking - M);
    }
}

Measured memory_bytes: 35764
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int INF = 1000;
int solve(vector<string> &field,int n,int sx,int sy,int gx,int gy){
    if(n == 10) return INF;
    int h = field.size();
    int w = field[0].length();
    int mi = INF;
    for(int i=0;i<4;i++){
        int ax=-1,ay=-1;
        for(int j=1;;j++){
            int nx=sx+dx[i]*j;
            int ny=sy+dy[i]*j;
            if(nx >= w or nx < 0 or ny >= h or ny < 0) break;
            if(field[ny][nx] == '1' or field[ny][nx] == '3'){
                ax = nx-dx[i];
                ay = ny-dy[i];
                break;
            }
        }
        if(ax != -1 and ay != -1){
            if(field[ay+dy[i]][ax+dx[i]] == '3'){
                return n+1;
            }else if(sx != ax or sy != ay){
                field[ay+dy[i]][ax+dx[i]] = '0';
                mi = min(mi,solve(field,n+1,ax,ay,gx,gy));
                field[ay+dy[i]][ax+dx[i]] = '1';
            }

        }
    }
    return mi;
}

int main(){
    while(true){
        int w,h;
        cin >> w >> h;
        if(w == 0) break;
        vector<string> field(h,string(w,'0'));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> field[i][j];
            }
        }

        int sx,sy,gx,gy;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j] == '2'){
                    sx = j,sy=i;
                }else if(field[i][j] == '3'){
                    gx = j,gy=i;
                }
            }
        }
        int ans = solve(field,0,sx,sy,gx,gy);
        if(ans == INF) ans = -1;
        cout << ans << endl;;
    }
    return 0;
}

Measured memory_bytes: 1220
import java.util.*;

class Main{

  public static void main(String[] args){
  
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int A=sc.nextInt();
    int B=sc.nextInt();
    
    if(N*A<B){
    System.out.println(N*A);
    }else{
    System.out.println(B);
    }
  }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

string k;
int d;
ll dp[10010][110][2];

void input(){
	cin>>k>>d;
	return;
}

void solve(){
	dp[0][0][1]=1;
	for(int i=0;i<k.size();i++){
		for(int j=0;j<d;j++){
			for(int l=0;l<=9;l++){
				if(l<(k[i]-'0')){
					dp[i+1][(j+l)%d][0]+=dp[i][j][0]+dp[i][j][1];
					dp[i+1][(j+l)%d][0]%=MOD;
				}
				else if(l==(k[i]-'0')){
					dp[i+1][(j+l)%d][0]+=dp[i][j][0];
					dp[i+1][(j+l)%d][1]+=dp[i][j][1];
					dp[i+1][(j+l)%d][0]%=MOD;
					dp[i+1][(j+l)%d][1]%=MOD;
				}
				else {
					dp[i+1][(j+l)%d][0]+=dp[i][j][0];
					dp[i+1][(j+l)%d][0]%=MOD;
				}
			}
		}
	}
	cout<<(dp[k.size()][0][0]+dp[k.size()][0][1]-1+MOD)%MOD<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	
	double a, b, c, r, s, l, h, d;
	
	cin >> a >> b >> c;
	
	if(c > 180 && c <= 270) c -= 90;
	if(c > 270) c -= 180;
	
	if(c <= 90){
		r = sin((c / 180) * 3.14159265);
		h = b * r;
		s = a * h / 2;
		d = sqrt(b*b - h*h);
		l = a + b + sqrt(h*h + (a - d)*(a - d));
	}
	else{
		r = sin((c / 180) * 3.14159265);
		h = b * r;
		s = a * h / 2;
		d = sqrt(b*b - h*h);
		l = a + b + sqrt(h*h + (a + d)*(a + d));
	}
	
	printf("%f\n%f\n%f\n",s,l,h);
	
	return 0;
}

Measured memory_bytes: 1256
#include<stdio.h>
int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int m, n, p;
	m=a;   
	n=b;  
    while(n!=0){ 
		p=m%n;
		m=n;  
		n=p;
	} 
    
	if(c%m == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	} 
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int h1,h2,m1,m2,k,res;
    cin>>h1>>m1>>h2>>m2>>k;
    res = (h2 - h1)*60;
    if(m1 <= m2) {
        res += m2 - m1;
    } else {
        res += m2 + (60 - m1) - 60;
    }
    res -=k;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<math.h>
typedef struct{
  double x,y;
}Point;
void koch(int,Point,Point);
int main(){
  Point a,b;
  int total;
  scanf("%d",&total);
  a.x = a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%f %f\n",a.x,a.y);
  koch(total,a,b);
  printf("%f %f\n",b.x,b.y);
  return 0;
}
void koch(int n,Point a,Point b){
  Point s,t,u;
  double th = M_PI * 60.0 / 180.0;
  if(n==0)return;
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.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;
  koch(n-1,a,s);
  printf("%f %f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  koch(n-1,t,b);
}




Measured memory_bytes: 2064
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S[3]; cin >> S[0] >> S[1] >> S[2];
    int p = 0; int itr[3] = {};
    while(S[p].size()>itr[p]) p = S[p][itr[p]++]-'a';
    cout << (p==0?"A":p==1?"B":"C");
}

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


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

int main()
{
	int n; cin >> n;
	vector<vector<int>> alp(n, vector<int>(26, 0));
	string ans; cin >> ans;
	rep(i, 1, n - 1)
	{
		string s; cin >> s;
		for (char x : s)
		{
			++alp[i][x - 'a'];
		}
	}
	sort(all(ans));
	rep(i, 1, n - 1)
	{
		int len = ans.size() - 1;
		string temp = "";
		rep(j, 0, len)
		{
			if (alp[i][ans[j]-'a'] > 0)
			{
				temp += ans[j];
				--alp[i][ans[j] - 'a'];
			}
		}
		ans = temp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N > 1) {
			int num = 1;
			int prev = sc.nextInt();
			Boolean isInc = null;
			for (int i = 1; i < N; i++) {
				int tmp = sc.nextInt();
				if (prev < tmp) {
					if (isInc == null) {
						isInc = true;
					} else if (!isInc) {
						num++;
						isInc = null;
					}
				}
				if (prev > tmp) {
					if (isInc == null) {
						isInc = false;
					} else if (isInc) {
						num++;
						isInc = null;
					}
				}
				prev = tmp;
			}
			System.out.println(num);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 48624
/* Copyright 2016 AcrossTheSky */
#include <iostream>
#include <cstdio>
#include <utility>
#include <cassert>
#include <map>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <sstream>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define PER(i, a, b) for (int i = (a); i >= (b); --i)
#define RVC(i, c) fot (int i = 0; i < (c).size(); ++i)
#define RED(k, u) for (int k = head[(u)]; k; k = edge[k].next)
#define SQR(k) (k) * (k)
#define lowbit(x) ((x) & (-(x)))
#define CL(x, v) memset(x, v, sizeof x)
#define MP std::make_pair
#define PB push_back
#define FR first
#define SC second
#define rank rankk
#define next nextt
#define link linkk
#define index indexx
#define abs(x) ((x) > 0 ? (x) : (-(x)))
using namespace std;
typedef long long LL; typedef pair<int, int> PII;

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

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

template<class T> inline
void read(T *a) {
    char c;
    while (isspace(c = getchar())) {}
    bool flag = 0;
    if (c == '-') flag = 1, *a = 0;
    else
        *a = c - 48;
    while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
    if (flag) *a = -*a;
}

const int mo = 1000000007;
template<class T>
T pow(T a, T b, int c = mo) {
    T res = 1;
    for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c) if (b & i) res = 1LL * res * a % c;
    return res;
}
/*======================= TEMPLATE =======================*/
bool cmp(const PII &A, const PII &B) {
    return A.FR + A.SC == B.FR + B.SC;
}

PII a[100];
int n, m;

int main() {
    cin >> n >> m;
    int k = 0;
    REP(i, 1, n) REP(j, 1, m) {
        char c;
        while (isspace(c = getchar()));
        if (c == '#') a[++k] = MP(i, j);
    }
    if (k != n + m - 1) 
        return cout << "Impossible" << endl, 0;
    sort(a + 1, a + k + 1);
    REP(i, 2, k) {
        if (a[i].FR == a[i - 1].FR) {
            if (a[i].SC != a[i - 1].SC + 1) 
                return cout << "Impossible" << endl, 0;
        } else if (a[i].SC == a[i - 1].SC) {
            if (a[i].FR != a[i - 1].FR + 1) 
                return cout << "Impossible" << endl, 0;
        } else 
                return cout << "Impossible" << endl, 0;
    }
    return cout << "Possible" << endl, 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for(int i = 0; i < 100100; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    for(int i = 0; i < N; i++) {
        for(int j = 1; j <= K; j++) {
            chmin(dp[i+j], dp[i] + abs(H[i]-H[i+j]));
        }
    }

    cout << dp[N-1] << endl;
    

    return 0;
}

Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline ll getLowestOneBit(ll a)
{
	return a & (-a);
}

inline ll getHighestOneBit(ll a)
{
	while ((a & (a - 1)) != 0)
	{
		a = a & (a - 1);
	}
	return a;
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getSpecifiedBit(ll a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	if (S == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else if (S == "Rainy")
	{
		cout << "Sunny" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int a,b;
  cin>>a>>b;
  cout<<a*b<< endl;

  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(){
    string a;
    cin >> a;
    if(a=="hi"||a=="hihi"||a=="hihihi"||a=="hihihihi"||a=="hihihihihi")cout << "Yes";
    else cout << "No";
}


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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String ans = "NONE";
		
		Player a = new Player(scanner.next().toCharArray());
		Player b = new Player(scanner.next().toCharArray());
		Player c = new Player(scanner.next().toCharArray());
		
		
		char nc = a.cards.poll();
		while (true) {
			if (nc == 'a') {
				if (a.cards.isEmpty()) {
					ans = "A";
					break;
				}
				nc = a.cards.poll();	
			}else if (nc == 'b') {
				if (b.cards.isEmpty()) {
					ans = "B";
					break;
				}
				nc = b.cards.poll();
			}else if (nc == 'c') {
				if (c.cards.isEmpty()) {
					ans = "C";
					break;
				}
				nc = c.cards.poll();
			}
		}
		System.out.println(ans);
		
		scanner.close();
	}
	static class Player{
		private Queue<Character> cards;
		
		public Player(char[] source) {
			cards = new ArrayDeque<Character>();
			for (int i = 0; i < source.length; i++) {
				cards.add(source[i]);
			}
		}		
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define forn(i, s, t) for (int i = s ; i < (int)t ; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x)  cout<<it<<endl;
#define pi pair<int,int>
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define mem(a,x) memset(a,x,sizeof(a))
#define copy(b,a) memcpy(a,b,sizeof(a))
#define SZ(x) (int)x.size()
#define VI vector<int>
#define VII vector<pair<int,int>>
#define PI pair<int,int>
using namespace std;
typedef long long ll;
ll qpow(ll x,ll y,ll p){ll ans=1;for(x%=p;y;y>>=1,x=x*x%p)if(y&1) ans=ans*x%p;return ans;}
ll inv(ll x,ll p){return x<=1?1:(p-p/x)*inv(p%x,p)%p;}
ll sqrt2(ll x){ll l=1,r=2e9;while(l<r){ll mid=(l+r+1)>>1;if(mid*mid<=x) l=mid;else r=mid-1;}return l;}
ll sqrt3(ll x){ll y=(ll)(powl((long double)x,1.0/3.0)+0.5);while(y*y*y<x) y++;while(y*y*y>x) y--;return y;}
ll comb(ll n,ll m,ll p){if(m>n||n<0) return 0;if(m>n-m) m=n-m;ll ans=1;for(int i=1;i<=m;i++)ans=ans*n%p,ans=ans*inv(i,p),n--;return ans;}
ll comb(ll n,ll m){if(m>n||n<0) return 0;if(m>n-m) m=n-m;ll ans=1;for(int i=1;i<=m;i++)ans=ans*n,ans/=i,n--;return ans;}
ll ceil(ll x,ll y){return (x+y-1)/y;}
int lowerbit(int x) {return x&-x;}
int HighBit(int x){for(int i=30;i>=0;i--)if(x>>i&1) return i;}
const int maxn=2e5+5;
int main(){
	ll n;
	cin>>n;
	int ans=0;
	ll i=2;
	while(i*i<=n){
		if(n%i==0){
			int cnt=0;
			while(n%i==0) {
				n/=i;
				cnt++;
			}
			int sub=1;
			while(cnt>=sub){
				cnt-=sub,sub++;
				ans++;
			}
		}
		i++;
	}
	if(n!=1) ans++;
	pf(ans);
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int A, B, C, D, E, F;

int dp[3000+2] = {0}; // 0 未, 1不可, 2可能

int possibleWater(int water){
	int ret = 1;
	if(dp[water] != 0){
		return dp[water];
	}
	for(int i=0; (100 * A * i) <= F; i++){
		for(int j=0; (100 * B * j) <= F; j++){
			int tmp = (100 * A * i) + (100 * B * j) ;
			if(tmp <= F)
				dp[tmp] = 2;
			if(water == tmp){
				ret = 2;
				break;
			}
		}
		if(ret == 2){
			break;
		}
	}
	if(water <= F){
		dp[water] = ret;
	}
	return ret;
}

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

	cin >> A >> B >> C >> D >> E >> F;
	double maxconc = (double)(E) / (double)(100 + E);
	
	// 水 100A g : x回 
	// 水 100B g : y回 
	// さとう C g : u 回
	// さとう D g : v 回
	int water, water1;
	int sugar, sugar1;
	water1 = 100 * A , sugar1 = 0;
	for(water = 100; water <= F; water += 100){
		int possibleW = possibleWater(water);
		if(possibleW != 2) continue;
		int water2 = 100 * A, sugar2 = 0;
		int k = water / 100;
		int u, v;
		for(v = 0; (D * v) <= F - water; v++){
			for(u = 0; (C * u) <= F - water - (D * v); u++){
				sugar = (C * u) + (D * v);
				if( sugar > (E * k) ) continue;
				if((water + sugar) > F) continue;
				if( (sugar + C) <= E * k && (sugar + C + water) <=F){
					u = u + 1;
					sugar = sugar + C;
				}
				double tmp = ((double) sugar) / ((double) (water + sugar));
				if(sugar * (100 + E) > E * (sugar + water)) continue;
				if(sugar2 * (water + sugar) <= sugar * (water2 + sugar2)){
				    sugar2 = sugar;
				    water2 = water;
			    }
			}
		}
		if(sugar1 * (water2 + sugar2) <= sugar2 * (water1 + sugar1)){
			water1 = water2;
			sugar1 = sugar2;
		}
	}
#ifdef DEBUG1
	printf("conc=%.6lf\n", (double)(sugar1) / (double)(sugar1 + water1));
#endif
	printf("%d %d\n", water1+sugar1, sugar1);
	return 0;
}

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

//ABC138A
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
	int n;
	cin >> n;
	vector <int> v(n);
	for(int i=0;i<n;i++){
		cin >> v.at(i);
	}
	sort(v.begin(),v.end());
	double sigma = v.at(0);
	for(int i=1;i<n;i++){
		sigma = (sigma + v.at(i))/2.0;
	}
	cout << sigma << endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
co = []
for i in range(N):
    co.append(list(map(int, input().split())))

ans = 0
for c in co:
    if (c[0] ** 2 + c[1] ** 2) ** 0.5 <= D:
        ans += 1

print(ans)


Measured memory_bytes: 103096
def gcd(a, b):
    r = a % b
    return b if 0 == r else gcd(b, r)


def lcm(a, b):
    return a * b // gcd(a, b)


def g(n, c, d):
    return n - n // c - n // d + n // lcm(c, d)


a, b, c, d = map(int, input().split())
print(g(b, c, d) - g(a - 1, c, d))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    forn(i, n) scanf("%d", &h[i]);
    vector<int> dp(n, INF);
    dp[0] = 0;
    forn(i, n){
        if(i+1 < n) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]- h[i]));
        if(i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
    }
    cout << dp[n-1];
}

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

int main(void)
{
int a, b, c, flag, n;

scanf("%d %d %d", &a, &b, &c);

flag=0;
for(n = 1; n <= b; n++){
 if((n * a % b) == c){
   flag=1;
   break;
 }
}

if(flag==1){
   printf("YES\n");
}else{
   printf("NO\n");
}

return 0;
}

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

int n,a,b;
bool check(ll k,vector<ll> x){
  //bool ok;
  ll ti=0;
  for(int i=0;i<n;++i){
    x[i]-=b*k;
    if(x[i]>0){
      if(x[i]%(a-b)==0) ti+=x[i]/(a-b);
      else ti+=x[i]/(a-b)+1;
    }
  }
  if(ti>k) return 0;
  else return 1;
}

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

  sort(h.rbegin(),h.rend());
  //int diff=a-b;
  ll l=-1;
  ll r=h[0]/b+10;
  //cout << r << endl;
  //cout << l << endl;
  while(r-l>0){
    ll mod=(l+r)/2;
    //cout << check << endl;
    if(check(mod,h)) r=mod;
    else l=mod+1;
  }
  if(!check(l,h)) l=r;
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int D,G,ans=100000000;
  cin>>D>>G;
  vector <int> p(D),c(D);
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }
  for (int bit = 0; bit < (1<<D); ++bit){
    int sum=0, cnt=0;
    for(int i=0;i<D;i++){
      if(bit&(1<<i)){
        sum+=p[i]*100*(1+i)+c[i];
        cnt+=p[i];
      }
    }
    if(sum>=G){
      ans = min(ans,cnt);
    }else{
      for(int i=D-1;i>=0;i--){
        if(!(bit&(1<<i))){
          if((p[i]-1)*100*(1+i)>=G-sum){
            ans = min(ans,cnt+(G-sum+100*i)/(100*(1+i)));
            break;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
vector<pair<ll,ll>> primefac(ll A, ll B){
  ll G=__gcd(A,B);
  vector<pair<ll,ll>>res;
  if(G==1)return res;
  for(int i=2;i<sqrt(G);i++){
    if(G%i!=0)continue;
    ll cnt=0;
    while(G%i==0){
      cnt++;
      G=G/i;
      //cout<<G<<endl;
    }
    res.push_back(make_pair(i,cnt));
  }
  if(G!=1)
  res.push_back(make_pair(G,1));
  return res;
}
int main(){
  ll A,B;
  cin>>A>>B;
  vector<pair<ll,ll>>ans;
  ans=primefac(A,B);
  cout<<ans.size()+1<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
coins = tuple(map(int, input().split(' ')))

dp = [N + 1] * (N + 1)
dp[0] = 0

for i in range(N + 1):
    for coin in coins:
        if coin <= i:
            dp[i] = min(dp[i], dp[i - coin] + 1)

print(dp[N])



Measured memory_bytes: 7256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int i,n,s=0;
	cin>>n;
	vi b(n);
	for0(i,n-1) cin>>b[i];
	s += b[n-2] + b[0];
	for(i=n-2 ; i>0 ; i--){
		s += min(b[i],b[i-1]);
		}
	cout<<s<<nw;
	return 0;
}

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

 
int main() {
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n)cin>>A[i];
    int sum=abs(A[0]);
    rep(i,n-1)sum+=abs(A[i+1]-A[i]);
    //最初と最後だけ例外処理
    cout<<sum-abs(A[0])-abs(A[1]-A[0])+abs(A[1])+abs(A[n-1])<<endl;
    for(int i=1;i<n-1;i++){
        cout<<sum-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])+abs(A[n-1])<<endl;
    }
    cout<<sum-abs(A[n-1]-A[n-2])+abs(A[n-2])<<endl;
}

Measured memory_bytes: 1664