akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
/* Filename: ARC065C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			StringBuilder S = new StringBuilder(input.next());

			while (S.length() >= 7) {
				if (S.substring(S.length() - "dreamer".length()).equals("dreamer")) {
					S.delete(S.length() - "dreamer".length(), S.length());
				} else if (S.substring(S.length() - "eraser".length()).equals("eraser")) {
					S.delete(S.length() - "eraser".length(), S.length());
				} else if (S.substring(S.length() - "erase".length()).equals("erase")) {
					S.delete(S.length() - "erase".length(), S.length());
				} else if (S.substring(S.length() - "dream".length()).equals("dream")) {
					S.delete(S.length() - "dream".length(), S.length());
				} else {
					break;
				}
			}

			switch (S.toString()) {
			case "dream":
			case "erase":
			case "eraser":
			case "":
				System.out.println("YES");
				break;
			default:
				System.out.println("NO");
				break;
			}
		}
	}

}


Measured memory_bytes: 15464
module Main where

import Data.Maybe (fromJust)
import Data.List
import qualified Data.ByteString.Char8 as BS


bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine
getIntL_H = map bytestr2Int. BS.words <$> BS.getLine
getIntL_V n = replicate n $ getInt
getInt2D n = replicate n $ getIntL_H


main :: IO ()
main = do
    [w,k] <- getIntL_H
    let r = w - k * 2
    print $ if r < 0 then 0 else r



Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    int a, b, c;
    a = b = c = 0;
    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        if (e % 4 == 0) {
            a++;
        }
        else if (e % 2 == 0) {
            b++;
        }
        else {
            c++;
        }
    }
    int d = 0;
    for (int i = 0; i < n; i++) {
        if (c) {
            if (d == 0) {
                c--;
                d = 2;
                continue;
            }
        }
        if (b) {
            if (d != 2) {
                b--;
                d = 1;
                continue;
            }
        }
        if (a) {
            a--;
            d = 0;
            continue;
        }
        puts("No");
        return 0;
    }
    puts("Yes");
}

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

int main() {
	int H, W; cin >> H >> W;
	if(H%3<1 || W%3<1) cout << 0 << endl;
	else{
	    if(H>W) swap(H, W);
	    if(H%2<1) cout << H/2 << endl;
	    else if(W%2<1) cout << min(H, W/2) << endl;
	    else{
	        if(H<W) cout << H << endl;
	        else{
	            int P=(H+1)/6;
	            cout << H-P << endl;
	        }
	    }
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()


using namespace std;

const ll N = 2e5 + 10;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

ll a, b;

int main() {
	speed;
	cin >> n;
	ll ans = 0;
	a = 100;
	while(n > a){
		a = a + a / 100; 
		ans++;
	}
	cout << ans;
}

/*

0 133 14 135 28 137 42 139 56 141 70 143

*/



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

int main(){
    string s;
    cin >> s;
    string a[2] = {"A",""};
    bool can = false;
    rep(i,1 << 4){
        string t = a[1&(i>>0)] + "KIH" + a[1&(i>>1)] + "B" + a[1&(i>>2)] + "R" + a[1&(i>>3)];
        if(s == t) can = true;
    }
    cout << (can? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
a = set([i for i in s])
if len(a) != 2:
    print('No')
else:
    i,j = a
    ni = s.count(i)
    nj = s.count(j)
    if ni == 2 and nj == 2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, P> Pll;
int par[200002];
int rk[200002];
 
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
		rk[i]=0;
	}
}
 
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
 
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}

int main()
{
	int n, m, k;
	cin>>n>>m>>k;
	init(n+k);
	int c[100000];
	int ct[100000]={};
	for(int i=0; i<n; i++){
		cin>>c[i];
		if(c[i]){
			unite(i, n+c[i]-1);
			ct[c[i]-1]++;
		}
	}
	int ct0=0;
	for(int i=0; i<k; i++){
		if(ct[i]>0) ct0+=(ct[i]-1);
	}
	Pll e[100000];
	for(int i=0; i<m; i++){
		int a, b; ll w;
		cin>>a>>b>>w;
		a--; b--;
		unite(a, b);
		e[i]=Pll(w, P(a, b));
	}
	vector<int> vr[100000];
	int r[100000];
	for(int i=0; i<n; i++){
		r[i]=find(i);
		vr[r[i]].push_back(i);
	}
	int rn=0;
	for(int i=0; i<n; i++){
		if(!vr[i].empty()) rn++;
	}
	init(n+k);
	for(int i=0; i<n; i++){
		cin>>c[i];
		if(c[i]) unite(i, n+c[i]-1);
	}
	int ct1=n-k-ct0;
	if(ct1-(rn-1)<0){
		cout<<-1<<endl;
		return 0;
	}
	sort(e, e+m);
	ll ans=0;
	vector<ll> use;
	for(int i=0; i<m; i++){
		if(!same(e[i].second.first, e[i].second.second)){
			unite(e[i].second.first, e[i].second.second);
			use.push_back(e[i].first);
		}
	}
	int c0=ct1-rn+1;
	while(!use.empty()){
		if(c0==0) break;
		use.pop_back();
		c0--;
	}
	for(int i=0; i<use.size(); i++) ans+=use[i];
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	double r = 0;
	for (size_t i = 1; i <= n; i++)
	{
		int p = i;
		int j = 0;
		while(p < k) {
			p *= 2;
			j++;
		}
		r += pow(2, -j);
	}
	cout << setprecision(10) << 1/(double)n * r << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    string w;
    cin >> w;
    int count[26];
    REP(i,26){
        count[i] = 0;
    }
    REP(i,w.length()){
        count[int(w[i])-int('a')]++;
    }
    string ans;
    REP(i,26){
        if(count[i]%2==0){
            ans = "Yes";
        }else{
            ans = "No";
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ___                      \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define pii pair<int, int>
#define MAX INT_MAX
#pragma GCC optimize("Ofast")
#define int long long
const int MOD = (1e9 + 7);
using namespace std;
#define vvi vector<vector<int>>
signed main()
{
	___ 
	int r,d,x;
	cin >>r >>d>>x;
	for(int i=0;i<10;i++){
		cout<<r*x-d<<endl;
		x=r*x-d;
	}
}

Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n;
	cin>>n;
	int m;
	cin>>m;
	int cnt=0;
	while(n!=0)
	{
		n/=m;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f[10000],a;
int main()
{
    cin>>a;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=a;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[a]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int H, N, A[1000], B[1000];
  cin >> H >> N;
  REP(i, 1000) {
    cin >> A[i] >> B[i];
  }
  int mp[20001] = {0};
  for(int i = 1; i <= 20000; ++i) {
    mp[i] = 0x3FFFFFFF;
  }
  REP(i, H) {
    REP(j, N) {
      if(mp[i+A[j]] > mp[i] + B[j]) {
        mp[i+A[j]] = mp[i] + B[j];
      }
    }
  }
  int ret = 0x3FFFFFFF;
  for(int i = H; i < H + 10000; ++i) {
    if(ret > mp[i]) {
      ret = mp[i];
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
import collections
def main():
    N, P = (int(_) for _ in input().split())

    def bunkai_suru(n):
        ary = collections.defaultdict(int)
        p = 2
        while p * p <= n:
            while n%p == 0:
                n //= p
                ary[p] += 1
            p += 1
        if n != 1:
            ary[n] += 1
        return ary

    output = 1
    x = bunkai_suru(P)
    for p in x.keys():
        ex = x[p]//N
        output *= p ** ex
    print(output)
    return

if __name__ == '__main__':
    main()


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

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  int suma = 0, sumb = 0, sumc = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    suma += a[i];
    sumb += b[i];
    sumc += c[i];
  }
  int inf = sumc + 1;

  int dp[n+1][suma+1][sumb+1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= suma; j++) {
      for (int k = 0; k <= sumb; k++) {
        dp[i][j][k] = inf;
      }
    }
  }

  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= suma; j++) {
      for (int k = 0; k <= sumb; k++) {
        if (dp[i][j][k] == inf) continue;
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
      }
    }
  }

  int ans = inf;
  for (int j = 1; j <= suma; j++) {
    for (int k = 1; k <= sumb; k++) {
      if (j*mb == k*ma) ans = min(ans, dp[n][j][k]);
    }
  }
  cout << (ans != inf ? ans : -1) << endl;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;

int main() {FIN

	ll n, m, i, _min;
	cin >> n;
	for (i = 1; i * i <= n; i++) {
		if (i == 1)
			_min = n - 1;
		else if (n % i == 0) {
			m = n / i;
			_min = min(_min, (i - 1) + (m - 1));
		}
	}
	cout << _min << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
    vector<int> par; // uf(x,y)->y
    UnionFind() {}
    UnionFind(int NV) { init(NV); }
    void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) { x = operator[](x); y = operator[](y); if (x != y) par[x] = y; }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
int N, R, P[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> R;
	if (N - R < R) R = N - R;
	rep(i, 0, N) cin >> P[i];
	rep(i, 0, N) P[i]--;

	UnionFind uf;
	uf.init(N);
	rep(i, 0, N) uf(i, P[i]);
	map<int, int> cnt;
	rep(i, 0, N) cnt[uf[i]]++;
	vector<int> v;
	fore(p, cnt) v.push_back(p.second);

	bitset<150001> dp;
	dp.set(0);
	fore(x, v) dp = dp | (dp << x);

	if (dp[R]) cout << "Yes" << endl;
	else cout << "No" << endl;
}
 


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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1000000007;
ll arr[200005];
ll sum[200005];

void prefix(int n)
{
    sum[0] = arr[0] % mod;
    for(int i = 1; i < n; i++)
    {
        sum[i] = (sum[i - 1] + arr[i]) % mod;
    }
}

int main()
{
    fast_in_out;
    int n;
    cin >> n;
    ll s = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    prefix(n);
    for(int i = 0; i < n; i++)
    {
        ll x = (sum[n - 1] - sum[i]) % mod;
        if(x < 0)
        {
            x += mod;
        }
        ll y = arr[i] % mod;
        ll z = (x * y) % mod;
        s += z;
        s %= mod;
    }
    cout << s;
}


Measured memory_bytes: 6764
def solve():
    S = input()

    ans = ""

    if int(S[:2]) == 0:
        if 0 < int(S[2:4]) <= 12:
            ans = "YYMM"
        else:
            ans = "NA"
    elif int(S[2:4]) == 0:
        if 0 < int(S[:2]) <= 12:
            ans = "MMYY"
        else:
            ans = "NA"
    elif int(S[:2]) > 12 and 0 < int(S[2:4]) <= 12:
        ans = "YYMM"
    elif int(S[2:4]) > 12 and 0 < int(S[:2]) <= 12:
        ans = "MMYY"
    elif 0 < int(S[:2]) <= 12 and 0 < int(S[2:4]) <= 12:
        print ("AMBIGUOUS")
    else:
        print ("NA")
        
    print (ans)
    
if __name__ == "__main__":  
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 , -1};
struct mint {
  int x;
  mint(int 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(int 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;}
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b && b < c) puts("Yes");
    else puts("No"); 
}



Measured memory_bytes: 3064
#include <iostream>

long long resolve(const std::string a, long long n) {
    auto val = std::stoll(a);
    if (val > n) {
        return 0;
    }
    bool g3 = false, g7 = false, g5 = false;
    while (val > 0) {
        long long tmp = val % 10;
        if (tmp == 3) {
            g3 = true;
        } else if (tmp == 7) {
            g7 = true;
        } else if (tmp == 5) {
            g5 = true;
        }
        val /= 10;
    }
    int result = 0;
    if (g3 && g7 && g5) {
        result++;
    }
    result += resolve(a + "3", n);
    result += resolve(a + "5", n);
    result += resolve(a + "7", n);

    return result;
}


int main() {
    long long N;
    std::cin >> N;
    std::cout << resolve("0", N) << std::endl;
    return 0;
}

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

void solve() {
  int n;
  while (cin >> n, n) {
    vvi v(n, vi(n + 1));
    rep(i, n) rep(j, n + 1) cin >> v[i][j];
    vi dp(1 << n, INF);
    dp[0] = 0;
    rep(i, 1 << n) rep(j, n) {
      if (i >> j & 1) continue;
      int cost = v[j][0];
      rep(k, n) if (i >> k & 1) cmin(cost, v[j][k + 1]);
      cmin(dp[i | 1 << j], dp[i] + cost);
    }
    cout << dp.back() << endl;
  }
}

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

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


  vector<int> e(m);
  for ( int i = 0; i < m; i++ ) {
    cin >> e[i];
    e[i]--;
  }

  bool used[n] = {0};
  for ( int i = m-1; i >= 0; i-- ) {
    if ( !used[e[i]] ) cout << e[i]+1 << endl;
    used[e[i]] = true;
  }
  for ( int i = 0; i < n; i++ ) {
    if ( !used[i] ) cout << i+1 << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3356
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    m,nmin,nmax = inpl()
    if m == 0:
        break
    else:
        pp = [int(input()) for _ in range(m)]
        pp.sort(reverse=True)
        ans = 0
        ansgap = -1
        for n in range(nmin,nmax+1):
            gap = pp[n-1] - pp[n]
            if ansgap <= gap:
                ansgap = gap
                ans = n

        print(ans)



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

int main()
{
    int n;
    cin >> n;
    char check[5] = {'M', 'A', 'R', 'C', 'H'};
    vector<ll> s(5, 0);
    for (int i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        for (int j = 0; j < 5; j++)
        {
            if (temp[0] == check[j])
            {
                s[j] += 1;
                break;
            }
        }
    }
    cout << s[0] * s[1] * (s[2] + s[3] + s[4]) + s[0] * s[2] * (s[3] + s[4]) + s[0] * s[3] * s[4] +
                s[1] * s[2] * (s[3] + s[4]) + s[1] * s[3] * s[4] + s[2] * s[3] * s[4]
         << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main()
{
    ll n, x;
    ll ans = 0;
    ll cnt = 0;
    ll l = 0;
    cin >> n >> x;
    vector <ll> L(n, 0);
    for (int i = 0; i < n; i ++){
        cin >> L.at(i);
    }
    while (l<=x){
        l += L[cnt];
        cnt += 1;
        if (cnt==n+1) break;
    }
    ans = cnt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#define PI 3.14159265358979323846264

using namespace std;

int main()
{
	double a, b, C;
	cin >> a >> b >> C;
	C = C * PI / 180.0;
	cout << fixed << setprecision(8);
	cout << a * b * sin(C) / 2 << endl;
	cout << a + b + sqrt(a* a + b * b - 2 * a * b * cos(C)) <<endl;
	cout << b * sin(C)<<endl;
	return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#define rep(i, n) for (inti = 0; i < (n); ++i)
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int64_t> Luca(N + 1);
  Luca[0] = 2;
  Luca[1] = 1;
  for (int i = 2; i <= N; ++i) {
    Luca[i] = Luca[i - 1] + Luca[i - 2];
  }
  cout << Luca[N] << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
adj = [[] for i in range(N)]


for i in range(N-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)


dq = deque([(0, 1), (N-1, 2)])

colors = [0] * N
colors[0] = 1
colors[-1] = 2


while dq:
    node, color = dq.popleft()
    for dest in adj[node]:
        if colors[dest] != 0:
            continue
        else:
            colors[dest] = color
            dq.append((dest, color))

print('Fennec' if colors.count(1) > N//2 else 'Snuke')

Measured memory_bytes: 23440
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 10000
#define MO 998244353
using namespace std;
int dp[MAXN+5][MAXN+5];
char A[MAXN+5],B[MAXN+5];
int fact[MAXN+5],inv[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void prepare()
{
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;
}
int C(int n,int m)
{
	return 1LL*fact[n]*inv[m]%MO*inv[n-m]%MO;
}
int main()
{
	prepare();
	scanf("%s %s",A+1,B+1);
	int n=strlen(A+1),x=0,y=0;
	for(int i=1;i<=n;i++)
		if(A[i]=='1'&&B[i]=='1')
			x++;
		else if(A[i]=='1'&&B[i]=='0')
			y++;
	for(int j=0;j<=y;j++)
		dp[0][j]=1LL*fact[j]*fact[j]%MO;
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
			dp[i][j]=(1LL*dp[i-1][j]*i%MO*j%MO+1LL*dp[i][j-1]*j%MO*j%MO)%MO;
	int ans=0;
	for(int i=0;i<=x;i++)
		ans=(1LL*ans+1LL*dp[x-i][y]*fact[i]%MO*fact[i]%MO*C(x,i)%MO*C(x+y,i)%MO)%MO;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 387712
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<>());
  priority_queue<TP> que;
  que.push(TP(a[1],0,1));
  que.push(TP(a[1],0,1));
  ans += a[0];
  for(int i=2;i<n;i++){
    auto [val, x, y] = que.top(); que.pop();
    ans += val;
    que.push(TP(a[i],x,i));
    que.push(TP(a[i],y,i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 11036
N = gets.to_i
as = gets.split.map(&:to_i)

min = as.min
max = as.max

if max - min >= 2
    puts 'No'
    exit
elsif max == min
    if max == N - 1
        puts 'Yes'
        exit
    else
        n = N
        colors = max
    end
else
    cmin = as.count(min)
    n = N - cmin
    colors = max - cmin
    if colors <= 0
        puts 'No'
        exit
    end
end

if n / 2 >= colors
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 8068
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> count(n);
  for(int i = 0;i <= m - 1;i++){
    int a,b;
    cin >> a >> b;
    count[a - 1]++;
    count[b - 1]++;
  }
  bool yes = true;
  for(int i = 0;i <= n - 1;i++)if(count[i] % 2 != 0)yes = false;
  if(yes)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;
 
int main() {
	int n, inpnum;
	scanf("%d", &n);
	char comm[20];

	list<int> linkedlist;
	for(int comind = 0; comind < n; comind++){
		scanf("%s", comm);

		if(comm[0] == 'i'){
			scanf("%d", &inpnum);
			linkedlist.push_front(inpnum);
		}else if(comm[6] == 'L'){
			linkedlist.pop_back();
		}else if(comm[6] == 'F'){
			linkedlist.pop_front();
		}else{
			scanf("%d", &inpnum);
			for(list<int>::iterator it = linkedlist.begin(); it != linkedlist.end(); it++){
				if(*it == inpnum){
					linkedlist.erase(it);
					break;
				}
			}
		}
	}

	int allsize = linkedlist.size();
	for(int i = 0; i < allsize;){
		if(i++){
			printf(" ");
		}
		printf("%d", linkedlist.front());
		linkedlist.pop_front();
	}

	printf("\n");
}

Measured memory_bytes: 32220
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
typedef pair<string,int> psi;
vector<psi> v;
int main()
{
	IOS();
	int t;
	cin>>t;
	while(t--)
	{
		psi n;
		cin>>n.fi>>n.se;
		v.push_back(n);
	}
	string s;
	cin>>s;
	int flag=0;
	int ans=0;
	for(auto it:v)
	{
		
		if(flag) ans+=it.se;
		if(it.fi==s) flag=1;
	}
	cout<<ans<<endl;
	
	
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		if(c.equals("a") || c.equals("i") || c.equals("u") || c.equals("e") || c.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
		sc.close();
	}
 }


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int d[10][10],n,k,s[16001],tmp,ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<k;j++){
            cin>>d[i][j];
        }
    }
    for(int i=0;i*i<16001;i++){
        s[i*i]=1;
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            tmp=0;
            for(int ii=0;ii<k;ii++){
                tmp+=(d[i][ii]-d[j][ii])*(d[i][ii]-d[j][ii]);
            }
            if(s[tmp]==1)ans++;
        }
    }
    cout<<ans<<endl;
}


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

ans = 0
for i, Ai in enumerate(A):
    Bi = B[Ai - 1]
    ans += Bi
    if i == 0: continue
    #
    if A[i - 1] + 1 == Ai:
        ans += C[A[i - 1] - 1]

print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  double N;
  string S;
  cin >> N;

  cout << N * 2*3.1415926 << endl;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=400010;
int n,m,c1,c0,col[maxn],tot=0,last[maxn];
bool flag;
long long ans;
struct edge{
	int to,pre;
}e[maxn];

void read(int &k){
	k=0; int f=1; char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while ('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
	k*=f;
}
void add(int x,int y){
	e[++tot].to=y;
	e[tot].pre=last[x];
	last[x]=tot;
}
void dfs(int x,int color){
	col[x]=color;
	if (color==1) c1++;
	else c0++;
	for (int i=last[x],to=e[i].to;i;i=e[i].pre,to=e[i].to){
		if (col[to]==col[x]){
			if (flag==false){
				printf("%lld\n",(long long)n*(n-1)/2-m);
				flag=true;
			}
			return;
		}
		if (col[to]==-1) dfs(to,1-color); 
	}
}
int main(){
	flag=false;
	read(n); read(m);
	for (int i=1;i<=n;i++) col[i]=-1;
	for (int i=1;i<=m;i++){
		int x,y; read(x); read(y);
		add(x,y);
		add(y,x);
	}
	dfs(1,0);
	if (not flag) printf("%lld\n",(long long)c0*c1-m);
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int bag[100005];
int main()
{
    map <string, int> mp, mpp;
    map <string, int> :: iterator it;
    int x;
    cin >> x;
    while(x--){
        string s;
        cin >> s;
        mp[s]++;
    }
    int y;
    cin >> y;
    while(y--){
        string ss;
        cin >> ss;
        mpp[ss]++;
    }
    int Max = INT_MIN;
    for(it = mp.begin(); it != mp.end(); it++){
        if(it->second > mpp[it->first]){
            Max = max(Max, it->second - mpp[it->first]);
        }
        else Max = max(Max, 0);
    }
    cout << Max << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        MyReader reader = new MyReader();
        int a = reader.readInt();
        int b = reader.readInt();
        int c = reader.readInt();
        int x = reader.readInt();
        System.out.println(problem087b(a, b, c, x));
    }

    private static int problem087b(int a, int b, int c, int x) {
        int count = 0;
        for (int ai = a; ai >= 0; ai--) {
            for (int bi = b; bi >=0; bi--) {
                for (int ci = c; ci >= 0; ci--) {
                    int price = ai * 500 + bi * 100 + ci * 50;
                    if (price == x) {
                        count++;
                    }
                }
            }
        }
        return count;
    }

    private static class MyReader {
        private final BufferedReader br;
        private MyReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String readLine() throws IOException {
            return br.readLine();
        }

        private int readInt() throws IOException {
            return Integer.parseInt(readLine().split(" ")[0]);
        }

        private long readLong() throws IOException {
            return Long.parseLong(readLine().split(" ")[0]);
        }

        private String[] readStrings(String regex) throws IOException {
            return readLine().split(regex);
        }

        private int[] readInts(String regex) throws IOException {
            String[] strings = readStrings(regex);
            int[] ints = new int[strings.length];
            for (int i = 0; i < ints.length; i++) {
                ints[i] = Integer.parseInt(strings[i]);
            }
            return ints;
        }

        private long[] readLongs(String regex) throws IOException {
            String[] strings = readStrings(regex);
            long[] longs = new long[strings.length];
            for (int i = 0; i < longs.length; i++) {
                longs[i] = Long.parseLong(strings[i]);
            }
            return longs;
        }
    }
}

Measured memory_bytes: 25420
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X, t = li_input()

    print(max(X - t, 0))


main()


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string ss;cin>>ss;
  rep(i,ss.size()){
      if(i%2!=0 && ss[i]=='R'){
          cout<<"No"<<endl;
          return 0;
      }
      else if (i%2==0 && ss[i]=='L'){
          cout<<"No"<<endl;
          return 0;
      }
  }
  cout<<"Yes"<<endl;
  return 0;
  }


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

using ll = long long;

int main() {
    ll N, X, ans = 1, D = 0, L;
    cin >> N >> X;
    rep(i, N) {
        cin >> L;
        D += L;
        if (D <= X) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	LL n, m;
	cin >> n >> m;
	vector<LL> a(n), s(n + 1);
	inc(i, n) { cin >> a[i]; }
	sort(ALL(a));
	
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	auto f = [&](LL v) -> pair<bool, LL> {
		LL c = 0, z = 0;
		inc(i, n) {
			LL p = LB(a, v - a[i]);
			c += n - p;
			z += s[n] - s[p] + (n - p) * a[i];
		}
		z += (m - c) * (v - 1);
		return { (c <= m), z };
	};
	
	LL L = 0, H = 200001;
	until(H - L == 1) {
		LL M = (L + H) / 2;
		(f(M).FI ? H : L) = M;
	}
	
	cout << f(H).SE << endl;
	return 0;
}


Measured memory_bytes: 1920
#define vi vector<int>
#define pb push_back
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<string> v;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		v.pb(s);
	}
	int ac = 0, wa = 0, tle = 0, re = 0;

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

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

Measured memory_bytes: 7408
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	int count = 0;

	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '1') count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    int arr[n+5];
    bool flag = false;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i < n; i++)
    {
        if(!(arr[i]%2))
        {
            if((arr[i]%3 != 0) && (arr[i]%5 != 0))
            {
                flag = true;
            }
        }
    }
    if(flag)
        cout << "DENIED" << endl;
    else
        cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 892
n = int(input())
arr = list(map(int,input().split()))
dp=[999999999]*n
dp[0]=0
for i in range(len(arr)):
    for j in [i+1,i+2]:
        if j<n:
            dp[j]=min(dp[j],dp[i] + abs(arr[j] - arr[i]))
print(dp[n-1])

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  int n,m;
  if(a%d==0) n=a/d;
  else  n=a/d+1;

  if(c%b==0) m=c/b;
  else  m=c/b+1;

  if(n>=m) cout << "Yes" << endl;
  else  cout << "No" << endl;
}



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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// dp[i][j][k] := 3個の皿がi枚，2個の皿がj枚，1枚の皿がk枚から開始したときのサイコロを降る回数の期待値

// dp[i][j][k] = n/(i+j+k) + dp[i-1][j][k] * i / (i+j+k) + dp[i][j-1][k] * j/(i+j+k)

// 確率pのものを引くまでに繰り返すとき，繰り返す回数の期待値は1/p
// 幾何分布でggl

double dp[301][301][301];
int cnt[5];

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

    dp[0][0][0] = 0;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            for (int k = 0; k <= N; ++k) {
                if (i+j+k == 0) {
                    dp[i][j][k] = 0;
                    continue;
                }
                dp[i][j][k] = (double)N / (i+j+k);
                if (i-1 >= 0) dp[i][j][k] += dp[i-1][j+1][k] * ((double)i / (i+j+k));
                if (j-1 >= 0) dp[i][j][k] += dp[i][j-1][k+1] * ((double)j / (i+j+k));
                if (k-1 >= 0) dp[i][j][k] += dp[i][j][k-1] * ((double)k / (i+j+k));
            }
        }
    }
    printf("%.15lf\n", dp[cnt[3]][cnt[2]][cnt[1]]);
}


Measured memory_bytes: 213248
i,f,p[5];main(){for(;~scanf("%d\n",p+i)&&(f|=1<<p[i++]);)i-5?:({for(i=-1;i++<4;puts(f%5+1-p[i]?f%5-p[i]%3?"3":"1":"2"));f=i=0;});}

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

#define int long long

constexpr int INF = 1LL << 60;
constexpr int MAXN = 100005;

struct UF
{
	int n, par[MAXN], bukatsu[MAXN];
	void Init(int pn)
	{
		n = pn;
		for (int i = 1; i <= pn; ++i)
		{
			par[i] = i;
		}
	}

	int Find(int x)
	{
		if (par[x] == x) return x;
		return par[x] = Find(par[x]);
	}

	int FindBukatsu(int x)
	{
		return bukatsu[Find(x)];
	}

	void Unite(int x, int y)
	{
		x = Find(x);
		y = Find(y);
		if (x == y) return;

		par[x] = y;
		if (bukatsu[y]) return;
		bukatsu[y] = bukatsu[x];
	}

	void SetBukatsu(int x, int b)
	{
		x = Find(x);
		bukatsu[x] = b;
	}
};

int n, m, k;
UF uf;

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

	cin >> n >> m >> k;
	uf.Init(n);
	
	for (int i = 1; i <= k; ++i)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			int a, b;
			cin >> a >> b;
			int bukaa = uf.FindBukatsu(a), bukab = uf.FindBukatsu(b);
			if (bukaa && bukab && bukaa != bukab)
			{
				cout << i << endl;
				return 0;
			}
			uf.Unite(a, b);
		} else
		{
			int c, x;
			cin >> c >> x;
			int buka = uf.FindBukatsu(c);
			if (buka && buka != x)
			{
				cout << i << endl;
				return 0;
			}
			uf.SetBukatsu(c, x);
		}
	}

	cout << 0 << endl;
}

Measured memory_bytes: 4792
//Frog-1
#include<bits/stdc++.h>

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define N (ll)(1e7+5)
#define mod (ll)(1e9+7)

using namespace std;

int main()
{
    ll n,k; cin>>n>>k;
    vector<ll> dp(n),v(n);
    for(auto &x:v)
        cin>>x;
    dp[1] = abs(v[1]-v[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i] = abs(v[i]-v[i-1])+dp[i-1];
        for(ll j=2;j<=min(k,i);j++)
            dp[i] = min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		long[] a = new long[3];
		boolean flag = false;
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
			if (a[i] % 2 == 0) flag = true;
		}
		
		if (flag) {
			out.println(0);
		} else {
			Arrays.sort(a);
			out.println(a[0] * a[1]);
		}
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

int main() {
    int N;
    int A[2][110];
    cin >> N;
    for (int i=0; i<2; i++) {
        for (int j=0; j<N; j++) {
            cin >> A[i][j];
        }
    }
    
    int res=0;
    for (int k=0; k<N; k++){
        int tmp=0;
        for (int i=0; i<N; i++) {
            if (i <= k) tmp += A[0][i];
            if (k <= i) tmp += A[1][i];
        }
        res = max(res, tmp);
    }
    
    cout << res << endl;

}



Measured memory_bytes: 256
S=list(input().strip())

n=False
e=False
s=False
w=False
for i in S:
    if(i=="N"):
        n=True
    elif(i=="E"):
        e=True
    elif(i=="S"):
        s=True
    elif(i=="W"):
        w=True
    if(n and e and s and w):
        break

if(n == s) and (e == w):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int id[510];
int x[510];
int a[250010];
bool cmp(int a,int b)
{
	return x[a]<x[b];
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
		id[i]=i;a[x[i]]=i;
	}
	sort(id+1,id+n+1,cmp);
	int now=1;
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		for(int j=1;j<u;j++)
		{
			while(a[now])now++;
			if(now>x[u]){
				printf("No\n");
				return 0;
			}
			a[now]=u;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		for(int j=u;j<n;j++)
		{
			while(a[now])now++;
			if(now<x[u]){
				printf("No\n");
				return 0;
			}
			a[now]=u;
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n*n;i++)
		printf("%d ",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2176
using System;

namespace abc120a
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int D = 0;
            while (A * (D+1) <= B)
            {
                D++;
            }
            if (D >= C)
                Console.WriteLine(C);
            else
                Console.WriteLine(D);
        }
    }
}


Measured memory_bytes: 11092