akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


void solve() {
	char a, b; cin >> a >>b;
	if (a == 'H'&&b == 'H')print("H");
	else if (a == 'D'&&b == 'D')print("H");
	else print("D");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int  N;
    cin >> N;
    for(int i=1 ; i<=N; ++i){
        double P =0;
        int K;
        P=i*1.08;
        K =(int)P;
       if(N ==K){
        cout << i << endl;
        return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int ans = 100010;
int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i = 1; i < (int)s.size(); ++i){
		if(s[i] != s[i - 1]){
			ans = min(ans, max(i, (int)s.size() - i));
		}
	}
	cout << min(ans, (int)s.size()) << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    ll sum = 0;
    rep(i, 0, M){
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.lang.Integer;
import java.lang.Math;
import java.lang.String;
import java.lang.System;
import java.util.Scanner;

public class Main {
    static final String[] KEYWORDS = {"the", "this", "that"};

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            String str = sc.nextLine();

            // 復号するための移動量を算出
            int movement = getMovement(str);
            if (movement >= 0) {
                // 復号処理
                String desryptedStr = decrypt(str, movement);
                System.out.println(desryptedStr);
            } else {
                System.out.println("NOT FOUND");
            }
        }
    }

    // 移動量を算出
    public static int getMovement(String str) {
        int movemnet = 0;
        for (int i = 0; i < 26; i++) {
            String decrptedStr = decrypt(str, i);
            for (int j = 0; j < KEYWORDS.length; j ++) {
                if(decrptedStr.contains(KEYWORDS[j] + " ") || decrptedStr.contains(KEYWORDS[j] + ".")) {
                    return i;
                }
            }
        }
        return -1;
    }

    public static String decrypt(String str, int movement) {
        char c[] = str.toCharArray();
        for (int i = 0; i < c.length; i++) {
            // a-z以外は処理しない
            if (c[i] < 'a' || 'z' < c[i]) {
                continue;
            }

            // 複合
            c[i] = (char)(c[i] + movement);
            if (c[i] > 'z') {
                int fixMovement = c[i] - 'z';
                c[i] = (char)('a' - 1 + fixMovement);
            }
        }
        return String.valueOf(c);
    }
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;
  vector<vector<int>> edges(9,vector<int> (9));
  void solve(){
     int n,m;
     cin >> n >> m;
     vector<int> v(n);
     v[0]=1;
     for(int i=n-1;i>=1;i--){
       v[i]=i+1;
     }
     for(int i=0;i<m;i++){
       int a,b;
       cin >> a >> b;
       edges[a][b]=1;
       edges[b][a]=1;
     }
     int cnt=0;
     do{
       bool ok = true;
       for(int i=1;i<n;i++){
          if(!edges[v[i-1]][v[i]]){
              ok = false;
          }
       }
       if(ok)cnt++;
     }while(next_permutation(v.begin()+1,v.end()));

     cout << cnt;
  }



  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 256
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes = [-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x] = self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x = self.get_root(x)
        root_y = self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root = root_x
                small_root = root_y
            else:
                small_root = root_x
                big_root = root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root] = big_root


N, M = map(int, input().split())
uf = UnionFind(N)
get_root, unite, nodes = uf.get_root, uf.unite, uf.nodes

for _ in range(M):
    x, y, _ = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)
ans = 0
for i in range(N):
    if nodes[i] < 0:
        ans += 1
print(ans)


Measured memory_bytes: 67928
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long int ll;
const ll inf=100000000000000;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  rep(i,n) cin>>x.at(i);

  //火を付けるろうそくはx_i~x_(i+k-1)と仮定する
  ll min=inf,ans=inf;
  rep(i,n-k+1)
  {
    ll a=abs(x.at(i)),b=abs(x.at(i+k-1));
    if(a>b) min=b;
    else min=a;
    min+=(x.at(i+k-1)-x.at(i));

    if(ans>min) ans=min;
  }

  cout<<ans<<endl;
}

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

int main()
{
  char S[101], T[101];
  cin >> S >> T;

  int N = strlen(S);

  char R[101];
  strcpy(R,S);
  rep(j,N){
    rep(i,N){
      int k = i-1;
      if(k<0) k=N-1;
      R[i]=S[k];
    }
    if(strcmp(T,R)==0) {
      cout << "Yes" << endl;
      return 0;
    }
    strcpy(S, R);
  }

  cout << "No"  << endl;
}



Measured memory_bytes: 256
#B
N,K=map(int,input().split())
d=0
A=[]
SET=[]

for i in range(K):
    d=int(input())
    A=[int(x) for x in input().split()]
    for j in range(d):
        SET.append(A[j-1])
SET=set(SET)    
print(N-len(SET))

Measured memory_bytes: 68028
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = v[0];
  rep(i, 1, n) { ans = (ans + v[i]) / 2; }
  cout << ans << endl;
}


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

//long long型(64bit整数)
typedef long double ll;

int main(){
    ll n, a[5];
    cin >> n;
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    ll minA = a[0];
    for(int i=1; i<5; i++){
        minA = min(minA, a[i]);
    }

    cout << (long long)ceil(n/minA) + 4LL << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define kk long long
using namespace std; 
 
int main() 
{ 
	
	
	kk i,j,n,m,a;
	cin>>n>>m;
	kk sum=0;
	int ara[m];
	for(i=0;i<m;i++)
	{
		cin>>ara[i];
		
		sum+=ara[i];
		
			}
			
			if(sum>=n)cout<<"Yes\n";
			else cout<<"No\n";
	  
	return 0; 
} 

// This is code is contributed by rathbhupendra 


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

using namespace std;

int main()
{
  int n, q;
  cin >> n;
  vector<int> a(n), ac(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    ac[i] = a[i];
  }
  sort(ac.begin(), ac.end());
  int dif = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != ac[i])
      dif++;
  if (dif == 0)
  {
    cout << 0 << endl;
    return 0;
  }
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int x, y;
    cin >> x >> y;
    int tx = a[x - 1], ty = a[y - 1];
    swap(a[x - 1], a[y - 1]);
    if (tx == ac[x - 1] && ty != ac[x - 1])
      dif++;
    if (tx != ac[x - 1] && ty == ac[x - 1])
      dif--;
    if (ty == ac[y - 1] && tx != ac[y - 1])
      dif++;
    if (ty != ac[y - 1] && tx == ac[y - 1])
      dif--;
    if (dif == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}



Measured memory_bytes: 5216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace algorithm
{
	class Program
	{
		static void Main(string[] args)
		{

			char[] str = Console.ReadLine().ToCharArray();
			int min1 = 0,min2 =0;
			char[] chk = { '0', '1' };
			char[] chk2 = { '1', '0' };
			for (int i = 0; i < str.Length; i++)
			{
				if (str[i] != chk[i % 2])
					min1++;
				else
					min2++;
			}

			Console.WriteLine(Math.Min(min1, min2));
			
		}
	}

}




Measured memory_bytes: 13176
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pie = acos(-1.0);
const ll MOD = 1e9 + 7;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*   *   *   *   *   *   *   *   *   *   *   */

void solve() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    sort(ALL(a));
    ll ans = 1001001001;
    Rep(i, a[0], a[n-1]){
        ll sum = 0;
        rep(j, 0, n){
            sum += (a[j]-i)*(a[j]-i);
        }
    ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}


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

#define fi first
#define se second

const int N = 200200;
const int mod = 1e9 + 7;

using namespace std;

int n, m;
long long d[N], f[N];
long long cd[N], cf[N];
vector < pair < int, int > > v[N];

void add(long long &x, long long y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        }
}

void djk(int x, long long *d, long long *c)
{
        long long inf = 1e18;
        for(int i = 1; i <= n; i++){
                d[i] = inf;
                c[i] = 0;
        }
        d[x] = 0;
        c[x] = 1;
        set < pair < long long, int > > s;
        s.insert({0, x});
        while(!s.empty()){
                int x = s.begin()->se;
                s.erase(s.begin());
                for(auto y: v[x]){
                        if(d[y.fi] > d[x] + y.se){
                                s.erase({d[y.fi], y.fi});
                                d[y.fi] = d[x] + y.se;
                                c[y.fi] = c[x];
                                s.insert({d[y.fi], y.fi});

                        } else if(d[y.fi] == d[x] + y.se){
                                add(c[y.fi], c[x]);
                        }
                }
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n >> m;
        int s, t;
        cin >> s >> t;
        for(int i = 1; i <= m; i++){
                int x, y, w;
                cin >> x >> y >> w;
                v[x].push_back({y, w});
                v[y].push_back({x, w});
        }

        djk(s, d, cd);
        djk(t, f, cf);

        long long need = d[t];
        long long res = cd[t] * cf[s] % mod;
        for(int i = 1; i <= n; i++){
                if(d[i] * 2 == need && f[i] * 2 == need){
                        long long ways = cd[i] * cf[i] % mod;
                        res -= ways * ways % mod;
                }
                for(auto j: v[i]){
                        if(d[i] > d[j.fi] || d[i] + f[j.fi] + j.se != need){
                                continue;
                        }
                        long long L1 = min(d[i], d[j.fi]);
                        long long R1 = max(d[i], d[j.fi]);
                        long long L2 = min(f[i], f[j.fi]);
                        long long R2 = max(f[i], f[j.fi]);
                        if(L1 * 2 < need && need < R1 * 2 && L2 * 2 < need && need < R2 * 2){
                                long long ways = cd[i] * cf[j.fi] % mod;
                                res -= ways * ways % mod;
                        }
                }
        }

        res %= mod;
        res += mod;
        res %= mod;

        cout << res << "\n";
}


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

int main() {
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
    else if(n[1] == n[2] && n[2] == n[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
c=10**9+7
a = [-1 for _ in range(m + 1)]
for i in range(1, m+1):
    a[i] = int(input())
a =a+[n+1] 
for i in range(m+1):
    a[i]=a[i+1] - a[i]-1
b=[0 for _ in range(max(a) + 1)]
b[1]=1
for i in range(2, max(a)+1):
    b[i] = (b[i-1] + b[i-2])%c
s=1
for i in range(m+1):
    s=(s*b[a[i]])%c
print(s)

Measured memory_bytes: 7848
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    int ans=0;
    REP(i,st.size()){
        ans+=stoi(st.substr(i,1));
    }
    if(stoi(st)%ans){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)


Measured memory_bytes: 26780
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

class UFT {
private:
  vi data, rnk;

public:
  UFT(const int &size)
    : data(size), rnk(size) {
    iota(all(data), 0);
  }

  int root(const int &x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  bool same(const int &a, const int &b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    data[b] = a;
  }
};

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<tuple<int, int, int>> v;
    while (m--) {
      int t, s, d;
      cin >> t >> s >> d;
      v.emplace_back(t, --s, --d);
    }
    sort(all(v));
    UFT uf(n);
    rep(i, v.size()) {
      int s, d;
      tie(ignore, s, d) = v[i];
      if (uf.same(0, s)) uf.unite(0, d);
    }
    int c = 0;
    rep(i, n) c += uf.same(0, i);
    cout << c << endl;
  }
}

Measured memory_bytes: 4064
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 *fact = NULL;
i32 *iFact = NULL;
void init (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  i32 t = 1;
  i32 a = fact[n];
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = t;
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

void run (void) {
  i32 n, a, b, c, d;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32 "%" SCNi32 "%" SCNi32, &n, &a, &b, &c, &d);
  init (n);
  i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));
  i32 *pow = (i32 *) calloc (n + 1, sizeof (i32));
  dp[0] = 1;
  for (i32 i = a; i <= b; ++i) {
    pow[0] = 1;
    for (i32 j = 1; j <= n; ++j) {
      pow[j] = (i64) iFact[i] * pow[j - 1] % mod;
    }
    for (i32 j = n; j >= 1; --j) {
      i32 local = dp[j];
      for (i32 k = c; k <= d && k * i <= j; ++k) {
	i32 way = (i64) comb (j, k * i) * fact[k * i] % mod * pow[k] % mod * iFact[k] % mod;
	local = (local + (i64) way * dp[j - k * i]) % mod;
      }
      dp[j] = local;
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 128
const input = require("fs").readFileSync("/dev/stdin", "utf8")

function pow (x ,n) {
    let res = 1
    while (n > 0) {
        if (n & 1) res = mul(res, x)
        x = mul(x, x)
        n >>= 1
    }
    return res
}

function inv (x) {
    if (x == 1) return 1;
    return pow(x, mod - 2);
}

function mul (a, b) {
    return ((a >> 16) * b % mod * 65536 + (a & 65535) * b) % mod
}

const mod = 998244353

;(input => {
    const lines = input.split('\n')
    let [N, M, K] = lines[0].split(' ').map(Number)

    let ans = 0
    let fa = 1
    let fa2 = 1
    for (let k = 0; k <= K; k++) {
        fa = fa * (k || 1) % mod
        fa2 = fa2 * (k ? (N - k) : 1) % mod
        let left = mul(fa2, inv(fa)) % mod
        ans += mul(left, pow((M - 1), (N - (k + 1)))) * M % mod
    }

    console.log(ans % mod)
 
})(input)


Measured memory_bytes: 34496
#include <iostream>
#include <algorithm>
using namespace std;
 
int rec(int n, int p, int s) {
  if(s < 0) return 0;
  if(n == 0) return s == 0;
  int res = 0;
  for(; p <= 9; ++p) {
    res += rec(n-1, p+1, s-p);
  }
  return res;
}
 
int main() {
  int n, s;
  while(cin >> n >> s && (n|s)) {
    cout << rec(n,0,s) << endl;
  }
  return 0;
}

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

int main(){
	int n,s=1;
	cin >> n;
	
	while( n>=s ){
		int i=0,k=0,j=0,l=0;
		cin >> i >> k >> j;

		if( i<k ){
			l = i;
			i = k;
			k = l;
		}
		if( i<j ){
			l = i;
			i = j;
			j = l;
		}

		i = i*i;
		j = j*j;
		k = k*k;

		if( i==(j+k) ) cout << "YES" << "\n";
		else cout << "NO" << "\n";
		s++;
	}
}

Measured memory_bytes: 2916
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define acc(v) accumulate(v.begin(), v.end(),0);
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> above(n+1, 0);
  vector<int> below(n+1, 0);
  reps(i,1,n+1) {
    int a;
    cin >> a;
    above[i] = above[i-1] + a;
  }
  reps(i,1,n+1) {
    int a;
    cin >> a;
    below[i] = below[i-1] + a;
  }

  int res = -inf;
  reps(i,1,n+1) {
    int candy = 0;
    candy += above[i];
    candy += below[n] - below[i-1];
    res = max(res, candy);
    //cout << i << " => " << above[i] << " " << below[n] - below[i-1] << endl;
  }
  //print_array(above);
  //print_array(below);
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    int x=scn.nextInt();
    int x_=x;
    int n=scn.nextInt();
    ArrayList<Integer> p=new ArrayList<>();
    
    for(int i=0;i<n;i++){
      p.add(scn.nextInt());
    }
    Collections.sort(p);
    int a=0;
    int ans=x;
    
OUT: for(int i=0;i<p.size();i++){
      if(x<=p.get(i)||i>=p.size()){
        a=i;
        for(int j=a;j>=0;j--){
          if(x_-p.get(j)==0) x_--;
          else if(x_>p.get(j)) break;
        }
         a=Math.abs(x-x_);
         ans=x_;
         x_=x;
        
         for(int j=i;j<p.size();j++){
          if(x_-p.get(j)==0) x_++;
          else if(x_<p.get(j)||x_>x+a-1) break OUT;
          if(j>=p.size()-1) break OUT;
        }
      }
    }
    
    if(Math.abs(x_-x)<a) ans=x_;
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 35912
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
const int MAXT = 66000;
const int mod = 1e9 + 7;

struct strongly_connected{
	vector<int> gph[MAXN];
	vector<int> rev[MAXN];
	vector<int> dfn;
	int vis[MAXN], comp[MAXN];
	void clear(){
		memset(vis, 0, sizeof(vis));
		memset(comp, 0, sizeof(comp));
		dfn.clear();
		for(int i=0; i<MAXN; i++){
			gph[i].clear();
			rev[i].clear();
		}
	}
	void add_edge(int x, int y){ 
		gph[x].push_back(y);
		rev[y].push_back(x);
	}
	void dfs(int x){
		if(vis[x]) return;
		vis[x] = 1;
		for(auto &i : gph[x]) dfs(i);
		dfn.push_back(x);
	}
	void rdfs(int x, int p){
		if(comp[x]) return;
		comp[x] = p;
		for(auto &i : rev[x]) rdfs(i, p);
	}
	int get_scc(int n){
		int piv = 0;
		for(int i=0; i<n; i++) if(!vis[i]) dfs(i);
		reverse(dfn.begin(), dfn.end());
		for(auto &i : dfn) if(!comp[i]) rdfs(i, ++piv);
		return piv;
	}
};

struct twosat{
	strongly_connected scc;
	int n; // = number of clauses
	void init(int _n){ scc.clear(); n = _n; }
	int NOT(int x){ return x >= n ? (x - n) : (x + n); }
	void add_edge(int x, int y){ // input ~x to denote NOT
		if((x >> 31) & 1) x = (~x) + n;
		if((y >> 31) & 1) y = (~y) + n;
		scc.add_edge(x, y), scc.add_edge(NOT(y), NOT(x));
	}
	bool satisfy(vector<bool> &res){
		res.resize(n);
		scc.get_scc(2*n);
		for(int i=0; i<n; i++){
			if(scc.comp[i] == scc.comp[NOT(i)]) return 0;
			if(scc.comp[i] < scc.comp[NOT(i)]) res[i] = 0;
			else res[i] = 1;
		}
		return 1;
	}
}twosat;

int n;
struct pnt{ int pos, idx; }a[MAXN];

struct seg{
	int vtx_cnt = 0;
	int lim;
	int tree[MAXT];
	void init(int n){
		for(lim = 1; lim <= n; lim <<= 1);
		vtx_cnt = n / 2;
		for(int i=1; i<2*lim; i++){
			tree[i] = vtx_cnt++;
		}
		twosat.init(vtx_cnt);
		for(int i=2; i<2*lim; i++) twosat.add_edge(tree[i/2], tree[i]);
		for(int i=0; i<n; i++) twosat.add_edge(tree[i + lim], ~a[i].idx);
	}
	void query(int src, int s, int e){
		s += lim;
		e += lim;
		while(s < e){
			if(s % 2 == 1) twosat.add_edge(src, tree[s++]);
			if(e % 2 == 0) twosat.add_edge(src, tree[e--]);
			s >>= 1;
			e >>= 1;
		}
		if(s == e) twosat.add_edge(src, tree[s]);
	}
}seg;

bool trial(int l){
	int s = 0;
	seg.init(n*2);
	for(int i=0; i<2*n; i++){
		while(s < 2 * n && a[s].pos <= a[i].pos - l) s++;
		seg.query(a[i].idx, s, i - 1);
	}
	vector<bool> ok;
	return twosat.satisfy(ok);
}


int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		int x, y; scanf("%d %d",&x,&y);
		a[2*i] = {x, i};
		a[2*i+1] = {y, ~i};
	}
	sort(a, a + 2 * n, [&](const pnt &a, const pnt &b){
			return a.pos < b.pos;
			});
	int s = 0, e = 1e9;
	while(s != e){
		int m = (s + e+1) / 2;
		if(trial(m)) s = m;
		else e = m-1;
	}
	cout << s << endl;
}


Measured memory_bytes: 33276
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn=2e5+5;

int a[maxn];
int Abs(int x){return x>=0?x:-x;}
int main()
{
    int n,x,y,tn,d;
    scanf("%d%d%d",&n,&x,&y);
    tn=n-(y-x-1);
    for(int i=1;i<tn;i++)a[i]=tn-i;
    for(int i=x+1;i<y;i++)
    {
        d=min(i-x,y-i+1);
        for(int j=x;j>=1;j--)a[min(i-j,x-j+y-i+1)]++;
        d=min(y-i,i-x+1);
        for(int j=i+1;j<=n;j++)a[min(j-i,Abs(j-y)+i-x+1)]++;
    }
    for(int i=1;i<n;i++)printf("%d\n",a[i]);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  char s[100000];
  bool f[100000];
  while(scanf("%s",s),s[0]!='0'){
    memset(f,0,sizeof(f));
    int n = strlen(s);
    int ans = 0;
    for(int i=0;i<n;i++){
      if(f[i] || s[i] =='0') continue;
      int sum = 0;
      int count = 1;
      for(int j=i;j<n;j++){
        if(j % 2 == 0){
          sum += s[j] - '0';
        }
        else{
          sum -= s[j] - '0';
        }
        if(sum % 11 == 0){
          f[j+1] = true;
          ans += count;
          if(s[j+1] !='0')
            count++;
        }

        //printf(" %2d",sum);
        //cout/*<<j%2<<":"*/<<sum<<",";
      }
      //cout<<endl;
      //cout<<ans<<endl;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

int main() {
  int n, l, r;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  l = a[n - 1];
  r = a[0];
  for (int i = 1; i < n - 1; i++)
    if (abs(l / 2. - a[i]) < abs(l / 2. - r))
      r = a[i];

  cout << l << " " << r;
  return 0;
}

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

using namespace std;

vector<int> a;

bool comp(int i, int j) {
  return a[i - 1] < a[j - 1];
}

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

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

  sort(indices.begin(), indices.end(), comp);

  for (int i = 0; i < N; ++i) {
    if (i > 0)
      cout << " ";
    cout << indices[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1536
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, p = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [1, 0]
    for a in A:
        if a & 1:
            s = sum(dp)
            dp = [s, s]
        else:
            dp = [dp[0] * 2, dp[1] * 2]

    print(dp[p])
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
    int N;
    int64_t C, K;
    cin >> N >> C >> K;

    vector<int64_t> T(N);
    for(auto& c : T) cin >> c;

    sort(T.begin(), T.end());

    int f = 0;
    int l = 0;
    int ans = 0;
    while(f < N){
        if(T[f] + K < T[l]){
            f = l;
            ++ans;
            ++l;
        }
        else if(l - f + 1 == C){
            ++l;
            f = l;
            ++ans;
        }
        else ++l;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,Q;
    int b,c;
    ll sum=0;
    cin>>N;
    map<int,int>a;

    for(int i=0;i<N;i++){
        cin>>b;
        a[b]++;
        sum+=b;
    }
    cin>>Q;
    vector<int>B(Q);
    vector<int>C(Q);
    for(int i=0;i<Q;i++){
        cin>>B.at(i)>>C.at(i);
    }
    for(int i=0;i<Q;i++){
        if(a.count(B.at(i))){
            sum+=(C.at(i)-B.at(i))*a[B.at(i)];
            a[C.at(i)]+=a[B.at(i)];
            a[B.at(i)]=0;
        }
        cout<<sum<<endl;
    }
}

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

int main(int argc, char const *argv[]){
    char S[200000];
    scanf("%s",S);
    int N=strlen(S);
    int SS[N];
    int A[N],B[N];
    for (size_t i = 0; i <N; i++){
        A[i]=(i+1)%2;
        B[i]=i%2;
        SS[i]=S[i]-'0';
    }
    int ansA,ansB;
    ansA=0;ansB=0;
    for (size_t i = 0; i < N; i++){
        if (SS[i]!=A[i]){
            ansA++;
        }
        if (SS[i]!=B[i]){
            ansB++;
        }
    }
    int ans=ansA;
    if (ans>ansB){
        ans=ansB;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1408
let get_citation l =
  let rec loop p c = function
      [] -> p::c
    | hd::tl ->if (snd p)+1 = hd then
                  loop (fst p, hd) c tl
                else
                  loop (hd,hd) (p::c) tl
  in loop (-1,-1) [] l
;;

let print_citation t =
  if (fst t) = (snd t) then
    Printf.printf "%d" (fst t)
  else
    Printf.printf "%d-%d" (fst t) (snd t)
;;

let () =
  let rec read () =
    let n = read_int () in
    if n != 0 then
      begin
        let l = read_line ()
                |> Str.split (Str.regexp " ")
                |> List.map int_of_string in
        let ct = get_citation l |> List.rev in
        let len = List.length ct in
        List.iteri
          (fun i x ->
            if fst x != -1 then begin
                print_citation x;
                if i = len-1 then Printf.printf "\n" else Printf.printf " "
              end
          ) ct;
        read ()
      end
  in read ()
;;

Measured memory_bytes: 3336
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  int a, b;
  cin >> a >> b;

  int ret = 0;
  FOR(i, a, b+1) {
    string t = to_string(i);
    bool flag = true;
    REP(j, t.size()/2) if(t[j] != t[t.size()-j-1]) flag = false;
    if(flag) ret++;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main()
{
    vector<int> V = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int N;
    cin >> N;

    cout << V.at(N - 1) << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
import math

#残差最小化の解
x = sum(a)/N
x_large = math.ceil(x)
x_small = math.floor(x)

#大きい残差と小さい残差を計算
sum_large = 0
sum_small = 0
for i in a:
	sum_large += (x_large-i)**2
	sum_small += (x_small-i)**2
#最小残差
print(min(sum_large,sum_small))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define st first
#define nd second

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

int main(){
	ll n, k;
	scanf("%lld %lld", &n, &k);
	ll x = n % k;
	printf("%lld", min(x, k - x));

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k; cin >> n >> k;
    vec<ll> p(n); rep(i,n)cin >> p[i];
    sort(p.begin(),p.end());
    ll ans = 0;
    rep(i,k){
        ans += p[i];
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n,q,h,s,d; cin >> q>>h>>s>>d;
  vector<ll> v;
  v.push_back(4*q);
  v.push_back(2*h);
  v.push_back(s);
  auto min_val = *min_element(all(v));
  cin >> n;
  ll out = 0LL;
  if(n>=2){
    ll val = min(2*min_val, d);
    out += val*(n/2);
    out += min_val*(n%2);
  } else {
    out += min_val;
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int x[10004], y[10004];
vector<int> g[10004];
bool c[10004];

bool dfs(int s) {
    for (int i : g[s]) if (!c[i]) {
        c[i] = 1;
        if (!y[i] || dfs(y[i])) {
            x[s] = i; y[i] = s;
            return true;
        }
    }
    return false;
}


int main() {
    ios::sync_with_stdio(false);
    int n, m, k, u, v, z = 0;
    string s[102] = {};
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (s[i][j] == '.' && (i + j) % 2 == 0) {
        if (i && s[i - 1][j] == '.') g[i * m + j + 1].push_back(i * m + j + 1 - m);
        if (i + 1 < n && s[i + 1][j] == '.') g[i * m + j + 1].push_back(i * m + j + 1 + m);
        if (j && s[i][j - 1] == '.') g[i * m + j + 1].push_back(i * m + j + 1 - 1);
        if (j + 1 < m && s[i][j + 1] == '.') g[i * m + j + 1].push_back(i * m + j + 1 + 1);
    }
    for (int i = 1; i <= n * m; i++) {
        for (int j = 1; j <= n * m; j++) c[j] = 0;
        if (dfs(i)) z++;
    }
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (x[i * m + j + 1]) {
        if (i && x[i * m + j + 1] == i * m + j + 1 - m) s[i][j] = '^', s[i - 1][j] = 'v';
        if (i + 1 < n && x[i * m + j + 1] == i * m + j + 1 + m) s[i][j] = 'v', s[i + 1][j] = '^';
        if (j && x[i * m + j + 1] == i * m + j + 1 - 1) s[i][j] = '<', s[i][j - 1] = '>';
        if (j + 1 < m && x[i * m + j + 1] == i * m + j + 1 + 1) s[i][j] = '>', s[i][j + 1] = '<';
    }
    cout << z << '\n';
    for (int i = 0; i < n; i++) cout << s[i] << '\n';
}


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

#define MAX 2000000
#define INFTY 999999

int H, A[MAX+1];

void swap(int A,int B){

  int t;
  t=A;
  A=B;
  B=t;
  
}

void maxHeapify(int i) {

  int l,r,largest;
  int t;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    t=A[i];
    A[i]=A[largest];
    A[largest]=t;
    maxHeapify(largest);
  }
}

int extract() {

  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;

}

void increaseKey(int i, int key) {

  int t;

  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    
    t=A[i];
    A[i]=A[i/2];
    A[i/2]=t;
    i = i / 2;
  }
  
}

/*
void insert(int key) {

  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
  
}
*/

int print(char com[]){

  int key;
  
  if ( com[0] == 'e' && com[1] == 'n' ) return -1;
  if ( com[0] == 'i' ) {

    scanf("%d", &key);

    H++;
    A[H] = -INFTY;
    increaseKey(H, key);

  }
  else {
    printf("%d\n", extract());
  }

  return 0;
}

int main() {

  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if(print(com)==-1) break;    
  }
  return 0;
  
}



Measured memory_bytes: 5620
x1, y1, x2, y2 = map(int, input().split())

X = x2 - x1
Y = y2 - y1
x3 = x2 - Y
y3 = y2 + X
x4 = x1 - Y
y4 = y1 + X

print(x3, y3, x4, y4)

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

using namespace std;

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

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

  vector<int> x, y;
  for(int i = 0; i < m; i++) {
    if(a[i] == 1) {
      x.push_back(b[i]);
    }
    if(b[i] == n) {
      y.push_back(a[i]);
    }
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  for(int i = 0; i < x.size(); i++) {
    if(binary_search(y.begin(), y.end(), x[i])) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2812
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long
#define pii pair<intt,intt>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;

/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    string s, t;
    cin >> s >> t;
    for (intt i = s.size() - 1; i >= 0; i--) {
        if (i + t.size() - 1 < s.size()) {
            intt ok = 1;
            for (intt j = i; j <= i + t.size() - 1; j++) {
                if (s[j] == '?' || s[j] == t[j - i]) {
                    ///;
                } else {
                    ok = 0;
                    break;
                }
            }
            if (ok == 1) {
                for (intt j = i; j <= i + t.size() - 1; j++) {
                    if (s[j] == '?') {
                        s[j] = t[j - i];
                    }
                }
                for (intt j = 0; j < s.size(); j++) {
                    if (s[j] == '?') {
                        s[j] = 'a';
                    }
                }
                cout << s << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char a;
    cin >> a;
    if(isupper(a)){
        cout << "A\n";
    }else{
        cout << "a\n";
    }
    return 0;
}


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

int main() {
  string S;
  int a;
  cin >>S;
  a = S.size();
  for(int i=0; i<a;i=i+2){
    if(S.at(i)=='L'){
      cout <<"No" <<endl;
      return 0;
    }
    else{
      continue;
    }
  }
  for(int i=1; i<a;i=i+2){
    if(S.at(i)=='R'){
      cout <<"No" <<endl;
      return 0;
    }
    else{
      continue;
    }
  }
  cout <<"Yes" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 305;
const ll INF = 1e18;

map<ll, int> zip;
VL unzip;
void compress_coordinate(VL x){
    int n = x.size();
    REP(i,n) unzip.push_back(x[i]);
    sort(ALL(unzip));
    unzip.erase(unique(ALL(unzip)), unzip.end());
    REP(i,unzip.size()) zip[unzip[i]] = i;
}

int main() {
    int n, k;
    cin >> n >> k;
    VL h(n);
    REP(i,n){
        h[i] = in();
    }
    VL x(h);
    x.push_back(0);
    compress_coordinate(x);
    int m = zip.size();

    vector<VVL> dp(n + 1, VVL(m, VL(k + 1, INF)));
    dp[0][0][0] = 0;
    REP(i,n) REP(x,k+1){
        VL mi(m, INF), mi2(m, INF);
        REP(j,m){
            mi[j] = dp[i][j][x] - unzip[j];
            if (j) chmin(mi[j], mi[j - 1]);
        }
        FORR(j,m-1,0){
            mi2[j] = dp[i][j][x];
            if (j < m - 1) chmin(mi2[j], mi2[j + 1]);
        }
        REP(j,m){
            int y = x + (j != zip[h[i]]);
            if (y > k) continue;
            dp[i + 1][j][y] = min(mi[j] + unzip[j], mi2[j]);
        }
    }
    ll ans = INF;
    REP(j,m) REP(x,k+1) chmin(ans, dp[n][j][x]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 218880
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
int n,t,a;
cin>>n>>t>>a;
double h[n];
double min = 10000;
int ans = -1;
REP(i,n){
  int x;
  cin>>x;
  h[i] = abs(a-(t-(double)x * 0.006));
  if(h[i]< min){
    min = h[i];
    ans = i;
  }
}

cout<<ans+1<<endl;

  return 0;
}

Measured memory_bytes: 256