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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

typedef unsigned long long ull;
typedef long long ll;

#define F first
#define S second
#define all(x) begin(x), end(x)

using namespace std;

// store longest subtree length
vector<int> dp;

// return the length
int dfs(vector<vector<int>>& p, int root) {
	if (p[root].empty()) {
		dp[root] = 0;
		return 0;
	}
	if (dp[root] > -1) 
		return dp[root];

	int ans = 0;
	for (int i : p[root]) {
		ans = max(ans, 1 + dfs(p, i));
	}
	dp[root] = ans;
	return ans;
}

void exec()
{
	int n, m;
	cin >> n >> m;

	dp.resize(n + 1, -1);
	vector<vector<int>> children(n + 1);
	vector<bool> root(n + 1, true);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		children[a].push_back(b);
		root[b] = false;
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (root[i]) dfs(children, i);
	}
	for (int i : dp)
		ans = max(ans, i);

	cout << ans << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 10752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
int main(){
	ll n,s;
	cin>>n>>s;
	ll I=1,out=inf;
	for(ll i=2;i*i<=n;i++){
		I=i;
		ll sum=0;
		ll t=n;
		while(t){
			sum+=t%i;
			t/=i;
		}
		if(sum==s){
			cout<<i<<endl;
			return 0;
		}
	}
	ll t=n/(I+1);
	for(;t>0;t--){
		if(s-t>=0&&(n-s+t)%t==0){
			ll q=(n-s+t)/t;
			if(t<q&&s-t<q)
				out=min(out,(n-s+t)/t);
		}
	}
	if(out!=inf)cout<<out<<endl;
	else if(n==s)cout<<s+1<<endl;
	else cout<<-1<<endl;
}
 
 







Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main (void)
{
    int n, m;
    cin >> n >> m;

    char **image = (char **)malloc(sizeof(char *) * n);
    char **temp = (char **)malloc(sizeof(char *) * m);

    for (int i = 0; i < n; i++) {
        image[i] = (char *)malloc(sizeof(char) * n);
        scanf("%s", image[i]);
    }
    for (int i = 0; i < m; i++) {
        temp[i] = (char *)malloc(sizeof(char) * m);
        scanf("%s", temp[i]);
    }

    /*for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%c", image[i][j]);
        }
        printf("\n");
    }
    printf("\n");
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            printf("%c", temp[i][j]);
        }
        printf("\n");
    }*/

    bool exist;
    for (int i = 0; i <= n - m; i++) {
        for (int j = 0; j <= n - m; j++) {
            exist = true;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (image[i + k][j + l] != temp[k][l]) {
                        exist = false;
                    }
                }
            }
            if (exist) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
moji = list(input())
listlist=[]
inlist=[]
result=0
for i in range(len(moji)-1):
    if moji[i] == '>' and moji[i+1]=='<':
        listlist.append(inlist)
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
        inlist=[]
    elif moji[i] == '>' and moji[i+1]=='>':
            inlist.append(1)
    elif moji[i] == '<' and moji[i+1]=='<':
            inlist.append(2)
    elif moji[i] == '<' and moji[i+1]=='>':
            inlist.append(3)
if moji[len(moji)-2] == '>' and moji[len(moji)-1]=='<':
    result +=1
elif moji[len(moji)-2] == '>' and moji[len(moji)-1]=='>':
    result += 1 + max([inlist.count(1),inlist.count(2)])
    for m in range(inlist.count(1)+1):
        result += m
    for n in range(inlist.count(2)+1):
        result += n
elif moji[len(moji)-2] == '<' and moji[len(moji)-1]=='<':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
elif moji[len(moji)-2] == '<' and moji[len(moji)-1]=='>':
        result += 1 + max([inlist.count(1),inlist.count(2)])
        for m in range(inlist.count(1)+1):
            result += m
        for n in range(inlist.count(2)+1):
            result += n
print(result)

Measured memory_bytes: 22832
using EducationalDPContest.Questions;
using EducationalDPContest.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace EducationalDPContest.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            int n = inputStream.ReadInt();
            var h = inputStream.ReadIntArray();
            var dp = Enumerable.Repeat(int.MaxValue, n).ToArray();

            dp[0] = 0;

            for (int i = 1; i < n; i++)
            {
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));
                if (i > 1)
                {
                    dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
                }
            }

            yield return dp[n - 1];
        }
    }
}


namespace EducationalDPContest
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace EducationalDPContest.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace EducationalDPContest.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 21216
#if 0
????????£????????????35m
Floyd-Warshall????????£?????¨??????????????????????±??????????
???????????????????????????????????????????°?????????????
#endif


#include <iostream>
#include <cstdio>
using namespace std;

int N, M, A, B, C, D, x1, x2, y1, y2;
int K[32][32];
const int inf=1001001001;

int main() {
	long long pay,ans;
	for(int i=0;i<32;i++)
		for(int j=0;j<32;j++)
			K[i][j]=inf;

	scanf("%d%d", &N, &M);
	for (int i=0; i<M; ++i) {
		scanf("%d,%d,%d,%d", &A, &B, &C, &D);
		//cerr << "read " << A <<" "<< B <<" " << C <<" " << D<< endl;
		K[A][B]=C;
		K[B][A]=D;
	}
	
	for(int k=1;k<N+1;k++){
		for(int i=1;i<N+1;i++){
			for(int j=1;j<N+1;j++){
	if(K[i][j]>K[i][k]+K[k][j]){
		K[i][j]=K[i][k]+K[k][j];
	}
			}
		}
	}
	scanf("%d,%d,%d,%d", &A, &B, &C, &D);
	pay=K[A][B]+K[B][A];
	ans=C-D-pay;
	cout<<ans<<endl; 
}
#if 0
??£??\???????¨????????????§???
Inf  2   4   4  Inf Inf 
 2  Inf Inf Inf  3  Inf 
 3  Inf Inf  4  Inf  1  
 2  Inf  2  Inf Inf  1  
Inf  2  Inf Inf Inf  1  
Inf Inf  2   1   2  Inf 
Inf  2   4   4  Inf Inf 
 2   4   6   6   3  Inf 
 3   5   7   4  Inf  1  
 2   4   2   6  Inf  1  
Inf  2  Inf Inf Inf  1  
Inf Inf  2   1   2  Inf 
??¨?????????????????????
???????????????
4   2   4   4   5   5  
 2   4   6   5   3   4  
 3   5   3   2   3   1  
 2   4   2   2   3   1  
 4   2   3   2   3   1  
 3   4   2   1   2   2
 ?????§????????????????¢??????§?????????
#endif

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    int n = (W==x*2&&H==y*2);
    printf("%10f %d\n", (double)W * H / 2,n);

    return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    // debug(i);
    ll idx = i;
    ll fl = -1;  // 0 -> 0 1 2
    while (1) {
      if (idx == n) break;
      if (a[idx] == a[idx + 1]) {
        idx++;
        continue;
      } else if (fl == -1) {
        if (a[idx] < a[idx + 1])
          fl = 0;
        else
          fl = 1;

        idx++;
      } else {
        if (!fl) {
          if (a[idx] <= a[idx + 1])
            idx++;
          else
            break;
        } else {
          if (a[idx] >= a[idx + 1])
            idx++;
          else
            break;
        }
      }
    }
    // debug(idx);
    i = idx;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  P(max({a + b, a - b, a * b}));

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string S;
  cin >> S;
  vi arr(26,0);
  arr[S[0]-'A']++;
  arr[S[1]-'A']++;
  arr[S[2]-'A']++;
  arr[S[3]-'A']++;
  rep(i,26) {
    if(arr[i] != 0 && arr[i] != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// B - Trained?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a[100000];
bool pressed[100000];

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

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

	int i = 0;
	int cnt = 0;
	pressed[0] = true;
	int ans;
	while(1) {
		cnt++;
		i = a[i];
		if (pressed[i]) {
			ans = -1;
			break;
		}

		if (i == 1) {
			ans = cnt;
			break;
		}

		pressed[i] = true;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    v = []
    while N:
        N -= 1
        v.append(N % 26)
        N //= 26
        if N == 0:
            break

    ans = ""
    for x in v:
        ans += chr(ord('a') + x)
    print(ans[::-1])


def main():
    solve()


if __name__ == '__main__':
    main()


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ll d;
vll c(26);
vvll s;

void create_first_answer(vll& ans) {
  vll last(26, -1);

  rep(today, d) {
    vll cand(26);

    rep(j, 26) {
      cand[j] = s[today][j] + c[j] * (today - last[j]);
    }

    ll choice = distance(cand.begin(), max_element(all(cand)));
    ans[today] = choice;
    last[choice] = today;
  }
}

ll update_diff(ll idx, const vll& choice) {
  ll last = -1;
  ll total = 0;
  rep(today, d) {
    if (choice[today] == idx) {
      last = today;
      total += s[today][idx];
    } else {
      total -= c[idx] * (today - last);
    }
  }
  return total;
}

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

  cin >> d;
  rep(i, 26) {
    cin >> c[i];
  }

  s = vvll(d, vll(26));
  rep(i, d) {
    rep(j, 26) {
      cin >> s[i][j];
    }
  }

  srand(s[0][0]);

  vll ans(d);

  create_first_answer(ans);

  vll score_con(26);
  ll score = 0;

  rep(i, 26) {
    score_con[i] = update_diff(i, ans);
    score += score_con[i];
  }

  rep(i, 100000) {
    vll cand = ans;
    vb changed(26);

    rep(j, rand() % 3 + 1) {
      ll tgt = (i + j) % d;
      cand[tgt] = rand() % 26;

      changed[ans[tgt]] = true;
      changed[cand[tgt]] = true;
    }

    ll cs = score;
    vll score_cand = score_con;
    rep(i, 26) {
      if (changed[i]) {
        cs -= score_cand[i];
        score_cand[i] = update_diff(i, cand);
        cs += score_cand[i];
      }
    }
    if (cs > score) {
      ans = cand;
      score_con = score_cand;
    }
  }

  rep(i, d) {
    cout << ans[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3728
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        a: usize,
    }
    println!("{}", a + a * a + a * a * a);
}


Measured memory_bytes: 2116
#include<cstdio>
#include<cstring>
int main()
{
	char a[4],b[4];
	int x=0;
	scanf("%s%s",a,b);
	for(int i=0;i<strlen(a);i++)
		x=x*10+a[i]-'0';
	for(int i=0;i<strlen(b);i++)
		x=x*10+b[i]-'0';
	bool f=0;
	for(int i=0;i<330;i++)
		if(i*i>=x)
		{
			if(i*i==x)
				f=1;
			break;
		}
	if(f)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 128
/// 8:27 PM 21/06/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, q;
    cin >> n;
    vector<ll> v(n);
    ll csum = 0;
    map<ll, ll> m;
    for (auto &x:v) {
        cin >> x;
        csum += x;
        m[x]++;
    }
    cin >> q;
    while (q--) {
        ll a, b;
        cin >> a >> b;
        csum -= a * m[a];
        m[b] += m[a];
        csum += b * m[a];
        m[a] = 0;
        cout << csum << endl;
    }
    return 0;
}

Measured memory_bytes: 10076
c=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int, input().split())
A=list(map(int, input().split()))
INF=100010
dp = [-INF for _ in range(N+1)]
dp[0]=0

for i in range(N+1):
  for a in A:
    if i-c[a]>=0:
      dp[i]=max(dp[i],(dp[i-c[a]])*10+a)

print(dp[N])

Measured memory_bytes: 14672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		System.out.println(2*b == a+c ? "YES" : "NO");
    }
}

Measured memory_bytes: 22612
#include<stdio.h>

int main(void)
{
	int X;

	scanf("%d", &X);

	if (X >= 400 && X <= 599)
	{
		printf("8");
	}
	else if (X >= 600 && X <= 799)
	{
		printf("7");
	}
	else if (X >= 800 && X <= 999)
	{
		printf("6");
	}
	else if (X >= 1000 && X <= 1199)
	{
		printf("5");
	}
	else if (X >= 1200 && X <= 1399)
	{
		printf("4");
	}
	else if (X >= 1400 && X <= 1599)
	{
		printf("3");
	}
	else if (X >= 1600 && X <= 1799)
	{
		printf("2");
	}
	else if (X >= 1800 && X <= 1999)
	{
		printf("1");
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 1560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int n,m,x;
vvi in;
vs fil;
vvi info;
vp task;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	cin>>n>>m>>x;
	in=vvi(n*m);
	fil=vs(n);
	rep(i,n)cin>>fil[i];
	info=vvi(n*m,vi(3));
	rep(j,3)rep(i,n*m)cin>>info[i][j];
	task=vp(x);
	rep(i,x)cin>>task[i].first>>task[i].second;
	int tim=0;
	rep(i,x-1){
		vvi used(n,vi(m,inf));
		used[task[i].first][task[i].second]=0;
		priority_queue<pii>q;
		q.push(pii(task[i].first,task[i].second));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			rep(i,4){
				int nx=p.first+dx[i];
				int ny=p.second+dy[i];
				if(nx<0||ny<0||nx>=n||ny>=m||fil[nx][ny]=='#')continue;
				if(used[nx][ny]>1+used[p.first][p.second]){
					used[nx][ny]=1+used[p.first][p.second];
					q.push(pii(nx,ny));
				}
			}
		}
		int t=used[task[i+1].first][task[i+1].second],tmp=t;
		int x=task[i+1].first,y=task[i+1].second;
		while(t){
			rep(i,4){
				int nx=x+dx[i];
				int ny=y+dy[i];
				if(nx<0||ny<0||nx>=n||ny>=m||fil[nx][ny]=='#')continue;
				if(used[x][y]!=used[nx][ny]+1)continue;
				t--;
				in[nx*m+ny].pb(tim+t);
				x=nx;y=ny;
				break;
			}
		}
		tim+=tmp;
	}
	in[task[x-1].first*m+task[x-1].second].pb(tim);
	int out=0;
	rep(i,n*m)if(in[i].size()){
		out+=info[i][1]+info[i][2];
		rep(j,in[i].size()-1)out+=min((in[i][j+1]-in[i][j])*info[i][0],info[i][1]+info[i][2]);
	}
	cout<<out<<endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<pair<char,int> > a;
        rep(i,n){
            char t;
            cin>>t;
            
            int s=0;
            rep(j,n-1){
                int tr;
                cin>>tr;
                if(tr==0)s+=100;
                if(tr==1)s-=1;
            }
            a.pb(pii(t,s));
        }
        for(int i=0;i<n;i++){
            for(int j=n-1;j>i;j--){
                if( a[j-1].second < a[j].second )swap(a[j-1],a[j]);
            }
        }
        
        rep(i,n){
            cout<<a[i].first<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=2e5+10 ;

int ans[N] ;
int to[N] , nxt[N] , id[N] , lst[N] ;
inline void add ( int u , int v , int i )
{
	static int cnt=0 ;
	++cnt,to[cnt]=v,nxt[cnt]=lst[u],lst[u]=cnt,id[cnt]=i,
	++cnt,to[cnt]=u,nxt[cnt]=lst[v],lst[v]=cnt,id[cnt]=i;
}

int n ;

int deg[N] ;
inline void dfs ( int x , int f , int c )
{
	int i , y , nc=0 ;
	for ( i=lst[x],y=to[i] ; i ; i=nxt[i],y=to[i] )
		if ( y^f )
			nc=(nc+1==c?c+1:nc+1),
			ans[id[i]]=nc,
			dfs(y,x,nc);
	return ;
}

int main ()
{
	int i , u , v ;
	scanf("%d",&n);
	for ( i=1 ; i<n ; i++ )
		scanf("%d%d",&u,&v),
		add(u,v,i),
		deg[u]++,deg[v]++;
	int num=0 ;
	for ( i=1 ; i<=n ; i++ )
		num=max(num,deg[i]);
	printf("%d\n",num);
	dfs(1,1,0);
	for ( i=1 ; i<n ; i++ )
		printf("%d\n",ans[i]);
	return 0 ;
}


Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string S; cin >> S;

    int diff = 1000;
    for (int i = 0; i+2 < S.size(); i++) {
        diff = min(diff, abs(atoi(S.substr(i, 3).c_str())-753));
    }

    cout << diff << endl;
    return 0;
}


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

int main(){
  int N, K; cin >> N >> K;
  
  double result=0;
  
  for(int i=1; i<=N; i++){
    double p=1;
    int ii=i;
    while(ii<K){
      ii*=2;
      p/=2.0;
    }
    result+=p;
  }
  cout << setprecision(20) << result/N << endl;
}

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

n_hoge = int(N ** 0.5)
print

true_ans = 10 ** 12
for i in range(1,n_hoge+1):
    if N % i == 0:
        ans = N // i
        true_ans = min(ans + i - 2, true_ans)

print(true_ans)

Measured memory_bytes: 9420
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1,typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int X, t;
    cin >> X >> t;
    cout << max(X - t, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define DIM 100005
using namespace std;
int x, n, q, t, val, sol, u, i, sum;
int v[DIM], a[DIM], amax[DIM], vmin[DIM];
int main(){
    cin>> x >> n;
    for(i = 1; i <= n; i++){
        cin>> v[i];
    }
    amax[0] = x;
    for(i = 1; i <= n; i++){
        if(i % 2 == 1){
            a[i] = max(0, a[i - 1] - (v[i] - v[i - 1]) );
            amax[i] = max(0, amax[i - 1] - (v[i] - v[i - 1]) );
            sum -= v[i] - v[i - 1];
        }
        else{
            a[i] = min(x, a[i - 1] + v[i] - v[i - 1]);
            amax[i] = min(x, amax[i - 1] + v[i] - v[i - 1]);
            sum += v[i] - v[i - 1];
        }
        vmin[i] = min(vmin[i - 1], sum);
    }
    v[n + 1] = 1000000001;
    u = 0;
    cin>> q;
    for(; q; q--){
        cin>> t >> val;
        while(v[u + 1] <= t){
            u++;
        }
        sol = min(a[u] + max(0, val + vmin[u]), amax[u]);
        if(u % 2 == 1){
            sol = min(x, sol + t - v[u]);
        }
        else{
            sol = max(0, sol - (t - v[u]) );
        }
        cout<< sol <<"\n";
    }
    return 0;
}


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

int main()
{
    int l,r;
    std::cin >> l >> r;
    long long ans = 0;

    if (( l  / 2019 ) == ( r / 2019 )) {
        ans = 2200;
        for (long long i = l; i < r; i++) {
            for (long long j = i+1; j <= r; j++) {
                ans = std::min(ans, ( i*j ) % 2019);
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    int n; cin >> n;
    vector<P> v1,v2;
    string s[n];
    rep(i,n){
        cin >> s[i];
        int res=0,mini=0;
        rep(j,s[i].size()){
            if(s[i][j]=='(') res++;
            else res--;
            chmin(mini,res);
        }
        if(res>=0){
            v1.pb({-mini,i});
        }else{
            v2.pb({-(res-mini),i});
        }
    }
    sort(ALL(v1));
    sort(ALL(v2));
    int sz1=v1.size(),sz2=v2.size();
    if( (sz1>0&&s[v1[0].se][0]==')') || (sz2>0 && s[v2[sz2-1].se][s[v2[sz2-1].se].size()-1]=='(')){
        cout << "No" << endl;
        return 0;
    }
    int now=0;
    rep(i,sz1){
        int p=v1[i].se;
        rep(j,s[p].size()){
            if(s[p][j]=='(') now++;
            else now--;
            if(now<0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    rep(i,sz2){
        int p=v2[i].se;
        rep(j,s[p].size()){
            if(s[p][j]=='(') now++;
            else now--;
            if(now<0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << (now==0 ? "Yes" : "No") << endl;
}


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

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> mp;
    REP(i,n) {
        int a; cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto p:mp) {
        if (p.second % 2 != 0) ans++;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4992
N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  e = elm[i]
  placed += e["count"]
  if placed >= K:
    print(e["element"])
    break

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

using namespace std;

int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<pair<int,int>> v(m);
  int cnt[n+1][n+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      cnt[i][j]=0;
    }
  }
  for(auto &x:v){
    cin >> x.first >> x.second;
    cnt[x.first][x.second]++;
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      cnt[i][j]+=cnt[i][j-1];
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      cnt[j][i]+=cnt[j-1][i];
    }
  }
  while(q--){
    int x,y;
    cin >> x >> y;
    cout << cnt[y][y]-cnt[y][x-1]-cnt[x-1][y]+cnt[x-1][x-1] << endl;
  }
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int num = 0;

	int N, H;
	cin >> N >> H;

	vector<pii> ab(N);
	int max_a = 0, max_ai;

	REP(i, N) {
		cin >> ab[i].first >> ab[i].second;
		if (max_a < ab[i].first) {
			max_a = ab[i].first;
			max_ai = i;
		}
	}

	sort(ab.begin(), ab.end(), [](const pii x, const pii y) { if (x.second == y.second) { return x.first < y.first; } else { return x.second > y.second; }});

	REP(i, N) {
		if (max_a < ab[i].second) {
			num++;
			H -= ab[i].second;
			if (H <= 0) break;
		}
		else break;
	}

	if (H <= 0) cout << num << endl;
	else cout << num + (H + max_a - 1) / max_a << endl;

	return 0;
}

Measured memory_bytes: 1024
//file_name:ABC77_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    string a;
    cin >> a;

    if(s[0]==a[2]&&s[1]==a[1]&&s[2]==a[0])yn;
    return 0;
}



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

//create arrays outside of main()
int a[100000] = {};

int main()
{

    priority_queue<int> pq;

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

    int value;

    long long spend = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> value;
        pq.push(value);
    }

    for (int i = 0; i < m; i++)
    {
        int biggest = pq.top();
        pq.push(biggest / 2);
        pq.pop();
    }

    for (int i = 0; i < n; i++)
    {
        spend += pq.top();
        pq.pop();
    }

    cout << spend;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

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

const ll mod = 1000000007;

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

  int x, y;
  cin >> x >> y;

  int ans = 0;
  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;

  return 0;
}


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

ll dp[100001][3];

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

	return 0;
}

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

ll gcd (ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

const int mod = 1000000007;

int main() {
    ll n; cin >> n;
    vector<pair<ll, ll>> ab(n);
    rep (i, n) {
        ll a, b; cin >> a >> b;
        ab[i] = make_pair(b, a);
    }

    sort(ab.begin(), ab.end());
    ll s = 0;
    bool can = true;
    for (ll i = 0; i < n; i++) {
        s += ab[i].second;
        if (s > ab[i].first) {
            can = false;
            break;
        }
    }
    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
	int n; double v[51];
	cin>>n; for(int i=0;i<n;i++) cin>>v[i];
	sort(v,v+n);
	
	for(int i=0;i<n-1;i++) v[i+1]=(v[i]+v[i+1])/2;
	cout<<fixed; cout.precision(6);
	cout<<v[n-1];
}

Measured memory_bytes: 256
#include<stdio.h>

char seisekih(int m,int f,int r){
	char result;
	int sum=m+f;
	
	if((m==-1)||(f==-1)){
		result='F';
		
	}else if(sum>=80){
		result='A';
		
	}else if((sum>=65)&&(sum<80)){
		result='B';
		
	}else if((sum>=50)&&(sum<65)){
		result='C';
		
	}else if((sum>=30)&&(sum<50)){
		if(r>=50){
			result='C';
		}else{
			result='D';
		}
		
	}else if(sum<30){
		result='F';
	}
	//printf("%c",result);
	return result;
}

int main(){
	int seiseki[100][3];
	char hantei[100];
	int i=0,j;
	
	do{ 
		
		scanf("%d %d %d",&seiseki[i][0] ,&seiseki[i][1] ,&seiseki[i][2]);
		if((seiseki[i][0]==-1)&&(seiseki[i][1]==-1)&&(seiseki[i][2]==-1)){
			break;
		}
		i++;
		
	}while(1);
	//printf("%d %d %d\n",seiseki[0][0] ,seiseki[1][0] ,seiseki[2][0]);
	for(j=0;j<i;j++){
		
		hantei[j]=seisekih(seiseki[j][0],seiseki[j][1],seiseki[j][2]);
		printf("%c\n",hantei[j]);
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() { 

    int N; cin >> N;
    int ct = 1;
    REP(i, 3) {
        ct *= N;
    }
    cout << ct << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll a,b;

int main() {
    scanf("%lld%lld",&a,&b);
    int rev=0;
    if (a>0) {
        if (b<=0) rev=1;
        else {
            if (b>=a) rev=0;
            else rev=2;
        }
    } else if (a==0) {
        if (b>=0) rev=0;
        else rev=1;
    } else {
        if (b>0) rev=1;
        else if (b==0) rev=0;
        else {
            if (b<=a) rev=2;
            else rev=0;
        }
    }
    printf("%lld\n",abs(abs(a)-abs(b))+rev);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<pair<int,int>>xy;
	
	for(int i=1;i<=n;i++)
	{
		int a,b;
		cin>>a>>b;
		xy.emplace_back(b,a);
	}


	sort(xy.begin(),xy.end());
	int sum=0;
	bool isyes = true;
	for(auto v: xy)
	{
		sum+=v.second;
		if(sum>v.first)
		{
			isyes = false;
			break;
		}
	}
	cout<<(isyes ? "Yes" : "No")<<endl;
	return 0;
}

Measured memory_bytes: 2420
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<int> G[SIZE];
int ans[SIZE];

int main() {
  int N, M;

  scanf("%d%d", &N, &M);

  for (int i = 0; i < M; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    A--;
    B--;

    G[A].push_back(B);
    G[B].push_back(A);
  }

  queue<int> q1, q2;

  q1.push(0);

  for (int i = 0; i < N; i++) ans[i] = -1;

  while (q1.size()) {
    while (q1.size()) {
      auto p = q1.front();
      q1.pop();

      for (int to : G[p]) {
        if (ans[to] == -1) {
          q2.push(to);
          ans[to] = p + 1;
        }
      }
    }
    swap(q1, q2);
  }

  puts("Yes");

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

  return 0;
}

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

int main() {
 int N,K;
 cin >> N >> K;
 int x[N];
 int ans = 0;

 for(int i =0; i<N;i++){
   cin >> x[i];
   ans += min(x[i],K-x[i]);
 }

 cout << 2*ans <<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;//testcases
    cin>>t;
    string s;
    cin >> s;
    int l=(int)s.length();
    if(l<=t) cout << s;
    else cout << s.substr(0,t) + "...";
	return 0;
}


Measured memory_bytes: 3656
N,M = map(int,input().split())
ok = 0
ng = 0
Q = [0]*N
for _ in range(M):
    p,s = map(str,input().split())
    if Q[int(p)-1] != -1 and s == "AC":
        ok += 1
        ng += Q[int(p)-1]
        Q[int(p)-1]= -1
    elif Q[int(p)-1] != -1 and s == "WA":
        Q[int(p)-1] += 1
print(ok,ng)

Measured memory_bytes: 52312