akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

int main(void) {
    while(true) {
        int r, n;
        cin >> r >> n;
        if (r == 0) {
            break;
        }
        vector<PII> table(41, make_pair(0, 0));         
        for (int i = 0; i < n; i++) {
            int l;
            int r;
            int h;
            cin >> l >> r >> h;
            l += 20;
            r += 20;
            table[l].second = max(table[l].second, h);
            table[r].first = max(table[r].first, h);
            for (int j = l + 1; j <= r - 1; j++) {
                table[j].first = max(table[j].first, h);
                table[j].second = max(table[j].second, h);
            }
        }
        /*
        for (int i = 0; i <= 40; i++) {
            cout << table[i].first << " " << table[i].second << endl;
        }
        */
        double min_dist = (double)(1e09);
        int min_h;
        double sun_y;


        for (int i = 20 - r; i <= 20 + r; i++) {
            if (i == 20 - r) {
                min_h = table[i].second;
            } else if (i == 20 + r) {
                min_h = table[i].first;
            } else {
                min_h = min(table[i].first, table[i].second);
            }
            sun_y = (double)(sqrt(r * r - (i - 20) * (i - 20))) - (double)r;
            //cout << i << " " << min_h << " " << sun_y << endl;
            if (min_dist > min_h - sun_y) {
                min_dist = min_h - sun_y;
            }
        }
        printf("%.4f\n", min_dist);
    }
    return 0;
}

Measured memory_bytes: 3096
/* Headers */
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#define FOR(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define ROF(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define FORL(i,a,b,c) for(long long i=(a);i<=(b);i+=(c))
#define ROFL(i,a,b,c) for(long long i=(a);i>=(b);i-=(c))
#define FORR(i,a,b,c) for(register int i=(a);i<=(b);i+=(c))
#define ROFR(i,a,b,c) for(register int i=(a);i>=(b);i-=(c))
#define RevEdge(x) x^1
#define lowbit(x) x&(-x)
#define LeftChild(x) x<<1
#define RightChild(x) (x<<1)+1
#define CLOSE_IN() fclose(stdin);
#define CLOSE_OUT() fclose(stdout);
#define FILE_IN(x) freopen(x,"r",stdin);
#define FILE_OUT(x) freopen(x,"w",stdout);
#define IOS(x) std::ios::sync_with_stdio(x)
#define Dividing() printf("-----------------------------------\n");
namespace FastIO {
#define gc() (iS == iT ? (iT = (iS = ibuff) + fread(ibuff, 1, SIZ, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
    const int SIZ = 1 << 21 | 1;
    char* iS, * iT, ibuff[SIZ], obuff[SIZ], * oS = obuff, * oT = oS + SIZ - 1, fu[110], cc;
    int fr;
    inline void out() {
        fwrite(obuff, 1, oS - obuff, stdout);
        oS = obuff;
    }
    template<class Type>
    inline void read(Type& x) {
        x = 0;
        Type y = 1;
        for (cc = gc(); (cc > '9' || cc < '0') && cc != '-'; cc = gc());
        cc == '-' ? y = -1 : x = (cc & 15);
        for (cc = gc(); cc >= '0' && cc <= '9'; cc = gc())
            x = x * 10 + (cc & 15);
        x *= y;
    }
    template<class Type>
    inline void print(Type x, char text = '\n') {
        if (x < 0)
            * oS++ = '-', x *= -1;
        if (x == 0)
            * oS++ = '0';
        while (x)
            fu[++fr] = x % 10 + '0', x /= 10;
        while (fr);
            * oS++ = fu[fr--];
        * oS++ = text;
        out();
    }
    inline void prints(char x[], char text = '\n') {
        for (register int i = 0; x[i]; ++i)
            * oS++ = x[i];
        * oS++ = text;
        out();
    }
}
using namespace FastIO;
template<typename T>
inline T max(T a, T b) {return (a > b) ? a : b;}
template<typename T>
inline T min(T a, T b) {return (a > b) ? b : a;}
/* definitions */
const int MAXN = 3e2 + 10;
int n, m, att[MAXN][MAXN], buk[MAXN], ans;
int choose[MAXN], p[MAXN];
/* functions */
int main(int argc, char *argv[]) {
    /*FILE_IN("data.in");*/ read(n); read(m); ans = n;
    FOR(i, 1, n, 1) FOR(j, 1, m, 1) read(att[i][j]);
    FOR(i, 1, m, 1) choose[i] = 1;
    FOR(i, 1, n, 1) p[i] = 1;
    FOR(k, 1, m, 1) {
        FOR(i, 1, m, 1) buk[i] = 0;
        FOR(i, 1, n, 1) {
            while(!choose[att[i][p[i]]]) ++p[i];
            ++buk[att[i][p[i]]];
        } int maxp = 0;
        FOR(j, 1, m, 1) if(buk[maxp] < buk[j]) maxp = j;
        if(ans > buk[maxp]) ans = buk[maxp];
        choose[maxp] = 0;
    } printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4392
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return int64(a)
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanInt64Slice(n int64) []int64 {
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = scanInt64()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	c := scanText()
	a := c[0]
	a++

	fmt.Println(string(a))

}

func binarySearch(arr []int, number int) int {

	l := -1
	r := len(arr)
	index := 0
	for {
		mid := l + (r-l)/2
		tmp := arr[mid]

		if r-l <= 1 || tmp == number {
			index = mid
			break
		} else if tmp < number {
			l = mid
		} else {
			r = mid
		}
	}
	return index
}

func factorial(n int) int64 {
	sum := int64(1)
	for i := 2; i <= n; i++ {
		sum *= int64(i)
	}
	return sum
}

func deleteNumOfArray(arr []int, position int) []int {
	left := arr[:position]
	r := arr[position+1:]
	appendArr := append(left, r...)
	return appendArr
}


Measured memory_bytes: 640
N, M, C = map(int,input().split())
*b, = map(int,input().split())
ans = 0

for _ in range(N):
  *a, = map(int,input().split())
  if sum(i*j for i,j in zip(a, b))+C>0:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>

using namespace std;

int a[4800];
int rate[9];

int main(void){
	int N;
	int min = 0;
	int max = 0;
	cin >> N;
	for(int i=0; i<9; i++){
		rate[i]=0;
	}
	for(int i=0; i<N; i++){
		cin >> a[i];
		if(a[i]/400 < 8){
			rate[a[i]/400]++;
		}else{
			rate[8]++;
		}
	}
	for(int i=0; i<8; i++){
		if(rate[i]!=0){
			min++;
		}
	}
	max = min+rate[8];
	if(min==0){
		min=1;
	}
	cout << min <<' ' << max << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			char[] t = scanner.next().toCharArray();
			Arrays.sort(s);
			Arrays.sort(t);
			for (int i = 0; i < Math.min(s.length, t.length); i++) {
				if (t[t.length - 1 - i] > s[i]) {
					System.out.println("Yes");
					return;
				} else if (t[t.length - 1 - i] < s[i]) {
					System.out.println("No");
					return;
				}
			}
			System.out.println((t.length > s.length) ? "Yes" : "No");
		}
	}
}


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

typedef long long ll;
typedef long double ld;

const int inf = 1e9;
 
ll n;

const ll mod = 1000000007; // faster if const

ll modpow(ll a, ll e) {
	if (e == 0) return 1;
	ll x = modpow(a * a % mod, e >> 1);
	return e & 1 ? x * a % mod : x;
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	ll ans = modpow(10, n);
	ans -= (modpow(9, n) * 2) % mod;
	ans += modpow(8, n) % mod;
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


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

int main() {
	string S;
	long long K;
	cin >> S >> K;
	K--;
	vector<string> VS;
	for (int L = 0; L < S.size(); L++) {
		for (int R = 1; R <= 5 && L + R - 1 < S.size(); R++) {
			VS.push_back(S.substr(L, R));
		}
	}
	sort(VS.begin(), VS.end());
	VS.erase(unique(VS.begin(), VS.end()), VS.end());
	cout << VS[K] << endl;
}

Measured memory_bytes: 1660
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

s = i_s()
print(s[0] + str(len(s)-2) + s[-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    string s;cin >> s;
    int n = s.size();
    string ans = "";
    rep(i,n){
        if(s[i] == '?')ans += 'D';
        else ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3924
import sys


def main():
    n, *a = map(int, sys.stdin.read().split())

    l = 0
    r = sum(a)
    m = sum(a)
    for i in range(n):
        l += a[i]
        r -= a[i]
        m = min(m, abs(l - r))

    print(m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 25124
//monk
#include<bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= (int)(1e19+10LL);
void solve()
{
  int n,m;
  sl(n);sl(m);
  int val1=n*(n-1);
  int val2=m*(m-1);
  cout<<(val1/2 + val2/2)<<endl; 
}
 
signed main(){
	int test=1;
   //sl(test);
   while(test--){
	 solve();
   }
  return 0;
}


Measured memory_bytes: 256
N = list(input())
Y = [0]
for i in N:
    Y.append(int(i))
dp = [0 for i in range(len(N)+1)]
dp2 = [10 for i in range(len(N)+1)]
for i in range(1,len(N)+1):
    dp[i] = min(dp[i-1] + Y[i],dp2[i-1] + Y[i])
    dp2[i] = min(dp[i-1] + 1 + 10 - Y[i],dp2[i-1] - 1 + 10 - Y[i])
    #print(str(dp[i])+":" +str(dp2[i]))
ans = min(dp[-1],dp2[-1])
#print(dp,dp2)
print(ans)

Measured memory_bytes: 100544
n,m,x,y = map(int,input().split())
xl = list(map(int,input().split()))
yl = list(map(int,input().split()))
lm = list(range(x+1,y+1))
xl.sort(reverse=True)
yl.sort()
ans = "War"

for item in lm:
    if item > xl[0] and item <= yl[0]:
        ans = "No War"
        break
        
print(ans,end='')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
}
//}}}
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
/*
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) a=a*a%MOD;
		else res=res*a%MOD;
		b>>=1;
	}
	res=res*a%mod;
	return res;
}
*/
bool a[maxn][maxn];
const pii dir[]={{0,1},{0,-1},{1,0},{-1,0}};
pii operator+(pii a,pii b){
	return {a.F+b.F,a.S+b.S};
}

bool vis[maxn][maxn];
int dis[maxn][maxn];
vector<pii> q;
int pt=0;

int main()
{
	//IOS;
	int n,m;
	cin>>n>>m;
	REP(i,n){
		string s;
		cin>>s;
		REP(j,m){
			if(s[j]=='.') a[i+1][j+1]=1;
		}
	}
	int cnt=0;
	REP(i,n) REP(j,m) if(a[i+1][j+1]) cnt++;

	{
		q.pb({1,1});
		vis[1][1]=0;
		while(pt<q.size()){
			pii cur=q[pt++];
			REP(I,4){
				pii nxt=cur+dir[I];
				if(!a[nxt.F][nxt.S]||vis[nxt.F][nxt.S]) continue;
				dis[nxt.F][nxt.S]=dis[cur.F][cur.S]+1;
				vis[nxt.F][nxt.S]=1;
				q.pb(nxt);
			}
		}
	}
	if(vis[n][m]){
		cout<<cnt-dis[n][m]-1;
	}
	else cout<<-1;

	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	
	int remain = (x - a) % b;
	cout << remain << endl;
}

Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
map<string , ll>mp;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    ll ans = 0;
    for(int i=0;i<n;i++){
        string ar;
        cin >> ar;
        sort(ar.begin() , ar.end());
        ans+=mp[ar];
        mp[ar]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007LL;

// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; for(long long i = 2; i <= n; i++) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
// ※modが素数の場合、この関数で(mod - 2)乗したら、mod割り算ができるよ！
// (参考問題: ABC034 C問題など)
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    for(long long i = 0; i < r; i++) a = a * ((n-i) % mod) % mod;
    ll b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

signed main(){

    while(1){

        long long n, d, x; cin >> n >> d >> x;
        
        if(!n) break;

        //一日一個食べるという制約のもと
        //dp[i][j] := i日かかってクッキーj個食べる方法の通り数
        vector<vector<long long> > dp(n + 1, vector<long long> (n + 1, 0LL));
        dp[0][0] = 1LL;
        //cout << dp[0][0] << endl;

        for(long long i = 0LL; i < n; i++){

            //累積和
            vector<long long> acc(n + 1, 0LL);
            acc[0] = dp[i][0];
            //cout << acc[0] << " ";
            for(long long j = 1LL; j <= n; j++){
                acc[j] = (acc[j - 1] + dp[i][j]) % MOD;
                //cout << acc[j] << " ";
            }
            //cout << endl;

            for(long long j = i + 1LL; j <= n; j++){

                //食べる個数は 1 <= c <= x - 1
                long long r = j - 1LL;
                long long l = max(0LL, j - x + 1LL);

                if(l == 0) dp[i + 1][j] += acc[r] % MOD;
                else{
                    assert(r >= l - 1);    
                    dp[i + 1][j] += (acc[r] - acc[l - 1] + MOD) % MOD;
                }

                dp[i + 1][j] %= MOD;
                assert(dp[i + 1][j] >= 0);
            }
        }

        /*for(long long i = 0; i <= n; i++){
            for(long long j = 0; j <= n; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/
        


        long long ans = 0LL;
        for(long long i = 1LL; i <= n && i <= d; i++){
            //cout << i << endl;
            ans += ((dp[i][n] % MOD) * (combination_mod(d, i, MOD) % MOD)) % MOD;
            ans %= MOD;
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;

    std::string akiba = "AKIHABARA";

    if (s.length() > akiba.length()) {
        std::cout << "NO" << std::endl;
        return 0;
    }

    int ptr_akiba = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != akiba[ptr_akiba]) {
            if (akiba[ptr_akiba] != 'A') {
                std::cout << "NO" << std::endl;
                return 0;
            }
            i--;
        }
        ptr_akiba++;
    }

    if (ptr_akiba < akiba.length() - 1) {
        std::cout << "NO" << std::endl;
        return 0;
    }

    std::cout << "YES" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl b(n-1);
    rep(i, n-1) {
        cin >> b[i];
    }

    vl a(n);
    a[0] = b[0];
    a[n-1] = b[n-2];
    exrep(i, 1, n-2) {
        a[i] = min(b[i-1], b[i]);
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i];
    }

    out(ans);
    re0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, d;
	cin >> n >> d;
	cout << (n + 2 * d) / (2 * d + 1) << endl;
    
    return 0;
}



Measured memory_bytes: 3548
#include <cstdio>

int N;

int H[101];

int main()
{
  int max_height = 0;
  int counter = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &H[i]);
    if (H[i] >= max_height) {
      max_height = H[i];
      ++counter;
    }
  }
  printf("%d\n", counter);
  return 0;
}



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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  A = (A == 1 ? 14 : A);
  B = (B == 1 ? 14 : B);
  if (A > B) {
    cout << "Alice" << endl;
  } else if (A < B) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define BLACK 1
#define INFINITY 1000000000


int Array[MAX][MAX],color[MAX];
int d[MAX],p[MAX];
int n,u;

void prim(){
	int min;
	int i,j,m;

	for(i=0;i<n;i++){
		d[i] = INFINITY; /* ∞ */
		color[i] = WHITE;
		p[i] = NULL;
	}
	d[0] = 0;


	for(i=0;i<n;i++){
		min = INFINITY;

		for(j=0;j<n;j++){
			if(min > d[j] && color[j] != BLACK){
				min = d[j];
				u=j;
				
			}
		}

		for(m=0;m<n;m++){
			if(color[m] != BLACK && Array[u][m] + d[u] < d[m]){
					p[m] = u;
					d[m] = Array[u][m] + d[u];
					
			}
		}
			color[u] = BLACK;
	}
}

int main(){

	int i,j;
	int k,c,v;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			Array[i][j] = INFINITY;
		}
	}

for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d %d",&c,&v);
			Array[u][c] = v;
		}
	}

	prim();
	for(i=0;i<n;i++){
		printf("%d %d\n",i,d[i]);
	}

	return 0;
}


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

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

	vector<string> a(n);

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

	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	for (int i = 0; i < n; i++)
	{
		if (a[i] == "AC")
		{
			ac++;
		}
		if (a[i] == "WA")
		{
			wa++;
		}
		if (a[i] == "TLE")
		{
			tle++;
		}
		if (a[i] == "RE")
		{
			re++;
		}
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

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

typedef long long ll;

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

    int a[n];
    bool odd = false;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%2 == 1) odd = true;
    }

    if(odd == false && p == 0){
        ll ans = 1;
        for(int i = 0; i < n; i++)  ans *= 2;
        cout << ans << endl;
    }else if(odd == false && p == 1){
        cout << 0 << endl;
    }else{
        ll ans = 1;
        for(int i = 0; i < n-1; i++)  ans *= 2;
        cout << ans << endl;
    }

    return 0;
}

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

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

  int N, M; cin >> N >> M;

  int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define WIN 1
#define LOSE 2
#define DRAW 3
using namespace std;
int main(){
  while(1){
    int p=0,c=0,g=0,finish=0;
    int te[5];
    for(int i=0;i<5;i++){
      cin>>te[i];
      if(te[i]==0){
	finish=1;
	break;
      }
      switch(te[i]){
      case 1:g++;break;
      case 2:c++;break;
      case 3:p++;break;
      }
    }
    if(finish==1)
      break;
    if(g!=0&&c!=0&&p!=0||g==0&&c==0||g==0&&p==0||c==0&&p==0){
      for(int i=0;i<5;i++)
	cout<<DRAW<<endl;
    }else if(g==0){
      for(int i=0;i<5;i++){
	if(te[i]==2)
	  cout<<WIN<<endl;
	else
	  cout<<LOSE<<endl;
      }
    }else if(c==0){
      for(int i=0;i<5;i++){
	if(te[i]==3)
	  cout<<WIN<<endl;
	else
	  cout<<LOSE<<endl;
      }
    }else if(p==0){
      for(int i=0;i<5;i++){
	if(te[i]==1)
	  cout<<WIN<<endl;
	else
	  cout<<LOSE<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int a;
    cin >> a;
    cout << a*a << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		long[] L = new long[N];
		for(int i = 0; i < N; i++) {
			L[i] = s.nextLong();
		}
		
		Arrays.sort(L);
		int ret = 0;
		for(int i = 0; i < N; i++) {
			for(int j = i+1; j < N; j++) {
				if(L[i] == L[j]) continue;
				for(int k = j + 1; k < N; k++) {
					if(L[i] == L[k] || L[j] == L[k]) continue;
					if(L[i] + L[j] > L[k]) ret++;
				}
			}
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 36940
N,D = map(int,input().split())
X = [tuple(map(int,input().split())) for i in range(N)]

ans = 0
for i,a in enumerate(X[:-1]):
    for b in X[i+1:]:
        d = 0
        for x,y in zip(a,b):
            d += (x-y)**2
        if d**0.5 - int(d**0.5) < 10e-10:
            ans += 1
print(ans)


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

int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> guide(N);

    for (int i = 0; i < N;i++){
        string a;
        int b;
        cin >> a >> b;
        guide.at(i) = make_pair(make_pair(a, -b),i);
    }

    sort(guide.begin(), guide.end());
    
    //cout << endl;
    for (int i = 0; i < N;i++){
        
        cout << guide.at(i).second+1<< endl;
    }

}

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

#define ll long long

void solve(){
    ll x, k, d; cin>>x>>k>>d;
    x = abs(x);
    ll i = ceil(x/d);
    i = (i>k ? k: i);
    i = (x == d ? 0 : i);

    x = x-i*d;

    x = (k-i)%2 == 0 ? x : x-d;

    cout<<abs(x)<<endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  deque<int> q;
  for(char c: s) {
    if(c == '0') {
      q.push_back(0);
    } else if(c == '1') {
      q.push_back(1);
    } else {
      if(q.empty()) continue;
      q.pop_back();
    }
  }
  while(!q.empty()) {
    cout << q.front();
    q.pop_front();
  }
  cout << endk;
  return 0;
}


Measured memory_bytes: 3588
n = int(input())

ans = 0

if 100 <= n and n < 1000:
    ans = n%10
elif 10 <= n and n < 100:
    ans = n%10
else:
    ans = n

if ans == 3:
    print('bon')
elif ans == 0 or ans == 1 or ans == 6 or ans == 8:
    print('pon')
else:
    print('hon')

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n, k;
    ci >> n >> k;

    double sum = 0;
    double rr = log2(k);
    
    rep(i, 1, n + 1) {

	double t = 1 / (double)n;
	int val = i;
	rep(j, 1, rr + 2) {
	    if(val >= k) break;
	    val <<= 1;
	    t *= 0.5;
	}

	sum += t;
	
    }

    printf("%.16f\n", sum);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int l, r, d;
  int count = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++)
  {
    if (i%d==0) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3144
<?php
# スペース区切りの整数の入力
fscanf(STDIN, "%s %s %s", $x, $k, $d);

$x = intval($x);
$k = intval($k);
$d = intval($d);
$maxCount = intval(floor($x / $d));

if ($x > 0) {
	if ($maxCount >= $k) {
		$newX = $x - $k * $d;
	} else {
		$newX = $x - $maxCount * $d;
		$newK = $k - $maxCount;
		if ($newK % 2 != 0) {
			if (abs($newX - $d) < abs($newX + $d)) {
				$newX -= $d;
			} else {
				$newX += $d;
			}
		}
	}
} else {
	if (abs($maxCount) >= $k) {
		$newX = $x + $k * $d;
	} else {
		$newX = $x + abs($maxCount) * $d;
		$newK = $k - abs($maxCount);
		if ($newK % 2 != 0) {
			if (abs($newX - $d) < abs($newX + $d)) {
				$newX -= $d;
			} else {
				$newX += $d;
			}
		}
	}
}

# 出力
echo sprintf("%.0f", abs($newX)) . "\n";

Measured memory_bytes: 15872
def main():

    T = input()

    ans = 0
    S = []
    for i in range(len(T)):
        if T[i] == "?":
            S.append('D')
        else:
            S.append(T[i])
    return "".join(S)

    # for i in range(len(T)):
    #     if T[i] == 'D':
    #         ans += 1
    # for i in range(len(T)-1):
    #     if T[i:i+2] == "PD":
    #         ans += 1
    # return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 10856
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int n,a,b;
	while(~scanf("%d %d %d",&n,&a,&b))
	{
		if(a*n>b)
			printf("%d\n",b);
		else
			printf("%d\n",a*n);
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans, num = 0, 0
for i in range(N):
  ans += min(B[i], A[i]+A[i+1])
  d = B[i] - A[i]
  if d > 0:
    A[i+1] -= min(d, A[i+1])
print(ans)

Measured memory_bytes: 19116
#include<bits/stdc++.h>
 
#include<bits/stdc++.h>
#define _ cin.tie(0); ios::sync_with_stdio(false);
using namespace std;
 
int main(){ _
 
 
 
    string str1, tmp1;
    while(cin >> str1 >> tmp1){
    reverse(str1.begin(), str1.end());
    if(str1 == tmp1) cout << "YES" << endl;
    else cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 1e9 + 7;
class {
  public:
    i64 d[2222][2222][2];
    pi64 a[2222];
    void solve() {
        memset(d, -1, sizeof d);
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i) {
            cin >> a[i].first;
            a[i].second = i;
        }
        sort(a + 1, a + 1 + n, [](pi a, pi b) { return a.first > b.first; });
        d[1][1][0] = a[1].first * abs(a[1].second - 1);
        d[1][n][1] = a[1].first * abs(a[1].second - n);
        for (int i = 1; i < n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (d[i][j][0] != -1) {
                    d[i + 1][j + 1][0] =
                        max(d[i + 1][j + 1][0],
                            d[i][j][0] + a[i + 1].first *
                                             abs(a[i + 1].second - (j + 1)));
                    d[i + 1][n - i + j][1] =
                        max(d[i + 1][n - i + j][1],
                            d[i][j][0] + a[i + 1].first * abs(a[i + 1].second -
                                                              (n - i + j)));
                }
                if (d[i][j][1] != -1) {
                    d[i + 1][j - 1][1] =
                        max(d[i + 1][j - 1][1],
                            d[i][j][1] + a[i + 1].first *
                                             abs(a[i + 1].second - (j - 1)));
                    d[i + 1][i + j - n][0] =
                        max(d[i + 1][i + j - n][0],
                            d[i][j][1] + a[i + 1].first * abs(a[i + 1].second -
                                                              (i + j - n)));
                }
            }
        }
        i64 ans = 0;
        for (int i = 1; i <= n; ++i) {
            ans = max(ans, d[n][i][0]);
            ans = max(ans, d[n][i][1]);
        }
        cout << ans << "\n";
    }
} NSPACE;
int main() {
    // FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 80836
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    string w;
    cin >> w;

    vector<int> v(26, 0);
    for(const auto& e : w)
        v[e - 'a']++;

    bool ans = true;
    for(const auto& e : v)
    {
        if(e % 2)
            ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, k;
    cin >> n >> k;

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

    n -= k;

    cout << n << endl;
}

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

import sys

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

H, N = MAP()
AB = [()]
for i in range(N):
    a, b = MAP()
    AB.append((a, b))

dp = list2d(N+1, 20007, INF)
dp[0][0] = 0
for i in range(1, N+1):
    a, b = AB[i]
    for j in range(20007):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        if j-a >= 0:
            dp[i][j] = min(dp[i][j], dp[i][j-a] + b, dp[i-1][j-a] + b)
print(min(dp[N][H:]))


Measured memory_bytes: 191512
n = int(input())

al = list(map(int,input().split()))
tl = list(map(int,input().split()))


for i in range(n-1):
    if al[i] > al[i+1]:
        print(0)
        exit()
    if tl[i] < tl[i+1]:
        print(0)
        exit()

ans = 1
for i in range(n):
    a = False
    t = False
    if i != 0:
        if al[i] != al[i-1]:
            a = True
    else:
        a = True
    if i != n-1:
        if tl[i] != tl[i+1]:
            t = True
    else:
        t = True
    if a and t:
        if al[i] != tl[i]:
            print(0)
            exit()
    elif a:
        if al[i] > tl[i]:
            print(0)
            exit()
    elif t:
        if al[i] < tl[i]:
            print(0)
            exit()
    else:
        ans *= min(al[i], tl[i])
        ans %= 10**9 + 7

print(ans)






Measured memory_bytes: 82404
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define INFI 1000000000000000000

int main() {
    // ll t;
    // cin >> t;
    // while(t--) {
        ll n , k , d;
        cin >> n >> k >> d;
        n = abs(n);
        ll moves = (n) / d;
        ll mn = min(moves , k);
        k -= mn;
        ll pos = n - d * mn;

        if(k) {
            ll newpos = pos - d;
            newpos = abs(newpos);
            if(newpos < pos) {
                k --;
                ll temp = pos;
                pos = newpos;
                newpos = temp;
                if(k % 2 == 0) {
                    cout << pos << endl;
                }
                else{
                    cout << newpos << endl;
                }
            }
            else{
                if(k % 2 == 0) {
                    cout << pos << endl;
                }
                else{
                    cout << newpos << endl;
                }
            }
        }
        else{
            cout << pos << endl;
        }
    // }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
  int w,h,x,y;
   cin>>w>>h>>x>>y;
  double tot=w*h;
  tot=tot/2;
  cout<<tot<<" ";
  if(x*2==w && y*2==h)
    cout<<1<<"\n";
    else cout<<0<<"\n";
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C;
string S,T;
ll ans;
ll x[100000];
ll y[100000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	cin>>S>>T;
	char s[50];
	rep(i,0,50){
		s[i]='A';
	}
	rep(i,0,S.size()){
		if(s[T[i]-'a']=='A'){
			s[T[i]-'a']=S[i];
		}else{
			if(S[i]!=s[T[i]-'a']){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	map<char,ll> check;
	rep(i,0,50){
		if(s[i]=='A')continue;
		check[s[i]-'a']++;
		if(check[s[i]-'a']>1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

using namespace std;

int main(void) {
        int K;
        int A, B;

        int flag = 0;

        scanf("%d", &K);
        scanf("%d", &A);
        scanf("%d", &B);

        for(int i=A; i<=B; i++) {
                if(i%K == 0) {
                        flag = 1;
                        break;
                }
        }
        if(flag) {
                printf("OK\n");
        } else {
                printf("NG\n");
        }

        return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
string a;
int main(){
	int i, j;
	cin >> a;
	if(a[0] == a[a.length()-1] ^ a.length()%2==0){
		cout << "Second";
	}else {
		cout << "First";
	}
}


Measured memory_bytes: 512
N = int(input())
W = list(map(int, input().split()))
ansmin = -1
for i in range(N):
    countA = 0
    countB = 0
    flag = 0
    for j in range(N):
        if flag == 0:
            countA += W[j]
        else:
            countB += W[j]
        if i == j:
            flag = 1
    ans = abs(countA - countB)
    if ansmin == -1:
        ansmin = ans
    elif ansmin > ans:
        ansmin = ans
    #print(ansmin, ans)
print(ansmin)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d)cout << "Yes" << endl;
    else{
        if((abs(b-a)<=d)&&(abs(c-b)<=d))cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <map>

std::map<int, int> map;
std::multimap<int, int> emp;
int a[200005], b[200005];
int target[200005], tcnt = 0;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		emp.insert(std::make_pair(a[i], i));
	}
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	for (int i = 1; i <= n; i++)
	{
		int cnt = 1, tcnt = 0, cur = b[i];
		while (i < n && b[i+1] == b[i]) cnt++, i++;
		// printf("%d %d %d\n", cur, cnt, emp.size());
		for (auto j = emp.begin(); tcnt < cnt && j != emp.end() && j->first < cur; j = emp.begin())
		{
			target[tcnt++] = j -> second;
			emp.erase(j);
		}
		for (auto j = emp.upper_bound(cur); tcnt < cnt && j != emp.end(); j = emp.upper_bound(cur))
		{
			if (j->first <= cur) j++;
			if (j == emp.end()) break;
			target[tcnt++] = j->second;
			emp.erase(j);
		}
		for (auto j = map.begin(); tcnt < cnt && j != map.end(); j++) target[tcnt++] = j->first;
		if (tcnt < cnt)
		{
			printf("No\n");
			return 0;
		}
		for (int j = 0; j < tcnt; j++)
		{
			if (map.count(target[j]) == 0) map[target[j]] = cur;
			else
			{
				auto l = map.find(target[j]);
				auto r = emp.find(cur);
				map[r->second] = l->second;
				map[l->first] = cur;
				emp.erase(r);
			}
		}
	}

	printf("Yes\n");
	for (int i = 1; i <= n; i++) printf("%d ", map[i]); printf("\n");
}


Measured memory_bytes: 14908
import java.util.Scanner;

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

		String a_str = scanner.next();
		String b_str = scanner.next();

		int a = Integer.parseInt(a_str);
		int b = Integer.parseInt(b_str);

		if(a >= 1 && b <= 100) {
			int menseki = a * b;
			int syu = 2 * (a + b);

			System.out.println(menseki + " " + syu);
		}

    	scanner.close();
    }
}



Measured memory_bytes: 25812
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++)
  {
    int a, b; cin >> a >> b;
    v.push_back(make_pair(b, a));
  }
  sort(v.begin(), v.end());
  int cur = 0;
  for (int i = 0; i < n; i++)
  {
    int b = v[i].first;
    int a = v[i].second;
    if (cur + a <= b) cur += a;
    else {cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 2420
public class Main {

  private static void solve() {
    int n = ni();
    char[] c = ns();
    int ret = 0;
    int lp = n - 1;
    for (int i = 0; i < n; i++) {
      if (lp <= i)
        break;

      if (c[i] == 'W') {
        while (lp > i && c[lp] != 'R') {
          lp--;
        }
        if (lp == i)
          break;

        ret++;
        lp--;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

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

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 39984
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")

//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (int)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0
// a^b=(a+b)-2(a&b)

typedef double db;
typedef long long ll;

const int ary=1e5+5;
const int mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
int n,ans;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	int mn=mod;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		mn=min(mn,x);
		if(mn>=x){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007
typedef vector<vector<int>> Graph;


vector<bool> seen;
void dfs(Graph &G,int v){
    seen[v]=true;
    for(auto nextv : G[v]){
        if(seen[nextv]) continue;
        dfs(G,nextv);
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    Graph G(N,vector<int>());
    seen.assign(N,false);
    rep(i,M){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        G[x].push_back(y); // zが何であろうが関係ない
        G[y].push_back(x);
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        if(seen[i]==false){
            if(G[i].size()!=0) dfs(G,i);
            seen[i]=true;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
ll isprime(ll t){
	for(ll j=2;j<=sqrt(t);j++){
		if(t%j==0)
			return 0;
	}
	return 1;
}
int main(){
	ll n,m;
	ll cnt=0;
	cin >> n >> m;
	ll t;
	t=gcd(m,n);
	if(t==1){
		cout << "1\n";
		return 0;
	}
	for(ll i=1;i<=sqrt(t);i++){
		ll j=t/i;
		if(j*i==t){
			if(isprime(i))
				cnt++;
			if(isprime(j)) cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main() {
	int N,K,S;
	cin >> N >> K >> S;
  rep(i,K){
		cout << S << " ";
	}

	int zan = N-K;
	if(S != (int)1e9){
		rep(i,zan) cout << (int)1e9 << " ";
	} else {
		rep(i,zan) cout << 1 << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a;	cin>>b;	cin>>c;	cin>>d;	cin>>e;

	if(a<=0){
		f=c*(0-a);
		f=f+d;
		f=f+b*e;
	}
	else if(a>0){
		f=e*(b-a);
	}

	cout<<f<<endl;

	return 0;
}


Measured memory_bytes: 3104