akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	vector<vector<int>>dp(n+1,vector<int>(13,0));
	dp[0][0]=1;
	for(int i=0;i<n;i++)
		if(s[i]=='?')
		{
			for(int j=0;j<10;j++)
				for(int k=0;k<13;k++)
				{
					dp[i+1][(k*10+j)%13]+=dp[i][k];
					dp[i+1][(k*10+j)%13]%=mod;
				}
		}
		else
		{
			int j=s[i]-'0';
			for(int k=0;k<13;k++)
			{
				dp[i+1][(k*10+j)%13]+=dp[i][k];
				dp[i+1][(k*10+j)%13]%=mod;
			}
		}
	cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0'){
		t=(t<<3)+(t<<1)+v-48;
		v=getchar();
	}
	return t;
}
long long a,b,c;
int main(){
	a=read();b=read();c=read();
	if(c<a+b)puts("No");
	else if((c-a-b)*(c-a-b)<=4*a*b)puts("No");
	else puts("Yes");
}


Measured memory_bytes: 256
using System;

class Program {
    static void Main( string[] args )
    {
        while ( true ) {
            string[] s = Console.ReadLine().Split();

            int h = int.Parse( s[ 0 ] );
            int w = int.Parse( s[ 1 ] );

            if ( 0 == h + w ) {
                break;
            }

            for ( int i = 0; i < h; ++i ) {
                for ( int j = 0; j < w; ++j ) {
                    Console.Write( "#" );
                }

                Console.WriteLine();
            }

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8936
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 200010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long int modpow(long long int a, long long int n){
    long long int ans = 1;
    while(n != 0){
        if(n%2 == 1){
            ans = ans * a % MOD;
            n -= 1;
        }else{
            a = a * a % MOD;
            n /= 2;
        }
    }
    return ans;
}


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

    COMinit();

    long long int all = (modpow(2, n) - 1)%MOD;

    long long int nCa = 1;
    long long int nCb = 1;

    for(int i = 0; i < a; i++){
        nCa *= n-i;
        nCa %= MOD;
    }
    nCa *= finv[a];
    nCa %= MOD;

    for(int i = 0; i < b; i++){
        nCb *= n-i;
        nCb %= MOD;
    }
    nCb *= finv[b];
    nCb %= MOD;

    long long int ans;
    ans = (all - nCa + MOD)%MOD;
    ans = (ans- nCb + MOD)%MOD;
    cout << ans << endl;
}


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

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

  long long a, b, x;
  cin >> a >> b >> x;
  
  long long ans = (a == 0) ? b / x + 1 : b / x - (a - 1) / x;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
    int number[10];
    int i, j, a;
    for (i = 0; i < 10; ++i)
    scanf("%d", &number[i]);
    for (i = 0; i < 10; ++i)
    {
        for (j = i + 1; j < 10; j++)
        {
            if (number[i] < number[j])
            {
                a = number[i];
                number[i] = number[j];
                number[j] = a;
            }
        }
    }
    for (i = 0; i < 3; i++)
    {
    printf("%d\n", number[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

int main() {
	ll N, K; cin >> N >> K;
	
	vector<int> d;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			d.push_back(i);
			if (i * i != N) d.push_back(N / i);
		}
	}
	sort(ALL(d));
	
	map<int, int> cnt;
	REP(i, d.size()) {
		ll now = mod_pow(K, (d[i] + 1) / 2, MOD);
		
		for (map<int, int>::iterator it = cnt.begin(); it != cnt.end(); ++it) {
			if (d[i] % it->fi == 0) {
				now = (now - it->se + MOD) % MOD;
			}
		}
		
		cnt[d[i]] = now;
	}
	
	ll ans = 0;
	REP(i, d.size()) {
		if (d[i] & 1) ans = (ans + (ll)cnt[d[i]] * d[i] % MOD) % MOD;
		else ans = (ans + (ll)cnt[d[i]] * (d[i] / 2) % MOD) % MOD;
	}
	cout << ans << endl;
	
	
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> a(3*n);
    for(auto & b : a) cin>>b,b--;
    vector<vector<int>> dp(n,vector<int>(n,-(1<<20)));
    vector<int> ma(n,-(1<<20));
    dp[a[0]][a[1]] = 0;
    ma[a[0]] = ma[a[1]] = 0;
    int ret = 0;
    for(int i=2;i+2<3*n;i+=3){
        sort(a.begin()+i,a.begin()+i+3);
        if(a[i] == a[i+2]){
            ret++;
            continue;
        }
        
        vector<tuple<int,int,int>> co;
        if(a[i] == a[i+1]){
            for(int x=0;x<n;++x){
               co.emplace_back(x,a[i+2],max(dp[a[i]][x],dp[x][a[i]])+1); 
            }
        }
        if(a[i+1] == a[i+2]){
            for(int x=0;x<n;++x){
                co.emplace_back(x,a[i],max(dp[a[i+1]][x],dp[x][a[i+1]])+1);
            }
        }
                
        for(int j=i;j<i+3;++j){
            for(int x=0;x<n;++x)co.emplace_back(x,a[j],ma[x]);
        }
        
        co.emplace_back(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
        co.emplace_back(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
        co.emplace_back(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);

        
        int tmp = -1;
        for(int x=0;x<n;++x) tmp = max(tmp,ma[x]);
        co.emplace_back(a[i],a[i+1],tmp);
        co.emplace_back(a[i+1],a[i+2],tmp);
        co.emplace_back(a[i],a[i+2],tmp);
        
        for(auto  cur : co){
            int a,b,c;
            tie(a,b,c) = cur;
            dp[a][b] = max(dp[a][b],c);
            ma[a] = max(ma[a],c);
            ma[b] = max(ma[b],c);
        }
    }
    
    int sma = 0;
    for(int i=0;i<n;++i) sma = max(sma,ma[i]);
    sma = max(sma,dp[a[3*n-1]][a[3*n-1]] + 1);
    cout << ret+sma << endl;
    return 0;
}

Measured memory_bytes: 19496
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    vector<pair<int,int>> v;
    int p, s;
    while(scanf("%d,%d", &p, &s), p + s) {
        v.push_back(make_pair(s, p));
    }
    sort(v.begin(), v.end(), greater<pair<int,int>>());
    vector<pair<int,int>> w;
    int ord = 0;
    int ordsc = -1;
    REP(i,v.size()) {
        if (v[i].first == ordsc) {
            
        }else {
            ord++;
            ordsc = v[i].first;
        }
        w.push_back(make_pair(v[i].second, ord));
    }
    sort(w.begin(), w.end());
    int k;
    while(cin >> k) {
        cout << w[k-1].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    stack<char> st;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='S') st.push(s[i]);
        else{
            if(st.empty()) st.push(s[i]);
            else if(st.top()=='S'){
                st.pop();
            }else st.push(s[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 644
n=int(input())
s = {}
maxs = 1
wdlst = set()
for i in range(n):
  si = input()
  if si in s:
    s[si] = s[si] + 1
    maxs = max(maxs,s[si])
  else:
    s[si] = 1
    wdlst.add(si)
res = list()
for x in wdlst:
  if s[x]==maxs:
    res.append(x)
res.sort()
for x in res:
  print(x)

Measured memory_bytes: 40596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K, A;

	cin >> N >> K;
	rep(i, N) {
		cin >> A;
	}

	cout << 1 + (N - 2) / (K - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  rep(i, 1, n+1) {
    int cnt = 0;
    if(k <= i-1) {
      if(k == 0) {
        cout << n*n << "\n";
        return 0;
      }
      else {
        cnt += (n/i)*(i-1-k+1);
        cnt += max(0LL, n%i - k+1);
      }
    }
    ans += cnt;
  }
  
  cout << ans << "\n";

}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

// ??\????????? M ???????????????????´????????????????????????°??¢??°
int solve (int i, int m) {
  int res;
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 1800
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

N,A,B = map(int,input().split())
if (N == 2):
    print(0)
else:
    print((2**N - 1 - combination(N, A) - combination(N, B)) % (10**9+7))

Measured memory_bytes: 283544
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}






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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<pll> a,b;
  REP(i,n){
    string s;
    cin >> s;
    int32 d = 0;
    int32 mn = 0;
    REP(j,(int32)s.size()){
      if(s[j] == '('){
        d++;
      }else{
        d--;
      }
      mn = min(mn,d);
    }
    if(d >= 0){
      a.emplace_back(mn,d);
    }else{
      b.emplace_back(mn-d,d);
    }
  }
  int64 cur = 0;
  sort(ALL(a),greater<pll>());
  for(auto [mn,d] : a){
    // cout << mn << " " << d << endl;
    if(cur + mn < 0){
      Yes(false);
      return 0;
    }
    cur += d;
  }
  sort(ALL(b));
  for(auto [mn,d] : b){
    // cout << mn << " " << d << endl;
    if(cur + d + mn < 0){
      Yes(false);
      return 0;
    }
    cur += d;
  }
  Yes(cur == 0);
  return 0;
}

Measured memory_bytes: 19056
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

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

int h, w;
char mp[50][50];

void solve() {
	rep(i, h) {
		rep(j, w) {
			cin >> mp[i][j];
		}
	}
	vector<int> v;
	int x = 0, y = 0, d = 2;
	while (true) {
		//cout << x << " " << y <<" "<<d<< endl;
		int nx, ny;
		rep(j, 4) {
			int nd = d + 1 - j;
			nd = (nd % 4 + 4) % 4;
			nx = x + dx[nd], ny = y + dy[nd];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
			if (mp[nx][ny] == '.') {
				v.push_back(nx*w + ny);
				x = nx, y = ny, d = nd;
				break;
			}
		}
		if (x == 0 && y == 0)break;
	}
	vector<bool> exi(h*w, false);
	rep(i, v.size()) {
		//cout << v[i] << endl;
		if (exi[v[i]]) {
			int j = i - 1;
			while (v[j] != v[i]) {
				exi[v[j]] = false;
				j--;
			}
		}
		else {
			exi[v[i]] = true;
		}
	}
	if (exi[w - 1] && exi[(h - 1)*w] && exi[h*w - 1]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	while (cin >> h >> w, h) {
		solve();
	}
	//stop
		return 0;
}


Measured memory_bytes: 3132
from collections import defaultdict


def main():
    """
    acのあとにwaもあるということ。
    初めてacになるまでのwaが問題。一度acになったらもうその問題はおしまい。
    正答数: ACを出した問題の数
    ペナルティ数: 最初のACに至るまでのWA数
    一度もacを出してない問題ではwaは0。
    """

    n, m = map(int, input().split(' '))

    submits = []
    for _ in range(m):
        p, s = input().split(' ')
        submits.append((int(p), s))

    submits_iter = iter(submits)
    submit = next(submits_iter, None)
    done = set()
    passed = 0
    penalties = 0
    penalty_stock = defaultdict(int)
    while submit:
        p, s = submit
        if p not in done:
            if s == 'AC':
                passed += 1
                done.add(p)
                penalties += penalty_stock[p]
            else:
                penalty_stock[p] += 1
        submit = next(submits_iter, None)
    print('%s %s' % (passed, penalties))


main()


Measured memory_bytes: 32668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    char c;
        cin>>c;
        if(c-'a'>=0 && c-'a'<=25)
        {
            cout<<'a';

        }
        else
        {
            cout<<'A'<<endl;
        }
}

Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int vs[101];

int main(void) {
  int n;
  cin >> n;
  int res = 0;
  REP(i, n-1) {
    cin >> vs[i];
  }
  res += vs[0];
  for(int i = 1; i < n-1; ++i) {
    res += min(vs[i-1], vs[i]);
  }
  res += vs[n-2];
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
use proconio::*;
fn main(){
input!{t:usize}
for _ in 0..t{
input!{n:usize,mut a:[(usize,i64,i64);n]}
let mut z=0;
let mut b=vec![];
let mut c=vec![];
for(k,l,r)in a{z+=if l<r{l}else{r};if l>=r{b.push((k,r-l))}else if k<n{c.push((n-k,l-r))}}
for mut a in vec![b,c]{
a.sort();
let mut s=std::collections::BinaryHeap::new();
let mut i=0;
for(k,d)in a{
s.push(d);
if s.len()>k{s.pop();}
}
/*
for j in 1..=n{
while i<a.len()&&a[i].0==j{s.push(a[i].1);i+=1}
while s.len()>j{s.pop();}
}
*/
for d in s{z-=d}
}
println!("{}",z);
}
}

Measured memory_bytes: 13756
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;

    vector<pair<int,bool> > p;
    int min=INT_MAX;
    int count=0;
    f0(i,0,n){
        int temp;
        bool f=0;
        cin>>temp;
        if(temp<min){min=temp;f=1;}
        p.pb(mp(temp,f));
        if(f) count++;
    }

    cout<<count;

}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  double t,h,t2,t3,a;
  int i,j,k,n;
cin>>n;
cin>>t>>a;
double  hi[n+2];
for(i=1;i<=n;i++)
{
    cin>>h;
    hi[i]=(h*0.006);
    hi[i]=t-hi[i];
}
 t2=fabs(hi[1]-a);
for( j=1;j<=n;j++){

     t3=fabs(hi[j]-a);
    if(t3<=t2){
        t2=t3;
        k=j;
}
}
cout<<k<<endl;
return 0;
}


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

N = INT()
W = LIST()

mi = INF
for i in range(1, N):
	right_w = sum(W[0:i])
	right_l = sum(W[i:N])
	if abs(right_w - right_l) < mi:
		mi = abs(right_w - right_l)

print(mi)

Measured memory_bytes: 60140
open Printf open Scanf
module MyInt = struct
	let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v
	(* let input_int_array n = Array.init n (fun _ -> Scanf.scanf " %d" (fun v -> v))	
	let get_int () = Scanf.scanf " %d" (fun v -> v)
	let get_2_ints () = Scanf.scanf " %d %d" (fun u v -> u,v)
	let get_3_ints () = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w)
	let get_4_ints () = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x)
	let get_5_ints () = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
	let print_int_endline n = n |> string_of_int |> print_endline *)
end
(* module MyInt64 = struct *)
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * )
	let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v
	let labs p = if p < 0L then -1L*p else p
	let (~|) p = Int64.to_int p
	let (~~|) p = Int64.of_int p

	let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
	let get_i64 () = Scanf.scanf " %Ld" (fun v -> v)
	let get_2_i64 () = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
	let get_3_i64 () = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
	let get_4_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
	let get_5_i64 () = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
	let print_i64_endline n =
		n |> Int64.to_string |> print_endline
	
	let (mod) m n = m - (m/n) * n let (%) = (mod)
	let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
	let rec lcm m n = (m*n) / gcd m n
	let rep from_ to_ fbod =
		let i,f = ref ~|from_,ref true in while !i <= ~|to_-$1 && !f do
			match fbod !i with
			| `Ok -> i := !i +$ 1;
			| `Ng -> f := false
		done
(* end open MyInt64 *)

let () =
	let n,k = get_2_i64 ()
	in let a = input_i64_array n
	in
	ceil @@ Int64.to_float (n-1L) /. Int64.to_float (k-1L)
	|> int_of_float
	|> printf "%d\n";

Measured memory_bytes: 6656
#include<bits/stdc++.h>
#define EPS (1e-4)
#define N 40
using namespace std;

double x[N],y[N],z[N];

double getd(int i,int j){
  
  double X=x[i]-x[j],Y=y[i]-y[j],Z=z[i]-z[j];
  
  return sqrt(X*X+Y*Y+Z*Z);
}

int main(){

  int T;
  cin>>T;
  
  while(T--){
    
    double QR,RP,PQ;

    cin>>QR>>RP>>PQ;
    
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];
    
    int ans1,ans2,ans3;
    
    for(int P=0;P<n;P++){
      
      for(int Q=0;Q<n;Q++){
	
	for(int R=0;R<n;R++){
	  
	  if(P==Q||Q==R||R==P) continue;
	  
	  double rPQ=getd(P,Q);
	  double rQR=getd(Q,R);
	  double rRP=getd(R,P);

	  if(abs(RP/QR-rRP/rQR)<EPS&&abs(PQ/QR-rPQ/rQR)<EPS){
	    ans1=P+1;
	    ans2=Q+1;
	    ans3=R+1;
	  }
	}
      }
    }
    
    cout<<ans1<<' '<<ans2<<' '<<ans3<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int N, a, b, sum_, res = 99999;
cin >> N;

for (int i = 1; i < N; ++i) {
        sum_ = 0;
        a = i;
        b = N - a;
        while (a > 0) {
                sum_ += a % 10; 
                a /= 10; 
        }   
        while (b > 0) {
                sum_ += b % 10; 
                b /= 10; 
        }   
        res = min(res, sum_); 
} 
cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<ll>>;
vector<bool>seen;
ll N;
int main(){
  cin>>N;
  Graph G(N);
  vector<ll>indeg(N);
  seen.resize(N,false);
  for(ll i=0;i<N-1;i++){
  ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    indeg[a]++;indeg[b]++;
  }queue<ll>que;ll Sum=0;
  for(ll i=0;i<N;i++)
    if(indeg[i]==1)que.push(i);
  while(!que.empty()){
  ll v=que.front(); que.pop();
    if(seen[v])
      continue;
    seen[v]=true;
   ll sum=0;
    ll v1;
    for(auto u:G[v]){
    if(seen[u])
      continue;
      sum++;
      v1=u;
    }if(sum!=1)
      continue;
    Sum+=2;seen[v1]=true;
    for(auto u:G[v1]){
    if(seen[u])
      continue;
      indeg[u]--;
      if(indeg[u]==1)que.push(u);
     }
  }if( Sum==N)
    cout<<"Second"<<endl;
  else
    cout<<"First"<<endl;
  return 0;
}

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

int min(int a,int b){
  return (a>=b) ? b : a ;
}

int main() {
  
    int a,b,c,d ;
    cin >> a >> b >> c >> d ;
    
    cout << min(a,b)+min(c,d) << endl ;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I=int(A);I<int(B);I++)

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

	int N,ans=0;
	cin >> N;
	vector<int> A[N+1];
	FOR(i,1,N+1){
		A[i].resize(N);
		FOR(j,1,N){
			cin >> A[i][j];
		}
	}
	
	bool game = true;
	vector<int> ind(N+1,1);//A[i][ind[i]]
	vector<int> nextOPP(N+1,-1);
	vector<int> rest;
	FOR(i,1,N+1) rest.push_back(i);
	while(game){
		game = false;
		ans++;
		vector<int> restt;
		for(auto i:rest)nextOPP[i] = -1;
		for(auto i:rest){
			if(ind[i]>=N)continue;
			nextOPP[i] = A[i][ind[i]];
			if(nextOPP[nextOPP[i]]==i){
				game = true;
				ind[i]++;
				ind[nextOPP[i]]++;
				if(ind[i]<N)restt.push_back(i);
				if(ind[nextOPP[i]]<N)restt.push_back(nextOPP[i]);
			}
		}
		rest = restt;
	}
	bool allok = true;
	FOR(i,1,N+1)if(ind[i]<N)allok = false;
	if(allok){
		cout << ans-1 << endl;
	}else{
		cout << -1 << endl;
	}
}


Measured memory_bytes: 4224
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
  
        string s, t; cin >> s >> t;
        int ans = s.length();
        for(int i = 0; i < s.length() - t.length() + 1; i++){
            int xx = 0;
            int n = s.length() - i;
            if(n < t.length())
                continue;
            for(int j = i; j < t.length() + i; j++){
                xx += (s[j] != t[j - i]);
            }
            ans = min(ans, xx);
        }
        cout << ans ;
        return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

struct Edge{
	int to;
	int cost;
	int time, com;
	Edge(int to, int cost, int time, int com) : to(to), cost(cost), time(time), com(com) {}
};

struct Node{
	int dis;
	bool used;
	Node() : dis(INF), used(false) { }
	Node(int d, bool f) : dis(d), used(f) { }
};


typedef vector<vector<Edge>> graph;
typedef tuple<int,int,int> T;

int dijkstra(graph g, int s, int t, int n, int k, int bit){
	vector<vector<Node>> node(n, vector<Node>(25));
	priority_queue<int, vector<T>, greater<T>> q;

	q.push(T(0, 0, s));
	node[s][0] = Node{0, true};

	while(not q.empty()){
		int dis, t, pos;
		tie(dis, t, pos) = q.top(); q.pop();
		node[pos][t].used = true;

		for(auto e : g[pos]){
			if((bit >> e.com) & 1){
                //cout <<"asdf  " <<  bit << " " << e.com <<endl;
				 e.cost = 0;
			}
            if(t + e.time > k) continue;
            int nt = t + e.time;
			if(node[e.to][nt].used == true) continue;
			if(node[e.to][nt].dis > dis + e.cost){
				node[e.to][nt].dis = dis + e.cost;
				q.emplace(node[e.to][nt].dis, nt, e.to);
			}
		}
	}

	//show("s");
	//for(auto i : node){ for(auto j : i){ cout << j.dis << ' '; } cout << endl; }

    int mini = INF;
    rep(i,k + 1) {
        mini = min(mini, node[t][i].dis);
    }
	return mini;
}

int main(){
	int n, m, h, k;
	while(cin >> n >> m >> h >> k,n) {

		graph g(n);
		rep(i, m) {
			int a, b, c, h, r;
			cin >> a >> b >> c >> h >> r;
			a--;
			b--;
            r--;
			g[a].emplace_back(Edge{b, c, h, r});
			g[b].emplace_back(Edge{a, c, h, r});
		}
		int s, t;
		cin >> s >> t;
		s--;
		t--;

		int p;
		cin >> p;
		vector<int> ticket(p), d(p);
		rep(i, p) {
			int l;
			cin >> l >> d[i];
			rep(j, l) {
				int k;
				cin >> k;
				k--;
				ticket[i] |= 1 << k;
			}
		}

		vector<int> dp(1 << k, INF);
		dp[0] = 0;
		rep(i, 1 << k) {
			if (dp[i] == INF) continue;
			rep(j, p) {
				dp[i bitor ticket[j]] = min(dp[i bitor ticket[j]], dp[i] + d[j]);
			}
		}

		int ans = INF;
		rep(i, 1 << k){
			if(dp[i] == INF) continue;
            //cout << i << " " << dp[i] << endl;
			ans = min(ans, dijkstra(g, s, t, n, h, i) + dp[i]);
		}

		cout << (ans == INF ? -1 : ans)  << endl;
	}
}



Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int x,y;
    while(~scanf("%d%d",&x,&y))
    {
        if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
            printf("Yes\n");
        else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string s;
	cin >> s;
	ll k;
	cin >> k;

	if (k == 1) {
		cout << s[0] << endl;
		return 0;
	}

	if (s.size() == 1) {
		cout << s[0] << endl;
		return 0;
	}

	bool f = true;
	ll t = min(k, (ll)s.size());
	rep(i, t) {
		if (s[i] != '1') {
			f = false;
		}
	}

	if (f) {
		cout << '1' << endl;
		return 0;
	}


	rep(i, s.size()) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, k; cin >> n >> k;
  if (k & 1) cout << (n / k) * (n / k) * (n / k) << '\n';
  else {
    lint m = (n + k / 2) / k;
    cout << (n / k) * (n / k) * (n / k) + m * m * m << '\n';
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
 
long long int n,k,a[1000], dp[1000009];
// dp[k][turn];
 
int main(){
  
  cin>>n>>k;
  for(int i = 1; i<=n;i++)
    cin>>a[i];
  
  for(int i = 1; i<=k; i++){
    for(int j = 1; j<=n; j++){
      if(i-a[j]>=0){
          // dependencies of dynamic relation 
          dp[i]|=1 - (dp[i-a[j]]);
      }
    }
  }
  
  if(dp[k]) cout<<"First"<<endl;
  else 
    cout<<"Second"<<endl;
 
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

int n, k;
LL h[302];
LL Sdh[302];

LL dp[302][301] = {};

void solve() {
	cin >> n >> k;
	rep(i, n) cin >> h[i + 1];
	rep(i, n + 1) Sdh[i + 1] = abs(h[i] - h[i + 1]);
	rep(i, n + 1) Sdh[i + 1] += Sdh[i];

	for (int i1 = 1; i1 <= n + 1; i1++) {
		for (int i2 = 0; i2 <= k; i2++) {
			LL Mp = 0;
			for (int kp = 0; kp <= i2 && kp <= i1 - 1; kp++) {
				int j = i1 - kp - 1;
				LL p = Sdh[i1] - Sdh[j] - abs(h[i1] - h[j]);
				Mp = max(Mp, dp[j][i2 - kp] + p);
			}
			dp[i1][i2] = Mp;
		}
	}

	cout << (Sdh[n + 1] - dp[n + 1][k]) / 2 << endl;
}

int main() {

	solve();

	return 0;
}


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

int ri() {
    int n;
    scanf("%d", &n);
    return n;
}
int main() {
	int n = ri(), k = ri();
	int sum[n + 1];
	sum[0] = 0;
	std::map<int, int> ma{{0, 1}};
	int64_t res = 0;
	for (int i = 1; i <= n; i++) {
		if (i >= k) ma[sum[i - k]]--;
		int64_t a = ri() - 1 + k;
		sum[i] = (sum[i - 1] + a) % k;
		res += ma[sum[i]];
		ma[sum[i]]++;
	}
	std::cout << res << std::endl;
    return 0;
}


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

B = []
for row in A:
    if all(a=='.' for a in row): continue
    B.append(row)

C = ['' for _ in range(len(B))]
for col in zip(*B):
    if all(a=='.' for a in col): continue
    for i,a in enumerate(col):
        C[i] += a
for row in C:
    print(row)

Measured memory_bytes: 9080
#include<stdio.h>
int main()
{
int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
if(r<=x&&x<=w-r&&r<=y&&y<=h-r)
{
printf("Yes\n");
}
else 
{
printf("No\n");
}
return 0;


}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N;

int main() {
    cin >> N;

    if (N == 1) {
        cout << "Yes" << endl;
        cout << "2" << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
    }
    else {
        int k = -1;
        for (int i = 1; i < N; i++) {
            if (i * (i+1) == 2*N) {
                k = i+1;
                break;
            }
        }

        if (k == -1) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
            cout << k << endl;

            vector<int> S[k];
            int p = 0, q = 1;
            for (int i = 1; i <= N; i++) {
                S[p].push_back(i);
                S[q].push_back(i);
                q++;
                if (q == k) {
                    p++;
                    q = p+1;
                }
            }

            for (int i = 0; i < k; i++) {
                cout << S[i].size() << " ";
                for (int j = 0; j < S[i].size(); j++) {
                    cout << S[i][j] << " ";
                }
                cout << endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 2304
import java.io.*;
  public class Main{
    public static void main(String[] args)throws IOException{
      BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
      String str=mBufferedReader.readLine();
      double r=Double.parseDouble(str);
      double pi=3.141592653589;
      double l=2*r*pi;
      double s=r*r*pi;
      System.out.printf("%.8f %.8f%n",s ,l);
   }
}


Measured memory_bytes: 24584
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 

ll mod_pow(ll x, ll n){
 ll res=1;
  while(n>0){
   if(n&1) res=res*x%mod;
   x=x*x%mod;
   n>>=1;
}
return res;
}

void solve(){
  ll n;
  cin >> n;
  mint ans=mod_pow(10,n);
  
  
    ll x=mod_pow(9,n);
  ans-=x;
  ans-=x;
  ans+=mod_pow(8,n);
  
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3636
n = int(input())
nums = list(map(int, input().split()))
if n == 1:
  print(0)
dp = [0 for _ in range(n)]
dp[0] = 0
dp[1] = abs(nums[1]-nums[0])

for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(nums[i] - nums[i-1]), dp[i-2]+abs(nums[i]-nums[i-2]))

print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int x, y;
  cin >> x >> y;
  string ans = "No";
  rep(i, x + 1) {
    int tmp = i * 2 + (x - i) * 4;
    if (tmp == y) {
      ans = "Yes";
    }
    // cout << i << '\n';
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007

typedef long long ll;

ll t[7];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll Q,H,S,D,N,ans(0);
    cin >> Q >> H >> S >> D >> N;
    t[0]=Q*8;
    t[1]=H*4;
    t[2]=S*2;
    t[3]=D;
    t[4]=Q*4;
    t[5]=H*2;
    t[6]=S;
    ll m1,m2;
    for(int i = 0; i < 4; i++)
    {
        if(i==0)m1=t[0];
        m1 = min(m1,t[i]);
    }
    for(int i = 4; i < 7; i++)
    {
        if(i==4)m2=t[4];
        m2 = min(m2,t[i]);
    }
    while(N>=2)
    {
        N-=2;
        ans+=m1;
    }
    while(N>=1)
    {
        N-=1;
        ans+=m2;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
program main
    implicit none
    integer:: A, B
    integer:: i, c_num, e_num

    read*, A, B
    c_num = 1
    e_num = 0

    do while(c_num < B)
        c_num = c_num - 1
        c_num = c_num + A
        e_num = e_num + 1
    enddo

    print'(i0)', e_num
end program

Measured memory_bytes: 640
N,M,X = map(int,(input().split()))
C = [0]*N
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int,(input().split())))
    C[i] = A[i][0]

ans = []
# 全探査
K = 2 # 選択肢の数
for i in range(K**N):
    TF=[0]*N

    for j in range(N):
        TF[N-j-1] = i % K
        i //= K
    
    price = 0
    knowledge = [0]*M
    for j in range(N):
        if TF[j] == 1:
            price += C[j]
            for k in range(M):
                knowledge[k] += A[j][k+1]
        flag = 0
        for k in range(M):
            if knowledge[k] < X:
                flag = 1
        if flag == 0:
            ans.append(price)

if ans:
    print(min(ans))
else:
    print(-1)

Measured memory_bytes: 70476
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    double ans = 0.0;
    rep(i, N) {
        int A;
        cin >> A;
        ans += 1.0/A;
    }
    cout << fixed << setprecision(12) << 1.0/ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
const int MN = 200200;
int rv,cv,n;
ll ord(ll r, ll c) {
	if(r == 0) {
		return cv-c;
	} else if(c == 0) {
		return r+cv;
	} else if(r == rv) {
		return rv+cv+c;
	} else if(c == cv) {
		return 2*rv+2*cv-r;
	} else {
		return -1;
	}
}
vector<pl> w;
bitset<MN> bs;
int main() {
	scanf("%d %d %d",&rv,&cv,&n);
	bool po = true;
	for(int i=0;i<n;i++) {
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int ct = 0;
		ll fv = ord(a,b),sv = ord(c,d);
		if((fv >= 0) && (sv >= 0)) {
			w.push_back({fv,i});
			w.push_back({sv,i});
		}
	}
	sort(w.begin(),w.end());
	stack<ll> st;
	for(int i=0;i<w.size();i++) {
		ll id = w[i].second;
		if(bs[id]) {
			ll val = st.top();st.pop();
			if(val != id) {po = false;break;}
			bs.reset(id);
		} else {
			st.push(id);
			bs.set(id);
		}
	}
	printf("%s\n",po?"YES":"NO");
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(a, b);
    int2(c, d);

    int dist = abs(a - c);

    Int(t);
    int dd = b * t - d * t;

    if (dist <= dd) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
n,k = (int(x) for x in input().split())

h = []
h = list(map(int,input().split()))

asum=0

if n<=k :
	print(0)
else:
	h=sorted(h,reverse=True)
	for i in range(k,n):
		asum += h[i]

	print(asum)

Measured memory_bytes: 26024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
 
 
        // Scannerクラスのインスタンスの生成
        Scanner sc = new Scanner(System.in);
        
        String[] ss = sc.next().split("");
      
        if(ss[0].equals(ss[1]) && ss[2].equals(ss[3]) && !(ss[0].equals(ss[2]))) {
        	System.out.println("Yes");
        } else if (ss[0].equals(ss[2]) && ss[1].equals(ss[3]) && !(ss[0].equals(ss[1]))) {
        	System.out.println("Yes");
        } else if (ss[0].equals(ss[3]) && ss[1].equals(ss[2]) && !(ss[0].equals(ss[1]))) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
	}
 
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

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

    sort(a.begin(), a.end());
    if (a[0] >= 0) {
	for (int i=1; i<n-1; i++) {
	    ans.emplace_back(a[0],a[i]);
	    a[0] -= a[i];
	}
	int res = a[n-1] - a[0];
	ans.emplace_back(a[n-1],a[0]);
	cout<<res<<"\n";
	for (auto p: ans) {
	    cout<<p.first<<" "<<p.second<<"\n";
	}
	return 0;
    } else if (a[n-1] < 0) {
	for (int i=0; i<n-1; i++) {
	    ans.emplace_back(a[n-1],a[i]);
	    a[n-1] -= a[i];
	}
	cout<<a[n-1]<<"\n";
	for (auto p: ans) {
	    cout<<p.first<<" "<<p.second<<"\n";
	}
	return 0;
    }
    
    vector<int> neg, pos;
    for (int x: a) {
	if (x<0) {
	    neg.push_back(x);
	} else {
	    pos.push_back(x);
	}
    }
    
    assert(!neg.empty() && !pos.empty());
    
    while ((int)neg.size() > 1) {
	ans.emplace_back(pos.back(), neg.back());
	pos.back() -= neg.back();
	neg.pop_back();
    }

    while ((int)pos.size() > 1) {
	ans.emplace_back(neg.back(), pos.back());
	neg.back() -= pos.back();
	pos.pop_back();
    }

    ans.emplace_back(pos[0], neg[0]);
    int res = pos[0] - neg[0];
    cout<<res<<"\n";
    for (auto p: ans) {
	cout<<p.first<<" "<<p.second<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 5336