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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

  int n;
  cin >> n;
  vll s(n);
  REP(i,n) cin >> s[i];
  int m;
  cin >> m;
  int cnt = 0;

  for(int i=0;i<m;i++){
    int key;
    cin >> key;
    int l, r;
    int lef = -1;
    int rig = n;
    while(rig-lef>1){
      int mid = (lef + rig) /2;
      if(s[mid]>=key) rig = mid;
      else lef = mid;
    }
    l = rig;
    lef = -1;
    rig = n;
    while(rig-lef>1){
      int mid = (lef + rig) /2;
      if(s[mid]>key) rig = mid;
      else lef = mid;
    }
    r = rig;
    cnt += min(1,(r - l));
  }

  cout << cnt <<endl;
    
  return 0;
}




Measured memory_bytes: 3444
# include <iostream>
# include <cstdio>

using namespace std;
 
int A, B, C;

int main()
{
	scanf("%d %d %d", &A, &B, &C);
	
	if(B - A == C - B)
	{
		printf("YES\n");
	 } 
	else
	{
		printf("NO\n");
	}
			
	return 0;
} 

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, A, B, C, D;
string S;

int main(){
	cin >> N >> A >> B >> C >> D >> S;
	A--; B--; C--; D--;
	if(A > B){
		swap(A, B);
		swap(C, D);
	}
	if(C < D){
		for(int i=A; i<C; i++){
			if(S[i] == '#' && S[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=B; i<D; i++){
			if(S[i] == '#' && S[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else{
		for(int i=A; i<C && i+1<N; i++){
			if(S[i] == '#' && S[i+1] == '#'){
				cout << "No" << endl;
				return 0;
			}
		}
		for(int i=B; i<=D && i+1<N; i++){
			if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
	}
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define clr(n, r) memset(n,r,sizeof(n))
#define endl "\n"
typedef bitset<11> MASK;
typedef pair<int, int> ii;
typedef vector<int> vii;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<vector<int>> vvi;
#define all(v) v.begin(),v.end()

int main() {
    std::ios_base::sync_with_stdio(false);
//        freopen("scratch.txt", "r", stdin);
    int n;cin>>n;
    unordered_map<string ,int>freq;
    string s[]={"AC","WA", "TLE","RE"};
    for (int i = 0; i <4 ; ++i) {
        freq[s[i]]=0;
    }
    while(n--){
        string a;cin>>a;
        freq[a]++;
    }
    for (int j = 0; j < 4; ++j) {
        cout<<s[j]<<" x "<<freq[s[j]]<<endl;
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b, c, d;

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

    if (a * b <= c * d) {
        cout << c * d;
    } else {
        cout << a * b;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (a < k)
    {
        k -= a;
        cout << 0 << " " << max(0LL, b - k) << endl;
    }
    else
    {
        cout << a - k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
s=list(input())
white=s.count("W")
red=s.count("R")
llist=[]
wl=0
wr=white
bl=0
br=red
swap=0
for i in range(len(s)):
    if(s[i]=="W"):
        wr-=1
        if(wl<=br):
            llist.append(br)
        else:
            llist.append(wl)
        wl+=1
    else:
        br-=1
        if(wl<=br):
            llist.append(br)
        else:
            llist.append(wl)
        bl+=1
print(min(llist))

Measured memory_bytes: 91064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  rep(i, K)
  {
    if (B <= A)
      B *= 2;
    else if (C <= B)
      C *= 2;
  }
  bool ans = false;
  if (A < B && B < C)
    ans = true;
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	string str;
	cin >> str; N = sz(str);
	if(str[0] != 'A') {
		cout << "WA\n"; return;
	}
	else {
		int at = -1;
		rep(i, 2, N - 1) {
			if(str[i] == 'C') {
				at = i;
				break;
			}
		}
		if(at == -1) {
			cout << "WA\n";
			return;
		}
		rep(i, 1, N) {
			if(i != at && 'A' <= str[i] && str[i] <= 'Z') {
				cout << "WA\n"; return;
			}
		}
		cout << "AC\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
ll mx=0;
ll ans=0;
for(int i=0;i<n;i++)
{
if(a[i]<mx)
{
ans+=mx-a[i];
}
mx=max(a[i],mx);
}
cout<<ans<<endl;
}
/*
 *||||

 */

Measured memory_bytes: 5104
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""
if n == 1:
    r = collections.Counter(s[0])
    for k in sorted(r):
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Measured memory_bytes: 3316
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n,m,l=0,i;
    string id;
    string c;
    vector<string>vec;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>id;
        vec.push_back(id);
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>c;
        if(find(vec.begin(), vec.end(), c)!=vec.end()){
            cout<<((++l%2)==1?"Opened by ":"Closed by ")<<c<<endl;
        }
        else
            cout<<"Unknown "<<c<<endl;
    }
    return 0;
}

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

#define ll long long int
#define M 10007

int main()
{
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    ll dis=abs(b-a);
    v-=w;
    if(v<=0&&b!=a)
    {
        cout<<"NO\n";
        return 0;
    }
    if(b==a)
    {
        cout<<"YES\n";
        return 0;
    }
    ll time=0;
    if(v>0)
        time=dis/v;
    if(v>0&&dis%v)
        time++;
    dis=dis-min(time,t)*v;
    if(dis<=0&&v>=0)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> shops(N);
    rep(i, 0, N) cin >> shops[i].first >> shops[i].second;

    sort(shops.begin(), shops.end());

    ll budget = 0;
    int si = 0;
    while(M > 0) {
        int numBuy = min(M, shops[si].second);
        M -= numBuy;
        shops[si].second -= numBuy;
        budget += (ll)numBuy * (ll)shops[si].first;

        if (shops[si].second == 0) ++si;
    }

    cout << budget << "\n";
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		Structure[] s = new Structure[n];
		
		for(int i = 0; i < n; i++){
		    s[i] = new Structure(i+1, sc.next(), sc.nextInt());
		}
		// 計算
		int result = 0;
		Arrays.sort(s);

		// 出力
		for(int i = 0; i < n; i++){
		    System.out.println(s[i].num);
		}
		//System.out.println(result);
	}
}

class Structure implements Comparable<Structure> {
	int num;
	String city;
	int point;

	Structure(int n, String s, int p) {
		this.num = n;
		this.city = s;
		this.point = p;
	}

	@Override
	public int compareTo(Structure obj) {
	    // this > obj => 1
	    // this < obj => -1
	    // this == obj => 0
	    int order = 0;
	    
	    order = this.city.compareTo(obj.city);
	    if(order == 0){
	        order = Integer.compare(obj.point, this.point);
	    }

		return order;
	}

	public String toString() {
		return String.valueOf("");
	}
}


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

int main(){
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	
	for(int i=a; i<=b; i++){
		if(c % i == 0) ans++;
	}
	
	cout << ans << endl;
	return 0;
}


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

int main(){
    int N,M;
    cin >> N >> M;
    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long A, B;
    cin >> A >> B;
    const auto& f = [&A, &B](unsigned long x) -> unsigned long {
        return (A * x) / B - A * (x / B);
    };
    unsigned long N;
    cin >> N;
    cout << max(f(min(N, B - 1)), f(N)) << endl;
    return 0;
}

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

int main(){
        int n,m;cin >> n >> m;
        vector<int> v(n+m);
        for(int i=0;i<n;i++) v[i]=n-i;
        for(int i=0;i<m;i++) cin >> v[n+i];
        vector<bool> c(n+1,false);
        for(int i=n+m-1;i>=0;i--){
                if(c[v[i]]) continue;
                c[v[i]]=true;
                cout << v[i] << endl;
        }
        return 0;
}


Measured memory_bytes: 4180
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int n, a, s[200000];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &a);
    s[a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", s[i]);
  }
}

Measured memory_bytes: 2508
A = [[int(s) for s in input().split()] for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

def in_B(n, B):
  if n in B:
    return True
  else:
    return False
    
is_B = [[in_B(A[i][j],B) for j in range(3)] for i in range(3)]

bingo_idx = [[(0,0), (0,1), (0,2)],
             [(1,0), (1,1), (1,2)],
             [(2,0), (2,1), (2,2)],
             [(0,0), (1,0), (2,0)],
             [(0,1), (1,1), (2,1)],
             [(0,2), (1,2), (2,2)],
             [(0,0), (1,1), (2,2)],
             [(2,0), (1,1), (0,2)]]

bingo = False
for a, b, c in bingo_idx:
  ai, aj = a
  bi, bj = b
  ci, cj = c
  if is_B[ai][aj] and is_B[bi][bj] and is_B[ci][cj]:
    bingo = True
    break

if bingo:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 3e5+35;
int n,k,a[maxn],tr[maxn<<2];
void updata(int l,int r,int pos,int x,int v){
    if(l == r){
        tr[x] = v;
        return ;
    }
    int mid = (l+r) >> 1;
    if(pos > mid) updata(mid+1,r,pos,x<<1|1,v);
    else updata(l,mid,pos,x<<1,v);
    tr[x] = max(tr[x<<1],tr[x<<1|1]);
}
void query(int l,int r,int L,int R,int x,int &ans){
    if(l > R || r < L) return ;
    if(l >= L && r <= R){
        ans = max(ans,tr[x]);
        return ;
    }
    int mid = (l+r) >> 1;
    query(l,mid,L,R,x<<1,ans);
    query(mid+1,r,L,R,x<<1|1,ans);
}
int main(){
    scanf("%d %d",&n,&k);
    for(int i = 1;i <= n; ++i) scanf("%d",a+i);
    for(int i = 1;i <= n; ++i){
        int L = max(0,a[i]-k);
        int R = min(maxn-20,a[i]+k);
        int ans = 0;
        query(0,maxn-20,L,R,1,ans);
        updata(0,maxn-20,a[i],1,ans+1);
    }
    printf("%d\n",tr[1]);
    return 0;
}

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

int main(){
  int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v<w||v==w){
      cout<<"NO"<<endl;
      return 0;
  }
  int ans=0;
  if(abs(a-b)%abs(v-w)!=0){
      ans=abs(a-b)/abs(v-w)+1;
  }
  else{
      ans=abs(a-b)/abs(v-w);
  }
  if(ans<=t){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 3636
K=int(input())
S=input()
N=len(S)
mod=10**9+7

def cmb(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,3000003):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
P=0
for i in range(N,N+K+1):
  P=(P+cmb(N+K,i)*pow(25,N+K-i,mod))%mod
print(P)

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

using namespace std;

int main() {

	int n, m; cin >> n >> m;

	vector<string> arr(n);

	for (int i = 0; i < n; i++)
		cin >> arr[i];

	sort(arr.begin(), arr.end());

	string result;

	for (int i = 0; i < n; i++)
		result += arr[i];

	cout << result;

	return 0;

}

Measured memory_bytes: 256
from math import sqrt


def calc_distance(Y, Z):
    return sqrt(sum((y - z) ** 2 for y, z in zip(Y, Z)))


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        distance = calc_distance(X[i], X[j])
        cnt += distance.is_integer()
print(cnt)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    vector<int> r;
    while(true){
        int in;
        cin >> in;
        if(!in) break;
        r.emplace_back(in);
    }

    vector<vector<int>> graph;
    vector<int> cnts;
    auto it=r.begin();
    function<void(const int,const int)> dfs=[&](const int cnt,const int par){
        const int id=graph.size();
        graph.emplace_back(vector<int>(*it,-1));
        cnts.emplace_back(cnt);
        if(par!=-1) graph[id][0]=par;
        ++it;
        rep(i,1,graph[id].size()){
            if(graph[id][i]!=-1) continue;
            if(*it<0){
                [&](){
                    rep(j,0,graph.size()){
                        if(cnts[j]-cnts[id]!=*it) continue;
                        rep(k,0,graph[j].size()){
                            if(graph[j][k]!=-1) continue;
                            graph[id][i]=j;
                            graph[j][k]=id;
                            return;
                        }
                    }
                }();
                ++it;
            }else{
                graph[id][i]=graph.size();
                dfs(cnt+1,id);
            }
        }
    };
    dfs(0,-1);
    rep(i,0,graph.size()){
        cout << i+1;
        sort(graph[i].begin(),graph[i].end());
        for(const auto id:graph[i]) cout << " " << id+1;
        cout << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    int n;
    cin >> n;
    rep(i,0,n) solve();
    return 0;
}

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

using namespace std;

int main()
{
   long long a,b;
   cin>>a>>b;
   if (a<=5)
    cout<<0;
    else if (a>=6&&a<=12)
        cout<<b/2;
    else if (a>12)
        cout<<b;


    return 0;
}


Measured memory_bytes: 256
import numpy as np

s = list(input())
t = list(input())

if len(s)+1 == len(t):
    for i in range(len(s)):
        if s[i] == t[i]:
            if i == len(s)-1:
                print("Yes")
                continue
            else:
                continue
        else:
            print("No")
            break

else:
    print("No")

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, nn, ans = 0, d;
  cin >> n;

  
  for (ll a = 2; a * a <= n; ++a) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    int x = 0;
    while ((x + 1) * (x + 2) / 2 <= ex) x++;
    ans += x;
  }
  if (n != 1) ans++;


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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	while(true){
		int N;
		scanf("%d",&N);
		if(N==0)break;
		int Q[10];
		for(int i=0;i<10;i++){
			Q[i]=0;
		}
		for(int i=0;i<N;i++){
			int num;
			scanf("%d",&num);
			Q[num]++;
		}
		for(int i=0;i<10;i++){
			if(Q[i]==0){
				printf("-\n");
			}
			else{
				for(int j=0;j<Q[i];j++){
					printf("*");
				}
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    val ab = a.toString().repeat(b)
    val ba = b.toString().repeat(a)

    print(if (ab < ba) ab else ba)
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string>v;
    for(int i = 0; i < n; i++){
        string ch;
        cin >> ch;
        v.push_back(ch);
    }
    sort(v.begin(), v.end());
    int cnt = 1;
    for(int i = 1; i < n; i++){
        if(v[i] != v[i-1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 11660
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

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

    int mx_inter = 0;
    for (int i = 0; i < N - 1; i++) {
        mx_inter = max(mx_inter, A[i + 1] - A[i]);
    }
    mx_inter = max(mx_inter, (A[0] + K) - A[N - 1]);

    cout << K - mx_inter << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
#define int long long
const int mod = 1000000007;
const int maxn = 3005;
int dp[maxn][maxn];
int32_t main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0] = 1;
    for(int i = 1; i < n; i++)
    {
        if(s[i - 1] == '<')
        {
            int sum = 0;
            for(int j = 0; j <= i; j++)
            {
                dp[i][j] = sum;
                sum = (sum + dp[i - 1][j]) % mod;
            }
        }
        else
        {
            int sum = 0;
            for(int j = i; j > 0; j--)
            {
                dp[i][j] = sum;
                sum = (sum + dp[i - 1][j - 1]) % mod;
            }
            dp[i][0] = sum;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++)
        sum = (sum + dp[n - 1][i]) % mod;
    cout << sum << "\n";
    return 0;
}


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

int main(){

  int N;
  double x[11];
  string u[11];

  double ans = 0;

  cin >> N;

  for(int i = 0 ; i < N ; i++){
    cin >> x[i] >> u[i];
  }

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

    if(u[i] == "JPY") ans += x[i];
    if(u[i] == "BTC") ans += x[i]*380000.0;

  }

  cout << ans << endl;
  

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        int C = sc.nextInt();

        double S = Math.sin(Math.toRadians(C)) * a * b / 2;
        double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(C)));
        double h = b * Math.sin(Math.toRadians(C));

        System.out.println(S);
        System.out.println(L);
        System.out.println(h);


    }
}



Measured memory_bytes: 27912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,k,t,d;
    cin>>n>>k;
    vector<pair<ll,ll>> A,B,C;
    int var[200001]={0};
    rep(i,n) cin>>t>>d,A.push_back(make_pair(d,t));
    sort(A.begin(),A.end(),greater<pair<ll,ll>>());
    rep(i,k) B.push_back(A[i]),var[A[i].second]++;
    rep(i,n-k) C.push_back(A[i+k]);
    reverse(B.begin(),B.end());
    ll c=0,ans=0,sum=0,x=0;
    rep(i,k) sum+=B[i].first;
    rep(i,n) if(var[i+1]) x++;
    ans=sum+x*x;
    rep(i,k){
        if(var[B[i].second]>1){
            while(c<n-k&&var[C[c].second]!=0) c++;
            if(c==n-k) break;
            var[B[i].second]--;
            sum-=B[i].first;
            B[i].first=C[c].first;
            B[i].second=C[c].second;
            var[B[i].second]++;
            sum+=B[i].first;
            x++;
        }
        ans=max(ans,sum+x*x);
    }
    cout<<ans;
}

Measured memory_bytes: 6256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
 
 
using namespace std;
 
//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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  int a,b,k;
  cin>>a>>b>>k;
  int cnt = 0;
  for(int i=b; i >=1; i--){
    if(a%i==0 && b%i==0){
      // cout<<i<<endl;
      cnt++;
      if(cnt==k){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  string str[3];
  cin >> str[0] >> str[1] >> str[2];
  for (auto&& v : str) {
    char ch = v.front() - 'a' + 'A';
    cout << ch;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashSet, BTreeSet, BinaryHeap, HashMap};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Write};


fn main() {
    let t: usize = read();
    let query = read_matrix::<i64>();

    for i in 0..t {
        let (mut a, b, c, d) = (query[i][0], query[i][1], query[i][2], query[i][3]);

        if a < b {
            println!("No");
            continue;
        } else if d < b {
            println!("No");
            continue;
        } else if c >= b {
            println!("Yes");
            continue;
        } else {
            let g = gcd(&b, &d);
            let maximum = b - g + a % g;
            if maximum > c {
                println!("No");
                continue;
            } else {
                println!("Yes");
            }
        }
    }
}

fn gcd(a: &i64, b: &i64) -> i64 {
    let (mut a, mut b) = (min(*a, *b), max(*a, *b));
    let answer;
    loop {
        b = b % a;
        if b == 0 {
            answer = a;
            break;
        }
        swap(&mut a, &mut b);
    }
    return answer;
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   string s;
   cin >> s;
    int n=s.size();
    int cnt=0;
    rep(i,n){
        if(s.at(i)=='x')cnt++;
    }
    if(cnt>7)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()
arr=limii()

b=[10**100]*n
b[0]=0
b[1]=abs(arr[1]-arr[0])
for i in range(2,n):
    b[i]= min(b[i-1]+abs(arr[i]-arr[i-1]),b[i-2]+abs(arr[i]-arr[i-2]))
#print(b)
print(b[-1])


Measured memory_bytes: 77164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace arc_068_A
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong a = ulong.Parse(Console.ReadLine());
            ulong ans = (a / (int)11) * 2;
            ulong s = a % 11;
            if (s > 6) { ans += 2; }
            else if (s > 0) { ans += 1; }
            Console.WriteLine(ans);Console.ReadLine();
           
        }
    }
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main()
{
    int N;
    scanf("%d",&N);
    int i,j,A[N],B[N],min=1000000000;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        B[i] = A[i] - (i+1);
        if( min > B[i] ){
            min = B[i];
        }
    }

    long long int sad=0;
    int b,bmin,tmp;

    qsort(B,N,sizeof(int),compare_int);

    for(i=1;i<=N;i++){
        if( i >=  N - i ){
            b = B[i-1];
            break;
        }
    }
    for(i=0;i<N;i++){
        sad += abs(B[i] - b);
    }


    printf("%lld\n",sad);


    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <string>

int main(void) {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (((a == b) && (a != c))
		|| ((b == c) && (b != a))
		|| ((c == a) && (c != b))
		) {
		std::cout << "Yes" << std::endl;
	}
	else { std::cout << "No" << std::endl; }


	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int AB,BC,CA;
   cin>>AB>>BC>>CA;
   
   int ans=AB*BC/2;
   cout<<ans<<endl;
}

Measured memory_bytes: 3640
import java.util.*

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!
    val A = ArrayList<Pair<Char, Int>>()

    if (S[0] == '0') {
        A.add(Pair('1', 0))
    }

    var cc = S[0]
    var len = 0
    for (c in S) {
        if (cc == c) {
            len++
        } else {
            A.add(Pair(cc, len))
            len = 1
            cc = c
        }
    }
    if (len != 0) {
        A.add(Pair(cc, len))
    }

    var res = 0
    var k = K
    var l = 0
    var r = 0
    var sz = 0

    do {
        var updated = false

        while (r < A.size && k >= 0) {
            if (A[r].first == '0') {
                --k
            }
            sz += A[r].second
            if (k >= 0) {
                res = Math.max(res, sz)
            }
            r++
            updated = true
        }
        while (l < r && k < 0) {
            if (A[l].first == '0') {
                ++k
            }
            sz -= A[l].second
            if (k >= 0) {
                res = Math.max(res, sz)
            }
            l++
            updated = true
        }
    } while(updated);

    println(res)
}


Measured memory_bytes: 39616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

ll N;
cin >> N;
vl t(5);
rep(i,5) cin >> t[i];
sort(all(t));
cout << (N+t[0]-1) / t[0] + 4 << endl;
return 0;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    lld rmd[2019];
    lld tmp[2019];

    cin >> s;

    lld ans = 0;
    for (char &c : s) {
        c -= '0';
        for (int i = 0; i < 2019; i++) {
            
            if ((i * 10 + c) % 2019 == 0) {
                ans += rmd[i];
            }
        }

        for (int i = 0; i < 2019; i++) {
            tmp[(i * 10 + c) % 2019] = rmd[i];
        }

        for (int i = 0; i < 2019; i++) {
            rmd[i] = tmp[i];
        }
        rmd[c]++;

    }

    cout << ans << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

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

static const int NMAX = 10000;
int N,a[NMAX+1];

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

  int cnt = 0;
  for(int i=0;i<N;i++){
    while(a[i]%2==0){
      a[i] /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//using namespace __gnu_pbds;
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
vector<vector<ll> > vect;
ll ans = 0, n;
void dfs(ll parent, ll node){
	if(node != 1){
		if(node < parent){
			ans += node * (parent - node);
		}else{
			ans += (node - parent) * (n - node + 1);
		}
	}

	for(auto & child : vect[node]){
		if(child != parent)
			dfs(node, child);
	}
}
int main(){
	IOS;
	cin >> n;
	vect.resize(n + 1);
	ll u, v;
	loop(i, 1, n){
		cin >> u >> v;
		vect[u].pb(v);
		vect[v].pb(u);
	}

	dfs(0, 1);
	ans += n;
	cout << ans << endl;
}

Measured memory_bytes: 23432
N = int(input())
H = list(map(int,input().split()))



# DPテーブル
DP = [float('inf')]*N

# 初期条件
DP[0] = 0
DP[1] = abs(H[1] - H[0])

for i in range(2,N):
  one_step = DP[i-1] + abs(H[i]-H[i-1])
  two_step = DP[i-2] + abs(H[i]-H[i-2])
  DP[i] = min(one_step,two_step)

print(DP[N-1])

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strnx = str.split(" ");
		int n = Integer.parseInt(strnx[0]);
		int x = Integer.parseInt(strnx[1]);
		str = input.readLine( );
		String[] list = str.split(" ");
		long[] a = new long[n];

		for(int i=0; i<n; i++){
			a[i] = Integer.parseInt(list[i]);
		}

		long count = 0;

		for(int i=0; i<n-1; i++){
			if(a[i]+a[i+1] > x){
				if(x-a[i]>=0 && a[i+1]>=x-a[i]){
					count = count -x+a[i]+a[i+1];
					a[i+1] = x-a[i];
				}else{
					count = count + a[i+1];
					a[i+1] = 0;
					while(a[i]>x){
						count = count+1;
						a[i] = a[i]-1;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 50644
char a[999999],b[999999],*p;
main(i,n,c,s,d,l){
  for(;scanf("%d",&n),n;printf("%s\n",a)){
    scanf("%s",a);
    for(;n;n--){
      for(p=b,i=d=s=0,l=strlen(a);i<=l;i++){
        c=a[i];
        if(!s)s=c;
        if(s!=c){
          p+=sprintf(p,"%d",d);
          *(p++)=s;
          d=0;s=c;
        }
        d++;
      }
      *p=0;
      strcpy(a,b);
    }
  }
  return 0;
}

Measured memory_bytes: 704
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";

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

  int n;
  cin >> n;
  int ans = 0;
  for (int a = 1; a <= n; a++) {
    for (int b = 1; b <= n; b++) {
      for (int c = 1; c <= n; c++) {
        ans += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    auto u = unique(ALL(v));
    CFYN(u == v.end())

    return 0;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_b
//B - Similar Arrays
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll ttl=pow<ll>(3,N);
    ll sub=1;
    for(const auto& a:an){
        if(a%2==1)sub*=1;
        else sub*=2;
    }
    cout<<ttl-sub<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;
#define N 512
long long v[N], s[N], a[N][N], ans, mn, curr;
int pmn, i, n, j, k;
inline long long S(int pos){
    if (pos < 0)
        return 0LL;
    return s[pos];
}
int main()
{
    cin >> n;
    for (i = 0; i < n; ++i){
        cin >> v[i];
        a[i][i] = 0;
        s[i] = s[max(i - 1, 0)] + v[i];
    }
    ans = 0;
    for (i = 1; i < n; ++i)
    for (j = 0; j + i < n; ++j){
        a[j][i + j] = a[j][j] + a[j + 1][j + i];
        for (k = j + 1; k < i + j; ++k)
            a[j][i + j] = min (a[j][i + j], a[j][k] + a[k + 1][i + j]);
        a[j][i + j] += S(i + j) - S(j - 1);
    }
    cout << a[0][n - 1];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

class dice
{
	private:
		int _top;
		int _front;
	public:
		dice(int top, int front, int height);
		int x;
		int y;
		int height;
		int top();
		int front();
		int left();
		int right();
		int back();
		int under();
		void rollFront();
		void rollLeft();
		void rollRight();
		void rollBack();
};

dice::dice(int t, int f, int h) {
	_top = t;
	_front = f;
	x = 0;
	y = 0;
	height = h;
}

int dice::top() {
	return _top;
}

int dice::front() {
	return _front;
}

int dice::left() {
	int t[6][6] = {
		{0, 4, 2, 5, 3, 0},
		{3, 0, 6, 1, 0, 4},
		{5, 1, 0, 0, 6, 2},
		{2, 6, 0, 0, 1, 5},
		{4, 0, 1, 6, 0, 3},
		{0, 3, 5, 2, 4, 0}
	};
	return t[top() - 1][front() - 1];
}

int dice::right() {
	return 7 - left();
}

int dice::back() {
	return 7 - front();
}

int dice::under() {
	return 7 - top();
}

void dice::rollFront() {
	int t = back();
	_front = top();
	_top = t;
	y--;
}

void dice::rollLeft() {
	_top = right();
	x--;
}

void dice::rollRight() {
	_top = left();
	x++;
}

void dice::rollBack() {
	int t = front();
	_front = under();
	_top = t;
	y++;
}

int seek(vector<dice> v, int x, int y) {
	int i;
	for (i = 0; i < v.size(); i++) {
		if (v[i].x == x && v[i].y == y) {
			return i;
		}
	}
	return -1;
}

int next(vector<dice> v, dice d, int dx, int dy) {
	int i, h = 0, x = d.x, y = d.y;
	for (i = 0; i < v.size(); i++) {
		if (v[i].x == x + dx && v[i].y == y + dy) {
			if (v[i].height > h) {
				h = v[i].height;
			}
		}
	}
	return h;
}

bool roll(vector<dice> v, dice *d) {
	int i, h = d->height;
	for (i = 6; i >= 4; i--) {
		if (d->front() == i && next(v, *d, 0, -1) < h) {
			d->height = next(v, *d, 0, -1);
			d->rollFront();
			return true;
		} else if (d->left() == i && next(v, *d, -1, 0) < h) {
			d->height = next(v, *d, -1, 0);
			d->rollLeft();
			return true;
		} else if (d->back() == i && next(v, *d, 0, 1) < h) {
			d->height = next(v, *d, 0, 1);
			d->rollBack();
			return true;
		} else if (d->right() == i && next(v, *d, 1, 0) < h) {
			d->height = next(v, *d, 1, 0);
			d->rollRight();
			return true;
		}
	}
	return false;
}

int main() {
	int i, n, h = 0;
	vector<dice> v;
	cin >> n;
	if (n == 0) {
		return 0;
	}
	for (; n--;) {
		int top, front;
		cin >> top >> front;
		dice d(top, front, h);
		while (roll(v, &d));
		if (~(i = seek(v, d.x, d.y))) {
			v.erase(v.begin() + i);
		}
		if (!d.x && !d.y) {
			h++;
		}
		d.height++;
		//printf("%ld: (%d, %d, %d) %d %d %d\n", v.size(), d.x, d.y, d.height, d.top(), d.front(), d.left());
		v.push_back(d);
	}
	int a[] = {0, 0, 0, 0, 0, 0};
	for (i = 0; i < v.size(); i++) {
		a[v[i].top() - 1]++;
	}
	printf("%d %d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4], a[5]);
	main();
	return 0;
}

Measured memory_bytes: 1228
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
K = 1+N%2
dp = [[-10**18]*(K+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(K+1):
        if j+1<=K:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j])
        
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]+(A[i] if (i+j)%2==0 else 0))

print(dp[N][K])

Measured memory_bytes: 114636
#include <stdio.h>

int main(void){
  int a, b, c, temp;
  scanf("%d %d %d", &a, &b, &c);
  if (a > b) {
    temp = a;
    a = b;
    b = temp;
  }

  if (b > c) {
    temp = b;
    b = c;
    c = temp;
  }

  if (a > b) {
    temp = a;
    a = b;
    b = temp;
  }
  printf("%d %d %d\n", a, b, c);
  return 0;
}

Measured memory_bytes: 1816
x = int(input())
if 400<=x<600:
    print(8)
elif 600<=x<800:
    print(7)
elif 800<=x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
elif x<2000:
    print(1)

Measured memory_bytes: 61676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n = sc.nextLong(),m=n;
		long ans=0;
		sc.close();
		for(long i=2;i*i<m;i++) {
			long count=0; //iを素因数としていくつ含むか
			while(n%i==0) {
				n/=i;
				count++;
			}
			if(count!=0) {
				long temp=1;
				while(true) {
					count-=temp;
					if(count==0) break;
					if(count<0) {
						temp--;
						break;
					}
					temp++;
				}
				ans+=temp;
			}
		}
		if(n==1) System.out.println(ans);
		else System.out.println(ans+1);
	}
}

Measured memory_bytes: 35744
from collections import deque
N = int(input())
table=[[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    table[a-1].append(b-1)
    table[b-1].append(a-1)
adis=[0]*N
avis=[False]*N
avis[0]=True
bdis=[0]*N
bvis=[False]*N
bvis[N-1]=True
akei=deque()
akei.append(0)
bkei=deque()
bkei.append(N-1)
while akei:
    x = akei.popleft()
    for s in table[x]:
        if not avis[s]:
            adis[s]=adis[x]+1
            avis[s]=True
            akei.append(s)
while bkei:
    x = bkei.popleft()
    for s in table[x]:
        if not bvis[s]:
            bdis[s]=bdis[x]+1
            bvis[s]=True
            bkei.append(s)
white=0
brack=0
for i in range(N):
    if adis[i]<=bdis[i]:
        brack+=1
    else:
        white+=1
if white<brack:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 30940