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

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
struct Edge {
	int from, to, cost;

	bool operator<(Edge e) {
		return cost < e.cost;
	}
};

vvi g2i;
vi i2g;
vi weight;


int main() {
	while (true) {
		int N, Q;
		cin >> N >> Q;
		if (N == 0)break;
		g2i = vvi(N);
		i2g = vi(N);
		weight = vi(N, 0);

		rep(i, N) {
			g2i[i].push_back(i);
			i2g[i] = i;
		}

		rep(q, Q) {
			char ch;
			cin >> ch;
			if (ch == '!') {
				int a, b, w;
				cin >> a >> b >> w;
				a--; b--;
				if (i2g[a] == i2g[b])continue;
				//wb-wa=w
				if (g2i[i2g[a]].size() < g2i[i2g[b]].size()) {
					swap(a, b);
					w = -w;
				}
				w += weight[a] - weight[b];
				// gb???ga????§???????b?????°???????????¨??????w????????????
				int ga = i2g[a], gb = i2g[b];
				rep(i, g2i[gb].size()) {
					weight[g2i[gb][i]] += w;
					i2g[g2i[gb][i]] = ga;
				}
				g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
				g2i[gb].clear();
			}
			else {
				int a, b;
				cin >> a >> b;
				a--; b--;
				if (i2g[a] != i2g[b]) {
					cout << "UNKNOWN" << endl;
				}
				else {
					cout << weight[b] - weight[a] << endl;
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
#define MAX 55
#define INF 10000000

int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int H,W;
char a[MAX][MAX];
string s;
int p,ans,len;
int py,px,ty,tx;
int dir,flg;

bool vd[4][MAX][MAX][1005];

int mem[1005];
int search(int x){
  if(mem[x])return mem[x];
  char L=s[x],R;
  if(L=='{')R='}';
  else if(L=='[')R=']';
  else assert(0);
  
  int cnt=1;
  for(int i=x+1;i<len;i++){
    if(s[i]==L)cnt++;
    if(s[i]==R)cnt--;
    if(cnt==0)return mem[x]=i+1;
  }
}

void func(char ch){
  ans++;
  if(ch=='<')dir=(dir+3)%4;
  else if(ch=='>')dir=(dir+1)%4;
  else if(ch=='^'||ch=='v'){
    int k=-1;
    if(ch=='^')k=1;
    int ny=py+dy[dir]*k;
    int nx=px+dx[dir]*k;
    if(a[ny][nx]!='#')py=ny,px=nx;
    if(py==ty&&px==tx&&flg==0){
      cout<<ans<<endl;
      flg=1;
      ans=INF;
    }
  }
}

bool check(){
  char ch=s[p++];
  if(ch=='~')return !check();
  if(ch=='T')return true;
  if(ch=='N')return (dir==0);
  if(ch=='E')return (dir==1);
  if(ch=='S')return (dir==2);
  if(ch=='W')return (dir==3);
  int ny=py+dy[dir];
  int nx=px+dx[dir];
  return (a[ny][nx]=='#');
}

void solve();

void calc(){
  if(flg || ans>=INF)return;
  char ch=s[p++];
  if(ch=='['){
    int np=search(p-1);
    if(check())solve();
    if(flg || ans>=INF)return;
    p=np;
  }else if(ch=='{'){
    int b=p,np=search(p-1);

    while(check()){
      if(vd[dir][py][px][p-1]){
      ans=INF;
      return;
      }
      vd[dir][py][px][p-1]=true;
      solve();
      if(flg || ans>=INF)return;
      p=b;
    }
    p=np;
  }else func(ch);
}

void solve(){
  while(p<len){
    if(s[p]=='}')break;
    if(s[p]==']')break;
    calc();
    if(flg || ans>=INF)return;
  }
}

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
      if(a[i][j]=='s'){
        a[i][j]='.';
        py=i,px=j;
      }else if(a[i][j]=='g'){
        a[i][j]='.';
        ty=i,tx=j;
      }
    }
  }
  cin>>s;
  len=s.size();
  p=ans=dir=flg=0;
  solve();
  if(!flg)cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 12516
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val m, f, b = sc.nextInt
    if (m + f < b) {
      println("NA")
    } else {
      if (m >= b) {
        println(0)
      } else {
        println(b - m)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}




Measured memory_bytes: 45116
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K, Q;
int A[2000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K >> Q;
  rep(i, N) cin >> A[i];
  int m = INF;
  rep(lop, N) {
    int lo = A[lop];
    vector<int> sima;
    vector<int> all;
    rep(i, N) if (A[i] >= lo) {
      if (i==0 || A[i-1]<lo) {
        sort(all(sima), greater<int>());
        while (sima.size() >= K) all.pb(sima.back()), sima.pop_back();
        sima.clear();
      }
      sima.pb(A[i]);
    }
    sort(all(sima), greater<int>());
    while (sima.size() >= K) all.pb(sima.back()), sima.pop_back();
    sort(all(all));
    if (all.size() < Q) continue;
    m = min(m, all[Q-1]-lo);
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n;
    cin>>n;
    int sum  = 0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 or i%5==0)
            continue;
        sum += i;
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3632
import math
"""
def search(min_,max_,A,B,arr):
#    print(min_,max_)
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                #failure
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            #success
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

for i in range(N):
    arr.append(int(input()))

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        sum_+=max(0,math.ceil((x-mid*B)/d))
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

int main() {
    int n;string s; cin >> n >> s; int cnt = 0;
    for(int i = 1;i < s.length();i++){
        if(s[i] == s[i-1]) cnt++;
    }
    cout << n - cnt;
}


Measured memory_bytes: 3724
N = int(input())
S = input()

length = 0 

for i in range(N):
    l1 = i
    l2 = i + length
    _word = S[l1:l2]
    _S = S[l2:]
    while _word in _S and l1 + len(_word) <= l2:
        l2 += 1
        _word = S[l1:l2]
        _S = S[l2:]
    length = max(len(_word)-1, length)

print(length)


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        --a[i];
    }
    int odp = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[i] == i)
        {
            swap(a[i], a[i + 1]);
            ++odp;
        }
    }
    for (int i = 0; i < n; ++i)
        if (a[i] == i)
            ++odp;
    cout << odp;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> s;
	ll m = s.size();
	rep(i, 0, m-1){
		s[i] = ((s[i]-'A')+n)%26+'A';
	}
	print(s)
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int count = 1;

  for(int i = 0; i < N;) {
    if(A[i] < A[i+1]) {
      for(int j = i + 1; j < N-1; ++j) {
        i = j;
        if(A[j+1] < A[j]){
          ++count;
          break;
        }
      }
    } else if(A[i] > A[i+1]) {
      for(int j = i + 1; j < N-1; ++j) {
        i = j;
        if(A[j+1] > A[j]){
          ++count;
          break;
        }
      }
    }
      ++i;
  }
  cout << count << "\n";
}

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


using namespace std;



int main() 
{
	int w, a, b,ans;
	cin >> w >> a >> b;

	if (a > b) swap(a, b);

	ans = b - (a + w);

	if (ans <= 0)cout << "0" << endl;
	else cout << ans << endl;
	return 0;
}


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

ll solve() {
    ll N, a;
    cin >> N;
    ll ans = 0, h = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( a < h+1 ) continue;
        if ( a == h+1 ) {
            h++;
            continue;
        }
        ans += (a-1) / (h+1);
        if ( h == 0 ) h++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[1000000];

int search(int *A, int n, int key)
{
	int left = 0;
	int right = n - 1;

	while (left <= right)
	{
		int middle = (left + right) / 2;
		if (key == A[middle]) return 1;
		else if (key < A[middle]) right = middle - 1;
		else left = middle + 1;
	}
	return 0;
}


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

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}

	int m, key, sum = 0;
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &key);
		if (search(A, n, key) == 1) sum++;
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 3064
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n, k, h[100005], dp[100005];

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = INT_MAX;
		for (int j = max(0, i - k); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}

	cout << dp[n - 1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0019
{
	class Program
	{
		static void Main(string[] args)
		{
			var	n	= long.Parse( Console.ReadLine() );
			
			long	a	= 1;
			for( int i = 1; i <= n; i++ ) {
				a	*= i;
			}
			Console.WriteLine( a );
		}
	}
}

Measured memory_bytes: 5560
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1000000 + 5;
typedef long long ll;
ll edge_num, m, n, q, k;
ll head[maxn];
ll d[maxn];

struct Edge {
	ll from, to, next;
   	ll dis;
} edge[maxn];

void add_edge(ll from, ll to, ll c){
	edge[++edge_num].next = head[from];
	edge[edge_num].from = from;
	edge[edge_num].to = to;
	edge[edge_num].dis = c;
	head[from] = edge_num;
}

bool vis[maxn];
void dfs(ll p){
	vis[p] = true;
	for (ll i = head[p]; i; i = edge[i].next){
		ll to = edge[i].to;
		if (vis[to]) continue;
		d[to] = d[p] + edge[i].dis;
		dfs(to);	
	}
}

int main(){
	cin >> n;
	for (ll i = 1; i < n; i++){
		ll x, y, c;
		cin >> x >> y >> c;
		add_edge(x, y, c);
		add_edge(y, x, c);
	}
	cin >> q >> k;
	dfs(k);
	for (ll i = 1; i <= q; i++){
		ll qa, qb;
		cin >> qa >> qb;
		cout << d[qa] + d[qb] << "\n";
	}
	return 0;
}



Measured memory_bytes: 18432
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[100],i,cnt,mx;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	cnt=1;	mx=1;
	for(i=0;i<n;i++)	{
		if(a[i]==1)	{
			cnt++;
			if(mx<cnt)	mx=cnt;
		}
		else {
			cnt=1;
		}
	}
	printf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 2764
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	int n;					//人数
	int score[300][3];		//入力スコア
	int result[300] = {0};
	int temp;
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> temp;
			score[i][j] = temp;
		}
	}
	
	//i人目のスコア算出
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			temp = score[i][j];
			
			for(int k = 0; k < n; k++){
				//自分じゃない人の被りを見る
				if(i!=k){
					if(temp == score[k][j]){
						//この回の点数は無し
						temp = 0;
						break;
					}
				}
			}
			result[i] += temp;
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << result[i] << endl;
	}
}

	
	

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

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

int main()
{
    int N;
    cin >> N;
    cout << fixed << setprecision(10) << (double)((N + 1) / 2) / (double)N << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  vector<ll> v;
  v.pb(a);
  v.pb(b);
  v.pb(c);
  sort(all(v));
  if(v[0]%2==0||v[1]%2==0||v[2]%2==0){
    cout << 0 << endl;
  }
  else{
    cout << v[0]*v[1] << endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))

template <typename T>
void FILL_(void* ptr, size_t size, T value) {
  std::fill((T*)ptr, (T*)ptr + size, value);
}

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();
}

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n] = {};
  ll ret = 0;
  map<int,int> counts;
  for(int i=0;i<n;++i)
  {
    int tmp;
    cin >> tmp;
    ret += tmp;
    counts[tmp]++;
  }
  int q;
  cin >> q;
  for(int i=0;i<q;++i)
  {
    int b,c;
    cin >> b >> c;

    int change_count = counts[b];
    ret += (change_count) * (c - b);
    counts[c] += change_count;
    counts[b] = 0;
    cout << ret << endl;
  }
}

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

int main(){
  int x,a,b,c;
  cin >> x;
  //x = 100a + 10b + c
  c = x % 10;
  b = (x % 100 - c) / 10;
  a = (x - b * 10 - c) / 100;
  cout <<  a + b + c <<endl;
}


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

int main() {
  string O, E;
  cin >> O >> E;
  for (int i=0; i<E.size(); i++) {
    cout << O[i] << E[i];
  }
  if (E.size()!=O.size()) {
    cout << O[O.size()-1];
  }
  cout << endl;
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (b-a == c-b)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 35672
#include <stdio.h>

int main(){
double a,b,c,d,e,f;
double x,y;

while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
x=c/a-(b*(a*f-d*c))/(a*a*e-a*d*b);
y=(a*f-d*c)/(a*e-d*b);
printf("%4.3f %4.3f\n",x,y);
}

return 0;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector <int> v(n);
    for(int i = 0; i < n; i++)
    	cin >> v[i];
    sort(v.rbegin(), v.rend());
    int sol = v[0] / 2;
    for(int i = 1; i < n; i++) sol += v[i];
    cout << sol;
}


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

long long x, k, d, tmp;

int main() {
	cin >> x >> k >> d;
	if (x < 0) {
		if (abs(x / d) >= k) {
			cout << abs(x + k * d);
			return 0;
		}
		else {
			tmp = abs(x / d);
			x += d * tmp;
			k -= tmp;
		}
		if (abs(x + d) == x) cout << abs(x);
		else if (abs(x + d) < x) {
			x += d;
			k--;
			if (k & 1) cout << abs(x);
			else cout << abs(x + d);
		}
		else if (abs(x + d) > x) {
			if (k & 1) cout << abs(x + d);
			else cout << abs(x);
		}
		return 0;
	}
	if (x / d >= k) {
		cout << x - k * d;
		return 0;
	}
	tmp += x / d;
	x %= d;
	k -= tmp;
	if (abs(x - d) == x) cout << x;
	else if (abs(x - d) < x) {
		x -= d;
		k--;
		if (k & 1) cout << x + d;
		else cout << abs(x);
	}
	else if (abs(x - d) > x) {
		if (k & 1) cout << abs(x - d);
		else cout << x;
	}
	return 0;
}

Measured memory_bytes: 3624
from math import factorial
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    n, p = LI()
    a = LI()
    even = [i for i in a if i % 2 == 0]
    odd = [i for i in a if i % 2 != 0]
    if len(odd) == 0:
        if p == 0:
            ans = 2 ** n
        else:
            ans = 0

    else:
        ans = 2 ** (n - 1)
    print(ans)


main()


Measured memory_bytes: 9108
a = gets.split(' ').map(&:to_i)
a.sort!

if (a[0] + a[1]) % 2 == 0
  puts (a[2] - a[1]) + (a[1] - a[0]) / 2
else
  puts 1 + (a[1] - a[0] - 1) / 2 + a[2] + 1 - a[1]
end

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,ans=0,r,l;cin>>n;
  for (int i = 0; i < n; ++i){
  	cin>>l>>r;
  	ans+=r-l+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
	ll h,w; cin >> w >> h;
	vector<vector<char> > grid(w, vector<char>(h));
	for(auto &a : grid) for(auto &b : a) cin >> b;
	vector<vector<ll> > dp(w, vector<ll>(h));
	for(ll i = 0; i < w; i++) if(grid[i][0] == '#') break; else dp[i][0] = 1;
	for(ll i = 0; i < h; i++) if(grid[0][i] == '#') break; else dp[0][i] = 1;
	for(ll i = 1; i < w; i++) for(ll j = 1; j < h; j++){
		if(grid[i-1][j] != '#') dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
		if(grid[i][j-1] != '#') dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
	}
	cout << dp[w-1][h-1] << endl;
}

Measured memory_bytes: 9088
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

l = []
for i in range(0, len(S), 2):
    tmp = S[i:i+2]
    l.append(tmp)

flag = 0
for j in l:
    if j != 'hi':
        flag = 1
        break

if len(S) > 0 and flag == 0:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {

    int n;
    string str1, str2;

    cin >> n;

    for(int cnt = 0; cnt < n; ++cnt) {

        cin >> str1 >> str2;

        int dp[str1.size() + 1][str2.size() + 1];

        for(int i = 0; i <= str1.size(); ++i) {
            dp[i][0] = 0;
        }

        for(int i = 0; i <= str2.size(); ++i) {
            dp[0][i] = 0;
        }

        for(int i = 1; i <= str1.size(); ++i) {
            for(int j = 1; j <= str2.size(); ++j) {
                if(str1[i - 1] == str2[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        cout << dp[str1.size()][str2.size()] << endl;

    }

}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];




void test_case() {
	
    int h;
    cin>>h;

    int n;
    cin>>n;

    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

    int  sum = accumulate(all(arr),0);

    if(sum >= h) {
        yes;
    } else {
        no;
    }



}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 3992
import java.util.Scanner;
import java.util.Queue;
import java.util.PriorityQueue;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    Queue<Integer> items = new PriorityQueue<Integer>(Collections.reverseOrder());
    for (int i = 0; i < N; i++)
      items.add(sc.nextInt());
    while (M > 0) {
      items.add(items.poll() / 2);
      M--;
    }
    long sum = 0;
    for (int item : items)
      sum += item;
    System.out.println(sum);
  }
}

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

struct node {
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x) {


}

Node treeSearch(Node u, int k) {
	while (u != NIL && k != (*u).key)
	{
		if (k < (*u).key)
			u = (*u).left;
		else
			u = (*u).right;
	}
	return u;
}

Node treeSuccessor(Node x) {


}

void treeDelete(Node z) {
	Node y; // node to be deleted
	Node x; // child of y
}

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if ((*z).key < (*x).key)
			x = (*x).left;
		else x = (*x).right;
		(*z).parent = y;
	}
	if (y == NIL)
		root = z;
	else if ((*z).key < (*y).key)
		(*y).left = z;
	else (*y).right = z;
}

void inorder(Node u) {
	if (u != NIL)
	{
		inorder((*u).left);

		printf(" %d", (*u).key);

		inorder((*u).right);
	}
}

void preorder(Node u) {
	if (u != NIL)
	{
		printf(" %d", (*u).key);

		preorder((*u).left);

		preorder((*u).right);
	}
}


int main() {
	int n, i, x;
	char c[20];
	scanf("%d", &n);

	for (i = 0; i<n; i++) {
		scanf("%s", c);
		if (c[0] == 'f') {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (c[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (c[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (c[0] == 'd') {
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;

}

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


void ten_to_four(int x){
  
  if(x == 0) cout << "0\n";
  vector<int> ans;
  for(int i=0; x!=0 ; i++){
    ans.push_back(x % 4);
    x = (x - (x%4))/4;
  }
  for(int i=ans.size()-1; i>=0 ;i--){
    cout << ans[i] ;
    if(i == 0) cout << "\n";
  }
  
}


int main(){

  while(1){
    int x; cin >> x;
    if(x == -1) break;
    ten_to_four(x);
  }

}

Measured memory_bytes: 1208
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n, m, k;
  std::cin >> n >> m >> k;
  std::vector<long> a(n + 1), b(m + 1);
  a.at(0) = 0;
  b.at(0) = 0;
  for (int i = 1; i <= n; ++i) {
    std::cin >> a.at(i);
    a.at(i) += a.at(i - 1);
  }
  for (int i = 1; i <= m; ++i) {
    std::cin >> b.at(i);
    b.at(i) += b.at(i - 1);
  }

  int ans = 0;
  int j = m;
  for (int i = 0; i <= n; ++i) {
    if (k < a.at(i))
      break;
    while (b.at(j) > k - a.at(i))
      --j;
    ans = std::max(ans, i + j);
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 5984
N=int(input())
L=[0]*4
for i in range(N):
    S=input()
    if(S=="AC"):
        L[0]+=1
    if(S=="WA"):
        L[1]+=1
    if(S=="TLE"):
        L[2]+=1
    if(S=="RE"):
        L[3]+=1
print("AC x {0}".format(L[0]))
print("WA x {0}".format(L[1]))
print("TLE x {0}".format(L[2]))
print("RE x {0}".format(L[3]))


Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

struct card{char suit,bet;};

void bub(struct card a[],int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(a[j].bet<a[j-1].bet){
                card t=a[j];a[j]=a[j-1];a[j-1]=t;
            }
        }
    }
}
void selection(struct card a[],int n){
    int min;
    for(int i=0;i<n-1;i++){
        min=i;
        for(int j=i;j<n;j++){
            if(a[j].bet<a[min].bet)min=j;
        }
        card t=a[i];a[i]=a[min];a[min]=t;
    }
}

void print(struct card a[],int n){
    for(int i=0;i<n;i++){
        if(i>0)cout<<" ";
        cout<<a[i].suit<<a[i].bet;
    }
    cout<<endl;
}

bool stable(struct card b1[],struct card b2[],int n){
    for(int i=0;i<n;i++){
        if(b1[i].suit!=b2[i].suit)return false;
    }
    return true;
}

int main(){
    card b1[100],b2[100];
    int n;
    char ch;
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b1[i].suit>>b1[i].bet;
    }
    
    for(int i=0;i<n;i++)b2[i]=b1[i];
    
    bub(b1,n);
    selection(b2,n);
    
    print(b1,n);
    cout<<"Stable"<<endl;
    print(b2,n);
    if(stable(b1,b2,n)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3108
/* seq332.c */

#include <stdio.h>

int operate(void){
  int p = 0;
  int t_count = 0;
  int N;

  scanf("%d",&N);
  int a[N];

  while(p < N){
    scanf("%d",&a[p]);
    p++;
  }

      for (int j=0; j<N; j++){

        while(a[j] % 2 == 0){

          a[j] = a[j] / 2;
          t_count++;
        }
      }

  return t_count;
}

int main(void){

   printf("%d\n",operate());

}


Measured memory_bytes: 256
s = int(input())

if s % 10 == 2 or s % 10 == 4 or s % 10 == 5 or s % 10 == 7 or s % 10 == 9:
    print("hon")
elif s % 10 == 0 or s % 10 == 1 or s % 10 == 6 or s % 10 == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 61784
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define     loopp(i,n) 	for(int i = 1 ; i <=n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::reverse_iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define     sorted      is_sorted(v.begin(),v.end())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>
#define 	set_it 	    set<int>::reverse_iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  //  freopen ("(input).txt" , "r",  stdin) ;
  //  string st,stt ;
  //  int low=0,high=0;
  //  int l=0,r;
    int n,k,t,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n>>k  ; vect v ,a ,b  ; sett s ; set_it ; mapp m,mm ;  map_it ; pairr p[k] ;
    loop(i,k)
    {
        cin>>p[i].ff>>p[i].ss;
        if(p[i].ff==1)
            m[p[i].ss]++;
    }
    loop(i,k)
    {
        if(m[p[i].ff]>0&&p[i].ss==n)
        {
            temp=1;break;
        }

    }
    if(temp==1)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 19072
#include <iostream>
    #include <queue>
    #include <vector>
    const int INF = 1001001001;
    using namespace std;
    int main() {
    	int N,M;
    	cin>>N>>M;
    	vector<int> to[100005];
    	for(int i=0;i<M;i++){
    	    int a,b;
    	    cin>>a>>b;
    	    --a;
    	    --b;
    	    to[a].push_back(b);
    	    to[b].push_back(a);
    	}
    	queue<int> q;
    	vector<int> dist(N,INF);
    	vector<int> prev(N,-1);
    	dist[0]=0;
    	q.push(0);
    	while(!q.empty()){
    	    int v=q.front();q.pop();
    	    for(int u:to[v]){
    	        if (dist[u] != INF) continue;
                dist[u] = dist[v]+1;
                prev[u] = v;
                q.push(u);
    	    }
    	}
    	cout<<"Yes"<<endl;
    	for(int i=0;i<N;i++){
    	    if(i==0){
    	        continue;
    	    }
    	    int ans=prev[i];
    	    ans++;
    	    cout<<ans<<endl;
    	}
    	return 0;
    }

Measured memory_bytes: 10620
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int x = 1;
	// char ;

	//cin >> W >> H >> x >> y >> r;
	
	for(int i = 1;x!= 0;i++){
		cin >> x;
		if(x != 0) cout <<"Case "<<i<< ": " << x <<endl;
	}
	

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
  int p,q,r;
  scanf("%d %d %d",&p,&q,&r);

  
  if( p+q <= q+r && p+q <= p+r)
    printf("%d",p+q);

  else if(q+r <= p+q && q+r <= p+r)
    printf("%d",q+r);

  else
    printf("%d",p+r);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int N = stdIn.nextInt();
		int K = stdIn.nextInt();

		if(N%K == 0)
		{
			System.out.println(0);
		}
		else {
			System.out.println(1);
		}



	}

}


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

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

#define MOD 1000000007

int main(void) {
    ll s = 0, e = 0, n = 0, w = 0;
    string S;
    cin >> S;
    for(auto &c: S) {
        if(c == 'N') n++;
        if(c == 'S') s++;
        if(c == 'E') e++;
        if(c == 'W') w++;
    }
    cout << ((!s == !n) && (!e == !w) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,k;
    cin>>a>>b>>k;
    if(k<=a)
    {
        cout<<a-k<<" "<<b<<endl;
    }
    else if(k<=a+b)
    {
        cout<<"0 "<<b+a-k<<endl;
    }
    else
    {
        cout<<"0 0"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import typing

def binary_serch(x:int, b_sum:list):
    l = 0
    r = len(b_sum) - 1
    mid = (l + r + 1) // 2
    res = mid
    while True:
        if x == b_sum[mid]:
            return mid
        elif x < b_sum[mid]:
            res = mid - 1
            r = mid
            mid = (l + r + 1) // 2
        elif b_sum[mid] < x:
            res = mid 
            l = mid
            mid = (l + r + 1) // 2
        if l + 1 == r:
            return res

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b_sum = [0] * (m + 2)
for i in range(m):
    b_sum[i + 1] = b[i] + b_sum[i]

b_sum[-1] = 10 ** 9 + 1
a = [0] + a
pass_k = 0
ans = 0
for i in range(n + 1):
    if pass_k + a[i] <= k:
        pass_k += a[i]
        book = i
        book += binary_serch(k - pass_k, b_sum)
        ans = max(ans, book)
    else:
        break

print(ans)

Measured memory_bytes: 120880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll n;
	cin>>n;
	ll arr[n];
	for (ll i=0;i<n;i++) {
		cin>>arr[i];
		
	}
	ll counter=0;
	sort(arr,arr+n);
	for (ll i=0;i<n-1;i++) {
		if (arr[i]==arr[i+1]) {
			counter=1;
			
		}
		
		
	}
	if (counter) {
		cout<<"NO";
	}
	else {
		cout<<"YES";
	}
}
	



Measured memory_bytes: 5160
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);
 
ll n;
vector<ll> powers;

ll go(ll x){
    ll lo = 1, hi = x;
    ll ans = 0;
    while(lo<=hi){
        ll m = (lo+hi)>>1;
        if((m*(m+1)/2) <= x){
            ans = m;
            lo = m+1;
        }else{
            hi= m-1;
        }
    }
    return ans;
}

void solve(){
 

    powers.assign(sqrt(n)+5, 0);
    ll N= n;
    if(n==1){
        printf("%d\n", 0);
        return;
    }

    ll  cnt =0;
    while(n%2==0){
       cnt++;
       n/=2; 
    }


    //printf("%lld\n", n);
    powers[2] = cnt;
    cnt = 0;

 
    for(int i = 3; i <= sqrt(N); i+=2){


        while(n%i==0){
            cnt++;
            n/=i;
        }
        powers[i] = cnt;

        cnt = 0;
    }

    ll ans = 0;
    for(auto x:powers){
        //printf("%d", x);
        ans += go(x);
    }
    if(n >= sqrt(N)){
        ans++;

    }
    printf("%lld\n",ans );
} 
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 
    scanf("%lld", &n);
    solve();
 
 
    return 0;
 
 
}


Measured memory_bytes: 11108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
ll a[100005];

int main()
{
	ll ans = 0;
	ll sum = 0;

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

	for (int i = 0; i <= n; i++) {
		if (a[i] == 0) {
			ans += sum / 2;
			sum = 0;
		}
		else {
			sum += a[i];
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
	int n;
	while( cin >> n && n ){
		int count = 0;
		while( n != 1 ){
			++count;
			if( n % 2 ){
				n = n * 3 + 1;
			}else{
				n /= 2;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
s = input()

s = list(s)
sowth = s.count('S') if 'S' in s else 0
east  = s.count('E') if 'E' in s else 0
north = s.count('N') if 'N' in s else 0
west  = s.count('W') if 'W' in s else 0

if (sowth != 0 and north == 0) or\
    (sowth == 0 and north != 0) or\
    (west != 0 and east == 0) or\
    (west == 0 and east != 0):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9040
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int a[200010],b[200010];
signed main() {
	int n;
	cin >> n;
	int wa = 0,sum=0;
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
		if (a[i] > wa) {
			wa = a[i]; sum = i;
		}
	}
	sort(b, b + n);
	rep(i, n) {
		if (i != sum)cout << wa << endl;
		else cout << b[n - 2] << endl;
	}
}

Measured memory_bytes: 4736
#include<stdio.h>

#define N 100000

int partition(int, int);

int A[N];

int main(){
  int n,q,i;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  q = partition(0,n-1);

  for(i=0 ; i<n ; i++){
    if(i > 0) printf(" ");
    if(i == q) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");

  return 0;
}

int partition(int p, int r){
  int x, i, j, k;

  x = A[r];
  i = p-1;

  for(j=p ; j<r ; j++){
    if(A[j] <= x){
      i++;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }

  k = A[i+1];
  A[i+1] = A[r];
  A[r] = k;

  return i+1;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  ll n,anss;
  IN1(n);
  vector<string>s_array(n);
  FOR(i,n){
    cin >> s_array.at(i);
  }
  set<string>ans;
  FOR(i,n){
    ans.insert(s_array.at(i));
  }
  anss = ans.size();
  OUT(anss);
}

Measured memory_bytes: 25100
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 //要climits#includ
#define SIZE 100001;
#define MOD 1000000007

typedef long long ll;

using namespace std;


int main(void){
	string str;
	cin >> str;
	char ch1=NULL, ch2=NULL;
	for(int i=0; i<str.length(); i++){
		if(str[i] != ch1){
			if(ch1 == NULL){
				ch1 = str[i];
			}else if(str[i] != ch2){
				if(ch2 != NULL){
					cout << "No" << endl;
					return 0;
				} else ch2 = str[i];
			}
		}
	}
	if(ch2 == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

 
 int main(){

   int i,j,m,n,cnt=0;
   long long a[10005],b[505];

   scanf("%d",&m);
   for(i=0;i<m;i++){
     scanf("%lld",&a[i]);
     //  printf("%d ",a[i]);
   }
   scanf("%d",&n);
   for(i=0;i<n;i++){
     scanf("%lld",&b[i]);
     //  printf("%d ",b[i]);
   }

   for(j=0;j<n;j++){
     i=0;
     a[m]=b[j];
     
     while(1){
       if(i==m-1){
	 break;
       }
       if(a[i]==a[m]){
	 cnt++;
	 break;
       }
       i++;
     }
     
   }

   printf("%d\n",cnt);

   
   
   return 0;
 }



Measured memory_bytes: 2108
#include <stdio.h>
int main(void){char s[3][99];int i=0,j=0,p=0,c;int a[3],b[3]={};while(i!=3){c=getchar();if(c=='\n'){a[i++]=j;j=0;}else{s[i][j++]=c;}}while(b[p]!=a[p]){p=s[p][(b[p])++]-'a';}printf("%c\n",p+'A');return 0;}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits>
#include <queue>
#include <map>
#include <ctime>

using namespace std;

#define rip(i,n,s) (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()

int inc = 0;
int n;

void dfs(vector<int> &day, vector<int> &co, vector<vector<int>> &da, int gg) {
	if (co[gg] == n - 1) {
		return;
	}
	int x = da[gg][co[gg]];
	if (co[x] == n - 1) {
		return;
	}
	if (da[x][co[x]] == gg) {
		co[x]++;
		co[gg]++;
		day[x] = max(day[x], day[gg]) + 1;
		day[gg] = day[x];
		inc++;
		dfs(day, co, da, gg);
		dfs(day, co, da, x);
	}
}

int main() {
	cin >> n;
	vector<vector<int>> da(n, vector<int>(n - 1));
	for rip(i, n, 0) {
		for rip(j, n - 1, 0) {
			cin >> da[i][j];
			da[i][j]--;
		}
	}
	vector<int> day(n, 0), co(n, 0);
	int ma = n * (n - 1) / 2;
	for rip(i, n, 0) {
		dfs(day, co, da, i);
	}
	for rip(i, n, 0) {
		if (co[i] != n - 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = 0;
	for rip(i, n, 0) {
		ans = max(ans, day[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 27520