akhauriyash/Code-Regression huggingface dataset:
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
int k;
VI cnt(100);

signed main() {
    cin >> n >> k;
    cnt.resize(n);
    REP(i, k) {
        int d;
        cin >> d;
        REP(j, d) {
            int p;
            cin >> p;
            cnt[p - 1]++;
        }
    }

    int res = 0;
    REP(i, n) {
        if (cnt[i] == 0) {
            res++;
        }
    }

    cout << res << endl;
    return 0;
}


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

int main() {
    // 頂点数 (木なので辺数は N-1 で確定)
    int a,b,c; cin >> a>>b>>c;
set<int> data;

data.insert(a);
data.insert(b);
data.insert(c);



if(data.size()==2)
cout <<"Yes" ;
else
cout <<"No" ;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long  
using namespace std;
int main()
{
  ll n;
  cin>>n;
  vector<ll> arr(n,0); for(ll i=0;i<n;i++)cin>>arr[i];
  ll mx=arr[0];
  ll ans=0;
  for(ll i=1;i<n;i++)
  {
      mx=max(mx,arr[i]);
      ans+=(mx-arr[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4832
#if defined(LOCAL)
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define max(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x>__y?__x:__y;})
#define min(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  l n, m, k; cin >> n >> m >> k;
  F(i, 0, n + 1) {
    F(j, 0, m + 1) {
      if (i * m + j * n - 2 * i * j == k) {
        cout << "Yes" << lf;
        return;
      }
    }
  }
  cout << "No" << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    char x;
    char y;
    cin >> x >> y;
    if (x < y) {
        cout << '<' << endl;
    } else if (x == y) {
        cout << '=' << endl;
    } else {
        cout << '>' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int max=0,fl=a[0];
    for(int i=0;i<n;i++)
    {
        if(a[i]>max)max=a[i];
        else;
    }
    int d=abs(max-2*a[0]);
    for(int i=0;i<n;i++)
    {
        if(abs(max-2*a[i])<=d&&max!=a[i])
        {
            d=abs(max-2*a[i]);
            fl=a[i];
        }
        else;
    }
    cout<<max<<" "<<fl<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,d[100005], res, visit[100005];
vector<int> ke[100005];
void dfs(int u) {
  visit[u]=1;
  for(int i=0; i<ke[u].size(); i++) {
    int v=ke[u][i];
    if (!visit[v])
      dfs(v);
    d[u]=max(d[u],d[v]+1);
  }
}
int main() {
//  freopen("LONGESTPATH.INP","r",stdin);
  cin>>n>>m;
  for(int i=1; i<=m; i++) {
    int u,v;
    cin>>u>>v;
    ke[u].push_back(v);
  }
  for(int i=1; i<=n; i++) {
    if (!visit[i])
      dfs(i);
    res=max(res,d[i]);
  }
  cout<<res;
}


Measured memory_bytes: 8576
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse=True)[:K+1]
B = sorted(B, reverse=True)[:K+1]
C = sorted(C, reverse=True)[:K+1]

res = []

for i in A:
    for j in B:
        res.append(i + j)
res2 = []
res = sorted(res, reverse=True)[:K+1]

for i in C:
    for re in res:
        res2.append(i + re)
        
res2 = sorted(res2, reverse=True)[:K+1]
          

for i in range(K):
    print(res2[i])

Measured memory_bytes: 184560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();

		int i = 0;
		int c = 0;
		while(i < n) {
			while(s[i] != 'A' && i < n-2) {
				i++;
			}

			if(i >= n-2)
				break;

			if(s[i+1] == 'B' && s[i+2] == 'C') {
				c++;
			}
			i++;
		}

		System.out.println(c);
        return;
    }


}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	map<int,int>mp;
	vector<int>vec;
	cin>>n;
	while(cin>>a)
		mp[a]++;
	for(auto x:mp)
		for(int i=0;i<x.second/2;i++)
			vec.push_back(x.first);
	sort(vec.begin(),vec.end(),greater<>());
	cout<<(vec.size()<2?0:(long long)vec[0]*vec[1])<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
    #include<vector>
    using namespace std;
    long N,M,R,r,d[210][210]={},INF=9999999999999,ans=99999999999999,prime[10]={2,3,5,7,11,13,17,19,23,29};
    vector<long> v;
     
    void dfs(long i,long s,long sum,long jdg){
      if(i==R){
        if(sum<=ans){
          ans=sum;
          return;
        }
      }else{
        for(long j=0;j<R;++j){
          if(jdg%prime[j]!=0){
           dfs(i+1,j,sum+d[v[s]][v[j]],jdg*prime[j]);
          }
        }
      return;
      }
    }
     
    int main(){
      cin>>N>>M>>R;
      for(long i=0;i<R;i++){
        cin>>r;
        v.push_back(r-1);
      }
     
      for(long i=0;i<210;i++){
        for(long j=0;j<210;j++){
            d[i][j]=INF;
        }
      }
      for(long i=0;i<N;i++){
        d[i][i]=0;
      }
      long A,B,C;
      for(long i=0;i<M;i++){
        cin>>A>>B>>C;
        d[A-1][B-1]=C;
        d[B-1][A-1]=C;
      }
     
      for(long k=0;k<N;k++){
        for(long i=0;i<N;i++){
          for(long j=0;j<N;j++){
            d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
          //  cout<<"d["<<i<<"]["<<j<<"]="<<d[i][j]<<endl;
          }
        }
      }
      for(long i=0;i<R;i++){
        dfs(1,i,0,prime[i]);
      }
      cout<<ans<<endl;
     
      return 0;
    }

Measured memory_bytes: 640
import math
N, M = map(int, input().split())

mod = 10 ** 9 + 7

if abs(N - M) > 1:
  ans = 0
elif abs(N - M) == 1:
  ans = (math.factorial(N) % mod) * (math.factorial(M) % mod)
else:
  ans = (math.factorial(N) % mod) * (math.factorial(M) % mod) * 2
  
print(ans % mod)

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    string a;
    cin >> a;

    string b = a;

    transform(a.begin(), a.end(), a.begin(), ::toupper);

    if (a == b)
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;
}


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

int main (){
	int a,b;
	cin >> a >> b;
	if (a >= 13){

	} else if (a>= 6 && a <= 12){
		b= b/2;
	}
	else {
		b = 0;
	}
	cout << b<< endl;
}


Measured memory_bytes: 888
N=int(input());ans=0
a=sorted(list(map(int,input().split())))
for i in range(N):
	for j in range(i+1,N):
		for k in range(j+1,N):
			if a[i]!=a[j] and a[j]!=a[k] and a[i]+a[j]>a[k]:ans+=1
print(ans)

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

using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  int mp=2*D+1;
  
  int a=N/mp;
  
  N=N-a*mp;
  if(N>0){
    cout << a+1 << endl;
  }
  else{
    cout << a << endl;
  }
}

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

/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;

string s;
int n;

bool ln(int lnt){
    for(int i=0;i<n-(lnt-1);i++){
        string s2(s,i,lnt);
        int ps=0;
        int cnt=0;
        while((ps=s.find(s2,ps))!=string::npos){
            cnt++;
            ps+=s2.length();
            if(cnt>=2)
                return true;
        }
        if(cnt>=2)
            return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    cin>>s;
    int mx=0;
    int l=1;
    int r=n/2+1;
    while(l<=r){
        int md=l+(r-l+1)/2;
        bool smd=ln(md);
        if(smd){
            l=md+1;
            mx=md;
        }
        else{
            r=md-1;
        }
    }
    cout << mx << endl;


    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
//{0,1,...,n-1}のn個の要素数のbit集合から要素数k個の部分集合のみ列挙して探索する
//k = 0ではうまく動かないので例外処理が必要
int next_combination(int bit){
    int x = bit & -bit, y = bit + x;
    return(((bit & ~y) / x) >> 1) | y;
}

/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n,k; cin >> n >> k;
    --n, --k;
    if(k == 0) {
        cout << 0 << '\n';
        return 0;
    }
    i32 front_h; cin >> front_h;
    vi a(n); rep(i,n) cin >> a[i];

    i32 ans = infll;
    for(i32 bit = (1<<k)-1; bit < (1<<n); bit = next_combination(bit)) {
        i32 tmp = 0;
        i32 before_h = front_h;
        for(i32 i = 0; i < n; ++i) {
            if(bit >> i & 1) {
                if(a[i] <= before_h) {
                    ++before_h;
                    tmp += before_h - a[i];
                }
            }
            chmax(before_h, a[i]);
        }
        chmin(ans, tmp);
    }
    cout << ans << '\n';

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

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

	int cnt=0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			int k = S - i - j;
			if (k < 0)break;
			else if (k > K)continue;

			cnt++;
		}
	}

	cout << cnt << endl;

    return 0;
}

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


int main() 
{
    int N;
    scanf("%d", &N);

    int i;
    long int H = 0;
    long int currentH = 0;
    long int currentMove = 0;
    long int maxMove = 0;
    for (i = 0; i < N; i++) {
        scanf("%ld", &H);
        if (H <= currentH) {
            if (++currentMove > maxMove) {
                maxMove = currentMove;
            }
        } else {
            currentMove = 0;
        }
        currentH = H;
    }
    printf("%ld\n", maxMove);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> s(n-1, a[0]);
  rep(i,n-2) s[i+1] = (s[i] + a[i+1])%M;

  ll ans = 0;
  for (int i = 1; i <n; i++){
    ans += (a[i] * s[i-1])%M;
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    bool flag = false;

    for(int i = 0; i < N; i++){
        string hina;
        cin >> hina;
        if(hina=="Y"){
            flag = true;
        }
    }
    if(flag==true){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
    // ここにプログラムを追記
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

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

void solve(long long H, long long N, std::vector<long long> A){
    i64 sum = 0;
    rep(i, N) sum += A[i];
    if(H <= sum) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


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

using namespace std;

int n, a[200005], maximum, sec;

int main(void)
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] > maximum) sec = maximum, maximum = a[i];
        else if (a[i] > sec) sec = a[i];
    }
    for (int i = 1; i <= n; ++i)
        if (a[i] == maximum)
            printf("%d\n", sec);
        else printf("%d\n", maximum);
    return 0;
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int main(void){
    int n;
    int a;
    int i;
    int sum = 0;
    scanf("%d", &n);
    a = n;
    while (a > 0){
        sum += a%10;
        a = a/10;
    }
    if (n % sum == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N,M;

int main(){
	cin>>N>>M;
	vector<int> ct(N,0);
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		ct[a]++;ct[b]++;
	}
	REP(i,N){
		if(ct[i]%2==1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}


Measured memory_bytes: 640
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long len; long long fr; long long to;
bool operator<(const edge& rhs) const {
return len > rhs.len;
}
};

ll const MAX = 300005;
ll parent[MAX];
ll rk[MAX];
ll BIGV = 100005;

void init(ll n) {
	for (ll i = 1; i <= n; i++) {
		parent[i] = i;
		rk[i] = 1;
	}
}

ll find(ll x) {
	if (parent[x] == x) {
		return x;
	}
	parent[x] = find(parent[x]);
	return parent[x];
}

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

void unite(ll x, ll y) {
	if (!same(x, y)) {
		x = parent[x];
		y = parent[y];
		if (rk[x] < rk[y]) {
			parent[x] = y;
		}
		else {
			parent[y] = x;
			if (rk[x] == rk[y]) {
				rk[x]++;
			}
		}
	}
}

ll color[MAX];
vll v;
vll g[MAX];
priority_queue<edge> pq;

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	init(MAX-10);
	REP(i, 1, n) {
		cin >> color[i];
		if (color[i] == 0) {
			color[i] = i + BIGV;
		}
	}
	REP(i, 1, m) {
		ll a, b, w;
		cin >> a >> b >> w;
		pq.push({ w,color[a],color[b] });
	}
	ll cnt = k - 1;
	ll ans = 0;
	while (cnt > 0 && !pq.empty()) {
		edge e = pq.top();
		pq.pop();
		if (!same(e.fr, e.to)) {
			ans += e.len;
			unite(e.fr, e.to);
			cnt--;
		}
	}
	if (cnt > 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
}

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

int main() {
    int a, b, c;
    int tmp; 
    string out;

    cin >> a >> b >> c;

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    ll l = a / x;
    ll r = b / x;
    if(a % x == 0) {
        cout << r - l + 1 << endl;
    }
    else cout << r - l << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    ll a,b,k;
    cin >>a>>b>>k;
    if(a>=k){
        cout <<a-k <<' '<<b<<endl;
    }else if(a+b>=k){
        cout << 0 << ' '<<a+b-k<<endl;
    }else{
        cout <<0<<' '<<0<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    int b0 = 0, b1 = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > b1) {
            b1 = a[i];
            if (b1 > b0) swap(b0, b1);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << (a[i] == b0 ? b1 : b0) << '\n';
    }

    return 0;
}

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

using namespace std;

using ll = long long;

const int maxp = 1e6 + 5;

vector<bool> primes(maxp, true);

int prefsum[10] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45};

int main()
{
    ll n, orign;
    int ans = 0, count;
    cin >> n;
    orign = n;
    for(ll i = 2; (i * i) <= orign; i++) {
        if(primes[i]) {
            for(int j = 2; (i * j) * (i * j) <= orign; j++) {
                //cout << i << ' ' << j << ' ' << n << endl;
                primes[i * j] = false;
            }
            count = 0;
            while(!(n % i)) {
                n /= i;
                count++;
                //cout << count << endl;
            }
            if(count) {
                for(int j = 9; j >= 0; j--) {
                    if(count >= prefsum[j]) {
                        ans += j;
                        break;
                    }
                }
            }
        }
    }
    if(n != 1) ans += 1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,m,l,d[301][301],q,inf=1e18;
    cin>>n>>m>>l;
    int a,b,c;
    rep(i,n)rep(j,n) d[i][j]=inf;
    rep(i,m) cin>>a>>b>>c,d[a-1][b-1]=c,d[b-1][a-1]=c;
    rep(i,n) d[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    rep(i,n)rep(j,n){
        if(i==j) d[i][j]=0;
        else if(d[i][j]<=l) d[i][j]=1;
        else d[i][j]=inf;
    }
    rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        if(d[s-1][t-1]==inf) cout<<-1<<"\n";
        else cout<<d[s-1][t-1]-1<<"\n";
    }
}


Measured memory_bytes: 1280
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

void get_permutation(vvi& perm, vi a){
    sort(a.begin(), a.end());
    do {
        vi pt;
        for (int i : a) pt.push_back(i);
        perm.push_back(pt);
    } while (next_permutation(a.begin(), a.end()));
}

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


  int N; cin>>N;
  vi P(N); REP(i,N) cin>>P[i];
  vi Q(N); REP(i,N) cin>>Q[i];

  vi A(N); REP(i,N) A[i] = i+1;
  vvi perm;
  get_permutation(perm, A);

  int a=0, b=0;
  for(int i=0; i<perm.size(); i++) {
    if (perm[i] == P) a=i;
    if (perm[i] == Q) b=i;
  }

  int ans = abs(a-b);
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3384
#include <iostream>
#include <string>
#include <map>
#define llint long long

using namespace std;

llint n;
string s[55]; llint t[55];
string x;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> s[i] >> t[i];
	cin >> x;
	
	llint ans = 0; bool flag = false;
	for(int i = 1; i <= n; i++){
		if(flag) ans += t[i];
		if(s[i] == x) flag = true;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
tmpA = 0
tmpB = 0
tmpC = 0
count = 1
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
  print(0)
  exit()
if A == B and A == C and B == C:
  print(-1)
  exit()

while True:
  tmpA = (B + C) / 2
  tmpB = (A + C) / 2
  tmpC = (A + B) / 2
  if tmpA % 2 == 1 or tmpB % 2 == 1 or tmpC % 2 == 1:
    break
  else:
    A = tmpA
    B = tmpB
    C = tmpC
    count += 1
print(count)

Measured memory_bytes: 9196
fun main(args: Array<String>) {
    val (h, w) = readInputLine().split(" ").map{it.toInt()}
    
    val arr = Array(h, {IntArray(w)})
    
    for (i in 1..h) {
        val row = readInputLine().split(" ").map{it.toInt()}
        for (j in 1..w) {
            arr[i - 1][j - 1] = row[j - 1]
        }
    }
    
    // (from(x, y), to(x, y))
    val ops = mutableListOf<Pair<Pair<Int, Int>, Pair<Int, Int>>>()
    
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (arr[i][j] % 2 == 1) {
                if (j == w - 1) {
                    if (i != h - 1) {
                        arr[i][j]--
                        arr[i + 1][j]++
                        ops.add(Pair(Pair(i + 1, j + 1), Pair(i + 2, j + 1)))
                    }
                } else {
                    arr[i][j]--
                    arr[i][j + 1]++
                    ops.add(Pair(Pair(i + 1, j + 1), Pair(i + 1, j + 2)))
                }
            }
        }
    }
    
    println(ops.size)
    for (op in ops) {
        val from = op.first
        val to = op.second
        
        println("${from.first} ${from.second} ${to.first} ${to.second}")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 99664
#include <stdio.h>
int main(void){
	int i,j,H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==1 || j==1 || i==H || j==W){
					printf("#");
				}
				else{
					printf(".");
				}
			
			
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int k;
    cin>>k;
    for(int i=1,x=7%k;i<=1e7;i++,x=(10*x+7)%k)
        if(x==0)
            cout<<i,exit(0);
    cout<<-1;
}


Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int n;cin>>n;
  vector<int>a(32);
  a.at(0)=1;
  a.at(1)=1;
  a.at(2)=1;
  a.at(3)=2;
  a.at(4)=1;
  a.at(5)=2;
  a.at(6)=1;
  a.at(7)=5;
  a.at(8)=2;
  a.at(9)=2;
  a.at(10)=1;
  a.at(11)=5;
  a.at(12)=1;
  a.at(13)=2;
  a.at(14)=1;
  a.at(15)=14;
  a.at(16)=1;
  a.at(17)=5;
  a.at(18)=1;
  a.at(19)=5;
  a.at(20)=2;
  a.at(21)=2;
  a.at(22)=1;
  a.at(23)=15;
  a.at(24)=2;
  a.at(25)=2;
  a.at(26)=5;
  a.at(27)=4;
  a.at(28)=1;
  a.at(29)=4;
  a.at(30)=1;
  a.at(31)=51;
  cout<<a.at(n-1);
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string a, b, c,x;
	cin >> a >> b >> c;
	a = a[0];
	b = b[0];
	c = c[0];
	x = a + b + c;
	transform(x.begin(), x.end(), x.begin(), ::toupper);
	cout << x << endl;
}

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

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

    bool flag = true;
    if (s[0] != 'A') flag = false;
    int scnt = 0;
    for (int i = 1; i < s.length(); i++) {
        if ('a' <= s[i] && s[i] <= 'z') scnt++;
    }
    int Ccnt = 0;
    for (int i = 2; i < s.length() - 1; i++) {
        if (s[i] == 'C') Ccnt++;
    }
    if (scnt != s.length() - 2 || Ccnt != 1) flag = false;

    cout << ((flag) ? "AC" : "WA") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define pi acos(-1)
#define fastIO_ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int main()
{
    fastIO_
    ll n; cin>>n;
    vector <ll> freq(n+1, 0);
    for (ll i=0, k; i<n-1; i++)
    {
        cin>>k;
        freq[k]++;
    }
    for (ll i=1; i<=n; i++)
        cout<<freq[i]<<endl;
    return 0;
}

Measured memory_bytes: 4788
#include <iostream>

int main()
{
	int a, b, c;
	
	std::cin >> a >> b >> c;
	
	if ( a > b )
	{	
		int tmp = a;
		a = b;
		b = tmp;
	}
	if ( b > c )
	{
		int tmp = b;
		b = c;
		c = tmp;
	}
	if ( a > b )
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	
	std::cout <<a <<" " <<b <<" " <<c <<std::endl;
	
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
vector<int> p(200000);
vector<int> sz(200000);


int find(int x) {
    while (p[x] != x) {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void merge(int x, int y) {
    int a = find(x);
    int b = find(y);
    if (a == b) return;
    if (sz[a] < sz[b]) {
        p[a] = b;
        sz[b] += sz[a];
    } else {
        p[b] = a;
        sz[a] += sz[b];
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, n) {
        p[i] = i;
        sz[i] = 1;
    }
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        merge(x, y);
    }
    int ans = 0;
    rep (i, n) ans = max(ans, sz[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4648
module A
  sub main()
    dim RD as string
    dim SD() as string
    dim ans as string
    
    RD = console.readline()
    SD=split(RD," ")
    
    if ((sd(0)*sd(1)) mod 2) = 0 then
      ans = "Even"
    else
      ans = "Odd"
    end if
    
    console.writeline(ans)
    
  end sub
end module

Measured memory_bytes: 13532
S = input()
flag = True
for i, c in enumerate(S):
    if i % 2 == 0:
        if c != 'h':
            flag = False
            break
    else:
        if c != 'i':
            flag = False
            break

if len(S) % 2 == 1 or not flag:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;


int main(void) {

	int n, a[100] = { 0 };

	cin >> n;

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

	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n - i - 1; j++) {
			swap(a[j], a[j + 1]);
		}
	}

	for (int i = 0; i < n; i++) {
		if (i != 0)
			cout << " ";
		cout << a[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3072
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
LL a[MAXN+5],f[MAXN+5];
bool cmp(LL x,LL y){return x>y;}
LL k;
int n;
bool check(LL val){
	LL ret=0;
	for(int i=1;i<=n;i++)
		ret+=max(0ll,(a[i]*f[i]-val+f[i]-1)/f[i]);
	return ret<=k;
}
int main(){
	n=read();k=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=n;i++)
		f[i]=read();
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	LL L=-1,R=10000000000000ll;
	while(L+1<R){
		LL Mid=(L+R)>>1;
		if(check(Mid)) R=Mid;
		else L=Mid;
	}
	printf("%lld\n",R);
	return 0;
}

Measured memory_bytes: 3456
N,M = map(int,input().split())
k = [list(map(int,input().split()))for _ in range(M)]
p = list(map(int,input().split()))
ans = 0
for S in range(1 << N):
    res = [pp==0 for pp in p]
    for j in range(N):
        if (S >> j) & 1:
            for l in range(M):
                if j+1 in k[l][1:]:
                    res[l] = not res[l]
    if res == [True] * M:
        ans += 1
print(ans)


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int r,g;
	cin>>r>>g;
	cout<<g*2-r<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long int a,b;
    b = 0;
    cin >> a;
    for(int i=0; i<a; i++){
        if((i+1)%3!=0&&(i+1)%5!=0){
            b += i+1;
        }
    }
    cout << b;
}

Measured memory_bytes: 3192
from scipy.sparse.csgraph import floyd_warshall

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

edge = [[float("inf") for i in range(N)] for j in range(N) ]

abc = []
for _ in range(M):
    a,b,c = map(int,input().split())
    abc.append((a,b,c))
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

dist = floyd_warshall(edge)

ans = 0

for a,b,c in abc:
    if dist[a-1][b-1] != c:
        ans += 1

print(ans)

Measured memory_bytes: 14276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	map<string, int> mp;
	vector<pair<int,string>> res;

	rep(i, n) mp[s[i]]++;

	for (auto& c : mp) {
		res.emplace_back(make_pair(c.second, c.first));
	}
	sort(rall(res));
	int sol = res[0].first;
	vector<string> ans;
	rep(i, res.size()) {
		if (res[i].first == sol) ans.emplace_back(res[i].second);
	}
	sort(all(ans));
	rep(i, ans.size()) {
		dunk(ans[i]);
	}
	return 0;
}

Measured memory_bytes: 32876
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,temp;
	scanf("%d%d",&n,&m);
	int a[100009];
	memset(a,-1,sizeof(a));
	a[0]=1;
	a[1]=1;
	for (i=0;i<m;i++)
	{
		scanf("%d",&temp);
		a[temp]=0;
	}
	for (i=2;i<=n;i++)
	{
		if (a[i]!=0) a[i]=(a[i-1]+a[i-2])%1000000007;
	}
	printf("%d\n",a[n]);
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
import copy

def main():
    N,M = map(int,input().split())
    d = defaultdict(int)
    MOD = 10**9+7
    R = 10**5+100
    fac = [0 for _ in range(R+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,R+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
        
    def coef(x,y):
        num = (((fac[x+y]*invfac[y])%MOD)*invfac[x]%MOD)
        return num

    while M%2 == 0:
        d[2] += 1
        M //= 2
    f = 3
    while f ** 2 <= M:
        if M % f == 0:
            d[f] += 1
            M //= f
        else:
            f += 2
    if M != 1:
        d[M] += 1
    
    l = list(d.values())
    ans = 1
    for num in l:
        ans *= coef(num,N-1)
        ans %= MOD
        
    print(ans)
    
if __name__ == "__main__":
    main()

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    // key : 順番  value : 出席番号
    // 順番でソートするためkey
    map<int, int> a;

    rep(n) {
        int num; cin >> num;
        a.emplace(num, i+1);
    }

    for(auto i : a) {
        cout << i.second << " ";
    }
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &&i : A) {
        cin >> i;
    }
    auto print = [&]() {
        REP(i, N) {
            cout << A[i];
            i == N - 1 ? cout << '\n' : cout << ' ';
        }
    };

    REP(i, N) {
        int v = A[i];
        int j = i - 1;
        while (0 <= j && v < A[j]) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print();
    }

    return 0;
}


Measured memory_bytes: 3220
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev, *next;
};
 
struct Node *nil;
 
void init() {
    nil = (struct Node *)malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}
 
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
 
struct Node* listSearch(int key) {
    struct Node *cur = nil->next;
    while(cur != nil && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}
 
void deleteNode(struct Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
 
void deleteFirst() {
    deleteNode(nil->next);
}
 
void deleteLast() {
    deleteNode(nil->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}
 
void printList() {
    struct Node *cur;
    cur = nil->next;
    int isf = 0;
 
    while(1) {
        if (cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
 
 
int main(void) {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d",com, &key);
        if(com[0] == 'i') {
            insert(key);
            np ++;
            size++;
        }else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if( com[6] == 'F') {
                    deleteFirst();
                }else if(com[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
                nd ++;
            }
            size --;
        }
    }
    printList();
    return 0;
 
}

Measured memory_bytes: 32928
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int x; cin >> x;
	
	int j = 1;
	while(j*(j+1)/2 < x) j++;
	
	cout << j << endl;
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, c;
    cin >> a >> b >> c;
    
    if (b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int A[101][101]={0};
    long long int B[101][101]={0};
    long long int C[101][101]={0};
    long long  i, j, m, n, l, k;
    
    scanf("%lld %lld %lld", &n, &m, &l);
    
    for(j=0; j<n; j++){
        for(i=0; i<m; i++){
            scanf("%lld", &A[j][i]);
            
        }
    }
    for(j=0; j<m; j++){
        for(i=0; i<l; i++){
            scanf("%lld", &B[j][i]);
        }
    }
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            C[i][j]=0;
            for(k=0; k<m; k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            printf("%lld", C[i][j]);
            if(j !=l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2104
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
const int N = 1e5 + 100;
pii dp[N][12][12];
int n, m, q;
vector<int> adj[N];

int32_t main(){
        n = in(), m = in();
        for(int i = 0;i < m;i ++){
                int u = in()-1, v = in()-1;
                adj[u].push_back(v);
                adj[v].push_back(u);
        }
        q = in();
        for(int i = 0;i < q; i++){
                int v = in()-1, d = in(), c = in();
                for(int j = d; j > -1; j--)
                        dp[v][0][j] = pii(i+1,c); 
        }
        for(int d = 1;d < 11; d++){
                for(int i = 0;i < n;i ++){
                        for(int u : adj[i]){
                                for(int j = 10; j > -1; j--)
                                        dp[i][d][j] = max(max(dp[i][d-1][j],dp[i][d][j+1]), max(dp[i][d][j], dp[u][d-1][j+1])); 
                        }
                }
                for(int i = 0;i < n;i ++)
                for(int j = 10; j > -1; j--)
                        dp[i][d][j] = max(max(dp[i][d-1][j],dp[i][d][j+1]), dp[i][d][j]); 
        }
        for(int i = 0;i < n;i ++) cout << dp[i][10][0].se <<'\n'; 
}


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

using namespace std;
typedef long long LL;
typedef pair<LL, LL> pL;
const int N = 1e5 + 5;

int n, m, fpd;
LL a[N], Index, ans[N];
priority_queue < pL, vector<pL>, less<pL> > Q;

void init() {
    Q.push(make_pair(0ll, 0ll));
    cin >> fpd >> n;
    a[++Index] = fpd; // a[1] = N
    for(int i = 1; i <= n; i++) {
        LL x;
        scanf("%lld", &x);
        while(a[Index] >= x) Index -- ;
        a[++Index] = x;
    }
    reverse(a + 1, a + Index + 1); // now from big to small
    LL cur = 1, k;
    for(int i = 2; i <= Index; i++) {
        k = a[i - 1] / a[i];
        if(k * a[i] != a[i - 1]) Q.push(make_pair(a[i - 1] - k * a[i], cur));
        cur *= k;
        pL tmp;
        while((tmp = Q.top()).first >= a[i]) {
            Q.pop();
            k = tmp.first / a[i];
            cur += k * tmp.second;
            if(k * a[i] != tmp.first) Q.push(make_pair(tmp.first - k * a[i], tmp.second));
        }
    }
    m = a[Index];
    ans[m] = cur;
    while(Q.empty() == false) {
        pL tmp = Q.top();
        Q.pop();
        ans[tmp.first] += tmp.second;
    }
    for(int i = m - 1; i > 0; i--) ans[i] += ans[i + 1];
    for(int i = 1; i <= fpd; i++) printf("%lld\n", ans[i]); 
}

int main() {
    init();
    return 0;
}

Measured memory_bytes: 5488
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7



a, b = MAP()
ans = -1

for x in range(1, a * 100):
    if int(x * 0.08) == a and int(x * 0.1) == b:
        ans = x
        break

print(ans)

Measured memory_bytes: 5296