akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ
vector<int> deg; // 各頂点の入次数

int dp[100100];
int main() {
    // 入力受け取り, 入次数も管理する
    cin >> N >> M;
    G.assign(N, vector<int>());
    deg.assign(N, 0);
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
        deg[y]++;
    }

    // source をキューに突っ込む
    queue<int> que;
    for (int v = 0; v < N; ++v) if (deg[v] == 0) que.push(v);

    // BFS
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            deg[nv]--; // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                que.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                dp[nv] = dp[v] + 1; // さらにソースから nv までの再長距離が確定する
            }
        }
    }

    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, dp[v]);
    cout << res << endl;
}


Measured memory_bytes: 6528
//
// Created by mamurai on 16/09/14.
//

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X, Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

set<pair<int, int> > p;
set<pair<int, int> > q;
i64 ans[10];
int h, w, n;

int main() {
    scanf("%d %d %d", &h, &w, &n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        p.insert({a, b});
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (a - j >= 0 && a - j < h - 2 && b - k >= 0 && b - k < w - 2) q.insert({a - j, b - k});
            }
        }
    }
    for (int l = 0; l < 10; ++l) {
        ans[l] = 0;
    }
    ans[0] = (i64) (h - 2) * (w - 2);
    for (auto g : q) {
        int x = g.first;
        int y = g.second;
        int num = 0;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (p.count({x + i, y + j})) num++;
            }
        }
        ans[0]--;
        ans[num]++;
    }
    for (int m = 0; m < 10; ++m) {
        printf("%lld\n", ans[m]);
    }
    return 0;
}

Measured memory_bytes: 47104
N,M = map(int,input().split())

# E[i]: 頂点iから伸びる頂点の集合
E = [[] for _ in range(N)]
# parent_cnt[i]: 頂点iの親
parent_cnt = [0] * N
for _ in range(N-1+M):
    A,B = map(int,input().split())
    E[A-1].append(B-1)
    parent_cnt[B-1] += 1

# 根を見つける
for i,num in enumerate(parent_cnt):
    if num == 0:
        root = i
        break

parent = [None] * N
parent[root] = 0

q = [root]
# BFS O(N+M)
while q:
    qq = []
    for V in q:
        for Vto in E[V]:
            parent_cnt[Vto] -= 1

            # 親が決定
            if parent_cnt[Vto] == 0:
                parent[Vto] = V + 1
                qq.append(Vto)
    
    q = qq

print(*parent, sep="\n")

Measured memory_bytes: 25172
#include <stdio.h>
#define N 16

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	int n[N]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, i, flag=0;
	
	for(i=0;i<N;i++){
		if(i==15){
			if(n[0]!=1 && n[i-1]!=1){
				A--;
				n[i]=1;
			}
		}
		else if(i==0){
			if(n[i+1]!=1){
				A--;
				n[i]=1;
			}
		}
		else{
			if(!n[i-1]&&!n[i+1]){
				A--;
				n[i]=1;
			}
		}
		if(A<=0){
			flag=1;
			break;
		}
	}
	if(!flag){
		printf(":(");
		return 0;
	}
	for(i=0;i<N;i++){
		if(n[i]==0){
			if(i==0){
				if(n[15]!=2 && n[i+1]!=2){
					B--;
					n[i]=2;
				}
			}
			else if(i==15){
				if(n[0]!=2 && n[i-1]!=2){
					B--;
					n[i]=2;
				}
			}
			else{
				if(n[i-1]!=2 && n[i+1]!=2){
					B--;
					n[i]=2;
				}
			}
		}
		if(B<=0){
			flag=2;
			break;
		}
	}
	if(flag==2){
		printf("Yay!");
		return 0;
	}
	else{
		printf(":(");
		return 0;
	}
	
}

Measured memory_bytes: 128
import queue

N, M = map(int, input().split())
A = list(map(int, input().split()))

q = queue.PriorityQueue()
for a in A:
    q.put((-a,a))

for _ in range(M):
    v = q.get()[1] // 2
    q.put((-v, v))

ans = 0
while not q.empty():
    ans += q.get()[1]
print(ans)


Measured memory_bytes: 84456
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define p push
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	string s;
	scans(s);
	rep(i, s.length()) {
		if (s[i] + n > 'Z') {
			int tmp = n - ('Z' - 'A' + 1);
			s[i] += tmp;
		}
		else s[i] += n;
	}
	prints(s);
	Please AC;
}


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

using namespace std;

#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size())
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; i++)
#define FO(i, k, n) for(int i = k; i < n; i++)
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ii = pair<int, int>;
using ll = long long;


int main(){
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    string s;
    cin >> s;
    int n = s.length();
    if(s[n-1] == 's')
    {
        s.append("es");
    }else
    {
        s.append("s");
    }
    cout << s;
    
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
H = list(map(int, input().split()))
flag = 1
count = 0
if N >= 2:
    for i in range(1, N):
        if H[i-1] == H[i]:
            count += 1
        #print(count, H, i)
        if H[i-1] == H[i] + 1:
            for j in range(i - count - 1, i):
                H[j] -= 1
            count = 0
        if H[i-1] != H[i]:
            count = 0
    for i in range(1, N):
        if H[i-1] > H[i]:
            flag = 0
            print("No")
            break
    if flag == 1:
        print("Yes")
else:
    print("Yes")


Measured memory_bytes: 14976
#include <bits/stdc++.h>
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 mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

map<vector<int>,int> conv;
vector<int> f[300005];
vector<int> g[300005];
int pre[300005];
int val[300005];
bool checked[300005];

// vec?????§v???????????¨?????????
vector<int> center(int v, vector<int> *vec){
  auto bfs = [&](int d){
    queue<pair<int,int>> q;
    q.push(mp(d,-1));
    val[d] = 0;
    int last = d;
    while(q.size()){
      auto p = q.front(); q.pop();
      int node = p.first;
      int from = p.second;
      checked[node]=true;
      for(auto to : vec[node]) if(to!=from){
        q.push(mp(to,node));
        val[to] = val[node]+1;
        pre[to] = node;
      }
      last = node;
    }
    return last;
  };
  int p = bfs(v);
  int q = bfs(p);

  int d = q;
  rep(i,val[q]/2) d = pre[d];

  if(val[q]%2==1) return {d, pre[d]};
  else return {d};
}

// vec?????§i???????????¨?????????????????¨?????????????????°
pair<int,int> tree2idx(int i, vector<int> *vec){
  auto c = center(i, vec);

  function<int(int,int)> dfs = [&](int d, int from){
    vector<int> ord;
    queue<pair<int,int>> q;
    q.push(mp(d,from));
    while(q.size()){
      auto p = q.front(); q.pop();
      int node = p.first;
      int prev = p.second;
      ord.pb(node);
      pre[node] = prev;
      for(auto to : vec[node]) if(to != prev){
        q.push(mp(to, node));
      }
    }
    reverse(all(ord));
    for(auto node : ord){
      vector<int> v;
      for(auto to : vec[node]) if(to!=pre[node]) v.pb(val[to]);
      sort(all(v));
      if(conv.count(v)==0) conv[v] = conv.size();
      val[node] = conv[v];
    }
    return val[d];
  };

  if(c.size()==1){
    return mp(-1, dfs(c[0],-1));
  }
  else if(c.size()==2){
    int a = dfs(c[0], c[1]);
    int b = dfs(c[1], c[0]);
    return mp(min(a,b), max(a,b));
  }
  else while(1);
}

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    f[a].pb(b);
    f[b].pb(a);
  }

  vector<pair<int,int>> nums;

  fill(checked, checked+n, false);
  rep(i,n) if(!checked[i]){
    nums.pb(tree2idx(i, f));
  }

  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  auto p = tree2idx(0, g);

  int cnt = 0;
  for(auto q : nums) if(p == q) cnt++;

  cout << cnt << endl;

  return 0;
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    if(N/2+N%2>=K) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <iostream>
using namespace std;

const int N_MX = 200000;
const long long int MOD = pow(10, 9) + 7;
int n;
long long int a[N_MX];
long long int ans;
long long int sum;

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

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    REP(i, N) {
        cin >> P[i];
    }
    std::sort(P.begin(), P.end());
    int ans = 0;
    REP(i, K) {
        ans += P[i];
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long a, b, c, d;
int main(){
    scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
    if(a+b < c+d){
        printf("Right\n");
    }else if(a+b == c+d){
        printf("Balanced\n");
    }else{
        printf("Left\n");
    }
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long int ll;

ll max(ll a, ll b){return a>b?a:b;}

int main(void){
    int n;
    scanf("%d", &n);
    ll happy[3][n+1];
    for(int i=1; i<n+1; i++){
        scanf("%lld%lld%lld", &happy[0][i], &happy[1][i], &happy[2][i]);
        // printf("%lld %lld %lld", happy[0][i], happy[1][i], happy[2][i]);
        // printf("\n");
    }

    ll dp[3][n+1];
    for(int i=0; i<3; i++){dp[i][0] = 0;}

    for(int i=1; i<n+1; i++){
        dp[0][i] = happy[0][i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = happy[1][i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = happy[2][i] + max(dp[0][i-1], dp[1][i-1]);
        // printf("dp[0][%d]:%lld dp[1][%d]:%lld dp[2][%d]:%lld\n", i, dp[0][i], i, dp[1][i], i, dp[2][i]);
    }

    ll ans = max(dp[0][n], max(dp[1][n], dp[2][n]));
    printf("%lld\n", ans);
}

Measured memory_bytes: 4864
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEqueue solver = new DEqueue();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEqueue {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            if (true) {
                logMe("test");
                //test();
                long res = solveMe(in, out);
                out.println(res);
                return;
            }
        /*    long res = solveOk(in, out);
            out.println(res);
            return;
        }
        solveMe(in, out);*/
        }

        private long solveMe(Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long v[] = new long[n];
            for (int i = 0; i < n; i++) {
                v[i] = in.nextInt();
            }

            return solveMeArr(v, k);


        }

        private long solveMeArr(long[] v, int k) {
            int n = v.length;
            long sum[] = new long[n];

            for (int i = 0; i < n; i++) {
                if (i > 0)
                    sum[i] = sum[i - 1];
                sum[i] += v[i];
            }

            long res = 0;
            if (k >= n)
                res = sum[n - 1];
            for (int i = 0; i < n; i++)
                for (int j = i; j < n; j++) {
                    int remaining = k - (i + n - 1 - j);
                    if (remaining < 0)
                        continue;

                    long tmp = sum[n - 1] - sum[j];
                    if (i > 0)
                        tmp += sum[i - 1];
                    //logMe("BEFORE i="+i+";j="+j+";tmp="+tmp+";remaining="+remaining);
                    List<Long> arr = new ArrayList<>();
                    for (int l = 0; l < n; l++)
                        if (l < i || l > j)
                            arr.add(v[l]);
                    //arr.sort(Long::compare);
                    Collections.sort(arr);
                    for (int l = 0; l < remaining && l < arr.size(); l++) {
                        if (arr.get(l) < 0) {
                            tmp -= arr.get(l);
                        }
                    }
                    //logMe("i="+i+";j="+j+";tmp="+tmp);
                    res = Math.max(res, tmp);
                }
            return res;
        }

        void logMe(String msg) {
            System.err.println(msg);
        }

    }
}



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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  map<string, int>mp;
  mp[s]=a;
  mp[t]=b;
  mp[u]--;
  cout << mp[s] << " " << mp[t] << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define db double
#define ll long long
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const int maxn = 200005;
int n, m;
ll k, ans;
ll a[maxn];
ll t[maxn];
ll b[maxn];
ll ask(int x){
	ll ret = 0;
	for(;x;x-=x&-x)	ret += b[x];
	return ret;
}
void change(int x){
	while (x <= m + 1){
		++b[x];
		x += (x & -x);
	}
}
int main(){
	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; ++i){
		scanf("%lld", &a[i]);
		t[i] = (a[i] += a[i-1] - k);
	}
	sort(t, t + n + 1);
	m = unique(t, t + n + 1) - t + 1;
	for (int i = 0; i <= n; ++i){
		a[i] = lower_bound(t, t + m, a[i]) - t + 1;
		ans += ask(a[i]);
		change(a[i]);
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

typedef struct{
	int weight,bridge;
}sima;


bool lessw(const sima& Left,const sima& Right){return Left.weight<Right.weight;}
bool lessb(const sima& Left,const sima& Right){return Left.bridge<Right.bridge;}

vector<sima> tou;
int n;

int main(){
	while(cin>>n){
		if(n==0)break;
		
		tou.clear();
		
		for(int i=0;i<n;i++){
			int w,b;
			cin>>w>>b;
			sima t={w,b};
			tou.push_back(t);
		}
		
		
		
		int cuw=0,difmin=0;
		stable_sort(tou.begin(),tou.end(),lessw);
		stable_sort(tou.begin(),tou.end(),lessb);
		
		int out=0;
		for(int i=0;i<n;i++){
			cuw+=tou[i].weight;
			if(cuw>tou[i].bridge){
				out=1;
				break;
			}
		}
		
		if(out==1)puts("No");
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 3005;

int dp[N][N][2];
int n, a[N];

int32_t main() {
	fast_cin();  

	cin >> n; 
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	for (int i = 0; i < n; i++) {
		dp[i][i][0] = a[i];
		dp[i][i][1] = -a[i];
	}
	for (int len = 2; len <= n; len++) {
		for (int i = 0; i + len <= n; i++) {
			int j = i + len - 1;
			dp[i][j][0] = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]);
			dp[i][j][1] = min(dp[i + 1][j][0] - a[i], dp[i][j - 1][0] - a[j]);
		}
	}
	cout << dp[0][n - 1][0] << endl;
	
	return 0;
}

Measured memory_bytes: 139648
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int q;
    cin >> q;
    int a = 0;
    while (q--) {
        int p, n;
        char c;
        cin >> p >> c >> n;
        if (c == '(')   a += n;
        else            a -= n;

        if (a == 0)     cout << "Yes" << endl;
        else            cout << "No" << endl;
    }
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const long long inf=1e17;
struct edge{int to,cap,rev;};
vector<edge>G[100006];
vector<int>G2[100006];
int dis[100006];
int iter[100006];
int a[100006],b[100006];
int clr[100006];

void dfs2(int now,int par){
	for(int e:G2[now]){
		if(e==par)continue;
		clr[e]=clr[now]+1;
		dfs2(e,now);
		}
	}

void add_edge(int from,int to,int cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
	}	
	
void bfs(int s){
	memset(dis,-1,sizeof(dis));
	queue<int>Q;
	dis[s]=0;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();Q.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0&&dis[e.to]<0){
				dis[e.to]=dis[v]+1;
				Q.push(e.to);
				}
			}
		}
	}
	
int dfs(int v,int t,int f){
	if(v==t)return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0&&dis[v]<dis[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
				}
			}
		}
		return 0;
	}
	
int maxflow(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		if(dis[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,inf))>0){
			flow+=f;
			}
		}
	}	
			
signed main(){
	int n;cin>>n;
	rep(i,n-1){
		int A,B;cin>>A>>B;
		a[i]=A;b[i]=B;
		G2[A-1].push_back(B-1);
		G2[B-1].push_back(A-1);
		}
	dfs2(0,-1);
	rep(i,n-1){
		if(clr[a[i]-1]&1)add_edge(a[i],b[i],1);
		else add_edge(b[i],a[i],1);
		}	
	rep(i,n){
		if(clr[i]&1)add_edge(0,i+1,1);
		else add_edge(i+1,n+1,1);
		}	
		
	int res=maxflow(0,n+1);
//	cout<<res<<endl;
	if(res*2==n)puts("Second");
	else puts("First");	
	
	}


Measured memory_bytes: 26344
// C.

#include <iostream>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
	int n, a;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (s.find(a) == s.end()) {
			s.insert(a);
		} else {
			s.erase(a);
		}
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	string s;
	cin>>s;
	int flag=0;
	if(s[2]!=s[3])
		flag=1;
	if(s[4]!=s[5])
		flag=1;
	if(flag==1)
		cout<<"No";
	else
		cout<<"Yes";
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);

    int n;
    int count[100000] = {};

    cin >> n;
    int m1;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &m1);
        count[m1]++;
        if (m1 - 1 >= 0)
            count[m1 - 1]++;
        if (m1 + 1 < 100000)
            count[m1 + 1]++;
    }

    int max = 0;
    for (int i = 0; i < 100000; i++)
    {
        if (count[i] > max)
            max = count[i];
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 1272
/*package whatever //do not write package name here */

import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;

class Main {
    static long dp[][];
    static boolean is[][];
    public static long knapsack(int i,int v[],int w[],int value,int C){
         if(i==0&&value!=0)return Integer.MAX_VALUE;
         if(i==0)return 0;
         if(is[i][value])return dp[i][value] ;
         is[i][value]=true;
         if(value<v[i-1])dp[i][value]= knapsack(i-1, v, w, value, C);
         else dp[i][value]= Math.min(w[i-1]+knapsack(i-1, v, w,value-v[i-1],C),knapsack(i-1, v, w,value,C));
         return dp[i][value];
    }
	public static void main (String[] args)throws IOException{
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[]s=br.readLine().split("\\s+");
		
            int n=Integer.parseInt(s[0]);
            int C=Integer.parseInt(s[1]);
            int []v=new int[n];
            int []w=new int[n];
		   
		    for(int i=0;i<n;i++){
                s=br.readLine().split("\\s+");
                w[i]=Integer.parseInt(s[0]);
                v[i]=Integer.parseInt(s[1]);
            }
            int value=0;
            for(int i=0;i<n;i++)value+=v[i];
            dp=new long[n+1][value+1];
            is=new boolean[n+1][value+1];
            for(int i=0;i<=n;i++)
           Arrays.fill(dp[i],Integer.MAX_VALUE);
            
           int max=0;
            for(int j=value;j>=0;j--)
             {
                long res=knapsack(n, v, w, j,C);
                 if(res<=C){
                   //  System.out.println(res);
                     max=j;
                     break;
                 }
             }
            //for(int i=0;i<n;i++)
             //System.out.println(Arrays.toString(dp[i]));
            System.out.print(max);
		
		    
	
		
	}
}


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

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	string s;
	cin >> s;
	int min = 1000000;
	for (int i = 0; i < s.size()-2; i++) {
		int k = (s[i]-48)*100 + (s[i+1]-48)*10 + s[i+2]-48;
		if(abs(753-k) < min) min = abs(753-k);
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	ll x;
	cin>>x;
	ll n=100;
	int y=0;
    while(n<x){
    	n=n*1.01;
    	y++;
    }
    cout<<y;
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

class Ball {
    public:
        Ball(ll _x, ll _y) : x(_x), y(_y) {
        }

        ll x;
        ll y;
};

class Line {
    public:
        Line(Ball _a, Ball _b) : a(_a), b(_b) {
        }
        Ball a;
        Ball b;

        ll diff_x() const {
            return b.x - a.x;
        }

        ll diff_y() const {
            return b.y - a.y;
        }

        ll slope() const {
            return diff_y() / diff_x();
        }
};

const ll INF = LONG_LONG_MAX / 2;

vector<pair<ll, ll>> balls;
vector<Line> lines;

ll gcd(const ll sx, const ll sy) {
    ll x = min(sx, sy);
    ll y = max(sx, sy);
    ll tmp;
    while (x > 0) {
        tmp = y;
        y = x;
        x = tmp % x;
    }
    return y;
}

int solve(const int N) {
    vector<pair<ll, ll>> slopes;
    for (int i = 0; i < (int) lines.size(); i++) {
        auto &line = lines[i];
        slopes.push_back({line.diff_x(), line.diff_y()});
    }

    sort(slopes.begin(), slopes.end());
    auto prev = slopes[0];
    // printf("(%d, %d)\n", slopes[0].first, slopes[0].second);
    int ans = 1;
    int cnt = 1;
    for (int i = 1; i < (int) slopes.size(); i++) {
        // printf("(%d, %d)\n", slopes[i].first, slopes[i].second);
        if (slopes[i] == prev) {
            cnt++;
        } else {
            // printf("ans=%d, cnt=%d\n", ans, cnt);
            chmax(ans, cnt);
            prev = slopes[i];
            cnt = 1;
        }
    }
    // printf("ans=%d, cnt=%d\n", ans, cnt);
    chmax(ans, cnt);
    return N - ans;
}

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

    if (N == 1 || N == 2) {
        cout << 1 << endl;
        return 0;
    }

    balls.resize(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        balls[i] = {x, y};
    }
    sort(balls.begin(), balls.end());

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            Ball a(balls[i].first, balls[i].second);
            Ball b(balls[j].first, balls[j].second);
            lines.push_back(Line(a, b));
        }
    }

    // for (auto &l : lines) {
    //     printf("(%d, %d) - (%d, %d)\n", l.a.x, l.a.y, l.b.x, l.b.y);
    // }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  int k = (a + d - 1) / d;
  int l = (c + b - 1) / b;
  if(k >= l)cout << "Yes" << endl;
  else cout << "No" << endl;
  }



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
const ll mod=1e+9+7;
int main(void){
    int n;cin>>n;
    string s1,s2;cin>>s1>>s2;
    ll res=1;
    int pt=1;//前のパターンを保存
    rep(i,n){
        if(i==0){
            if(s1[i]!=s2[i]){
                res*=6;
                res%=mod;
                i++;
                continue;
            }else{
                res*=3;
                res%=mod;
                pt=2;
                continue;
            }
        }
        if(s1[i]!=s2[i]){
            if(pt==1){
                res*=3;
            }else{
                pt=1;
                res*=2;
            }
            res%=mod;
            i++;
        }else{
            if(pt==1){
                pt=2;
            }else{
                res*=2;
            }
            res%=mod;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
S = input()
if S[0:2] > '00' and S[0:2] <'13':
    if S[2:4] > '00' and S[2:4] <'13':
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif S[0:2] == '00':
    if S[2:4] > '00' and S[2:4] <'13':
        print('YYMM')
    else:
        print('NA')
    
elif S[0:2] >='13':
    if S[2:4] > '00' and S[2:4] <'13':
        print('YYMM')
    else:
        print('NA')

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

int dp[100001];
vector<int> adj[100001];

int solve(int src){


	if(dp[src]!=-1)
		return dp[src];

	bool leaf=1;
	int best=1;
	for(int child : adj[src])
	{
		leaf=0;
		best  = max(best,1 + (solve(child)));
	}

	return leaf ? 0 : (dp[src] = best);
}


int main(){

	#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	freopen("input.txt", "r", stdin);
    	// for writing output to output.txt
    	freopen("output.txt", "w", stdout);
	#endif

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

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


       for(int i=0;i<=n;i++)
       	dp[i] = -1;

       

       for(int i=0;i<m;i++)
       {
       		int x,y;
       
       		cin>>x>>y;
       		x--;
       		y--;

       		adj[x].push_back(y);
       }

       int ans=0;
       for(int i=0;i<n;i++)
       	ans  = max(ans, solve(i));


       cout<<ans<<endl;






}

Measured memory_bytes: 11448
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, L): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let S: Vec<String> = (0..N).map(|_| {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }).collect();

    let T = {
        let mut T = S.clone();
        T.sort();
        T
    };
    let ans = T.join("");

    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import defaultdict


def main():
    input()  # n is never used
    dct = defaultdict(int)
    ans = 0
    it = (int(x) for x in input().split())
    for i, height in enumerate(it):
        dct[i + height] += 1
        ans += dct[i - height]
    print(ans)
    return


if __name__ == '__main__':
    main()


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

ll sum;
ll dp[2020];

int main(){
	cin >> sum;
	dp[0] = 1;
	for(int i = 3; i <= sum; i++){
		for(int j = 3; j <= i; j++){
			dp[i] = (dp[i] + dp[i - j]) % Mod;
		}
	}
	cout << dp[sum] << endl;
	return 0;
}

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

void bubble(vector<int> &array,int n,int &count){
    bool flag = true;
    while(flag){
        flag = false;
        for(int i=0; i<n-1; i++){
            if(array.at(i) > array.at(i+1)){
                swap(array.at(i),array.at(i+1));
                count ++;
                flag = true;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0; i<n; i++){
        cin >> array.at(i);
    }
    int count = 0;
    bubble(array,n,count);
    for(int i=0; i<n ; i++){
        if(i == n-1){
            cout << array.at(i) << endl;
        } else {
            cout << array.at(i) << " ";
        }
    }
    cout << count << endl;
    
}


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

int main(){
  int N;
  cin >> N;
  string ans="";
  if (N==0){
    cout << 0 << endl;
  }
  else {
  while (N!=1){
    char x=abs(N)%(-2)+'0';
    ans=x+ans;
    if (N<0&&x=='1'){
      N=N/(-2)+1;
    }
    else {
      N=N/(-2);
    }
  }
  cout << '1'+ans << endl;
  }
}

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

using namespace std;

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

int main() {
    int q; cin >> q;
    set<int> s;
    while (q--) {
        int a, x; cin >> a >> x;
        if (a) {
            cout << s.count(x) << endl;
        } else {
            s.insert(x); cout << s.size() << endl;
        }
    }
}



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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    int N;
    cin>>N;
    
    ll T=1, A=1;
    rep(k,N){
        ll t,a;cin>>t>>a;
        ll i = max(T/t,A/a);
        for(;;i++){
            if(T<=t*i) T=t*i;
            if(A<=a*i) A=a*i;
            if(T==t*i && A==a*i) break;
        }
    }
    cout1(T+A);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n;
    cin>>n;
    int sum = 0;
    rep(i,1,n+1)
    {
        if ( i % 3 == 0 || i % 5 == 0 )
        {
            continue;
        }
        sum += i;
    }

    cout<<sum<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3648
from math import sqrt

N = int(input())

res = 0
for i in range(2, int(sqrt(N)) + 1):
    a = set()
    b = 1
    while True:
        if N % i == 0:
            N = N // i
            b *= i
            if b not in a:
                a.add(b)
                res += 1
                b = 1
        else:
            break

if N != 1:
    res += 1

print(res)


Measured memory_bytes: 73140
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;

int main(){
   int r,g,b; 
   cin >> r >> g >> b;
   if((r*100+g*10+b)%4 == 0)puts("YES");
   else puts("NO");
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<vector<int>> A(2 ,vector<int>(N));

    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            cin>>A.at(i).at(j);
        }
    }
    int sum;
    int max_result = 0;
    for(int down=0;down<N;down++){
        sum=0;

        for(int i = 0;i<=down;i++){
            sum += A.at(0).at(i);
        }
        for(int i =down;i<N;i++){
            sum += A.at(1).at(i);
        }
        if(sum>max_result) max_result = sum;

    }
    cout<<max_result;


}








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

#define MOD(N) (N%1000000007)

std::vector< std::vector<unsigned long long>> comb(int n){
  std::vector<std::vector<unsigned long long>> v(
    n+1, std::vector<unsigned long long>(n+1,0));
  for(int i=0;i<v.size();i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k=1;k<v.size();k++){
    for(int j=1;j<k;j++){
      unsigned long long sum = MOD(v[k-1][j-1])+MOD(v[k-1][j]);
      v[k][j] = MOD(sum);
    }
  }
  return v;
}

int main(int argc, char *argv[]){
  int N,K;
  std::cin >> N >> K;
  auto C = comb(std::max(N-K+1, K-1));
  for(int i=1;i<=K;i++){
    if(N-K+1 < i){
      std::cout << 0 << std::endl;
      continue;
    }
    unsigned long long x = MOD(C[N-K+1][i]) * MOD(C[K-1][i-1]);
    std::cout << MOD(x) << std::endl;    
  }
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int a,b;cin>>a;
    int ans =a+a*a+a*a*a;
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<int> as, bs, cs, ds, table = {0};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        as.push_back(a);
    }
    for(int i = 0; i < N; i++){
        cs.push_back(as[(i + 1) % N] ^ as[i]);
    }
    for(int i = 0; i < N - 1; i++){
        cs.push_back(cs[i]);
    }

    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        bs.push_back(b);
    }
    for(int i = 0; i < N; i++){
        ds.push_back(bs[(i + 1) % N] ^ bs[i]);
    }
    int idx = 0;
    for(int i = 1; i < N; i++){
        table.push_back(idx);
        if(ds[i] == ds[idx]) idx++;
        else idx = 0;
    }
    table.push_back(idx);
    
    int p = 0;
    idx = 0;
    vector<int> ks;
    while(p < 2 * N - 1){
        if(cs[p] == ds[idx]) idx++, p++;
        else if(idx == 0) p++;
        else idx = table[idx];
        if(idx == N){
            ks.push_back(p - N);
            idx = table[idx];
        }
    }
    for(auto u : ks){
        cout << u << " " << (as[u] ^ bs[0]) << endl;
    }
    return 0;
}

Measured memory_bytes: 9968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 10**9

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c)<=d){
        cout << "Yes" << endl;
    }
    else if (abs(a-b)<=d and abs(b-c)<=d){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3644
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

const int N = 2e5 + 100;

int n, a[N];
int val = 1, ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		if (a[i] == val)
			val++;
		else
			ans++;
	cout << (ans == n? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,ans;
    cin>>a>>b>>c>>d;
    if(a>b){
        ans=b;
    }else{
        ans=a;
    }
    if(c>d){
        ans=ans+d;
    }else{
        ans=ans+c;
    }
    cout<<ans<<endl;
}

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


using namespace std;

int main(){
    
    int S;
    cin >> S;
    
    
    int sa = int(S/100);
    int sb = S - sa*100;
    
    int ans = 0;
    
    
    if (sb >= 1 && sb <= 12) {
        ans += 1;
    }
    if (sa >= 1 && sa <= 12) {
        ans += 10;
    }
    
    
    if(ans == 1){
        cout << "YYMM" << endl;
    }else if(ans == 10){
        cout << "MMYY" << endl;
    }else if(ans == 11){
        cout << "AMBIGUOUS" << endl;
    }else{
        cout << "NA" << endl;
    }
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,k;
  cin>>n>>k;
  int a[n];
  map<int,int> m;
  m[1]++;
  vector<int> v;
  v.push_back(1);
  int index=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  for(int i=0;;i=a[i]-1)
  {
      m[a[i]]++;
      if(m[a[i]]<=1)
      {
          v.push_back(a[i]);
          cout<<endl;
    }
    else
    {
        
        for(int j=0;j<v.size();j++)
        if(v[j]==a[i])
        {index=j;
        break;}
        break;
    }

  }
  if(k<index)
  {
      cout<<v[k]<<endl;
      return 0;
  }
  k-=index;
  k=k%(v.size()-index);
  cout<<v[index+k]<<endl;
  
  
  //cout<<k<<" "<<t<<" "<<v[k]<<endl;
  
}


Measured memory_bytes: 13904
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        long n = int.Parse(Console.ReadLine());
        long factorial = 1;
        for (long i = 1; i <= n; i++)
        {
            factorial *= i;
        }

        Console.WriteLine(factorial);
    }
}



Measured memory_bytes: 13832
#include <stdio.h>
int main(void){
	int i,j,h,p_top,p_base,c_top[100],c_base,n,max=0;
	scanf("%d%d%d%d",&n,&p_base,&p_top,&c_base);
	for(i=0; i<n; i++){
		scanf("%d",&c_top[i]);
		for(j=0; j<i; j++){
			if(c_top[i]>c_top[j]){
				h=c_top[i];
				c_top[i]=c_top[j];
				c_top[j]=h;
			}
		}
	}
	for(i=0; i<n; i++){
		h=c_base;
		for(j=0; j<=i; j++){
			h+=c_top[j];
		}
		h/=(p_base+p_top*(i+1));
		if(max<h){
			max=h;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 596