akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define ppl pair<pl,ll>
#define pb push_back
#define pi acos(-1.0)
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define vl vector<ll>
#define mp make_pair
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define vll vector<vector<ll>>
#define all(a) a.begin(),a.end()
#define INF 1e9+5
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
 
 //ll n,m;
ll MOD1=1000000007;
ll MOD2=998244353;
 
 
void yes() {cout<<"YES"<<endl;}
void no() {cout<<"NO"<<endl; }
/*
ll gcd(ll a,ll b);
ll lcm(ll a, ll b);
ll mod_exp(ll x,ll power,ll m);
ll ext_gcd(ll a,ll b,ll& x,ll& y);
void swap(ll& a,ll& b);
ll root(vector<ll>& arr,ll a);
void Union(vector<ll>& arr,ll a,ll b);
const ll N=32001;
vl fenwick(N,0);
void update(ll index,ll add);
ll sum(ll index);
ll find_kth_smalest(ll k);
ll find(ll k);
ll ETF(ll n);
*/
 
 
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a, a);
}
 
ll lcm(ll a, ll b)
{
    return ( a*b/(gcd(a,b)));
}
 
//void sieve();
//vector<ll> factorise(1000+2,-1);
//vector<ll> prime(20005,1);
//vl fug;
//void p();
//void fact();
 
 
/*
void sieve()
{
    prime[0]=prime[1]=0;
    for(ll i=2;i<=sqrt(2005);i++)
    {
        if(prime[i]==1)
        {
            for(ll j=i*i;j<2005;j+=i)
                prime[j]=0;
        }
    }
}
*/


ll knapsack1(vl& value,vl& weight,ll w,ll n,vll& dp)
{
    if(w==0 || n==0) return 0;
    if(dp[n][w]!=-1) return dp[n][w];
    if(weight[n-1]<=w)
        return dp[n][w]=max(value[n-1]+knapsack1(value, weight, w-weight[n-1], n-1, dp), knapsack1(value, weight, w, n-1, dp));
    else
        return dp[n][w]=knapsack1(value, weight, w, n-1, dp);
}


void solve()
{
  
    ll n,w; cin>>n>>w;
    ll temp=n;
    vl value,weight;
    
    while (temp--) {
        ll wt,val;
        cin>>wt>>val;
        value.eb(val); weight.eb(wt);
    }
    
    vector<vector<ll>> dp(n+1,vl(w+1,-1));
   // memset(dp,-1,sizeof(dp));
    
    cout<<knapsack1(value, weight, w, n, dp)<<endl;
    
    
    
    
    
 
    
}
 
int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tests=1;
    //cin>>tests;
    while (tests--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 83156
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int H = sc.nextInt();
        int A = sc.nextInt();
        System.out.println((H/A+((H%A!=0)?1:0)));
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 21716
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();
        long ans=0;
        for(int i=0; i<n; i++) {
            ans+=sc.nextInt()-1 ;
        }

       

        out.println(ans);
        out.flush();
    }
    
    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

int main(){
    int a,b,n;
    bool ans = 0;
    cin >> n;
    for (int i = 9; i > 0 ; --i) {
        a = n / i;
        if(i*a == n and a < 10){
            ans = 1;
        }
    }
    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

const int MAXN = 100100;

int n, m;
int dp[MAXN];
vector<int> ar[MAXN];

int fazDP(int node){
	if(dp[node] != -1) return dp[node];
	dp[node] = 0;
	for(int i = 0; i < ar[node].size(); i++)
		dp[node] = max(dp[node], fazDP(ar[node][i]) + 1);
	return dp[node];
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		int aux1, aux2;
		scanf("%d %d", &aux1, &aux2);
		ar[aux1].push_back(aux2);
	}
	for(int i = 0; i <= n; i++)
		dp[i] = -1;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, fazDP(i));
		//printf("dp[%d] = %d\n", i, fazDP(i));
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 8192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = tuple<string, int, int>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<P> ps;
    for (int i = 0; i < N; i++) {
      string s;
      int p;
      cin >> s >> p;
      ps.emplace_back(s, p, i);
    }
    sort(ps.begin(), ps.end(), [&](auto& a, auto& b) {
      if (get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
      if (get<1>(a) != get<1>(b)) return get<1>(a) > get<1>(b);
      return get<2>(a) < get<2>(b);
    });
    for (auto& p : ps) {
      cout << get<2>(p) + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	x, y = MAP()

	absmax = max(abs(x),abs(y))
	absmin = min(abs(x),abs(y))
	absxy = absmax - absmin

	if y > x and (x >= 0 or y <= 0):
		print(y-x)
	elif y > x:
		print(absxy+1)
	
	if x > y and (y > 0 or x < 0):
		print(absxy+2)
	elif x > y:
		print(absxy+1)
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(31)]
for ai in a:
  i = 0
  while ai > 0:
    if ai%2 == 1:
      x[i] += 1
    ai = ai//2
    i += 1
for i in range(31):
  x[i] = x[i]%2
for ai in a:
  s = 0
  for i in range(31):
    if ai%2 == 1:
      if x[i] == 0:
        s += 2**i
    else:
      if x[i] == 1:
        s += 2**i
    ai = ai//2
  print(s)

Measured memory_bytes: 94068
def main():
    import sys
    sys.setrecursionlimit(311111)
    import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    n,k = ina()
    tmp = [[] for _ in range(n)]
    for _ in range(n-1):
        x,x1=  ina()
        x-=1
        x1-=1
        tmp[x].append(x1)
        tmp[x1].append(x)
    def dfs(teiru,ta):
        rick = 1
        coulduse = k-1 if ta==-1 else k-2
        for i in tmp[teiru]:
            if i == ta:
                continue
            rick*=coulduse
            rick%=1000000007
            coulduse-=1
            rick*=dfs(i,teiru) 
            rick%=1000000007
        return rick
    print(k*dfs(0,-1)%1000000007)
    

    


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()


Measured memory_bytes: 128624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int h,w,n;
string takahashi, aoki;

int dirchar_to_idx(char dirchar) {
    if(dirchar == 'U') return 0;
    if(dirchar == 'D') return 1;
    if(dirchar == 'L') return 2;
    return 3;
}

int main() {
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    --sr; --sc;
    cin >> takahashi;
    cin >> aoki;

    vector<vector<int>> counts_takahashi(n+1, vector<int>(4, 0)), counts_aoki(n+1, vector<int>(4, 0));
    for(int i=0;i<n;++i) {
        int t_idx = dirchar_to_idx(takahashi[i]);
        int a_idx  = dirchar_to_idx(aoki[i]);
        ++counts_takahashi[i+1][t_idx];
        ++counts_aoki[i+1][a_idx];
        for(int j=0;j<4;++j) {
            counts_takahashi[i+1][j] += counts_takahashi[i][j];
            counts_aoki[i+1][j] += counts_aoki[i][j];
        }
        counts_aoki[i+1][0] = min(sr + counts_takahashi[i+1][1], counts_aoki[i+1][0]);
        counts_aoki[i+1][1] = min(h-1 - (sr - counts_takahashi[i+1][0]), counts_aoki[i+1][1]);
        counts_aoki[i+1][2] = min(sc + counts_takahashi[i+1][3], counts_aoki[i+1][2]);
        counts_aoki[i+1][3] = min(w-1 - (sc - counts_takahashi[i+1][2]), counts_aoki[i+1][3]);
    }

    bool ans = true;
    for(int i=1;i<=n;++i) {
        if(sr - counts_takahashi[i][0] + counts_aoki[i-1][1] < 0) {
            ans = false;
            cerr << i << " U" << endl;
            break;
        }
        if(sr + counts_takahashi[i][1] - counts_aoki[i-1][0] >= h) {
            ans = false;
            cerr << i << " D" << endl;
            break;
        }
        if(sc - counts_takahashi[i][2] + counts_aoki[i-1][3] < 0) {
            ans = false;
            cerr << i << " L" << endl;
            break;
        }
        if(sc + counts_takahashi[i][3] - counts_aoki[i-1][2] >= w) {
            cerr << i << " R" << endl;
            ans = false;
            break;
        }

    }

    cout << (ans?"YES\n":"NO\n");
}


Measured memory_bytes: 22536
#include <iostream>
#include <vector>
#include <map>
#define MAX_N 210000

class UnionFind {
  public :
    void init(int n) {
      for (int i = 0; i <= n; i++) {
        par[i] = i;
        rnk[i] = 0;
      }
    }
    
    int find(int x) {
      if (par[x] == x) return x;
      else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
      x = find(x); y = find(y);
      if (x == y) return;
      
      if(rnk[x] < rnk[y]) {
        par[x] = y;
      } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
      }
    }

    bool same(int x, int y) {
      return find(x) == find(y);
    }

  private:
    int par[MAX_N]; 
    int rnk[MAX_N];
};

using namespace std;

UnionFind ufp;
UnionFind ufr;
int main()
{
  int N, K, L;
  cin >> N >> K >> L;

  ufp.init(N);
  for (int i = 0; i < K; i++) {
    int p, q; cin >> p >> q;
    ufp.unite(p, q);
  }

  ufr.init(N);
  for (int i = 0; i < L; i++) {
    int r, s; cin >> r >> s;
    ufr.unite(r, s);
  }

  map<pair<int, int>, int> mp;
  for (int i = 1; i <= N; i++) {
    mp[make_pair(ufp.find(i), ufr.find(i))]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << mp[make_pair(ufp.find(i), ufr.find(i))] << ' ';
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

ll N;
inline void input(){
    fast_io();
    cin >> N;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b!=0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    }
    else{
        x = 1, y = 0;
    }
    return d;
}

void chmin(ll &a, ll b){if(a>b)a=b;}

ll solve(ll n){
    if(n==1) return 1;
    auto pf = prime_factor(2*n);
    ll k = 2*n;
    vector<ll> Pfs;
    for(auto [p,e]:pf) Pfs.push_back((ll)pow(p,e));
    int m = Pfs.size();
    for (int bit = 1; bit < (1<<m); bit++)
    {
        ll a = 1LL;
        for (int i = 0; i < m; i++)
        {
            if((bit>>i)&1LL) a *= Pfs[i];
        }
        ll b = 2*n/a;
        if(a==1LL || b==1LL) continue;
        ll x, y;
        extgcd(a,b,x,y);
        // debug(a,b,x,y);
        // if(x==0 || y==0) continue;
        if(x<0) chmin(k,-a*x);
        else chmin(k,-b*y);
    }
    return k;
}   

#include <atcoder/math>

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll wsolve(ll n){
    auto div = divisor(2*n);
    ll k = 2*n;
    for(ll x:div){
        ll y = 2*n/x;
        vector<ll> mod = {x, y};
        vector<ll> residue = {0, -1};
        auto p = atcoder::crt(residue, mod);
        if(p.first==0) continue;
        chmin(k, p.first);
    }
    return k;
}

int main()
{
    input();
    cout << wsolve(N) << "\n";
    return 0;
}


Measured memory_bytes: 3772
#include<iostream>

using namespace std;

int main()
{
	int a,b;
	char op='\0';
	
	for( ; '?' != op ; ) {
		cin>>a>>op>>b;
		switch( op ) {
			case '+':
				cout <<a+b<<endl;
				break;
			case '-':
				cout <<a-b<<endl;
				break;
			case '*':
				cout <<a*b<<endl;
				break;
			case '/':
				cout <<a/b<<endl;
				break;
			case '?':
				;
				break;
		}
	}
		    
    return 0;
}

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

#define LOOP(val,times) for(val = 0;val < (times);++val)

int main(){
    int dp[100030];
    int i,j,max6 = 0,max9 = 0,N,n = 1;
    vector <int> power6,power9;
    scanf("%d",&N);
    
    LOOP(i,100030){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    while(n <= N){
        n *= 6;
        if(n > N) break;
        power6.push_back(n);
    }
    n = 1;
    while(n <= N){
        n *= 9;
        if(n > N) break;
        power9.push_back(n);
    }

    LOOP(i,N){
        dp[i+1] = min(dp[i]+1,dp[i+1]);
        for(int x:power6){
            if(i+x <= N){
                dp[i+x] = min(dp[i+x],dp[i]+1);
            } 
        }
        for(int x:power9){
            if(i+x <= N){
                dp[i+x] = min(dp[i+x],dp[i]+1);
            }
        }
    }
    printf("%d",dp[N]);
    int k;cin >> k;
}

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

pair<complex<double>, double> min_circle (vector<complex<double>> data, int seed = 1331) {
    using point = complex<double>;
    using circle = pair<point, double>;
    const double eps = 1e-10; int n = data.size();
    if (n == 1) { return {data[0], 0}; };
    auto is_inner = [&](const point &a, const circle &c)->bool{ 
        return norm(a-c.first) <= c.second+eps;
    };
    auto make_circle_2p = [&](const point &a, const point &b)->circle {
        point c = (a+b)/(double)2; double r = norm(a-c);
        return {c, r};
    };
    auto make_circle_3p = [&](const point &a, const point &b, const point &c)->circle {
        double A = norm(b-c), B = norm(c-a), C = norm(a-b);
        double S = norm((a-c)*conj(b-c)-conj(a-c)*(b-c));
        point p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / S;
        double r = norm(p - a);
        return {p, r};
    };
    
    // MinDisk
    shuffle (data.begin(), data.end(), mt19937(seed));
    circle D = make_circle_2p(data[0], data[1]);
    for (int i = 2; i < n; i++) {
        if (!is_inner(data[i], D)) {
            // MinDiskWithPoint
            shuffle(data.begin(), data.begin()+i-1, mt19937(seed));
            D = make_circle_2p(data[0], data[i]);
            for (int j = 1; j < i; j++) {
                if (!is_inner(data[j], D)) {
                    // MinDiskWith2Point
                    D = make_circle_2p(data[i], data[j]);
                    for (int k = 0; k < j; k++) {
                        if (!is_inner(data[k], D)) {
                            D = make_circle_3p(data[k], data[j], data[i]);
                        }
                    }
                }
            }
        }
    }
    return D;
}



int main() {
    using point = complex<double>;
    int N;
    cin >> N;
    vector<point> data(N);
    for (int i = 0; i < N; i++) {
        double a, b;
        cin >> a >> b;
        data[i] = point(a, b);
    }
    
    double ans = min_circle(data).second;
    cout << fixed << setprecision(10) << sqrt(ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/



int main()
{
	ll sum0 = 0, sum1 = 0, ans0 = 0, ans1 = 0;
	cin >> n;
	REP(i, n)
	{
		ll a;
		cin >> a;
		sum0 += a; sum1 += a;
		if (i % 2 == 0) {
			if (sum0 >= 0) ans0 += sum0 + 1, sum0 = -1;
			if (sum1 <= 0) ans1 += 1 - sum1, sum1 = 1;
		} else {
			if (sum0 <= 0) ans0 += 1 - sum0, sum0 = 1;
			if (sum1 >= 0) ans1 += sum1 + 1, sum1 = -1;
		}
	}
	cout << min(ans0, ans1) << endl;
}

Measured memory_bytes: 384
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    set<int> a_s;
    rep(i,n)
    {
        int a;
        cin >> a;
        a_s.insert(a);
    }
    cout << (SZ(a_s) == n ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 12996
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

check1 :: [Integer] -> Bool
check1 (x:xs) = x == 0 && (length . filter (==0)) xs == 0

check2 :: [Integer] -> Bool
check2 [] = True
check2 [_] = True
check2 (x1:x2:xs) = succ x1 == x2 && check2 (x2:xs)

solve :: [Integer] -> Integer
solve [_] = 1
solve (x1:x2:xs) = ((x1^x2) `rem` 998244353) * (solve (x2:xs))

main :: IO ()
main = do
    n <- readLn :: IO Int
    d <- map (fst . fromJust . BS.readInteger)
        . BS.words <$> BS.getLine :: IO [Integer]
    let d' = group $ sort d
    print $
        if n /= 1 && check1 d && check2 (map head d')
            then solve (map (fromIntegral . length) d') `rem` 998244353
            else 0


Measured memory_bytes: 22908
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 3005;

int lcs[N][N];

signed main(){
    IOS;
    string s, t;
    cin >> s >> t;
    s = " " + s;
    t = "?" + t;
    for (int i = 1; i < s.length(); i++) {
        for (int j = 1; j < t.length(); j++) {
            if (s[i] == t[j]) lcs[i][j] = lcs[i-1][j-1] + 1;
            lcs[i][j] = max({lcs[i][j], lcs[i-1][j], lcs[i][j-1]});
        }
    }
    string ans = "";
    int i = s.length() - 1, j = t.length()-1;
    while (i && j) {
        if (s[i] == t[j]) ans += s[i], i--, j--;
        else if (lcs[i][j] == lcs[i-1][j]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
int main()
{
    int A,B,K,i,c=0;
    scanf("%d %d %d",&K,&A,&B);
    if((A>=1)&&(A<=1000)&&(B>=1)&&(B<=1000)&&(K>=1)&&(K<=1000))
    {
        for(i=A;i<=B;i++)
        {
            if(i%K==0)
            {
                c++;
            }
        }
        if(c>0)
        {
            printf("OK");
        }
        else
            printf("NG");
    }

}


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

int main(){
  int N;
  cin >> N;
  set<int> s;
  for(int i = 0; i < N; ++i){
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int f=0;
    while(a>0&&c>0){
        if(f%2==0){
            c-=b;
        }
        else {
            a-=d;
        }
        f++;
    }
    if(a<=0){
        printf("No");
    }
    else printf("Yes");
    return 0;

}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

  int n;
  while (cin >> n) {
    vector<int> a(n);
    each (i, a) cin >> i;
    map<int, int> cnt;
    each (i, a) {
      ++cnt[i - 1];
      ++cnt[i + 1];
      ++cnt[i];
    }
    int x = -2;
    each (i, cnt) {
      if (cnt[x] < i.second) {
        x = i.first;
      }
    }
    cout << cnt[x] << endl;
  }
  
  return 0;
}


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

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

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

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

int n;

int main() {
	cin >> n;
	cout << n * 32 << endl;
	return 0;
}


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

const int N = 110000;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    int p[N] = {};
    int a;
    for (int i = 0; i < q; i++) {
        cin >> a;
        p[a - 1]++;
    }

    for (int i = 0; i < n; i++) {
        if (k - (q - p[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;


string backtrack(const vector<vector<int>> f, string s, string t,int i,int j)
{
    if(i==0 || j==0) return "";
    if (s[i-1] == t[j-1]) {
        return backtrack(f, s,t,i-1,j-1) + s[i-1];
    }
    if (f[i][j-1] > f[i-1][j]) {
        return backtrack(f,s,t,i,j-1);
    }
    return backtrack(f,s,t,i-1,j);
}


auto LCS(string s, string t)
{
    int s_len = s.size();
    int t_len = t.size();

    vector<vector<int>> f;
    vector<int> fst_row;
    for (size_t i = 0; i < t_len + 1; ++i)
    {
        fst_row.push_back(0);
    }
    f.push_back(fst_row);

    for (size_t i = 1; i < s_len + 1; ++i)
    {
        vector<int> cur_row{0};
        for (size_t j = 1; j < t_len + 1; ++j)
        {
            if (s[i - 1] == t[j - 1])
            {
                // lcs += s[i-1];
                cur_row.push_back(1 + f[i - 1][j - 1]);
            }
            else
            {
                cur_row.push_back(max(cur_row[j-1], f[i - 1][j]));
            }
        }
        f.push_back(cur_row);
    }

    // for (auto &&row : f)
    // {
    //     for (auto &&e : row)
    //     {
    //         cout << e << " ";
    //     }
    //     cout << "\n";
    // }
    // cout << "\n";

    // return f;
    // string lcs = backtrack(f, s,t, s_len, t_len);

    // iterative method
    int i=s_len,j=t_len;
    int lcs_len = f[i][j];
    string lcs(lcs_len, '0');
    while(i>0 && j >0) {
        if (s[i-1] == t[j-1]) {
            lcs[lcs_len-1] = s[i-1];
            --i;
            --j;
            --lcs_len;
        } else if(f[i][j-1] >= f[i-1][j]) {
            --j;
        } else {
            --i;
        }
    }

    return lcs;
}





// int AA_LCS(string s, string t)
// {
//     int s_len = s.size();
//     int t_len = t.size();

//     vector<vector<int>> f;
//     int fij = (s[0] == t[0] ? 1 : 0);
//     int f_i1_j = (s[1] == t[0] && s[1] != s[0] ? fij + 1 : fij);
//     int f_i_j1 = (t[1] == s[0] && t[1] != t[0] ? fij + 1 : fij);
//     int f_i1_j1 = (s[1] == t[1] ? f_ij + 1 : max(f_i1_j, f_i_j1));

//     for (size_t i = 1; i < s_len; ++i)
//     {
//         for (size_t j = 1; j < t_len; ++j)
//         {
//         }
//     }
// }


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

    string s,t;
    cin >> s>>t;

    cout << LCS(s,t) << "\n";

}

Measured memory_bytes: 35584
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
from collections import Counter
INF = float('inf')


N=int(input())
An=sorted(list(map(int, input().split())))
# 各要素の出現回数をカウント
C = Counter(An)
# 1回以上出現しているものを抽出
C = [(k ,v) for k, v in C.items() if v > 1]
if len(C) < 2:
    print(0)
else:
    C = sorted(C, key=lambda x:x[0])
    # 正方形
    if C[-1][1] >= 4:
        print(C[-1][0] ** 2)
    else:
        print(C[-1][0]*C[-2][0])

Measured memory_bytes: 18728
def ceil(x, y):
    # ceil(x / y)
    return (x + y - 1) // y


def main():
    n = int(input())
    takahashi = 1
    aoki = 1
    for _ in range(n):
        t, a = map(int, input().split())
        diff = max(ceil(takahashi, t), ceil(aoki, a))
        takahashi = t * diff
        aoki = a * diff
    print(takahashi + aoki)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		Integer M = sc.nextInt();
      	List<Integer> list = new ArrayList<>();
      	for(int i = 0; i < N; i++){
 		Integer a = sc.nextInt();
         list.add(a);
        }
      int sum = 0;
      for(int j = 0; j < N; j++){ //合計計算
        sum = sum + list.get(j);
      }
      int flag = 0;
      for(int k = 0; k < N; k++){//条件計算
        if(list.get(k)*(4*M) >= sum){
          flag++;
        }
      }
      if(flag >= M){
      System.out.println("Yes");
      }else{
      System.out.println("No");
      }
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    ll n;
    cin >> n;
    string s;
    cin >> s;
    s = " " + s;

    tuple<ll,ll,ll> prefixrgb[4005];
    prefixrgb[0] = make_tuple(0,0,0);
    FOR(i,1,n){
        prefixrgb[i] = prefixrgb[i-1];

        if (s[i]=='R') get<0>(prefixrgb[i]) = get<0>(prefixrgb[i-1])+1;
        if (s[i]=='G') get<1>(prefixrgb[i]) = get<1>(prefixrgb[i-1])+1;
        if (s[i]=='B') get<2>(prefixrgb[i]) = get<2>(prefixrgb[i-1])+1;
    }

    ll ans=0;

    FOR(i,1,n){
        FOR(j,i+1,n){
            if (s[i] == s[j]) continue;
            else {
                if ( (s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R') ){
                    ans += get<2>(prefixrgb[n]) - get<2>(prefixrgb[j]);
                    ll k = j + (j-i);
                    if (k>n) continue;
                    else if (s[k] == 'B') ans--;
                }
                if ( (s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R') ){
                    ans += get<1>(prefixrgb[n]) - get<1>(prefixrgb[j]);
                    ll k = j + (j-i);
                    if (k>n) continue;
                    else if (s[k] == 'G') ans--;
                }
                if ( (s[i]=='B' && s[j]=='G') || (s[i]=='G' && s[j]=='B') ){
                    ans += get<0>(prefixrgb[n]) - get<0>(prefixrgb[j]);
                    ll k = j + (j-i);
                    if (k>n) continue;
                    else if (s[k] == 'R') ans--;
                }
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 3764
N = int(input())
h = list(map(int,input().split()))

mincost = [-1] * N
mincost[0] = 0
mincost[1] = abs(h[1] - h[0])

for i in range(2,N):
    a = mincost[i-2] + abs(h[i] - h[i-2])
    b = mincost[i-1] + abs(h[i] - h[i-1])
    mincost[i] = a if a < b else b

print(mincost[N-1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define CLR(a)              memset(a, 0, sizeof(a))
#define SET(a, x)           memset(a, x, sizeof(a))
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define FOR1(i, n)          for (int i=1; i<=n; i++)
#define ROF(i, n)           for (int i=n-1; i>=0; i--)
#define ROF1(i, n)          for (int i=n; i>=1; i--)
#define LOOP(i, x, n)       for (int i=x; i<=n; i++)
#define READ(x)             freopen(x, "r", stdin);
#define WRITE(x)            freopen(x, "w", stdout);
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define all(v)              v.begin(), v.end()

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<string, int>      psi;
typedef pair<char, int>        pci;

const double eps = 1e-9;

int fx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int fy[] = {0, 0, -1, 1, -1, 1, -1, 1};

int kx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky[] = {2, -2, 1, -1, 2, -2, 1, -1};

int main()
{
    ll n, a, b; cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(a, n % (a + b)) << endl;
    return 0;
}




Measured memory_bytes: 256
from collections import defaultdict

class Unionfind:

    __slots__ = ['parents','sizes']

    def __init__(self, n):
        self.parents = list(range(n))
        self.sizes = [1]*n

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            root_x = self.root(self.parents[x])
            self.parents[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    # 集合自体の数 ({1,2}, {3}, {4} : kind -> 3)
    def kind(self):
        for v in range(N):
            self.root(v)
        return len(list(set(self.parents)))

    # xが属する集合の要素の数　({1,2,3} : size(2) -> 3)
    def size(self, x):
        self.sizes[x] = self.sizes[self.root(x)]
        return self.sizes[x]

N, K, L = map(int,input().split())
road = Unionfind(N)
train = Unionfind(N)

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1; q -= 1
    road.unite(p, q)

for _ in range(L):
    r, s = map(int,input().split())
    r -= 1; s -= 1
    train.unite(r, s)

cnt = defaultdict(int)

for i in range(N):
    key = (road.root(i), train.root(i))
    cnt[key] += 1

ans_list = []
for i in range(N):
    key = (road.root(i), train.root(i))
    ans = cnt[key]
    ans_list.append(ans)

print(*ans_list)

Measured memory_bytes: 56284
#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
#include <sstream>
 
using namespace std;    


char getOpp(char c) {
    if (c == 'S')
	return 'W';
    else
	return 'S';
}

char getNext(char sc, char tc, char nc) {
    if (sc == 'o') {
	if (tc == 'S') {
	    return nc;
	} else {
	    return getOpp(nc);
	}
    } else {
	if (tc == 'S') {
	    return getOpp(nc);
	} else {
	    return nc;
	}
    }
    
}

string getAnimals(string &s, char first, char second, char last, int len)
{
    string t(len, '*');
    t[0] = first;
    t[1] = second;

    for (int i = 2; i < len; i++) {
	t[i] = getNext(s[i - 1], t[i - 1], t[i - 2]);
    }
    
    //cout << t << endl;
    if (last == t[len - 1] && getNext(s[len - 1], t[len - 1], t[len - 2]) == t[0]) {
	return t;
    } else {
	return "";
    }
    
}

int main(void){
    string s;
    string line;
    stringstream ss;
    int n;
    getline(cin, line);
    ss.str(line);
    ss >> n;
    
    getline(cin, s);
    int len = s.length();

    
    string t;

    string comb = "SW";
    for (int i = 0; i < comb.length(); i++) {
	for (int j = 0; j < comb.length(); j++) {
	    t = getAnimals(s, comb[i], comb[j], getNext(s[0], comb[i], comb[j]), len);
	    if (t != "") {
		goto result;
	    }
	}
    }
    
 result:
    if (t != "") {
	cout << t << endl;
    } else {
	cout << -1 << endl;
    }
 
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

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

    // if (j>i) then j-i = Ai + Aj
    // means Ai + i = j - Aj
    map<long long, vector<long long> > left_val;

    for(int i=0; i<N; ++i){
        long long left = (i+1) + A[i];
        if(left > 0) left_val[left].push_back(i+1);
    }

    long long ans = 0;

    // check right value exist in the left value;
    for(int j=0; j<N; ++j){
        long long right = (j+1) - A[j];
        if( left_val.count(right) > 0 ){
            ans += left_val[right].size();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 26744
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<long double> X(N), Y(N);
	for (int i = 0; i < N; i++){
		std::cin >> X[i] >> Y[i];
	}

	long double ans = 0;

	int A = N + N * (N - 3) / 2;
	int NUM = 1;
	int DEN = 1;
	for (int i = 0; i < N - 1; i++)
	{
		NUM *= (A - i);
	}
	for (int i = 0; i < N - 1; i++)
	{
		DEN *= (N - 1 - i);
	}
	int C = NUM / DEN;

	std::vector<long double>L(A);
	int B = 0;
	long double T = 0;
	for (int i = 0; i < N - 1; i++){
		for (int j = i + 1; j < N; j++)
		{
			L[B] = sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) *(Y[i] - Y[j]));
			T += L[B];
			B++;
		}
	}


	T *= 2.0 / (long double)N;
	ans = T;

	std::cout << std::fixed <<std:: setprecision(10) << ans << std::endl;

	return 0;
}


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

char grade(int, int, int);

char grade(int m, int f, int r){
    if(m == -1 || f == -1) return 'F';
    int sum = m + f;
    if(sum < 30) return 'F';
    if(30 <= sum && sum < 50) return (50 <= r)? 'C':'D';
    if(50 <= sum && sum < 65) return 'C';
    if(65 <= sum && sum < 80) return 'B';
    
    return 'A';
}

int main(void){
    int m, f, r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r ==-1) break;
        cout << grade(m, f, r) << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n,i,j,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(b-a<=0) {
		printf("delicious");
		return 0;
	}
	if(b-a>n) {
		printf("dangerous");
		return 0;
	}
	printf("safe");
	return 0;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X,A,B;
    int N=0;

    cin>>X>>A>>B;

    X=X-A;

    for(int i=1; i*B<=X; i++)
    {
       N++;
    }
    X=X-N*B;

    cout<<X;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll x;
	cin>>x;
	ll ans=0;
	ans+=(x/500)*1000;
	x-=(x/500)*500;
	ans+=(x/5)*5;
	x-=(x/5)*5;
	cout<<ans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,m;
  cin>>n>>m;
  long long shou=LLONG_MAX;
  priority_queue<pair<int,int>>q;
  vector<int>a(n);
  vector<int>b(m),c(m);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i]>>c[i];
  for(int i=0;i<n;i++){
    q.push(make_pair(a[i],1));
  }
  for(long long i=0;i<m;i++){
    q.push(make_pair(c[i],b[i]));
  }
  long long sum=0;
  for(int i=0;i<n;i++){
    pair<int,int> p=q.top();q.pop();
    sum+=p.first;
    if(p.second>1){
      p.second--;
      q.push(p);
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int visited[100005],dp[100005];
vi adj[100005];

int dfs(int s){
    visited[s]=1;

    dp[s]=0;
    for(int i=0;i<adj[s].size();i++){
        if(visited[adj[s][i]]==0){
            dfs(adj[s][i]);
        }
        dp[s]=max(dp[s],1+dp[adj[s][i]]);
    }
    return dp[s];
}
int main(){
    int n,m,x,y;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        cin>>x>>y;
        adj[x].pb(y);
    }

    memset(visited,0,sizeof visited);
    for(int i=1;i<=n;i++){
        if(visited[i]==0)
            dfs(i);
    }

    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

string s, t;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> s >> t;
	int ans = 0;
	for(int i=0; i<s.length(); i++) 
		ans += (s[i] != t[i]);
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector <int> upper (N-1);
  vector <int> lower (N);
  
  for (int i =0; i<(N-1); i++){

      cin >> upper.at(i);
      
    int j = upper.at(i);
    
        lower.at(j-1) +=1;
    }

  for (int i=0; i<(N-1); i++){
    cout << lower.at(i) << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)


int main(){
    ll n;
    cin >> n;

    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    vector<ll> dp0(n + 5, 0), dp1(n + 5, 0);

    dp0.at(n - 1) = 0;
    dp1.at(n - 1) = a.at(n - 1);

    for(ll i = n - 2; i >= 0; --i){
        if((n - i) % 2 == 0){
            dp0.at(i) = a.at(i) + dp0.at(i + 2);
            dp0.at(i) = max(dp0.at(i), a.at(i + 1) + dp1.at(i + 3));
        }else{
            dp0.at(i) = a.at(i) + dp0.at(i + 2);
            dp0.at(i) = max(dp0.at(i + 1), dp0.at(i));
            dp0.at(i) = max(dp1.at(i + 2), dp0.at(i));
        }

        if((n - i) % 2 == 0){
            dp1.at(i) = a.at(i) + dp1.at(i + 2);
            dp1.at(i) = max(dp1.at(i), a.at(i + 1) + dp1.at(i + 3));
        }else{
            dp1.at(i) = a.at(i) + dp1.at(i + 2);
        }
    }
    cout << dp0.at(0) << endl;

    return 0;
}


Measured memory_bytes: 8008
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",max(min(b,d)-max(a,c),0));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	vector<int> vec(n);
	for(int i = 0 ; i < n; i++)
		cin >> vec[i];
	sort(vec.begin(), vec.end(), greater<int>());
	int total = 0;
	for(int i = 0; i < n; i++)
		total += vec[i];
	double pro = 1.0 / double(4*m);
	// cout << pro << endl;
	double i = (double)vec[m-1] /(double) total;
	if(i >= pro)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

class DSU {
    vector<int> p;
    int c;
    public:
    DSU (int n): p(n, -1) , c(n) {}
    int find (int x) {
        return (p[x] <0) ? x:p[x] = find(p[x]);
    }
    int size(int x) {
        return -p[find(x)];
    }
    int count() {
        return c;
    }
    void join (int x, int y) {
        if ((x=find(x)) == (y = find (y))) return;
        if (p[x] < p[y]) swap(x, y);
        p[y] += p[x];
        p[x] = y;
        c--; 
    }
      
};
int deal(vector<pair<int, int>> balls, int p, int q) {
    DSU lines = DSU(balls.size());
    for (int i = 0; i < balls.size(); i++) {
        int x = balls[i].first;
        int y = balls[i].second;
        for (int j = 0; j < balls.size(); j++) {
            if (i==j) continue;
            if ((balls[j].first + p == x) && (balls[j].second + q == y)) {
                lines.join(i, j);
            }
        }
    }
    return lines.count();
}
int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> balls(n);
    for (int i = 0; i < n; i++) {
        cin >> balls[i].first>>balls[i].second;
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i==j) continue;
            int p = balls[i].first - balls[j].first;
            int q = balls[i].second - balls[j].second;
            ans = min(ans, deal(balls, p, q));
            
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> 
using namespace std;
#define ll long long
int main() 
{
    string s;
    cin >> s;
    if(s.at(s.size() - 1) == 's') {
        s.push_back('e');
        s.push_back('s');
        cout << s;
    }
    else {
        s.push_back('s');
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 3628
#include "stdio.h"

int main() {
  long long int x;
  long long int ans=0;
  scanf("%lld", &x);

  long long int a = x/11;
  int b = x%11;
  int c = b/6;
  int d = 1;
  if(b%6==0) d = 0;
  ans = 2*a+c+d;
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128