akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

struct Edge{
    int dst, cost, hour, co;
};

typedef vector<Edge> Node;
typedef vector<Node> Graph;

const int INF = 1000000000;
typedef tuple<int, int, int> P; // cost, vertex, hour

int main(){
    int N, M, H, K;
    while(cin >> N >> M >> H >> K && N > 0) {
        Graph G(N);
        REP(i, M) {
            int a, b, c, d, e;
            cin >> a >> b >> c >> d >> e;
            a--; b--;
            e--;
            G[a].push_back({b, c, d, e});
            G[b].push_back({a, c, d, e});
        }
        int S, T;
        cin >> S >> T;
        S--; T--;

        int PP;
        cin >> PP;
        int dp[1 << 8] = {};
        REP(s, 1 << K) dp[s] = (s > 0 ? INF : 0);
        REP(i, PP) {
            int l;
            cin >> l;
            int d;
            cin >> d;
            int mask = 0;
            REP(_, l) {
                int k;
                cin >> k;
                k--;
                mask |= 1 << k;
            }
            for(int s = (1 << K) - 1; s >= 0; s--) {
                dp[s | mask] = min(dp[s | mask], dp[s] + d);
            }
        }

        int ans = INF;

        REP(s, 1 << K) if(dp[s] < INF) {
            int dist[100][25] = {};
            REP(i, N) REP(j, H + 1) dist[i][j] = INF;
            priority_queue<P, vector<P>, greater<P>> que;

            dist[S][0] = 0;
            que.push(P(0, S, 0));
            while(!que.empty()){
                P t = que.top();
                que.pop();
                int c, v, h;
                tie(c, v, h) = t;
                if(dist[v][h] < c) continue;

                for(Edge e : G[v]) {
                    int nc = c + ((s >> e.co & 1) ? 0 : e.cost);
                    int nv = e.dst;
                    int nh = h + e.hour;
                    if(nh > H) continue;
                    if(dist[nv][nh] > nc) {
                        dist[nv][nh] = nc;
                        que.push(P(nc, nv, nh));
                    }
                }
            }
            for(int h = 0; h <= H; h++) {
                //printf("dp[%d] + dist[%d][%d] = %d + %d\n", s, T, h, dp[s], dist[T][h]);
                ans = min(ans, dp[s] + dist[T][h]);
            }
        }

        if(ans == INF) ans = -1;

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    for(int i = K; i < N; i++){
        if(A[i - K] < A[i]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

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

int main()
{
  int N; cin >> N;
  vector<int> ans(N);
  rep(i, N) {
    int A; cin >> A; A--;
    ans[A] = i;
  }

  rep(i, N) cout << ans[i] + 1 << " ";
  cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
typedef struct edge_ { ll to; ll cost; } edge;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



int main()
{
	ll K, A, B;
	cin >> K >> A >> B;

	ll ans = 0;

	if (A >= B - 1) {
		ans = 1 + K;
	}
	else {
		K -= A - 1;
		ans = A;
		while (K > 1) {
			ans += B - A;
			K -= 2;
		}
		if (K > 0)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
s  = str(input())
n = len(s)-1
ans = 0
for i in range(2**n):
  op = ['']*n
  for j in range(n):
    if (i>>j) & 1:
      op[j] = '+'
  # print(op)
  op = op + ['']
  formula = ''
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  ans += eval(formula)
print(ans)

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

int main() {
    //
    long long num, k, s;
    cin >> num >> k >> s;

    if (s == 1000000000) {
        for (int i = 0; i < k; i++) cout << s << " ";
        for (int i = k; i < num; i++) cout << 1 << " ";
    } else {
        for (int i = 0; i < k; i++) cout << s << " ";
        for (int i = k; i < num; i++) cout << 1000000000 << " ";
    }
}

Measured memory_bytes: 3636
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
L = list(map(int, sys.stdin.buffer.readline().split()))


L = np.array(L, dtype=int)
ok =  L.max() < L.sum() - L.max()
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13428
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N;
	cin >> N;

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

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

	vector<int> all;
	for (int i = N; i >= 1; i--) {
		int temp = 0;
		for (int j = 2; i * j <= N; j++) {
			temp += ans[i * j];
		}

		if (temp % 2 == a[i]) {
			ans[i] = 0;
		}
		else {
			ans[i] = 1;
			all.emplace_back(i);
		}

	}

	//for (int i = 1; i <= N; i++) {
	//	cout << ans[i] << " ";
	//}

	cout << all.size() << endl;
	for (int i = 0; i < all.size(); i++) {
		cout << all[i] << " ";
	}



}



Measured memory_bytes: 3192
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
//-------------------------------------------------------

int main()
{
        int N, M, C;
        cin >> N >> M >> C;
        int ans = 0;

        vector<int> B(M), A(M);
        for (int i = 0; i < M; i++)
        {
                cin >> B[i];
        }

        for (int i = 0; i < N; i++)
        {
                for (int j = 0; j < M; j++)
                {
                        cin >> A[j];
                }
                int res = 0;
                for (int k = 0; k < M; k++)
                {
                        res += A[k] * B[k];
                }
                res += C;
                if (res > 0)
                {
                        ans++;
                }
        }

        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,a,b,c,counter=0;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            counter++;
        }
    }
    printf("%d\n",counter);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;



int main(){
  string a,b,c;
  cin >> a >>b >> c;
  int an=a.size(),bn=b.size(),cn=c.size();
  if(a[an-1]==b[0] && b[bn-1]==c[0]){cout << "YES" << endl;}else{cout << "NO" <<endl;}
}

Measured memory_bytes: 3628
import java.util.Scanner;

// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_D
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int minv = sc.nextInt();
    int maxv = Integer.MIN_VALUE;

    for (int i = 1; i < n; i++) {
      int R = sc.nextInt();
      maxv = Integer.max(maxv, R - minv);
      minv = Integer.min(minv, R);
    }
    System.out.println(maxv);
  }
}



Measured memory_bytes: 68368
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=2e5+5, INF=1e9;
using namespace std;
int n, m, a[N], ans, cntg, cntl, helps, pos;
map< pii, int> Mtg, Mtl, Mtgh, Mtlh;
signed main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 2; i <= n; i++)
    {
        if(a[i] > a[i-1])
        {
            ans += (a[i] - a[i-1]);
            Mtgh[{a[i], 1}]+=a[i]-a[i-1]-1;
            Mtg[{a[i], 1}]++;
            Mtg[{a[i-1], 0}]++;
            cntg++;
        }
        else if(a[i-1] > a[i])
        {
            ans += m - (a[i-1] - a[i]);
            Mtlh[{a[i], 1}] += m - (a[i-1] - a[i]) - 1;
            Mtl[{a[i], 1}]++;
            Mtl[{a[i-1], 0}]++;
            helps += m-a[i-1]-1;
            pos++;
            cntl++;
        }
    }
    //cout << ans << endl;
    int mx = -1;
    for(int i = 1; i <= m; i++)
    {
        pos+=Mtg[{i-2, 0}];
        pos-=Mtg[{i-1, 1}];
        helps-=Mtgh[{i-1, 1}];
        pos-=Mtl[{i-1, 1}];
        helps-=Mtlh[{i-1, 1}];
        pos+=Mtl[{i-2, 0}];
        helps+=pos;
        //cout << i << " - " << pos << " " << helps << endl;
        mx = max(mx, helps);
    }
    cout << ans - mx;
}

Measured memory_bytes: 38528
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	long long n;
	cin >> n;
	
	vector<long long> a(n+1,0);
	for(long long i=1;i<=n;i++){
		int id=1;
		while(1){
			a[i*id]++;
			id++;
			if(i*id>n)break;
		}
	}
	
	long long ans=0;
	for(long long i=1;i<=n;i++){
		ans+=i*a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 81404
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n;cin>>n;
    vlli a(n);flli(i,0,n-1)cin>>a[i];
    sort(all(a));
    lli ans=0;
    flli(i,0,n-3)
    {
        flli(j,i+1,n-2)
        {
            flli(k,j+1,n-1)
            {
                if(a[i]==a[j] || a[j]==a[k])continue;
                if(a[i]+a[j]>a[k])ans++;
            }
        }
    }
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    string s; in >> s;
    ll dp[11]; memset(dp, 0, sizeof(dp));
    ll pow10[11]; pow10[0] = 1; REPE(i, 1, 10) pow10[i] = pow10[i-1] * 10;
    dp[0] = s[0]-'0';

    REP2(i, 1, s.size())
    {
        ll t = s[i]-'0';
        ll con = t;
        REPR(j,i,1)
        {
            dp[i] += dp[j-1] + (1LL<<(j-1))*con;
            con += (s[j-1]-'0') * pow10[i-j+1];
        }
        dp[i] += con;
    }

    out << dp[s.size()-1] << "\n";

    return 0;
}


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

int main(){
	int i,j,n,l;
	string st;
	vector<string>a;
	cin>>n>>l;
	for(i=0;i<n;i++){
		cin>>st;
		a.push_back(st);
	}
	for(i=0;i<a.size()-1;i++){
		for(j=i+1;j<a.size();j++){
			if(a[i]+a[j]>a[j]+a[i])swap(a[i],a[j]);
		}
	}
	for(i=0;i<a.size();i++)cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int len;
char a[1005];
int count;
int main(){
	scanf("%s", a);
	len = strlen(a);
	for(int i = 0; i < len; i++)
		if(a[i] == '2') count++;
	printf("%d\n", count);
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll C[100005];
ll D[100005];
ll P[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    memset(C, 0, sizeof(C));
    memset(P, 0, sizeof(P));
    REP(i, N) {
        cin >> A[i];
        C[A[i]]++;
        D[A[i] % M]++;
    }
    REP(i, 100005) {
        P[i % M] += C[i] / 2;
    }
    ll ans = 0;
    REP(i, M) {
        ll d = (M - i) % M;
        if (d != i) {
            ll m = std::min(D[d], D[i]);
            ans += m;
            D[d] -= m;
            D[i] -= m;
            ll x = std::min(P[d], D[d] / 2);
            ll y = std::min(P[i], D[i] / 2);
            ans += x + y;
            P[d] -= x;
            D[d] -= 2 * x;
            P[i] -= y;
            D[i] -= 2 * y;
        }
        else {
            ll m = D[i] / 2;
            ans += m;
            D[i] -= 2 * m;
            ll x = std::min(P[i], D[i] / 2);
            ans += x;
            P[i] -= x;
            D[i] -= 2 * x;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

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

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

    ll max = 0;
    for(int i = n - 2; i >= 0; i--){
        if(h[i] >= h[i + 1]){
            che[i] += che[i + 1] + 1;
        }

        if(max <= che[i]){
            max = che[i];
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		if (s.length() <= k) {
			System.out.println(s);
		} else {
			System.out.println(s.substring(0, k) + "...");
		}

		sc.close();
	}

}


Measured memory_bytes: 38612
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int h[100010];
    int dp[100010];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        if(i>=2){
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}



Measured memory_bytes: 1024
/*************************************************************************
    > File Name: c.cpp
    > Author: Amano Sei
    > Mail: amano_sei@outlook.com 
    > Created Time: 2020年01月19日 星期日 21时34分14秒
 ************************************************************************/

#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int n, cmin = 200005, cnum, ans = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &cnum);
        if(cnum < cmin){
            ans++;
            cmin = cnum;
        }
    }
    printf("%d\n", ans);
    return 0;
}



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

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            List<Integer> s = new ArrayList<>();
            int g = 0;
            for (int i = 0; i < n; i++) {
                s.add(in.nextInt());
                g += s.get(i);
            }
            if (g % 10 != 0) {
                out.println(g);
            } else {
                Collections.sort(s);
                for (int c : s) {
                    if (c % 10 != 0) {
                        g -= c;
                        break;
                    }
                }
                if (g % 10 == 0) {
                    out.println(0);
                } else {
                    out.println(g);
                }
            }
        }

    }
}



Measured memory_bytes: 23764
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
  cout<<n*m<<"\n";
}


Measured memory_bytes: 3664
import javax.swing.event.InternalFrameListener;
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

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

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long maxi = Integer.MAX_VALUE;
        long mod = (long) (1e9 + 7);
        int dp[];
        int n, k, a[];

        int grundy(int x) {
            if (dp[x] != -1)
                return dp[x];
            HashSet<Integer> map = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int t = x - a[i];
                if (t >= 0)
                    map.add(grundy(t));
            }
            dp[x] = 0;
            while (map.contains(dp[x]))
                dp[x]++;
            return dp[x];
        }

        void solve() {
            n = sc.ni();
            k = sc.ni();
            dp = new int[k + 1];
            Arrays.fill(dp, -1);
            a = sc.na(n);
            for (int i = 0; i <= k; i++)
                grundy(i);
            int ans = dp[k];
            if (ans == 0)
                out.println("Second");
            else
                out.println("First");
        }
    }
}


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

using namespace std;

int a[100005];
int b[100005];

int main(){

	int N,H;

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

	int i;

	int a_max=0;

	for(i=0;i<N;i++){
	scanf("%d %d",&a[i],&b[i]);
	if(a_max<a[i]){a_max=a[i];}
	}

	sort(b,b+N);
	reverse(b,b+N);

	int ans=H;

	for(i=0;i<=N;i++){
		if(i>0){H-=b[i-1];}
		int cnt=0;
		if(H>0){cnt=(H-1+a_max)/a_max;}
		ans=min(ans,i+cnt);
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int digsum(ll x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}


int main(){
  ll a[4];
  rep(i,4)cin >> a[i];
  sort(a,a+4);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cmath>
#include <utility>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> B(N + 1, 0);
  for (ll i = 1; i <= N; i++) {
    cin >> B[i];
  }

  ll tail = N;
  vector<ll> A;
  while (A.size() != N) {
    for (ll i = tail; i > 0; i--) {
      if (i < B[i]) {
        // cout << "error pos: " << i << " error num: " << B[i] << endl;
        cout << "-1" << endl;
        return 0;
      }

      if (i == B[i]) {
        A.push_back(B[i]);
        B.erase(B.begin() + i);
        tail--;
        break;
      }
    }
  }

  for (ll i = N - 1; i >= 0; i--) {
    cout << A[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s=S.size();
  for (int i=0;i<s;i++){
    if (i+1<s&&S[i]==S[i+1]){
      cout << i+1 << ' ' << i+2 << endl;
      break;
    }
    else if (i+2<s&&S[i]==S[i+2]){
      cout << i+1 << ' ' << i+3 << endl;
      break;
    }
    else if (i==s-1){
      cout << -1 << ' ' << -1 << endl;
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 2e5;

const int Q = 1e9 + 7;

int main() {

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

    long long cur = 1;
    long long res = 1;
    for (int i = 1; i < n; i++) {
        if (cur * 2 - 1 <= a[i - 1] || a[i] <= 2);
        else (cur--);
        cur++;
        res = (res * cur) % Q;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

//48
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	v[0]--;
	for (int i = 1; i < n; ++i) {
		if (v[i] < v[i - 1]) {
			cout << "No";
			return 0;
		}else if (v[i] > v[i - 1]) {
			v[i]--;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  long long ans = 0;
  long long can_eat_cookie = A + B + 1;
  if (C <= can_eat_cookie)
    ans = B + C;
  else
    ans = can_eat_cookie + B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> v(N), p(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
        p[i] = v[i];
    }
    sort(p.begin(), p.end());
    int midl = p[N/2-1], midr = p[N/2];

    for (int i = 0; i < N; i++) {
        if (v[i] <= midl) cout << midr << '\n';
        else cout << midl << '\n';
    }
}


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

int main() {
    int n;  cin >> n;
    int a[n], b[n] = {};
    rep(i,n)  cin >> a[i];

    rep(i,n) {
        b[a[i]-1] = i+1;
    }

    rep(i,n) {
        if (i < n-1)  cout << b[i] << ' ';
        else  cout << b[i] << endl;
    }
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)


string s;
string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
	cin >> s;

	int x = -1;
	int y = -1;
	rep(i,26){
		rep(j,s.size()-1){
			if (s[j]==alpha[i] && s[j+1]==alpha[i]){
				x = j+1;
				y = j+2;
				break;
			}
			else if (j < (s.size()-2) && s[j]==alpha[i] && s[j+2]==alpha[i]){
				x = j+1;
				y = j+3;
				break;
			}
		}
		if (x > 0) break;
	}
	cout << x << " " << y << endl;


    return 0;
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, t;
  std::cin >> n >> t;
  int ans = t, prev = read();
  REP(i, n - 1) {
    int ti = read();
    if (prev + t > ti)
      ans += t - (prev + t - ti);
    else
      ans += t;
    prev = ti;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string N;
    cin >> N;
    bool ans = (N[0] == '7' || N[1] == '7' || N[2] == '7');

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 3648
s = int(input())
L = []
for c in range(2 , 10 ** 6 + 1):
  L.append(s)
  if s % 2 == 0:
    s = s // 2
  elif s % 2 == 1:
    s = s * 3 + 1
  if s in L:
    break
print(c)

Measured memory_bytes: 9068
import sys


def main():
    S = sys.stdin.readline().strip()
    is_easy = True
    for i in range(len(S)):
        c = S[i]
        if i % 2 == 0 and c == 'L':
            is_easy = False
        if i % 2 and c == 'R':
            is_easy = False
    if is_easy:
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 38384
distanceSum = 0
spotCount = int(input())
spotList = input().split()
spotList = [int(i) for i in spotList]
spotList.append(0)

def calcDistance(num): # 配列num-1番のスポットから配列num番目のスポットへの距離を計算
    if num == 0: #開始地点から配列0番＝最初のスポット
        return abs(spotList[num])
    elif num == spotCount: #最後スポットから開始地点
        return abs(spotList[num-1])
    else:
        return abs(spotList[num]-spotList[num-1])

def calcSkipEffect(num): #配列num番をスキップした時の移動距離への影響を計算
    if num == 0: #最初のスポットの時だけの例外
        return abs(spotList[num+1])-abs(spotList[num])-abs(spotList[num+1]-spotList[num])
    else:
        return abs(spotList[num+1]-spotList[num-1])-abs(spotList[num]-spotList[num-1])-abs(spotList[num+1]-spotList[num])

for i in range(spotCount+1): #総移動回数はスポット数+1
    distanceSum += calcDistance(i)
    
for j in range(spotCount): #配列0～n-1番までの各スポットについて実行
    print(str(distanceSum + calcSkipEffect(j)))

Measured memory_bytes: 14172
// C.

#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; ++i) {
		cin >> s[i];
	}
	bool ans = true;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '#') {
				bool ok = false;
				for (int d = 0; d < 4; ++d) {
					const int dx[4] = { -1,1,0,0 };
					const int dy[4] = { 0,0,-1,1 };
					int p = i + dy[d], q = j + dx[d];
					if (p >= 0 && p < h && q >= 0 && q < w && s[p][q] == '#') {
						ok = true;
						break;
					}
				}
				if (!ok) {
					ans = false;
				}
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n , k ,q ,a[100001] ,x ;
int main()
{
    cin >> n >> k >> q ;
    for (int  i = 1 ;i <= n ;i++)
    {
        a[i] += k;
        a[i] -= q ;
    }
    while (q--)
    {
     cin >> x ;
        a[x]+=1;
    }
    for (int  i = 1 ;i <= n ; i++)
    {
        if (a[i]  > 0 )cout <<"Yes"<<endl;
        else cout <<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# やりやすさのため、小さい桁からいけるように逆順にしておく
S=input()[::-1]
N=len(S)

# dp[i][j] := 下からi桁を考えた時，13で割ったあまりがjであるものの数
dp=list2d(N+1, 13, 0)
dp[0][0]=1
mul=1
for i in range(N):
    for j in range(13):
        # ?だったら0~9を全て遷移させる
        if S[i]=='?':
            for k in range(10):
                # 桁を合わせる
                nxt=k*mul
                dp[i+1][(j+nxt)%13]+=dp[i][j]
                dp[i+1][(j+nxt)%13]%=MOD      
        else:
            # 決まっていたらその数字のみ遷移させる
            nxt=int(S[i])*mul
            dp[i+1][(j+nxt)%13]+=dp[i][j]
            dp[i+1][(j+nxt)%13]%=MOD
    # 桁を合わせ用(10万桁とか直接使ったら死ぬので、毎回ここでMOD13する)
    mul*=10
    mul%=13
# 最終的にN桁終わって余り5の数が答え
print(dp[N][5])


Measured memory_bytes: 61916
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll k; cin >> k;
    ll ans;
    if(k & 1)ans = b-a;
    else ans = a-b;
    if(abs(ans) > 1e18)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = static_cast<ll>(1e9) + 7;

int main()
{
    double L;
    cin >> L;

    const double l3 = L / 3.0;
    const double ans = l3 * l3 * l3;

    printf("%.06f\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  
  int i = 1;
  int64_t power = 1;
  while(i <= n){
    power = power * i % 1000000007;
    i++;
  }
  
  cout << power << endl;
  
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

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

    sort(D.begin(), D.end());
    cout << D[N / 2] - D[(N - 1) / 2] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, M;
	cin >> N >> M;
	vector<int> p(M);
	vector<string> S(M);
	for (int i = 0; i < M; i++) {
		cin >> p[i];
		p[i]--;
		cin >> S[i];
	}

	vector<int> first_ac(N, -1);
	vector<vector<int>> memo_wa(N);
	for (int i = 0; i < M; i++) {
		if (S[i] == "AC" && first_ac[p[i]] == -1) {
			first_ac[p[i]] = i;
		} else {
			memo_wa[p[i]].push_back(i);
		}
	}

	int total_ac = 0;
	int total_pena = 0;
	for (int i = 0; i < N; i++) {
		if (first_ac[i] != -1) {
			total_ac++;

			for (int j = 0; j < memo_wa[i].size(); j++) {
				if (memo_wa[i][j] < first_ac[i]) {
					total_pena++;
				} else {
					break;
				}
			}
		}
	}
	cout << total_ac << " " << total_pena << endl;
	return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
bitset<2000005>bit;
int sum,n,x;
int main(){
	scanf("%d",&n);
	bit[0]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		bit|=(bit<<x);
		sum+=x;
	}
	for(int i=(sum+1)/2;i<=sum;++i){
		if(bit[i]){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Deque<Integer>> list = new ArrayList<>();
		int n = sc.nextInt();
		int q = sc.nextInt();
		for (int i = 0; i < n; i++) {
			list.add(new ArrayDeque<>());
		}
		for (int i = 0; i < q; i++) {
			switch (sc.nextInt()) {
				case 0:
					list.get(sc.nextInt()).addFirst(sc.nextInt());
					break;
				case 1:
					int t = sc.nextInt();
					if (!list.get(t).isEmpty()) {
						System.out.println(list.get(t).peekFirst());
					}
					break;
				case 2:
					t = sc.nextInt();
					if (!list.get(t).isEmpty()) {
						list.get(t).removeFirst();
					}
					break;
			}
		}
	}
}


Measured memory_bytes: 169440
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#define llong long long
#define INF (pow(10, 15))
#define MAX_XYZ 1000

using namespace std;

int X, Y, Z, K;
llong A[MAX_XYZ], B[MAX_XYZ], C[MAX_XYZ];

class CakePair {
public:
    int x, y, z;
    llong sum;
    CakePair(int _x, int _y, int _z) { 
        this->x = _x; 
        this->y = _y; 
        this->z = _z;
        this->sum = A[_x] + B[_y] + C[_z];
    }

    bool operator<(const CakePair p) const {
        return sum < p.sum;
    }
};


void print(CakePair cp) {
    printf("%lld\n", cp.sum);
}

llong calc_id(int x, int y, int z) {
    return x * 1000000 + y * 1000 + z;
}

int solve() {
    set<llong> memo;
    priority_queue<CakePair> pque;
    pque.push(*new CakePair(0, 0, 0));
    memo.insert(0);

    int i = 0;
    while(!pque.empty()) {
        CakePair cp = pque.top();   pque.pop();
        print(cp);
        ++i;
        if(i == K) break;

        if(cp.x < X - 1 && memo.find(calc_id(cp.x + 1, cp.y, cp.z)) == memo.end()) {
            pque.push(*new CakePair(cp.x + 1, cp.y, cp.z));
            memo.insert(calc_id(cp.x + 1, cp.y, cp.z));
        }

        if(cp.y < Y - 1 && memo.find(calc_id(cp.x, cp.y + 1, cp.z)) == memo.end()) {
            pque.push(*new CakePair(cp.x, cp.y + 1, cp.z));
            memo.insert(calc_id(cp.x, cp.y + 1, cp.z));
        }

        if(cp.z < Z - 1 && memo.find(calc_id(cp.x, cp.y, cp.z + 1)) == memo.end()) {
            pque.push(*new CakePair(cp.x, cp.y, cp.z + 1));
            memo.insert(calc_id(cp.x, cp.y, cp.z + 1));
        }
    }
}

int main(int argc, char **argv) {
    scanf("%d %d %d %d", &X, &Y, &Z, &K);
    for(int i = 0; i < X; ++i) scanf("%lld", A + i);
    for(int i = 0; i < Y; ++i) scanf("%lld", B + i);
    for(int i = 0; i < Z; ++i) scanf("%lld", C + i);
    sort(A, A + X);
    sort(B, B + Y);
    sort(C, C + Z);
    reverse(A, A + X);
    reverse(B, B + Y);
    reverse(C, C + Z);

    solve();
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;
    char ch; cin >> ch;
    if (ch >= 'A' && ch <= 'Z') { cout << 'A' << endl; }
    else { cout << 'a' << endl; }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;

int main() {
 
int64_t N;
cin >>N;
// vector<int> A(N);
// for(int i=0; i<N; i++){cin>>A[i];}
// vector<vector<int>> A(N,vector<int>(M));
// for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
cout<<N*(N-1)/2<<endl;
}


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



int main(){
  std::cout<<std::fixed<<std::setprecision(10);
    
  
  int N;
  int K;
  cin>>N>>K;
  
  vector<int>cnt(N);
  
  
  
  for(int i=0;i<N;i++){
    int point=i+1;
    while(point<K){
      point*=2;
      cnt.at(i)++;
    }
  }
  
  vector<int>topV(N,1);
  
  sort(cnt.begin(),cnt.end());
  
  int max=cnt.at(N-1);
  
  for(int i=0;i<N;i++)
    cnt.at(i)=max-cnt.at(i);
  
  int under=1,top=0;
  
  for(int i=0;i<max;i++)
    under*=2;
  
  for(int i=0;i<N;i++){
    int point=1;
    for(int j=0;j<cnt.at(i);j++)
      point*=2;
    top+=point;
  }
  
  cout << (double)top/(under*N);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	ll n;
	cin >> n;
	vector<ll> v(n);
	ll sum = 0;
	for(ll i=0;i<n;i++) {
		cin >> v[i];
		sum += v[i];
	}
	sum -= v[0];
	ll ans = 0;
	for(ll i=0;i<n-1;i++) {
		ans = (ans + ((sum % MOD) * (v[i] % MOD)) % MOD) % MOD;
		sum -= v[i + 1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4728