akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int K = cin.nextInt();
        long[] A = cin.ArrayLong(K);
        Array.Reverse(A);
        long min = 2;
        long max = 2;
        foreach (var now in A)
        {
            if (min % now != 0) min += now - (min % now);
            if (max % now != 0) max -= (max % now);
            if(min > max)
            {
                Console.WriteLine(-1);
                return;
            }
            max += now - 1;
        }
        Console.WriteLine(min + " " + max);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 25312
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
    int i,j,a,b,c,d;
    char s[100];
    char t[100];
    scanf("%s",s);
    scanf("%s",t);
    a=strlen(s);
    b=strlen(t)-1;
    while(a--)
    {
        if(strcmp(s,t)==0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            c=s[b];
            for(i=b;i>0;i--)
                s[i]=s[i-1];
            s[0]=c;

        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main() {
	int N, Y;
	cin >> N >> Y;
	for(int i = 0; i <= N; i++){
		for(int j = i; j <= N; j++){
			int sum = 10000 * i + 5000 * (j - i) + 1000 * (N - j);
			if(sum == Y){
				cout << i << " " << j - i << " " << N - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
l = list(map(int, input().split()))
n = l[0]  # no of things he has to make
x = l[1]  # no of things he can make at a time
t = l[2]  # time taken for each set to be made = t
# 20 12 6 = 12
count = 0
while n > 0:
    n -= x
    count += t
print(count)


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

bool obs[1000][1000];
bool visited[1000][1000];

const int OFFS = 100;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    vector<int> ans;
    while(1){
        int t, n; cin >> t >> n;
        if(n == 0 && t == 0) break;

        memset(obs, false, sizeof obs);
        memset(visited, false, sizeof visited);

        for(int i=0;i<n;i++){
            int ox, oy; cin >> ox >> oy;
            obs[ox + OFFS][oy + OFFS] = true;
        }

        int sx, sy; cin >> sx >> sy;
        sx += OFFS;
        sy += OFFS;

        int cnt = 0;
        // BFS
        queue<pair<pair<int, int>, int> > Q; // (x, y) and step
        visited[sx][sy] = true;
        Q.push(make_pair(make_pair(sx, sy), 0));
        while(!Q.empty()){
            cnt++;
            auto p = Q.front();
            Q.pop();
            int px = p.first.first, py = p.first.second, cstep = p.second;
            for(int k=0;k<6;k++){
                int nx = px + dx[k], ny = py + dy[k];
                if(!visited[nx][ny] && !obs[nx][ny] && cstep + 1 <= t){
                    visited[nx][ny] = true;
                    // cout << nx - OFFS << " " << ny - OFFS << endl;
                    Q.push(make_pair(make_pair(nx, ny), cstep + 1));
                }
            }
        }
        ans.push_back(cnt);
    }
    for(ll a: ans) cout << a << endl;
}


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

long long n, x, ans = 1e18, a[2005], dp[2005][2005];

int main()
{
    scanf("%lld%lld", &n, &x);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = a[i];
        for (int j = 1; j < n; j++)
        {
            int now = i - j;
            if (now < 1)
                now += n;
            dp[i][j] = min(dp[i][j - 1], a[now]);
        }
    }
    for (int j = 0; j < n; j++)
    {
        long long sum = j * x;
        for (int i = 1; i <= n; i++)
            sum += dp[i][j];
        ans = min(sum, ans);
    }
    printf("%lld", ans);
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s;
	ll ans = 0;

	cin >> s;

	REP(i, 3) {
		if (s[i] == '1') {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	set<int> st;
	rep(i, n) {
		int a; cin >> a;
		st.insert(a);
	}
	dunk(st.size());
	return 0;
}

Measured memory_bytes: 256
s = input()
a, b = int(s[:2]), int(s[2:])

if (a==0 or a>12) and (b==0 or b>12): print("NA")
elif (a==0 or a>12) and b<=12: print("YYMM")
elif a<=12 and (b==0 or b>12): print("MMYY")
elif a<=12 and b<=12: print("AMBIGUOUS")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;

vector<pair<ll, int>> factorize(ll x){
	vector<pair<ll, int>> res;
	for(ll i = 2; i * i < x; i++){
		if(x % i) continue;
		res.emplace_back(i, 0);
		while(x % i == 0){
			x /= i;
			res.back().second++;
		}
	} 
	if(x != 1) res.emplace_back(x, 1);
	return res;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll a, b; cin >> a >> b;
	ll g = __gcd(a, b);
	auto f = factorize(g);
	ll ans = f.size() + 1;
	cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
string s;
cin >> s;
int ind;
    string ss = "";
    for (char c : s) {
        if (c == 'T' && !ss.empty() && ss.back() == 'S')
            ss.pop_back();
        else
            ss.push_back(c);
    }
cout << ss.length() << "\n";
    return 0;
}

Measured memory_bytes: 776
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

d = int(input())
c = lmp()
s = []
for i in range(d):
    s.append(lmp())
t = []
for i in range(d):
    t.append(int(input()))
last = [0] * 26
ful = 0
for i in range(d):
    tar = t[i]-1
    ful += s[i][tar]
    last[tar] = i+1
    for j in range(26):
        ful -= c[j]*(i+1-last[j])
    print(ful)







Measured memory_bytes: 68496
SIZE=5000; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

s, = map(int,read().split())

ans = 0
for c in range(1,2001):
    ans += choose(c+s-3*c-1,c-1)

print(ans%MOD)




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

typedef long long int lli;

const lli MOD = 1e9 + 7;
const lli N = 1e6 + 5;
lli n;
lli dp[N+1];

int main() {
	cin >> n;

	dp[1] = n;
	dp[2] = n*n % MOD;
	lli sum = dp[1] + dp[2];
	sum %= MOD;
	for(lli i = 3; i <= n; i++) {
		dp[i] = (n-1)*(n-1) + sum - dp[i-2] + n - i + 2;
		dp[i] += MOD;
		dp[i] %= MOD;
		sum += dp[i];
		sum %= MOD;
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>



using namespace std;


int main(){

    string s1,s2;cin >> s1 ; cin >> s2;
    int counter = 0;
    for(int i = 0;i<s1.length();i++){
        if(s1[i] != s2[i]){
            counter++;
        }
    }
    cout << counter ;
}


Measured memory_bytes: 3856
import sys
input=sys.stdin.readline

N,Q=map(int,input().split())
L=[[]for i in range(N+1)]
for i in range(N-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
    
S=[0 for i in range(N+1)]
for i in range(Q):
    p,x=map(int,input().split())
    S[p]+=x
    
ANS=[-1 for i in range(N+1)]
ANS[1]=S[1]
l=[]
for i in L[1]:
    l.append([i,1,S[1]])
    
for i in range(N-1):
    X=l[i][0]
    Y=l[i][1]
    Z=l[i][2]
    ANS[X]=Z+S[X]
    for j in L[X]:
        if ANS[j]<0:
            l.append([j,X,ANS[X]])
print(*ANS[1:])
        
    

Measured memory_bytes: 111152
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var t,a float64
	fmt.Scan(&n,&t,&a)

	ansTmp := 100000.0
	ans := 0
	for i := 0; i < n; i++{
		var h float64
		fmt.Scan(&h)
		tmp := t - h * 0.006
		if ansTmp > math.Abs(a-tmp) {
			ansTmp = math.Abs(a-tmp)
			ans = i + 1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;
  cin>>n;
  map<int,int> m;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    m[i-a[i]]++;
  }
  ll c=0LL;
  rep(i,n){
    c+=m[i+a[i]];
  }
  cout<<c;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	ll sum=0;
	vll a(n);
	rep(i, n){
		cin>>a[i];
		sum+=a[i];
	}
	vll ans(n);
	ans[0] = sum;
	for(int i=1; i<n; i+=2){
		ans[0] -= 2*a[i];
	}
	ans[1] = sum;
	for(int i=2; i<n; i+=2){
		ans[1] -= 2*a[i];
	}
	rep(i, n-2){
		ans[i+2] = ans[i] + 2*(a[i+1]-a[i]);
	}
	rep(i, n){
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int H,W;
		Scanner sc = new Scanner(System.in);
		while(true){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 || W == 0){
				break;
			}
			char [][] array = new char[H][W];
			sc.nextLine();
			for(int i = 0; i < H; i++){
				String line = sc.nextLine();
				for(int j = 0; j < W; j++){
					array[i][j] = line.charAt(j);
				}
			}
			int i = 0;
			int j = 0;
			boolean flag = true;
			boolean visit[][] = new boolean[H][W];
			while(flag){
				if(visit[i][j]){
					System.out.println("LOOP");
					flag = false;
					break;
				}
				visit[i][j] = true;
				switch(array[i][j]){
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case '^':
					i--;
					break;
				case 'v':
					i++;
					break;
				case '.':
					System.out.println(j+" "+i);
					flag = false;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 24216
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    res = 1
    for a in A:
        res *= a
        if res > 10 ** 18:
            print(-1)
            return
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  ll ix, iy, ih;
  cin >> n;
  vector<ll> x, y, h;
  REP(i, n) {
    cin >> ix;
    cin >> iy;
    cin >> ih;
    x.push_back(ix);
    y.push_back(iy);
    h.push_back(ih);
  }

  int cx, cy;
  int max_h = 0;
  REP(i, 101) {
    REP(j, 101) {
      int base_h;
      REP(k, n) {
        if (h[k] > 0) {
          base_h = h[k] + abs(i - x[k]) + abs(j - y[k]);
          break;
        }
      }
      bool right = true;
      REP(k, n) {
        int cmp_h = h[k] + abs(i - x[k]) + abs(j - y[k]);
        if (base_h != cmp_h && h[k] > 0 || cmp_h < base_h && h[k] == 0) {
          right = false;
          break;
        }
      }
      if (right && base_h > max_h) {
        cx = i;
        cy = j;
        max_h = base_h;
        break;
      }
    }
  }
  cout << cx << endl << cy << endl << max_h << endl;

}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int[] ans = new int[]{0,0,0,0};
        
        while(sc.hasNext()){
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(sc.nextInt());
            list.add(sc.nextInt());
            list.add(sc.nextInt());
            Collections.sort(list);
            int a = list.get(0);
            int b = list.get(1);
            int c = list.get(2);
            
            if(a+b <= c) break;
            if(a*a + b*b == c*c){
                ans[0]++;
                ans[1]++;
            }else if(a*a + b*b > c*c){
                ans[0]++;
                ans[2]++;
            }else{
                ans[0]++;
                ans[3]++;
            }
            
            
        }
        System.out.println( ans[0] + " " + ans[1] + " " + ans[2] + " " + ans[3]);
    }
}



Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
int A, B, C;
int main() {
    cin >> A >> B >> C;
    for(int i = 1; i <= B; ++i) {
        if(A*i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1788
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int main()
{
	string s, t;
	cin >> s;
	int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	if (a + b + c + d == 7)t = "*+*+*+*=7\n";
	if (a + b + c - d == 7)t = "*+*+*-*=7\n";
	if (a + b - c + d == 7)t = "*+*-*+*=7\n";
	if (a + b - c - d == 7)t = "*+*-*-*=7\n";
	if (a - b + c + d == 7)t = "*-*+*+*=7\n";
	if (a - b + c - d == 7)t = "*-*+*-*=7\n";
	if (a - b - c + d == 7)t = "*-*-*+*=7\n";
	if (a - b - c - d == 7)t = "*-*-*-*=7\n";
	t[0] = s[0], t[2] = s[1], t[4] = s[2], t[6] = s[3];
	cout << t;
}

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

int main() {
	int N,K;
	cin >>N >>K;
	int ans = 0;
	vector<int>D(N);
	for (int n = 0;n<N;++n) {
		int num;
		cin >> num;
		if (num >= K) {
			++ans;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3736
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>
 
using namespace std;
 
enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif
 
int a[200000];
ll sum[200001];
 
signed main() {
#ifndef CrafterKolyan
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    ll l = 1, r = 3;
    ll ans = LLONG_MAX;
    for (ll m = 2; m < n; ++m) {
        r = max(r, m + 1);
 
        while (l + 1 < m && abs(sum[m] - 2 * sum[l]) >= abs(sum[m] - 2 * sum[l + 1])) ++l;
        while (r + 1 < n && abs(sum[n] - 2 * sum[r] + sum[m]) >= abs(sum[n] - 2 * sum[r + 1] + sum[m])) ++r;
        ll a[4] = {
            sum[l],
            sum[m] - sum[l],
            sum[r] - sum[m],
            sum[n] - sum[r]
        };
        sort(a, a + 4);
        ans = min(ans, a[3] - a[0]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  for (int i = 0; i < N; ++i) cin >> X.at(i);
  
  int MIN = 100000000;
  for (int i = 1; i <= 100; i++) {
    int sum = 0;
    for (int x : X) sum += (x - i) * (x - i);
    
    if (sum < MIN) MIN = sum;
  }
  
  cout << MIN << endl;
}

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

typedef long long ll;

const int N = 200100;
int p[N];
int ans = 0;
int n;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int mn = INT_MAX;
    for (int i = 0; i < n; ++i) {
        if (p[i] <= mn) {
            ans++;
        }
        mn = min(mn, p[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long L,R;
    cin >> L >> R;
    if(R-L > 2020) cout << 0 << endl;
    else{
        long long ans = 2020;
        for(long long i = L; i <= R; i++){
            for(long long j = i+1; j <=R; j++){
                ans = min(ans,i*j%2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
using namespace std;

#define N 200002

int fdsu[N],sdsu[N];

vector<int> g[N];
bool isSorted[N];
int f(int *dsu,int x) {
  if(dsu[x]==x) {
    return x;
  }
  return dsu[x] = f(dsu,dsu[x]);
}
void merge(int *dsu,int x,int y,int bit=0) {
  x = f(dsu,x),y = f(dsu,y);
  if(x!=y) {
    if(g[x].size()>g[y].size()) {
      swap(x,y);
    }
    dsu[x] = y;
    if(bit) {
      while(!g[x].empty()) {
        g[y].push_back(g[x].back());
        g[x].pop_back();
      }
    }
  }
}
void solve() {
  int n,k,l;scanf("%d %d %d",&n,&k,&l);
  for(int i=n;i;--i) {
    fdsu[i] = i;sdsu[i] = i;
  }
  for(int i=k;i;--i) {
    int x,y;scanf("%d %d ",&x,&y);
    merge(fdsu,x,y);
  }
  for(int i=n;i;--i) {
    g[i].push_back(f(fdsu,i));
  }
  for(int i=l;i;--i) {
    int x,y;scanf("%d %d",&x,&y);
    merge(sdsu,x,y,1);
  }
  for(int i=1;i<=n;++i) {
    int id = f(sdsu,i);
    if(!isSorted[id]) {
      sort(g[id].begin(),g[id].end());
      isSorted[id] = true;
    }
    int x = f(fdsu,i);
    printf("%d ",
    int(lower_bound(g[id].begin(),g[id].end(),x+1) - lower_bound(g[id].begin(),g[id].end(),x))  );
  }
  putchar('\n');
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main() {
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	rep(i, k+1)rep(j, k+1) {
		if (s - i - j <= k && s - i - j >= 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    vector<vector<int>> dist(n, vector<int>(3, -1));
    dist[s][0] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(s, 0));
    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        int next_amari = (p.second + 1) % 3;
        for (auto v : graph[p.first])
        {
            if (dist[v][next_amari] == -1)
            {
                dist[v][next_amari] = dist[p.first][p.second] + 1;
                que.push(make_pair(v, next_amari));
            }
        }
    }
    if (dist[t][0] == -1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << dist[t][0] / 3 << endl;
    }
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,j,has;
char a[1010][1010],tem[1010][1010];
void geser()
{
	ll ii,jj;
	for(ii=1;ii<=n;ii++)
		for(jj=1;jj<=n;jj++)
			tem[ii][jj]=a[ii][jj];
	for(ii=1;ii<=n;ii++)
		for(jj=1;jj<=n;jj++)
			if(ii==1)
				a[ii][jj]=tem[n][jj];
			else
				a[ii][jj]=tem[ii-1][jj];
}
bool cek()
{
	ll ii,jj;
	for(ii=1;ii<=n;ii++)
		for(jj=1;jj<=n;jj++)
			if(a[ii][jj]!=a[jj][ii])
				return 0;
	return 1;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	for(i=1;i<=n;i++)
	{
		geser();
//		cout<<i<<"\n";
		if(cek())
			has+=n;
	}
	cout<<has<<"\n";
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  string s; cin >> s;
  int a = 0;
  if(s == "SSR" || s == "RSS" || s == "SRS" || s == "RSR") a = 1;
  if(s == "RRS" || s == "SRR" ) a = 2;
  if(s == "RRR") a = 3;
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;

// knapsack[i][j] :
// 0~i-番目まで荷物を選ぶとき
// 価値がjのとき
// 荷物の総重量の最小値

// 答えは, knapsack[n][0] ~ knapsack[n][100 * 1000]のうち
// <= Wとなる添字jのうち最大のもの

// 一般化できるポイント
// dp 更新において 計算量が大きすぎるときは
// まず, 添字の取替を考えよ

vector<vector<long long>> knapsack(110, vector<long long>(100010, INF));

template<class T> inline bool chmin(T &a, T b){
    
    if (a > b){
        a = b;
        return true;
    }
    else return false;
}

int main(void){
    int n, W;
    cin >> n >> W;
    
    vector<int> w(n), v(n);
    
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
    
    // initialization
    knapsack[0][0] = 0;
    
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 100000; j++){
            
            chmin(knapsack[i+1][j], knapsack[i][j]);
            
            if (j-v[i] >= 0) chmin(knapsack[i+1][j], knapsack[i][j-v[i]] + w[i]);
        }
    }
    
    int ans = 0;
    
    for (int i = 0; i <= 100000; i++){
        
        if (knapsack[n][i] <= W) ans = max(ans, i);
    }
    
    cout << ans << endl;
}


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


int main(){
	
	int a , b , res = 0 ;
	char op ;
	
	cin>>a>>op>>b;
	
	switch(op)
	{
		case '+':
			res = a + b ;
			break;
			
		case '-':
			res = a - b ;
			break;	
	}
	
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n,m;
	cin >> n >> m;
	vector<ll> a(n+5), b(n+5), c(m+5), d(m+5);
	REPS(i, n)cin >> a[i] >> b[i];
	REPS(i, m)cin >> c[i] >> d[i];
	REPS(i, n) {
		ll mh = INF;
		ll line = 1;
		REPS1(j, m) {
			ll can = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (mh > can) {
				line = j;
				mh = can;
			}
		}
		cout << line << endl;
	}
	
	return 0;
}

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

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

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

    const int TOTAL = 300000;

    int n, k;
    cin >> n >> k;

    segtree<int, op, e> seg(TOTAL + 1);
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        int l = max(0, a - k);
        int r = min(a + k, TOTAL);
        int ma = seg.prod(l, r + 1);
        seg.set(a, ma + 1);
    }
    cout << seg.all_prod() << '\n';
    return 0;
}


Measured memory_bytes: 8492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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 fact(ll n){
    ll ret=1;
    while(n){
        ret*=n;
        n--;
    }
    return ret;
}

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

    vector<ll> all_path(n);
    rep(i,n) all_path[i]=i;
    double sum=0;
    do{
        rep(i,n-1){
            sum+=sqrt(pow(x[all_path[i+1]]-x[all_path[i]],2)+pow(y[all_path[i+1]]-y[all_path[i]],2));
        }
    }while(next_permutation(all_path.begin(),all_path.end()));
    
    printf("%.7f\n",sum/fact(n));
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int m,k;cin>>m>>k;
  int i;
  if(m==1)
  {
    if(k==0)cout<<"0 0 1 1"<<endl;
    else cout<<-1<<endl;
  }
  else if(k>=(1<<m))
  {
    cout<<-1<<endl;
  }
  else
  {
    rep(i,(1<<m)-1)
    {
      if(i!=0)cout<<' ';
      if(i<k)cout<<i;
      else cout<<i+1;
    }
    cout<<' '<<k;
    for(i=(1<<m)-2;i>=0;i--)
    {
      cout<<' ';
      if(i>=k)cout<<i+1;
      else cout<<i;
    }
    cout<<' '<<k<<endl;
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> grid(2, vector<int>(n));
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> grid[i][j];
        }
    }
    int top = grid[0][0];
    int bottom = accumulate(grid[1].begin(), grid[1].end(), 0);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, top + bottom);
        if (i == n - 1) continue;
        top += grid[0][i + 1];
        bottom -= grid[1][i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a[32]={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 i;
cin>>i;
cout<<a[i-1]<<endl;	
	return 0;
}

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,n) for(int i=0;i<(n);i++)
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

#define INF 1000000

int main(){
  int N,Ma,Mb; cin>>N>>Ma>>Mb;
  vi A(N),B(N),C(N);
  int amax=1, bmax=1;
  rep(n,N){
    cin>>A[n]>>B[n]>>C[n];
    if(amax<A[n]) amax = A[n];
    if(bmax<B[n]) bmax = B[n];
  }

  int Na = N*amax, Nb = N*bmax;
  vector<vvi> dp(N+1, vvi(Na+1, vi(Nb+1, INF)));
  dp[0][0][0] = 0;

  rep(n,N)
    rep(a,Na+1)
      rep(b,Nb+1){
        if(dp[n][a][b]==INF) continue;
        dp[n+1][a][b] = min(dp[n+1][a][b], dp[n][a][b]);
        dp[n+1][a+A[n]][b+B[n]]
          = min(dp[n+1][a+A[n]][b+B[n]], dp[n][a][b] + C[n]);
      }

  int ans = INF;
  upto(a,1,Na+1,1)
    upto(b,1,Nb+1,1)
      if(a*Mb==b*Ma) ans = min(ans, dp[N][a][b]);

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

}

Measured memory_bytes: 27264
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int A, B, C;
    cin >> A >> B >> C;

    string ans = "NO";
    for(int k = A; k <= A * B; k += A){
        if(k % B == C) ans = "YES";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

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

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

int main() {
	
	
	int i, j;
	cin >> i >> j;

	if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10||i == 12) {

		if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12)cout << "Yes" << endl;
		else cout << "No" << endl;


	}
	else if (i == 2) {

		if (j == 2)cout << "Yes" << endl;
		else cout << "No" << endl;

	}
	else {
		if (j == 4 || j == 6 || j == 9 || j == 11 )cout << "Yes" << endl;
		else cout << "No" << endl;
	}





	return 0;
}

 

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

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

    for (int i=-120; i<120; ++i) {
        for (int j=-120; j<120; j++) {
            if (i*i*i*i*i - j*j*j*j*j == X) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll ans=0,a[N],b[N],x;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=N;i++)
	{
		ans+=(b[i]*(b[i]-1))/2;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans-b[a[i]]+1<<endl;
	}
 } 

Measured memory_bytes: 4736
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>

const char main_[] = {
	0x48, 0xc7, 0xc0, 0x00, 0x00, 0x00, 0x40,
	0x48, 0xff, 0xcf,
	0x48, 0x8b, 0x0c, 0xbe,
	0x48, 0xc7, 0xc2, 0x00, 0x00, 0x00, 0x00,
	0x48, 0x29, 0xca,
	0x48, 0x21, 0xd1,
	0x48, 0x39, 0xc1,
	0x73, 0x03,
	0x48, 0x89, 0xc8,
	0x48, 0x83, 0xff, 0x00,
	0x75, 0xde,
	0x48, 0xff, 0xc8,
	0xf3, 0x48, 0x0f, 0xb8, 0xc0,
	0xc3
};

int main(void){
	int fd = open("/dev/zero", O_RDONLY);
	int (*solve)(int, int[]) = mmap(NULL, sizeof main_, PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
	memcpy(solve, main_, sizeof main_);

	int n, a[210];
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", a + i);
	printf("%d\n", solve(n, a));

	close(fd);
	munmap(solve, sizeof main_);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		var p = Input();
		var n = p[0].ToInt();
		var k = p[1].ToInt();
		var s = p[2].ToLong();
		
		long ak = 1000000000;
		if(s == 1000000000)
		{
			ak = 1000000000 - 1;
		}
		for(int i = 0; i < n; i++)
		{
			if(i < k)
				Console.Write("{0} ", s);
			else
				Console.Write("{0} ", ak);
		}
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

int main () {
    int n;
    cin >> n;
    int M[n][n];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++){
        int id, k;
        cin >> id >> k;
        for (int j = 0; j < k; j++){
            int tmp;
            cin >> tmp;
            M[i][tmp-1] = 1;
        }
    }
    for (int i = 0; i< n; i++){
        for (int j = 0; j < n; j++){
            if (j < n - 1){
                cout << M[i][j] << " ";
            } else {
                cout << M[i][j] << endl;
            }
            
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <stdlib.h>

int main() {
    int r, g, b, nr;
    scanf("%d%d%d", &r, &g, &b);
    nr=r*100+g*10+b;
    if(nr%4==0)
       printf("YES");
    else
       printf("NO");
    return 0;
}

Measured memory_bytes: 128
import heapq

x, y, z, k = map(int, raw_input().split())
a = sorted(map(int, raw_input().split()))
b = sorted(map(int, raw_input().split()))
c = sorted(map(int, raw_input().split()))

q = []
memo = set()
def qpush(q, ai, bi, ci):
    if ai >= 0 and bi >= 0 and ci >= 0:
        t = (-(a[ai] + b[bi] + c[ci]), ai, bi, ci)
        if not t in memo:
            memo.add(t)
            heapq.heappush(q, t)

qpush(q, len(a) - 1, len(b) - 1, len(c) - 1)
for _ in range(k):
    s, ai, bi, ci = heapq.heappop(q)
    qpush(q, ai - 1, bi, ci)
    qpush(q, ai, bi - 1, ci)
    qpush(q, ai, bi, ci - 1)
    print -s


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> a;

i64 Z,W;

int main(){
  cin >> N >> Z >> W;
  a.resize(N);
  rep(i,0,N - 1) cin >> a[i];
  if(N == 1){
    cout << abs(a[N - 1] - W) << endl;
    return 0;
 }
  cout << max(abs(a[N - 1] - W) , abs(a[N - 2] - a[N - 1])) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>D(K);
  for(int i=0;i<K;i++){
      cin>>D[i];
  }
  for(int i=N;i<=10*N;i++){
      string s=to_string(i);
      int S=s.size();
      bool ok=true;
      for(int j=0;j<S;j++){
         for(int k=0;k<K;k++){
             if(s[j]-'0'==D[k]){ok=false;}
         }
      }
      if(ok){cout<<i<<endl;return 0;}
  }
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    int ans = 0;
    sort(p.begin(), p.end());
    for (int i = 0; i < k; i++)
        ans += p[i];

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


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

using namespace std;
#define ll long long int
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];

    }
    sort(a,a+n);
    int sum = 0;

    for(int i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
H, W = [int(i) for i in input().split()]
A = [input() for j in range(H)]

DH = set()
DW = set()

for h in range(H):
    for w in range(W):
        if A[h][w] == '#':
            DH.add(h)
            DW.add(w)

for h in range(H):
    if h in DH:
        for w in range(W):
            if w in DW:
                print(A[h][w], end='')
        print()

Measured memory_bytes: 4468
//
//  main.cpp
//  TP1_9-B
//
//  Created by Saicj on 2015/08/04.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;


int main(int argc, const char * argv[]) {

    std::vector<string> results;
    
    string str;
    int count;
    string shuffle;
    
    while (true) {
        
        cin >> str;
        
        if (str == "-"){
            break;
        }
        
        cin >> count;
        
        for (int i = 0; i < count; i++) {
            
            cin >> shuffle;
            
            int shuffleNum = atoi(shuffle.c_str());
            
            string left = str.substr(0, shuffleNum);
            string right = str.substr(shuffleNum, str.size());
            
            str = right + left;
        }
        cout << str << endl;
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



// youtube解説


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, k;
    cin >> n >> k;
    vector<pii> v(n);
    if (n % 2 == 0) {
        rep(i, n / 2) v[i * 2].F = i + 1;
        rep(i, n / 2) v[i * 2 + 1].F = n / 2 + i + 1;
        rep(i, n / 2) v[i * 2 + 1].S = n + i + 1;
        rep(i, n / 2) v[i * 2].S = n + n / 2 + i + 1;
        // rep(i, n) cout << v[i].F << " " << v[i].S << endl;
        vector<int> v2(n);
        rep(i, n) v2[i] = 2 * n + i + 1;
        rep(i, n) { v[i].F += k - 1; v[i].S += k - 1; v2[i] += k - 1; }
        rep(i, n) if (v[i].F + v[i].S > v2[i]) { cout << -1 << endl; return 0; }
        rep(i, n) cout << v[i].F << " " << v[i].S << " " << v2[i] << endl;
    } else {
        rep(i, n / 2 + 1) v[i * 2].F = i + 1;
        rep(i, n / 2) v[i * 2 + 1].F = n / 2 + i + 2;
        rep(i, n / 2) v[i * 2 + 1].S = n + i + 1;
        rep(i, n / 2 + 1) v[i * 2].S = n + n / 2 + i + 1;
        // rep(i, n) cout << v[i].F << " " << v[i].S << endl;
        vector<int> v2(n);
        rep(i, n) v2[i] = 2 * n + i + 1;
        rep(i, n) { v[i].F += k - 1; v[i].S += k - 1; v2[i] += k - 1; }
        rep(i, n) if (v[i].F + v[i].S > v2[i]) { cout << -1 << endl; return 0; }
        rep(i, n) cout << v[i].F << " " << v[i].S << " " << v2[i] << endl;
    }
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long int d;
    cin>>d;
    
    if(d==25){
        cout<<"Christmas";
    }
     if(d==24){
        cout<<"Christmas Eve";
    }
     if(d==23){
        cout<<"Christmas Eve Eve";
    }
     if(d==22){
        cout<<"Christmas Eve Eve Eve";
    }
    
    return 0;
}


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

int mx = 0x3f3f3f3f;
int cnt[3];
int ca, x;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		cnt[s[i] - 'a']++;
	}
	for (int i = 0; i < 3; i++) {
		ca += !!cnt[i];
		mx = min(mx, cnt[i]);
	}
	for (int i = 0; i < 3; i++) {
		cnt[i] -= mx;
		if (cnt[i] > 1) { 
			puts("NO");
			return 0;
		}
	}
	if (ca == 2 && s.length() == 2) {
		puts("YES");
	} else if (ca < 3 && s.length() > 1) {
		puts("NO");
	} else {
		puts("YES");
	}
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 MOD;

i64 dp[6060][2020];

int main()
{
	scanf("%d%lld", &N, &MOD);
	for (int i = 0; i <= N; ++i) dp[0][i] = 1;
	for (int i = 1; i <= 3 * N; ++i) {
		for (int j = 0; j <= N; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j > 0) {
				if (i >= 2) ADD(dp[i][j], dp[i - 2][j - 1] * (i - 1));
				if (i >= 3) ADD(dp[i][j], dp[i - 3][j - 1] * (i - 1) % MOD * (i - 2));
			}
		}
	}
	printf("%lld\n", dp[3 * N][N]);
	return 0;
}


Measured memory_bytes: 94976
#include<bits/stdc++.h>
using namespace std;
bool compare(int a, int b)
{
    if((a%10)>(b %10)) return true;
    return false;
}
int main()
{
    vector<int> v;
    int ans=0,a;
    for(int i=0;i<5;i++){
        cin>>a;
        if(a%10!=0) v.push_back(a);
        else ans+=a;
    }
    if(v.size()==0){ cout<<ans; return 0; }
    sort(v.begin(),v.end(),compare);
    for(int i=0;i<v.size()-1;i++){
       int b= v[i]/10;
       b++;
       ans+=b*10;
       
    }
    ans+=v[v.size()-1];
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
#define mod 1000000007;
long long jc(int x){
	long long n;
	if(x==1) return 1;
	else 
	{
		n=(x*jc(x-1))%mod;
	    return n;
	}
}

int main(){
	int d,m;
	long long sum;
	scanf("%d %d",&d,&m);
	if(d==m+1||m==d+1){
		sum=(jc(d)*jc(m))%mod;
		printf("%lld\n",sum);
	}
	else if(d==m){
		sum=((jc(d)*jc(m))*2)%mod;
		printf("%lld\n",sum);
	}
	else
		printf("0\n");
}

Measured memory_bytes: 1792