akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e2+5;
int n,m,k,mod,f[N][N],g[N][N],coef[N][N],C[N][N],pw[N][N*N];
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}
inline void dec(int& x,int y){x=x-y>=0?x-y:x-y+mod;}

int main(){
    //freopen("in.in","r",stdin);
    n=read(),m=read(),k=read(),mod=read();
    REP(i,0,N-1)REP(j,C[i][0]=1,N-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    REP(i,0,N-1)REP(j,pw[i][0]=1,N*N-1)pw[i][j]=1ll*pw[i][j-1]*i%mod;
    f[0][0]=1;
    REP(h,1,k){
	memset(g,0,sizeof g);
	REP(j,0,m)REP(l,0,n)coef[j][l]=1ll*pw[k-h+1][l*j]*pw[h][l*(m-j)]%mod;
	REP(i,0,n)REP(j,0,m)if(f[i][j]){
	    REP(l,0,n-i){
		int c=1ll*f[i][j]*C[n-i][l]%mod*coef[j][l]%mod;
		inc(g[i+l][j],c);
	    }
	}
	memset(f,0,sizeof f);
	REP(i,0,n)REP(l,0,m)coef[i][l]=1ll*pw[k-h+1][l*i]*pw[h][l*(n-i)]%mod;
	REP(i,0,n)REP(j,0,m)if(g[i][j]){
	    REP(l,0,m-j){
		int c=1ll*g[i][j]*C[m-j][l]%mod*coef[i][l]%mod;
		inc(f[i][j+l],c);
	    }
	}
	memset(g,0,sizeof g);
	REP(j,0,m)REP(l,0,n)coef[j][l]=1ll*pw[k-h][l*j]*pw[h][l*(m-j)]%mod;
	REP(i,0,n)REP(j,0,m)if(f[i][j]){
	    REP(l,0,n-i){
		int c=1ll*f[i][j]*C[n-i][l]%mod*coef[j][l]%mod;
		l&1?dec(g[i+l][j],c):inc(g[i+l][j],c);
	    }
	}
	memset(f,0,sizeof f);
	REP(i,0,n)REP(l,0,m)coef[i][l]=1ll*pw[k-h][l*i]*pw[h][l*(n-i)]%mod;
	REP(i,0,n)REP(j,0,m)if(g[i][j]){
	    REP(l,0,m-j){
		int c=1ll*g[i][j]*C[m-j][l]%mod*coef[i][l]%mod;
		l&1?dec(f[i][j+l],c):inc(f[i][j+l],c);
	    }
	}
    }
    printf("%d\n",f[n][m]);
    return 0;
}
/*
  $f_{h,i,j}=\sum_{x=0}^i\sum_{y=0}^j\binom{n-(i-x)}{x}\binom{m-(j-y)}{y}f_{h-1,i-x,j-y}h^{x(m-(j-y))+y(n-(i-x))-xy}\sum_{p=0}^x\sum_{q=0}^y(-1)^{p+q} \binom{x}{p}\binom{y}{q} (k-h)^{p(j-y)+q(i-x)+pq}(k-h+1)^{(x-p)(j-y)+(y-q)(i-x)+(x-p)(y-q)}$
 */


Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
    int A,B,T,i,bis;
    float act;
    while(scanf("%d %d %d",&A,&B,&T)!=EOF)
    {
        act=T+0.5;
        bis=0;
        for(i=A;i<=act;i+=A)
        {
            bis+=B;
        }
        printf("%d\n",bis);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int Y = sc.nextInt();

		String answer = "No";

		if(Y%2==0) {
			//そもそもの前提としてYは偶数
			for(int i = 0; i <= X; i++) {
				int leg = (2 * i) + (4 * (X - i));
				if(leg == Y) {
					answer = "Yes";
					break;
				}
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 27092
s = input()
k = int(input())

res=[]
for i in range(len(s)):
    num = ord(s[i])-97

    if i==len(s)-1:
        res.append(chr((num+k)%26+97))
    elif s[i] == "a":
        res.append("a")
    elif 26 - num <= k:
        res.append("a")
        k-=26-num
    else:
        res.append(s[i])

print("".join(res))

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) > abs(x - b))
    {
        cout << 'B' << "\n";
    }
    else
    {
        cout << 'A' << "\n";
    }
    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string s;
    cin >> s;
    
    int ac = 0;
    rep(i,s.size())
    {
        if(s[i] == 'o') ac++;
    }

    if(15 - s.size() + ac >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;

}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans;
  if ((b - a) % 2 == 0) {
    ans = (b - a) / 2;
  } else {
    ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;

typedef pair<int, int> P;

char itoc(int x) {
	return (int)'a' + x;
}

int ctoi(char c) {
	return (int)c - (int)'a';
}

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

	string S;
	cin >> S;
	int N = S.size();
	vector<int> a(26, 0);
	REP(i, N) a[ctoi(S[i])]++;
	if (N < 26) {
		int i = 0;
		while (a[i]) i++;
		S.push_back(itoc(i));
	}
	else {
		while (!S.empty()) {
			int i = ctoi(*(--S.end()));
			a[i++]--;
			S.pop_back();
			while (i < 26 && a[i])i++;
			if (i < 26) {
				S.push_back(itoc(i));
				break;
			}
		}
		if (S.empty()) S = "-1";
	}
	cout << S << "\n";

	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : ReversePoland.cpp
// Author      : koike
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <stack>
#include <sstream>

using namespace std;
const int BLOCK_LENGTH = 3;
const char PLUS = '+';
const char MINUS = '-';
const char POWER = '*';
const char NOT_BLOCK = 'n';
const char SPACE = ' ';
std::stack<int> numStack;


bool strIsDigit(string str) {
	try{
		stoi(str);
	}catch (std::invalid_argument e) {
		return false;
	}

	return true;
}

void calcStackNums(string ope) {

	int result = 0;
	const char* c_ope = ope.c_str();

	int var2 = numStack.top();
	numStack.pop();
	int var1 = numStack.top();
	numStack.pop();

	switch (c_ope[0]) {
		case PLUS:
			result = var1 + var2;
			break;
		case MINUS:
			result = var1 - var2;
			break;
		case POWER:
			result = var1 * var2;
			break;
		default:
			break;
	}

	numStack.push(result);
}

void calcPoland(vector<string> &formula) {

	string top;

	for (vector<string>::iterator it = formula.begin(); it != formula.end(); ++it)
	{
		if (strIsDigit(*it)) {
			numStack.push(stoi(*it));
		}
		else {
			calcStackNums(*it);
		}
	}
}


vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {

	string s;
	getline(cin, s);
	vector<string> formula = split(s,SPACE);

	calcPoland(formula);

	cout << numStack.top() << endl;

	return 0;
}

Measured memory_bytes: 3292
n = int(input())
a = list(map(int, input().split()))

cnt_1 = 0
base = 0
#奇数番目が正
for i in range(n):
    if ((base + a[i] >= 0) and (i % 2 == 1)) or ((base + a[i] <= 0) and (i % 2 == 0)):
        cnt_1 += (1 + abs(base + a[i]))
        base += a[i] + (1 + abs(base + a[i])) * (-1) ** i #調整後のa[0]~a[i]の和
    else:
      base += a[i] #調整後のa[0]~a[i]の和


cnt_2 = 0
base = 0
for i in range(n):
    if ((base + a[i] <= 0) and (i % 2 == 1)) or ((base + a[i] >= 0) and (i % 2 == 0)):
        #奇数番目が負
        cnt_2 += (1 + abs(base + a[i]))
        base += a[i] + (1 + abs(base + a[i])) * (-1) ** (i + 1)  #調整後のa[0]~a[i]の和
    else:
      base += a[i] #調整後のa[0]~a[i]の和

print(min(cnt_1, cnt_2))


Measured memory_bytes: 14468
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[5001];
int main(){
	int N;
	int ans = 0;
	while(cin>>N&&N){
		int index=0;
		ans = INT_MIN;
		FOR(i,1,N+1){
			cin>>sum[i];
			sum[i] += sum[i-1];
		}
		FOR(i,1,N+1){
			FOR(j,i,N+1){
				ans = max(ans,sum[j]-sum[i-1]);
			}
		}
		cout<< ans <<endl;
	}
}

Measured memory_bytes: 3028
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

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

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X,Y,Z;cin>>X>>Y>>Z;
	for(int i=0;;i++){
		int tmp=0;
		tmp+=i*Y;
		tmp+=(i+1)*Z;
		if(tmp>X){
			cout<<i-1<<endl;
			return 0;
		}
	}
	return 0;
}



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

int main(){
	int n, temp;
	cin >> n;
    int prev,maxc=0,count = 0;
    cin >> prev;
	for (int i=1;i<n;i++){
		cin >> temp;
		//cout << prev << " " <<temp << endl;
		if (temp <= prev) count++;
		else{
			//cout << maxc << " " << count << endl;
			maxc = max(maxc,count);
			count=0;
			
		}
		
		prev = temp;
		

	}
	maxc = max(maxc, count);
	cout << maxc;
		
}


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

int main(){
    using namespace std;
    int h, w;
    cin >> h >> w;
    while((h!=0)||(w!=0)){
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>

#define FILE_NAME "atcoder.agc026_c"
#define SZ(x) ((int) x.size())
#define pb push_back
#define ppb pop_back
#define x first
#define y second
#define mkp make_pair
#define show(x) cout << (#x) << ": " << x << endl

using namespace std;
// using namespace __gnu_pbds;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
template<typename T> using Array = vector<T>;
template<typename T> using Matrix = Array<Array<T>>;
using Graph = Matrix<int>;

// template<typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T> bool relax(T& r, const T& x) {
    if (x < r) {
        r = x;
        return true;    
    }
    return false;
}

template<typename T> bool heavy(T& h, const T& x) {
    if (h < x) {
        h = x;
        return true;            
    }
    return false;
}

const int DX[8] = {-1, +1, +0, +0, +1, -1, +1, -1};
const int DY[8] = {+0, +0, -1, +1, +1, -1, -1, +1};

/************************************************************
* find_by_order(k) = iterator to (k)-th greatest element    *
* order_of_key(k) = counts number of strictly less elements *
*************************************************************/                                                           

signed main() {
#ifdef LOCAL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<string, map<string, int>> cnt;
    for (int mask = 0; mask < (1 << n); mask++) {
        string s0 = "", s1 = "";
        for (int i = 0; i < n; i++)
            if (mask & (1 << i))
                s0 += s[i];
            else
                s1 += s[i];
        reverse(s1.begin(), s1.end());
        cnt[s0][s1]++;                                        
    }
    ll ans = 0;
    for (int submask = 0; submask < (1 << n); submask++) {
        ll mask = ((ll) submask << n);
        string s2 = "", s3 = "";
        for (int i = n; i < 2 * n; i++)
            if (mask & (1ll << i))                    
                s2 += s[i];
            else
                s3 += s[i];
        reverse(s3.begin(), s3.end());
        ans += cnt[s3][s2];                    
    }
    cout << ans;
    return false;
}

Measured memory_bytes: 119552
from collections import Counter
n = int(input())
L1 = list(map(int,input().split()))
m = int(input())
L2 = list(map(int,input().split()))
li1 = Counter(L1)
li2 = Counter(L2)

flag = False
for i in range(m):
    if li1[L2[i]] >= li2[L2[i]]:
        flag = True
    else:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

struct Edge{
   ll to;
   ll cost;
};
vector<vector<Edge> >e;
vector<bool>used;
vector<ll>d;

void dfs(int now,ll res){
   d[now]=res;
   ll ans = 0;
   used[now]=true;
   for(auto it:e[now]){
      if(used[it.to])continue;
      dfs(it.to,res+it.cost);
   }
   return;
}

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

   int N;
   cin>>N;
   e.resize(N+1);
   used.resize(N+1,false);
   for(int i=0;i<N-1;i++){
      ll a,b,c;
      cin>>a>>b>>c;
      Edge e1 = {.to=b,.cost=c};
      e[a].push_back(e1);
      Edge e2 = {.to=a,.cost=c};
      e[b].push_back(e2);
   }
   int Q,K;
   cin>>Q>>K;
   vector<pair<int,int> >query(Q);
   for(int i=0;i<Q;i++){
      pair<int,int>p;
      cin>>p.first>>p.second;
      query[i]=p;
   }

   d.resize(N+1);
   fill(used.begin(),used.end(),false);
   dfs(K,0);

   for(int q=0;q<Q;q++){
      
      int s = query[q].first;
      int g = query[q].second;
      cout<<d[s]+d[g]<<endl;

   }
   return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
#include <math.h>

	
using namespace std;
long long MOD=1000000007;

int main(){
	int M,D;
	cin>>M>>D;
	int ans=0;
	for(int m=1;m<=M;m++){
		for(int d=1;d<=D;d++){
			int d10=d/10;
			int d1=d%10;
			if(d10>1 && d1 >1 && d1*d10==m)ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

const int IN = 100000000;

// Binary Indexed Tree (Fenwick Tree)
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  // 0-indexed
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  // 0-indexed
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  // 半開区間
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
int main(){
    ll N, D, A; cin >> N >> D >> A;

    vector<pair<ll,ll>> XH(N);
    rep(i,N) cin >> XH[i].first >> XH[i].second;

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

    ll ans = 0;
    BIT<ll> bit(N+1);
    rep(i,N){
        ll x = XH[i].first;
        ll h = XH[i].second;
        h -= bit.sum(i);
        if (h <= 0) continue;
        ll num = (h+(A-1))/A;
        ans += num;
        ll damage = num*A;
        bit.add(i,damage);
        ll right_end = min(x+D*2, INF);        
        pair<ll, ll> right = make_pair(right_end+1, -1);
        int j = lower_bound(XH.begin(), XH.end(), right) - XH.begin();
        bit.add(j, -damage);
    }

    cout << ans << endl;


}

Measured memory_bytes: 7920
import numpy as np

n = int(input())
n = np.array(list(map(int, input().split())))
n_sort = np.sort(n)[::-1]
alice=0
bob=0

#print(np.sort(n)[::-1])
#print(len(n))

for i in range(len(n_sort)) :
  if i % 2 == 0 :
    alice = alice + n_sort[i]
  else :
    bob = bob + n_sort[i]

#print(alice)
#print(bob)
print(alice - bob)

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a')
    cout << "vowel" << endl;
  else if (c == 'i')
    cout << "vowel" << endl;
  else if (c == 'u')
    cout << "vowel" << endl;
  else if (c == 'e')
    cout << "vowel" << endl;
  else if (c == 'o')
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;

}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int maxi = 0;
    rep(i, n) {
        cin >> a[i];
        maxi = max(maxi, a[i]);
    }
    int k = 0, half = maxi / 2;
    for (int i = 0; i < n; i++) {
        if (a[i] == maxi) continue;
        if (abs(half - a[i]) < abs(half - k)) {
            k = a[i];
        }
    }
    printf("%d %d\n", maxi, k);
}

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

const int N =1300;

int main(void)
{ 
   
      char str[N];
      while(fgets(str , 1300 , stdin))
      {
      	for(int i =0 ; i < strlen(str);i++)
      	{
      		if(str[i]>='A' && str[i] <='Z')
      		{
      			printf("%c",str[i]+32);
			  }
			else if(str[i] >= 'a' && str[i]<='z')
			{
				printf("%c",str[i]-32);
			  }  
			  
			 else
			 {
			 	printf("%c",str[i]);
			  } 
		  }
	  }
}


Measured memory_bytes: 2628
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
	int a[200000];
	for (int i = 0; i < n; ++i){
		cin>>a[i];
		a[i]-=(i+1);
	}

	sort(a,a+n);
	int x=a[n/2];
	long sum=0;
	for (int i = 0; i < n; ++i){
		sum+=abs(a[i]-x);
	}

	cout<<sum<<endl;

}


Measured memory_bytes: 1024
ryo=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
cnt=int(input())

for i in range(cnt):
    b,f,r,v=map(int,input().split())
    ryo[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' '+str(ryo[i][j][k]),end="")
        print()
    if i<3:
        print("#"*20)


Measured memory_bytes: 5624
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;

	int s = 0, m = 0;

	for (int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		s += p;
		m = max(m, p);
	}

	int ans = s - m / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
d={}
for x in range(n):
  key=input()
  if key not in d:
    d[key]=0
  d[key]+=1
  
values=d.values()
a=max(values)
b=[]
for y in d:
  if d[y]==a:
    b.append(y)
    
b=sorted(b)
for r in b:
  print(r)

Measured memory_bytes: 35736
import sys
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


d1 = [None] * (N+1)
dn = [None] * (N+1)


def dfs(v, d, d_list):
    d_list[v] = d
    for nv in G[v]:
        if d_list[nv] is None:
            dfs(nv, d+1, d_list)

dfs(1, 0, d1)
dfs(N, 0, dn)

cnt = 0
for i in range(1, N+1):
    if d1[i] <= dn[i]:
        cnt += 1
    else:
        cnt -= 1

print('Fennec' if cnt > 0 else 'Snuke')


Measured memory_bytes: 215840
import math

def a():
    x = list(map(int, input().split()))
    print(x.index(0) + 1)


def b():
    x, y = map(int, input().split())
    if x * 2 <= y <= x * 4 and y % 2 == 0:
        print('Yes')
    else:
        print('No')



def c():
    print('')



def d():
    print('')


b()

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    vector<int> v;
    for (auto x : mp)
    {
        cerr << x.first << " " << x.second << endl;
        v.push_back(x.second);
    }
    sort(ALL(v));
    int ans = 0;
    rep(i, mp.size() - k)
    {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10748
x, y = map(int, input().split())
if x == y:
    ans = 0
elif x == 0 and y != 0:
    if y < 0:
        ans = -y + 1
    else:
        ans = y
elif x != 0 and y == 0:
    if x < 0:
        ans = -x
    else:
        ans = x + 1
elif x < y:
    if x < 0 < y:
        if y < abs(x):
            ans = min(y - x, abs(x) - y + 1)
        else:
            ans = y + x + 1
    else:
        ans = y - x
else:
    if y < 0 < x:
        if x < abs(y):
            ans = -(y + x) + 1
        else:
            ans = y + x + 1
    elif 0 < y < x:
        ans = y + x
    else:
        ans = -(y - x) + 2

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int N, M;
LL fac[500001], dp[500001];

LL p(LL a, LL b) {
	if (b == 0) return 1;
	LL cnt = p(a, b / 2);
	cnt = (cnt * cnt) % MOD;
	if (b % 2) cnt *= a;
	cnt %= MOD;
	return cnt;
}

LL P(int n, int r) {
	if (r == 0) return 1;
	LL cnt = fac[n];
	cnt *= p(fac[n - r], MOD - 2);
	cnt %= MOD;
	return cnt;
}

LL C(int n, int r) {
	if (r == 0 || r == n) return 1;
	LL cnt = fac[n];
	cnt *= p(fac[n - r], MOD - 2);
	cnt %= MOD;
	cnt *= p(fac[r], MOD - 2);
	cnt %= MOD;
	return cnt;
}

int main() {
	fac[0] = 1;
	for (int i = 1; i < 500001; i++) {
		fac[i] = (fac[i - 1] * i) % MOD;
	}
	scanf("%d%d", &N, &M);
	LL ans = (P(M, N) * P(M, N)) % MOD;
	for (int i = N; i >= 1; i--) {
		if (i == N) dp[i] = P(M, N);
		else {
			LL cnt = (P(M, N) * C(N, i)) % MOD;
			cnt *= P(M - i, N - i);
			cnt %= MOD;
			cnt -= dp[i + 1];
			while (cnt < 0) cnt += MOD;
			dp[i] = cnt;
		}
	}
	ans -= dp[1];
	while (ans < 0) ans += MOD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 11612
#include <stdio.h>

int main()
{
    int H,W;
    int i,j;
    
    while(1){
        scanf("%d %d", &H, &W);\
        if(H == 0&& W ==0){
            break;
        }
        for(i =0;i<H;i++){
            printf("#");
            for(j=0;j<W-2;j++){
                if(i ==0||H-i ==1){
                printf("#");
                }else{
                    printf(".");
                }
            }
            printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws Exception{
		FastReader in = new FastReader();
		//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String input = in.next();
		char s = input.charAt(0);
		if(s>='A' && s<='Z') out.println('A');
		else out.println('a');
        
		
		
		
		
		out.close();
	}
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
		
}


Measured memory_bytes: 32736
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;

void print_arr(vector<int> arr) {
  for(int i=0;i<arr.size();++i) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}

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

  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  for(int i=0;i<n;++i) {
    for(int j=i+1 ; j<=i+2; ++j) {
      if(j < n){
	dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]));
      }
    }
  }
  //  print_arr(dp);
  cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] pixels = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                pixels[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(pixels));

        sc.close();
    }

    static String solve(char[][] pixels) {
        int H = pixels.length;
        int W = pixels[0].length;

        char[][] result = new char[H + 2][W + 2];
        for (int r = 0; r < result.length; ++r) {
            for (int c = 0; c < result[r].length; ++c) {
                result[r][c] = (r == 0 || r == H + 1 || c == 0 || c == W + 1) ? '#' : pixels[r - 1][c - 1];
            }
        }

        return Arrays.stream(result).map(String::new).collect(Collectors.joining("\n"));
    }
}

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if(n >= 2) {
    ans += n * (n-1) / 2;
  }
  if(m >= 2) {
    ans += m * (m-1) / 2;
  }
  cout << ans;
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
a=[]
while True:
    l=list(input())
    if l[0]=="-":
        break
    else:
        #for shuffle
        m=int(input())
        i=0
        while i<m:
            h=int(input())
            n=0
            while n<h:
                l.append(l[0])
                l.remove(l[0])
                n+=1
            i=i+1
        #for print
        q=1
        Ans=l[0]
        while q<len(l):
            Ans+=l[q]
            q+=1
        a.append(Ans)
for A in a:
    print(A)


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


int main() {
  int N, K; cin >> N >> K;
  vector<int> hs(N);
  for (int i = 0; i < N; i++) {
    cin >> hs.at(i);
  }
  sort(hs.begin(), hs.end());
  int patterns = N - K + 1;
  int min_dh = hs.at(K - 1) - hs.at(0);
  for (int i = 1; i < patterns; i++) {
    int dh = hs.at(i + K - 1) - hs.at(i);
    if (dh < min_dh) {
      min_dh = dh;
    }
  }
  cout << min_dh << endl;
}


Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
	console.log(input.split(',').join(' '));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
fn main() {
    let n = read::<u32>();
    let a = read::<u32>();

    if n % 500 == 0 {
        println!("Yes");
        return
    }

    if n % 500 <= a {
        println!("Yes");
        return
    }

    println!("No");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

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

typedef long long ll;

main()
{
    ll a, b, n, z, x, y;
    cin >> a >> b >> n;
    if(n < b){
        x = (a*n)/b;
        y = 0;
    }
    else{
        n = b-1;
        x = (a*n)/b;
        y = 0;
    }
    cout <<x-y;



}





///promy_pompom
//hello world


Measured memory_bytes: 3624
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    lint a=input,b=input,n=input;
    cmn(n,b-1);
    std::cout<<a*n/b<<'\n';
}


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

using namespace std;

int main(){
    int len_array1,len_array2;
    
    scanf("%d",&len_array1);
    vector<int> int_array1(len_array1,0);
    for(int i = 0;i < len_array1;i++) cin >> int_array1[i];
    
    scanf("%d",&len_array2);
    vector<int> int_array2(len_array2,0);
    for(int i = 0;i < len_array2;i++) cin >> int_array2[i];
    
    cout << includes(int_array1.begin(),int_array1.end(),int_array2.begin(),int_array2.end()) << "\n";
    return 0;
}


Measured memory_bytes: 4448
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int cnt[1000];
void no()
{
	printf("No\n");
	exit(0);
}
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	char zzzz;
	for (int i = 0; i < mx; i++)for (int j = 0; j < my; j++)scanf(" %c", &zzzz), cnt[zzzz - 'a']++;
	int x1 = 0, x2 = 0;
	for (int i = 0; i < 26; i++)
	{
		if (cnt[i] % 2 == 1)x1++;
		if (cnt[i] % 4 == 2)x2++;
	}
	if (x1 > 1)no();
	if (x1 > 0 && (mx % 2 == 0 || my % 2 == 0))no();
	if (mx % 2 == 1)x2 -= my / 2;
	if (my % 2 == 1)x2 -= mx / 2;
	if (x2 > 0)no();
	printf("Yes\n");
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

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

	ll a[2][100001];
	rep(i, 2) {
		rep(j, 100001) {
			a[i][j] = 0;
		}
	}

	rep(i, n) {
		ll v;
		cin >> v;
		a[i % 2][v] += 1;
	}

	rep(i, 2) {
		rep(j, 4) {
			cerr << "a[" << i << "][" << j << "] = " << a[i][j] << endl;
		}
	}

	ll odd[2];              // index
	ll even[2];
	ll oddmax[2]  = {0, 0}; // 個数
	ll evenmax[2] = {0, 0};
	repd(i, 1, 100001) {
		if(a[0][i] > oddmax[0]) {
			odd[1] = odd[0];
			odd[0] = i;
			oddmax[1] = oddmax[0];
			oddmax[0] = a[0][i];
		} else if(a[0][i] > oddmax[1]) {
			odd[1] = i;
			oddmax[1] = a[0][i];
		}

		if(a[1][i] > evenmax[0]) {
			even[1] = even[0];
			even[0] = i;
			evenmax[1] = evenmax[0];
			evenmax[0] = a[1][i];
		} else if(a[1][i] > evenmax[1]) {
			even[1] = i;
			evenmax[1] = a[1][i];
		}
	}

	cerr << "    odd[] = { " << odd[0]     << ", " << odd[1]     << " }" << endl;
	cerr << "   even[] = { " << even[0]    << ", " << even[1]    << " }" << endl;
	cerr << " oddmax[] = { " << oddmax[0]  << ", " << oddmax[1]  << " }" << endl;
	cerr << "evenmax[] = { " << evenmax[0] << ", " << evenmax[1] << " }" << endl;

	ll ret = 0;
	if(odd[0] != even[0]) {
		ret = n - oddmax[0] - evenmax[0];
	} else {
		ret = n - max(oddmax[0] + evenmax[1], oddmax[1] + evenmax[0]);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define ll long long
const int N = 2e5 + 5;
int main(){
	int n;
	cin >> n;
	set <string> s;
	for(int i = 1; i <= n; i++){
		string f;
		cin >> f;
		s.insert(f);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 19256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String line = null;

		while((line = parseNum()) != null) {
			int nCnt = calc(line);
			System.out.println(nCnt);
		}
	}

	private static String parseNum() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}

	private static int calc(String str) {
		int	nCnt = 0;
		try {
			int	nNum = Integer.parseInt(str);

			if (nNum <= 36) {
				for(int n1 = 0; n1 < 10; n1++) {
					if (n1 > nNum) {
						break;
					}
					for(int n2 = n1; n2 < 10; n2++) {
						if (n1 + n2 > nNum) {
							break;
						}
						for(int n3 = n2; n3 < 10; n3++) {
							if (n1 + n2 + n3 > nNum) {
								break;
							}
							for(int n4 = n3; n4 < 10; n4++) {
								if (n1 + n2 + n3 + n4 == nNum) {
									nCnt += getCnt(n1, n2, n3, n4);
								}
								else if (n1 + n2 + n3 + n4 > nNum) {
									break;
								}
							}
						}
					}
				}
			}
		}
		catch (NumberFormatException e) {}

		return nCnt;
	}

	private static int getCnt(int n1, int n2, int n3, int n4) {
		int		nCnt = 0;
		int[]	aNum = new int[4];
		int[]	aCnt = new int[4];

		aNum[0] = n1;
		aNum[1] = n2;
		aNum[2] = n3;
		aNum[3] = n4;
		Arrays.sort(aNum);

		aCnt[0] = 1;
		
		for(int nLoop = 0, nTmp = 0; nLoop < aNum.length - 1; nLoop++) {
			nTmp += (aNum[nLoop] == aNum[nLoop+1]) ? 0 : 1;
			aCnt[nTmp]++;
		}
		nCnt = fact(aNum.length) / (fact(aCnt[0]) * fact(aCnt[1]) * fact(aCnt[2]) * fact(aCnt[3]));

		return nCnt;
	}

	private static int fact(int x) {
		int nFact = 1;

		for (int nLoop = 1; nLoop <= x; nLoop++) {
			nFact = nFact * nLoop;
		}

		return nFact;
	}
}

Measured memory_bytes: 17860
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}// x^n%mod
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    int n,m;cin>>n>>m;
    vector<P>ab(n);rep(i,n)cin>>ab[i].fi>>ab[i].se;
    sort(ALL(ab));
    priority_queue<int>q;
    int j=0;
    ll ans=0;
    for(int i=m-1;i>=0;i--){
        while(j<n&&i+ab[j].fi<=m){
            q.push(ab[j].se);
            j++;
        }
        if(q.empty())continue;
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> st(n);
  vector <int> cost(n,INT_MAX);
  for(int i =0;i<n;i++)
  {
    cin>>st[i];
  }
  cost[0] = 0;
  for(int i =1;i<n;i++)
  {
    for(int j = 1;j<=k && i-j>=0;j++)
    	cost[i] = min(cost[i],cost[i-j] + abs(st[i]-st[i-j]));
  }
  cout<<cost[n-1];
  return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <numeric>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm> 
#include <map> 
#include <set>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

string str;
set<string> ans;
//?????????????????£???????????£????????????


void change(string tmp,char rule){
	if(rule=='a'){
		ans.insert(tmp);
		return ;
	}
	
	rep(i,tmp.size()){
		if(tmp[i]==rule) return;
		if(tmp[i]==rule-1){
			string ctmp = tmp;
			ctmp[i]++;
			change(ctmp,rule-1);
		}
	}	
	
	change(tmp,rule-1);
}


int main(){
	while(1){
			
		cin >> str;
		ans.clear();
		if(str=="#"){
			break;	
		}
		change(str,'z');


		cout << ans.size() << endl;
		if(ans.size()>10){
			vector<string> vec(ans.begin(),ans.end());
			for(int i=0;i<5;i++){
				cout << vec[i] << endl;
			}
			for(int i=ans.size()-5;i<ans.size();i++){
				cout << vec[i] << endl;
			}

		}else if(ans.size()>0){	
			vector<string> vec(ans.begin(),ans.end());
			rep(i,ans.size()){
				cout << vec[i] << endl;
			}

		}

	}
}

Measured memory_bytes: 3248
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    println!("{}", (n - 1) * (m - 1));
}


Measured memory_bytes: 4352
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

ans = 1 << 60
(0...(1 << N)).each do |bits|
  sum = 0
  max = 0
  count = 0
  A.each.with_index do |a, i|
    if a > max
      max = a
      count += 1
    elsif bits[i] == 1
      sum = sum + (max - a) + 1
      max = max + 1
      count += 1
    end
    break if count == K
  end
  if count == K
    ans = sum if sum < ans
  end
end
puts ans

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

int func (int n, int max_v){
    for(int i =0; i< n; i++){
        max_v = max_v*2;
    }
    return max_v;
}
int v = 0;

int main(void){
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    if(a < b){
        if ( b < c){
            v = func(n, c);
            cout << a + b + v << endl;
        }else {
            v = func(n, b);
            cout << a + c + v << endl;
        }
    } else {
        if(a < c){
            v = func(n, c);
            cout << a + b + v << endl;
        } else {
            v = func(n, a);
            cout << b + c + v << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i] > a[j]:
      count = (count+(k*(k+1))//2)%(10**9+7)
    elif a[i] < a[j]:
      count = (count+(k*(k-1))//2)%(10**9+7)
print(count)
      
    

Measured memory_bytes: 3188
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    edge = [k for k, v in cnt.items() if v >= 2]
    edge.sort(reverse=True)


    if len(edge) >= 1 and cnt[edge[0]] >= 4:
        ans = edge[0] ** 2
    elif len(edge) >= 2:
        ans = edge[0] * edge[1]
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 23184
import Data.List
import Data.Function

solve :: String -> Char -> Int
solve []  _ = 0
solve s c
  | all (==c) s = 0
  | otherwise   = 1 + solve (go s) c
  where
    go []  = []
    go [_] = []
    go (s1:s2:ss) = (if s1 == c || s2 == c
                        then c else s1) : go (s2:ss)

main :: IO ()
main = do
    s <- getLine :: IO String
    print . minimum $ map (solve s) (nub s)

Measured memory_bytes: 1020
line1 = input()
line2 = input()
price, k = line1.split(" ")
num = line2.split(" ")
ans = ""

for i in range(int(price),100000):
    num2 = [str(x) for x in str(i)]
#     print(len(set(num)&set(num2)))
    if len(set(num)&set(num2))==0:
        print(i)
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define LMAX 100005
int v[LMAX];
int main(){
    int n,l;
    scanf("%d %d",&n,&l);
    for(int i=1;i<=n;++i)
        scanf("%d",&v[i]);
    for(int i=1;i<=n-1;++i){
        if(v[i]+v[i+1]>=l){
            printf("Possible\n");
            for(int j=1;j<=i-1;++j)
                printf("%d\n",j);
            for(int j=n-1;j>=i+1;--j)
                printf("%d\n",j);
            return printf("%d\n",i),0;
        }
    }
    printf("Impossible\n");
    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define mod 1000000007
#define M 1000005
using namespace std;
long long ans=1;
int n,m,col,nxt[M],head[M],to[M],tot,num1[M],num2[M],dfn[M],low[M],bel[M],XX[M],YY[M];
long long fac[M],inv[M],fac_inv[M];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(long long x){
	if (x<10) putchar(x^48);
	else Write(x/10),putchar((x%10)^48);
	return;
}
void add(int u,int v){nxt[++tot]=head[u];head[u]=tot;to[tot]=v;return;}
void tarjan(int x,int fa){
	dfn[x]=low[x]=++dfn[0];
	for (register int i=head[x],tmp;i;i=nxt[i]){
		if (to[i]==fa) continue;
		if (!dfn[to[i]]){
			XX[++XX[0]]=x,YY[++YY[0]]=to[i],tmp=XX[0];
			tarjan(to[i],x),low[x]=min(low[x],low[to[i]]);
			if (low[to[i]]>=dfn[x]){
				++bel[0];
				for (register int j=tmp;j<=XX[0];j++){
					if (bel[XX[j]]<bel[0]) bel[XX[j]]=bel[0],num1[bel[0]]++;
					if (bel[YY[j]]<bel[0]) bel[YY[j]]=bel[0],num1[bel[0]]++;
				}
				num2[bel[0]]=XX[0]-tmp+1,XX[0]=YY[0]=tmp-1;
			}
		}
		else if (dfn[to[i]]<dfn[x]) XX[++XX[0]]=x,YY[++YY[0]]=to[i],low[x]=min(low[x],dfn[to[i]]);
	}
	return;
}
long long C(int x,int y){return fac[x]*fac_inv[y]%mod*fac_inv[x-y]%mod;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
long long power(int x,int y){
	long long ans=1,now=x;
	for (register int i=y;i;i>>=1,now=now*now%mod)
		if (i&1) ans=ans*now%mod;
	return ans;
}
int main(){
	n=read(),m=read(),col=read();inv[1]=fac[0]=fac_inv[0]=1;
	for (register int i=1,u,v;i<=m;i++) u=read(),v=read(),add(u,v),add(v,u);
	for (register int i=1;i<=n;i++) if (!dfn[i]) tarjan(i,0);
	for (register int i=2;i<=1000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (register int i=1;i<=1000;i++) fac[i]=fac[i-1]*i%mod,fac_inv[i]=fac_inv[i-1]*inv[i]%mod;
	for (register int i=1;i<=bel[0];i++){
		if (num2[i]==1) ans=ans*col%mod;
		else if (num1[i]==num2[i]){
			long long now=0;
			for (register int j=0;j<num1[i];j++)
				now=(now+power(col,gcd(num1[i],j)))%mod;
			ans=ans*now%mod*inv[num1[i]]%mod;
		}
		else ans=ans*C(num2[i]+col-1,col-1)%mod;
	}
	Write(ans);
	return 0;
}


Measured memory_bytes: 24832
import sys
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

def main():

  n=int(input())

  A=[list(map(int,input().split()))[::-1] for i in range(n)]

  day=0
  zan=[n-1]*n
  zann=sum(zan)
  sumi=set(range(n))

  while True:
    day+=1

    kouho=list(sumi)
    sumi=set()
  
    for i in kouho:
      try:
        if A[A[i][-1]-1][-1]-1==i:
          sumi.add(i)
          sumi.add(A[i][-1]-1)
      except:
        pass

    for k in sumi:
      A[k].pop()
      zan[k]-=1

    if zann==sum(zan):
      print(-1)
      exit(0)
  
    zann=sum(zan)
  
    if zann==0:
      print(day)
      exit(0)
    
if __name__ == "__main__":
	main()

Measured memory_bytes: 56028