akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

struct Node
{
    int num;
    set<Node> neighbor;
    Node(int num) : num(num), neighbor(){}
    bool operator<(const Node &right) const {return this->num < right.num;}
};

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<Node> nodes;
  REP(i, n+1) {
    nodes.push_back(Node(i));
    // nodes.emplace_back(i);こっちでもよい
  }
  REP(i, n-1) {
    int a, b;
    cin >> a >> b;
    nodes[a].neighbor.insert(b);
    nodes[b].neighbor.insert(a);
  }
  vector<ll> c(n+1);
  REP(i, n) cin >> c[i];
  sort(all(c), greater<ll>());
  deque<Node> q;
  q.push_back(nodes[1]);
  vector<int> ans(n+1);
  ans[1] = c[0];
  int cnt = 1;
  while(!q.empty()) {
    Node a = q.front();
    q.pop_front();
    for(Node next: a.neighbor) {
      if(ans[next.num] != 0) {
        continue;
      }
      ans[next.num] = c[cnt];
      cnt++;
      q.push_back(nodes[next.num]);
    }
  }
  cout << accumulate(all(c), 0L) - c[0] << endl;
  REP_FROM(i, 1, n+1) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter < vec.end(); iter++)

struct BombRow
{
    BombRow(int i) : idx(i) {}

    int idx;
    set<int> bombs;

    bool operator > (const BombRow & other)
    {
        return this->bombs.size() > other.bombs.size();
    }
};

struct BombCol
{
    BombCol(int i) : idx(i), bombCount(0) {}

    int idx;
    int bombCount;

    bool operator > (const BombCol & other)
    {
        return this->bombCount > other.bombCount;
    }
};

int main()
{
    int height, width, bomb;
    cin >> height >> width >> bomb;
    // init
    vector<BombRow> rows;
    vector<BombCol> cols;
    FROM_0(i, height)
    {
        rows.push_back(BombRow(i));
    }
    FROM_0(i, width)
    {
        cols.push_back(BombCol(i));
    }
    // input
    FROM_0(i, bomb)
    {
        int h, w;
        cin >> h >> w;
        h--;
        w--;
        rows[h].bombs.insert(w);
        cols[w].bombCount++;
    }
    // sort
    std::sort(rows.begin(), rows.end(), std::greater<>());
    std::sort(cols.begin(), cols.end(), std::greater<>());
    //search
    int result = 0, maxCol = cols[0].bombCount;
    ITER_BEGIN_END(pRow, rows)
    {
        int now = 0;
        if (pRow->bombs.size() + maxCol <= result)
            break;
        ITER_BEGIN_END(pCol, cols)
        {
            if (pCol->bombCount + pRow->bombs.size() <= result)
                break;
            auto pFind = pRow->bombs.find(pCol->idx);
            int sum = pRow->bombs.size() + pCol->bombCount;
            if (pFind != pRow->bombs.end())
                sum--;
            result = max(sum, result);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 36080
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

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

    // debug
    // for (int i = 1; i < N + 1; i++)
    // {
    //     printf("%d ", i);
    // }
    // printf("\n");

    // for (int i = 1; i < N + 1; i++)
    // {
    //     printf("%d ", a[i]);
    // }

    int ans = 0;
    int checker = 1;
    for (int i = 0; i < N; i++)
    {
        if (a[i] != checker)
        {
            ans++;
        }
        else
        {
            checker++;
        }
    }
    if (checker == 1 && ans > 0)
    {
        ans = -1;
    }
    cout << ans << endl;
    return (0);
}

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

typedef unsigned long long ll;

int main()
{
    string s;
    cin >> s;
    int size = s.size();
    ll ans = 0, f, g;
    vector<int> x(size);
    for (int i = 0; i < size; i++)
        x[i] = s[i] - '0';

    for (int i = 0; i < size; i++)
    {
        for (int j = i; j < size; j++)
        {
            f = g = 1;
            for (int k = 0; k < size - j - 1; k++)
                f *= 10;
            for (int k = 0; k < j; k++)
                g = g << 1;
            if (i < j)
                g = g >> 1;
            ans += f * g * x[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    imfor(i, n) {
        ll a;
        cin >> a;
        while (a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    int A[N+1];
    int B[N];
    REP(i,N+1)cin>>A[i];
    REP(i,N)cin>>B[i];
    int ans=0;
    for(int i=N-1;i>=0;i--){
        if(B[i]>=A[i+1]){
            B[i]-=A[i+1];
            ans+=A[i+1];
            if(B[i]>=A[i]){
                ans+=A[i];
                A[i]=0;
            }
            else{
                ans+=B[i];
                A[i]-=B[i];
            }
        }
        else ans+=B[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

ld T,A;

ld f(ld x){return T-0.006*x;}

int main(){	
	fastio;
	int n;cin>>n;
	cin>>T>>A;
	ld dif=1000000;
	int pos;
	FER(i,0,n){
		ld k;cin>>k;
		ld val=fabs(A-f(k));
		if(val<dif)pos=i,dif=val;
	}
	cout<<pos+1<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int N = Integer.parseInt(line1);

		String[] inputData = new String[N];
		for (int i = 0; i < N; i++) {
			String line2 = sc.nextLine();
			inputData[i] = line2;
		}

		boolean[] cards = new boolean[52];
		for (int i = 0; i < cards.length; i++) {
			cards[i] = false;
		}

		int x = 0;
		for (int i = 0; i < inputData.length; i++) {
			String str = inputData[i].substring(0, 1);
			if (str.equals("S")) {
				x = 0;

			} else if (str.equals("H")) {
				x = 13;

			} else if (str.equals("C")) {
				x = 13 * 2;

			} else if (str.equals("D")) {
				x = 13 * 3;

			}
			x += Integer.parseInt(inputData[i].substring(2)) - 1;
			cards[x] = true;
		}
		for (int i = 0; i < cards.length; i++) {
			if (cards[i] == false) {
				if (i / 13 == 0) {
					System.out.print("S ");

				} else if (i / 13 == 1) {
					System.out.print("H ");
				} else if (i / 13 == 2) {
					System.out.print("C ");
				} else if (i / 13 == 3) {
					System.out.print("D ");
				}
				System.out.println(String.valueOf(i % 13 + 1));
			}
		}
	}
}

Measured memory_bytes: 26072
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b; cin >> a >> b;
	cout << max(0,a-b-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	a %= 500;
	if (b >= a) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std ;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n;
long long a[200000+5];
int main()
{
    while(~scanf("%d",&n))
    {
        bool flag=1;
        long long sum=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
        }
        int x=-1;
        for(int i=0;i<n;i++)
        {
            x++;
            if(!flag) break;
            if(a[i]>x) {flag=0;break;}
            if(a[i])
            {
               if(a[i-1]>=a[i]) sum+=a[i];
               else if(a[i]-a[i-1]==1) sum++;
               else flag=0;
            }
            else
            {
                x=0;
            }
        }
        printf("%lld\n",flag?sum:-1);

    }

    return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        static int[] visited ;
        static ArrayList<Integer>[] graph;
        public static void sol(int n , StringBuilder s , int[][] arr){
            



        }
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n = in.nextInt();
            int k = in.nextInt();
            double[] ex = new double[n];
            for (int i = 0; i <n; i++){
                ex[i] = (((double) (in.nextInt()+1))/2);
            }
            double[] sum = new double[n];
            sum[0]=ex[0];
            for (int i = 1; i <n ; i++) {
                sum[i]=sum[i-1]+ex[i];
            }
            double ans = sum[k-1];
            for (int i = 1; i+k-1 <n; i++){
                if (sum[i+k-1]-sum[i-1] > ans) ans=sum[i+k-1]-sum[i-1];
            }
            System.out.printf("%.12f", ans);







        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 42472
N = int(input())

digits = 0
tmp = N
while tmp != 0:
    tmp = tmp // 10
    digits += 1

if digits == 1:
    print(N)
if digits == 2:
    print(9)
if digits == 3:
    print(N-90)
if digits == 4:
    print(N-(90+(N-999)))
if digits == 5:
    print(N-90-9000)
if digits == 6:
    print(N-90-9000-1)       

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 55;
const int MAXM = 500;
 
struct Edge
{
    int to,next;
}edge[MAXM];
int head[MAXN],tot;
int Dfn[MAXN],Low[MAXN];
int Index,res;
 
void addedge(int u, int v)
{
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
}
 
void Tarjan(int u, int fa)
{
    Dfn[u] = Low[u] = ++Index;
    for(int i = head[u]; i != -1; i = edge[i].next)
    {
        int v = edge[i].to;
        if(!Dfn[v])
        {
            Tarjan(v,u);
            Low[u] = min(Low[u],Low[v]);
            if(Low[v] > Dfn[u])
                ++res;
        }
        else if(v != fa)
            Low[u] = min(Low[u],Dfn[v]);
    }
}
 
void solve(int n)
{
    Index = res = 0;
    memset(Dfn,0,sizeof(Dfn));
    memset(Low,0,sizeof(Low));
    Tarjan(1,-1);
    printf("%d\n",res);
}
 
int main()
{
    int n,m,u,v;
    memset(head,-1,sizeof(head));
    tot = 0;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m; ++i)
    {
        scanf("%d %d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    solve(n);
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	int N, Q;
	string S;
	int l[100000];
	int r[100000];
	cin >> N >> Q >> S;
	for(int i = 0; i < Q; i++){
		cin >> l[i] >> r[i];
	}
	
	int Count[100000];
	for(int i = 0; i < N-1; i++){
		if(S[i] == 'A' && S[i+1] == 'C'){
			Count[i] = 1;
		}
		else{
			Count[i] = 0;
		}
		if(i > 0){
			Count[i] += Count[i-1];
		}
	}
	
	for(int i = 0; i < Q; i++){
	  cout << Count[r[i]-2] - (l[i] > 1 ? Count[l[i]-2] : 0) << endl;
	}
	
	return 0;
}


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

# define fr first
# define sc second
# define ll long long
# define mk make_pair
# define pb emplace_back
# define sz(s) (int)s.size()
# define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e15+7;

int n;
ll a[1011][101];
ll b[1011][101];

int main () {
    cin >> n;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= 10; j++)
            cin >> a[i][j];
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= 10; j++)
            cin >> b[i][j];

    ll ans = -inf;
    for(int i = 1; i < 1024; i++) {
        ll cur = 0;
        for(int j = 1; j <= n; j++) {
            ll c = 0;
            for(int k = 0; k < 10; k++) {
                if(a[j][k+1] == 1) {
                    if(i & (1 << k)) {
                        c++;
                    }
                }
            }
            cur += b[j][c];
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
N=int(input())
a=[]
for i in range(N):
	a.append(int(input()))
k=max(a)
count=0
for j in range(N):
	if count==1:
		print(k)
	else:
		if a[j]==k:
			b=a[:j]+a[j+1:]
			count=1
			print(max(b))
		else:
			print(k)

Measured memory_bytes: 15604
#include <stdio.h>
#include <string.h>

int main(){
    char    s[100+1]={0}, t[100+1]={0}, x;
    scanf("%s %s", s, t);

    //s
    for(int i=0; s[i]!=0; i++){
        for(int j=i+1; s[j]!=0; j++){
            if( s[i] > s[j] ){
                x    = s[i];
                s[i] = s[j];
                s[j] = x;
            }
        }
    }

    //t
    for(int i=0; t[i]!=0; i++){
        for(int j=i+1; t[j]!=0; j++){
            if( t[i] < t[j] ){
                x    = t[i];
                t[i] = t[j];
                t[j] = x;
            }
        }
    }

    if( strcmp(s,t) < 0 ){ printf("Yes\n"); }
    else                 { printf("No\n");  }
    return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int X, Y, ans = 0;
  cin >> X >> Y;
  if (X==3) ans += 100000;
  else if (X==2) ans += 200000;
  else if (X==1) ans += 300000;
  if (Y==3) ans += 100000;
  else if (Y==2) ans += 200000;
  else if (Y==1) ans += 300000;
  if (X==1&&Y==1) ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	int x = 0, y = 0;
	for(int i = 0; i < s.size(); i++)
	{
		int cur = s[i] - '0';
		x += (cur != (i % 2));
		y += (cur == (i % 2));
	}
	cout << min(x, y);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

string s;
int main (){
    cin >> s;
    int ans = sz(s);
    for (int i = 0; i < sz(s); ++i){
        if (s[i] == s[i + 1]){
            --ans;
            i += 2;
        }
    }
    cout << ans << "\n";
    return 0;
}
 

Measured memory_bytes: 640
def gcd(a, b) :
    if b == 0 :
        return a
    ret = gcd(b, a % b)
    return ret

def main( ) :

  n = int(input())
  v = [int(i) for i in input().split()]

  l = [0 for i in range(n)]
  r = l[:]

  for i in range(1, n) :
      l[i] = gcd(l[i-1], v[i-1])
      r[-i-1] = gcd(r[-i], v[-i])

  ans = 0
  for i in range(n) :
      ans = max(ans, gcd(l[i], r[i]))
  print(ans)
                 

main()


Measured memory_bytes: 14060
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

from functools import lru_cache
@lru_cache(maxsize = 2 ** 12)
def solve(i, m):
	if m == 0:
		return True
	if i == n:
		return False
	return solve(i + 1, m) or solve(i + 1, m - A[i])

for m in M:
	if solve(0, m):
		print("yes")
	else:
		print("no")


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

public class Program{
    public static void Main(){
        int N=int.Parse(Console.ReadLine());
        int[] H=Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        string ans="Yes";
        for(int i=N-1;i>0;i--){
            if(H[i-1]-H[i]>1){
                ans="No";
                break;
            }else if(H[i-1]-H[i]==1){
                H[i-1]-=1;
            }
        }
        Console.WriteLine(ans);
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  ll n, m;
  cin >> n >> m;
  vl a(m);
  rep(i,0,m) cin >> a[i];
  ll tot = accumulate(all(a), 0LL);

  if (tot>n) cout << -1 << '\n';
  else cout << n-tot << '\n';
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
// const int INF=4e18+10;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

vector<pair<int, int> > factorisize(int a)
{
    vector<pair<int , int> > e;
    for(int i=2;i*i<=a;i++)
    {
        int cnt=0;
        if(a%i==0)
        {
            while(a%i==0)
            {
                cnt++;
                a/=i;
            }
            e.pb({i, cnt});
        }
    }
    if(a!=1)
    {
        e.pb({a, 1});
    }
    return e;
}
void solve()
{
    int n;
    cin>>n;
    auto ff = factorisize(n);

    int ans=0;
    for(auto i:ff)
    {
        int cnt= i.se;

        int l=0;
        for(l=1;l*(l+1)/2 <= cnt;l++);
        l--;
        ans+=l;


    }
    cout<<ans<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;

int main(void){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    


    H = H / 12.0 + (1/12.0)*(M/60);
    M = M / 60.0;
    double h_y = sin(M_PI*2 * H) * A + 2000 ; 
    double h_x = cos(M_PI*2 * H) * A + 2000;

    double m_y = sin(M_PI*2 * M) * B + 2000;
    double m_x = cos(M_PI*2 * M) * B  + 2000;
            
    double dx = abs(h_x - m_x);
    double dy = abs(h_y - m_y);
    std::cout << std::fixed;
    cout <<   std::setprecision(15) << sqrt(pow(dx,2) + pow(dy,2)) << endl;
    return 0;
}

Measured memory_bytes: 4108
from collections import Counter
n = input()
s = input()
ans = 0
for i in range(len(s)):
  l = s[:i]
  r = s[i:]
  cnt = 0
  cl = Counter(l)
  for i in cl.keys():
    if i in r:
      cnt += 1
  if ans < cnt:
    ans = cnt
print(ans)


  

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int S[1000] = { 0 };


int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << min(a, min(b, c)) << " " << max(a, max(b, c)) << endl;
	return 0;
}





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

using namespace std;

int ctoi (char c)
{
  return c - '0';
}

int main ()
{
  int N;
  int left[10],right[10];
  int cent,val,res;
  string S;
  bool found[1000];
  memset(found,0,sizeof(bool)*1000);
  memset(left,0,sizeof(int)*10);
  memset(right,0,sizeof(int)*10);

  cin >> N;
  cin >> S;
  
  left[ctoi(S[0])]++;

  for (int i=2;i<N;i++)
  {
    right[ctoi(S[i])]++;
  }
  
  for (int i=1;i<N-1;i++)
  {
    cent = ctoi(S[i]);
    for (int j=0;j<10;j++)
    {
      if (left[j] > 0)
      {
        for (int l=0;l<10;l++)
        {
          if (right[l] > 0)
          {
            val = j * 100 + cent * 10 + l;
            found[val] = true;            
          }
        }
      }            
    }
    left[cent]++;
    right[ctoi(S[i+1])]--;
  }

  res = 0;
  for (int i=0;i<1000;i++)
  {
    if (found[i])
      res++;
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s, t; int q; cin >> s >> t >> q;
  int n = s.length(), m = t.length();
  vector s_a(n + 1, 0), t_a(m + 1, 0);
  REP(i, n) s_a[i + 1] = s_a[i] + (s[i] == 'A') + 2 * (s[i] == 'B');
  REP(i, m) t_a[i + 1] = t_a[i] + (t[i] == 'A') + 2 * (t[i] == 'B');
  while (q--) {
    int a, b, c, d; cin >> a >> b >> c >> d; --a; --b; --c; --d;
    int sa = s_a[b + 1] - s_a[a], ta = t_a[d + 1] - t_a[c];;
    cout << (sa % 3 == ta % 3 ? "YES\n" : "NO\n");
  }
  return 0;
}


Measured memory_bytes: 4236
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s[110];
    bool flag=true;
    rep(i,0,n-1){
        cin>>s[i];
        if(s[i]=="Y"){
            flag = false;
            break;
        }
    }
    if(flag) cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int,readline().split())
A = (np.frombuffer(read(),'S1').reshape(H,-1)[:,:W] == b'#') * 1

R = np.zeros((H,W),np.int8)
R[0] = 1
R[:-1,::2] = 1
B = 1 - R

R |= A; B |= A

R = np.where(R,'#','.')
B = np.where(B,'#','.')

print('\n'.join(''.join(row) for row in R))
print()
print('\n'.join(''.join(row) for row in B))

Measured memory_bytes: 21036
/*****And nothing else matters!******/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 1e6 + 10;

int main()
{
    fast;
    int x;
    cin >> x;
    cout << 1 -x;
}


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

typedef long long LL;
LL expo[50];
LL prefP[50], prefN[50];
int main()
{
	expo[0]=1;
	for(int a=1;a<=45;a++)
	{
		expo[a]=expo[a-1]*(-2);
	}
	prefP[0]=1;
	prefN[0]=0;
	for(int a=1;a<=45;a++)
	{
		prefP[a]=prefP[a-1];
		prefN[a]=prefN[a-1];
		if(a%2==0) prefP[a]+=expo[a];
		else prefN[a]+=expo[a];
	}
	LL tmp;
	cin>>tmp;
	int ix=0;
	string hasil="";
	for(int b=0;b<=45;b++)
	{
		LL N=tmp;
		hasil="";
		for(int a=b;a>=0;a--)
		{
			if(N==0) hasil.push_back('0');
			else
			if(a%2==0)
			{
				if(N-prefP[a-1] > 0)
				{
					hasil.push_back('1');
					N-=expo[a];
				}
				else hasil.push_back('0');
			}
			else
			{
				if(N-prefN[a-1] < 0)
				{
					hasil.push_back('1');
					N-=expo[a];
				}
				else hasil.push_back('0');
			}
		}
		if(N==0) break;
	}
	while(hasil.length()>1 && hasil[0]=='0')
	{
		hasil.erase(0, 1);
	}
	cout<<hasil<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]*=t[i][0]+t[i][1]
            t[a][1]*=t[i][0]
f(1,0)
print(sum(t[1])%m)

Measured memory_bytes: 797744
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    answer = 0
    if K == 0:
        return N*N
    for b in range(K+1, N+1):
        answer += (N//b)*(b-K)+max(0, N%b-(K)+1)
    return answer


if __name__ == '__main__':
    print(solve())


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

signed main() {
	int n; cin >> n;
	vector<int> a(n); for (auto &A : a) cin >> A;
	vector<int> head;
	for (int i = 0; i < n; ++i) {
		auto it = upper_bound(head.begin(), head.end(), -a[i]);
		if (it == head.end())
			head.push_back(-a[i]);
		else
			*it = -a[i];
	}
	cout << head.size();
}


Measured memory_bytes: 1276
n=int(input())
a=list(map(int,input().split()))

def f(x):
  x.sort()
  if x[0]==0:
    return 0

  x.sort(reverse=True)
  
  ans=1
  
  for i in a:
    ans=ans*i

    if ans>10**18:
      return -1
      
  return ans
  


print(f(a))

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

using namespace std;

int N, T;

vector<pair<int, int>> AB;
int dp[3000 + 10][3000 + 10];

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		AB.push_back(make_pair(a, b));
	}
	
	sort(AB.begin(), AB.end());
	
	int ans = 0;
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= T - 1; j++) {
			dp[i][j] = dp[i - 1][j];
			ans = max(ans, dp[i][j] + AB[i - 1].second);
			if (j - AB[i - 1].first >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - AB[i - 1].first] + AB[i - 1].second);
		}
	}
	cout << ans << endl;
	return 0;
}


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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;
template <typename T>
bool Setmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

int main() {
  rd(int, n);
  V<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  int ai = a[n - 1];
  int aj, ajm = -1;
  rep(i, n - 1) if (Setmax(ajm, min(a[i], ai - a[i]))) aj = a[i];
  wt(ai, aj);
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct Doubling {
  vector<vector<int>> to;
  int mx;
  Doubling(int n, int d, const vector<int> &a):to(d, vector<int>(n)) {
    mx = d;
    to[0] = a;
    for(int i = 1; i < mx; i++) for(int j = 0; j < n; j++) {
      to[i][j] = to[i-1][to[i-1][j]];
    }
  }
  int operator()(int s, long long k) {
    int res = s;
    for(int i = mx-1; i >= 0; i--) {
      long long l = 1LL<<i;
      if(l <= k) {
        res = to[i][res];
        k -= l;
      }
    }
    return res;
  }
};

const int MX = 60;

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

  ll n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  Doubling d(n,MX,a);
  int ans = d(0,k)+1;
  cout << ans << endl;
}

Measured memory_bytes: 51780
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <list>
#include <queue>
#include <bitset>

using namespace std;

bool dfs(vector<long long>& o, long long node, vector< list< pair<long long, long long> > >& r, vector<int>& used){
    for (auto&& var : r[node]) {
        if (used[var.first] == 1) {
            if (o[var.first] == o[node] + var.second) {
                continue;
            } else {
                return false;
            }
        } else {
            used[var.first] = 1;
            o[var.first] = o[node] + var.second;
            if(dfs(o, var.first, r, used)) {
                continue;
            } else {
                return false;
            }
        }
    }
    return true;
}

void solve(long long N, long long M, vector<long long> L, vector<long long> R, vector<long long> D){
    vector<long long> o(N);
    vector<int> used(N, 0);
    vector< list< pair<long long, long long> > > r(N, list< pair<long long, long long> >());
    for (int i = 0; i < M; i++) {
        r[L[i]-1].push_back(make_pair(R[i]-1, D[i]));
        r[R[i]-1].push_back(make_pair(L[i]-1, -D[i]));
    }
    bool flag = true;
    for (int i = 0; i < N; i++) {
        if(used[i] == 1) {
            continue;
        }
        used[i] = 1;
        o[i] = 0;
        if(dfs(o, i, r, used)){
            continue;
        } else {
            flag = false;
            break;
        }
    }
    if (flag) {
        //long long minx = *min_element(o.begin(), o.end());
        //long long maxx = *max_element(o.begin(), o.end());
        //if (maxx - minx <= 1000000000) {
        //    std::cout << "Yes" << std::endl;
        //} else {
        //    std::cout << "No" << std::endl;
        //}
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long M;
    long long N;
    std::cin >> N;
    std::cin >> M;
    vector<long long> D(M);
    vector<long long> R(M);
    vector<long long> L(M);
    for(int i = 0 ; i < M ; i++){
        std::cin >> L[i] >> R[i] >> D[i];
    }
    solve(N, M, L, R, D);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

std::vector<vector<ll>> d;
void warshall_floyd(int n) { // ワーシャルフロイド nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
    int v,e;
    std::cin >> v>>e;
    d.resize(v);
    rep(i,v){
        d[i].resize(v);
    }
    reprep(i,j,v,v)d[i][j]=INF64;
    rep(i,v)d[i][i]=0;
    rep(i,e){
        int a,b,c;
        std::cin >> a>>b>>c;
        d[a][b]=c;
    }
    warshall_floyd(v);
    reprep(i,j,v,v){
        if(d[i][j]+d[j][i]<0){
            std::cout << "NEGATIVE CYCLE" << std::endl;
            exit(0);
        }
    }
    rep(i,v){
        rep(j,v){
            if(d[i][j]<=INF64/10)std::cout << d[i][j] <<((j==v-1)?"":" ");
            else std::cout << "INF" <<((j==v-1)?"":" ");
        }
        std::cout  << std::endl;
    }
    
    
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
i64 n,x,t;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    cin >> n >> x >> t;
    cout << t *((n+x-1)/x) << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
 
int main(void) {
    int i,n;
    int a[100];
    
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", a+i);
    }
    for(i=n-1; i>=0; i--){
        printf("%d", a[i]);
        if(i==0) printf("\n");
        else printf(" ");
    }
         
        return 0;
}

Measured memory_bytes: 600
# include <iostream>
using namespace std;
const int N=100006;
struct node
{
	int x,y,z;
}a[N];
int n;
void work (void)
{
	int i,p,q,t,f;
	f=1;
	for (i=1;i<=n;i++)
	{
		if (a[i].y>=a[i-1].y)
		p=a[i].y-a[i-1].y;
   else p=a[i-1].y-a[i].y;
        if (a[i].z>=a[i-1].z)
		q=a[i].z-a[i-1].z;
   else q=a[i-1].z-a[i].z;
        t=a[i].x-a[i-1].x;
        if (p+q>t)
        f=0;
   else if ((p+q+t)%2==1)
        f=0;
		if (f==0)
		break;
	}
	if (f==1)
	cout<<"Yes";
else cout<<"No";
}
int main (void)
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	cin>>a[i].x>>a[i].y>>a[i].z;
	work ();
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int X=0;
	int ma=0;
	cin>>n;
	char s[n];
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')
		X++;
		if(s[i]=='D')
		X--;
		ma=max(X,ma);
	}
	cout<<ma;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  long long int sstr=1;
  long long int tstr=1;
  vector<long long int> sset,tset;
  for(long long int i=1; i<s.size(); i++){
    if(s[i]==s[i-1]){
      sstr++;
    }else{
      sset.push_back(sstr);
      sstr=1;
    }

    if(t[i]==t[i-1]){
      tstr++;
    }else{
      tset.push_back(tstr);
      tstr=1;
    }
  }
  sset.push_back(sstr);
  tset.push_back(tstr);
  sort(sset.begin(),sset.end());
  sort(tset.begin(),tset.end());
  if(sset==tset){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 776
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
int n , W ;
vector<int> p , w ;
int dp[101][N] ;
int dfs(int i, int cur){
    if ( i == n ) {
        return 0 ;
    }
    if ( dp[i][cur] != -1 ) return dp[i][cur] ;
    int ans = dfs(i + 1, cur) ;
    if ( w[i] <= cur ){
        ans = max(ans, p[i] + dfs(i + 1, cur - w[i])) ;
    }
    return dp[i][cur] = ans ;
}
signed main(){
    fastio
    memset(dp, -1, sizeof dp) ;
    cin >> n >> W ;
    p = vector<int>(n) ;
    w = vector<int>(n) ;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> p[i] ;
    }
    int ans = dfs(0, W) ;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 82452
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int nCr(int r, int n){
    int num = 1;
    int den = 1;
    int ans;
    for (int i = 0; i < n; i++){
        num = (r-i) * num;
        den = (i+1) * den;
    }

    ans = num / den;

    return ans;

}

int main(void)
{
    
    int N,M;
    int ans;
    string S;
    

    cin >> N >> M;

    ans = nCr(N,2) + nCr(M,2);

    cout << ans;

    return 0;
}

Measured memory_bytes: 888