akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int n = in();
  pair<int, int> p(0, 0);
  int time = 0;
  bool flag = true;
  rep(i, n) {
    int t = in(), x = in(), y = in();
    int dt = t - time;
    int dx = abs(x - p.first);
    int dy = abs(y - p.second);
    if (dx + dy <= dt) {
      if ((dt - dx - dy) % 2 == 0) {
        time = t;
        p.first = x;
        p.second = y;
      } else {
        flag = false;
      }
    } else {
      flag = false;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000003;
struct wolf{
	int l,r;
	wolf(){}
	wolf(int a,int b){
		l=a;r=b;
	}
};
inline bool operator<(const wolf&a,const wolf&b){
	if(a.l!=b.l)return a.l<b.l;
	return a.r>b.r;
}
wolf p[51000];
int in[51000];
int next[51000];
int dp[51000][2][2];

void calc(int m){
	for(int A=m-1;A>=0;A--){
		for(int B=0;B<2;B++)for(int C=0;C<2;C++){
			int a=A;
			int b=B;
			int c=C;
			if(in[a]==-1){
				int ret=0;
				if((p[a].r-p[a].l+b+c)%2==0)dp[a][b][c]=0;
				else if(b==0&&c==0)dp[a][b][c]=2;
				else dp[a][b][c]=1;
				continue;
			}
			int ret=0;
			long long te=0;
			long long to=0;
			int at;
			if(b==0&&c==0&&(p[a].r-p[a].l)%2){
				to=1;
				at=p[a].l;
				for(int i=in[a];~i;i=next[i]){
					if(p[i].l>=p[a].r)break;
					long long tte;
					long long tto;
					if((p[i].l-at)%2){
						tte=te*dp[i][1][1]+to*dp[i][0][1];
						tto=te*dp[i][1][0]+to*dp[i][0][0];
					}else{
						tte=te*dp[i][0][1]+to*dp[i][1][1];
						tto=te*dp[i][0][0]+to*dp[i][1][0];
					}
					te=tte%mod;
					to=tto%mod;
					at=p[i].r;
				}
				if((p[a].r-at)%2==0)ret=te;
				else ret=to;
			}
			te=to=0;
			if(b)to=1;
			else te=1;
			at=p[a].l;
			for(int i=in[a];~i;i=next[i]){
				if(p[i].l>=p[a].r)break;
				long long tte;
				long long tto;
				if((p[i].l-at)%2){
					tte=te*dp[i][1][1]+to*dp[i][0][1];
					tto=te*dp[i][1][0]+to*dp[i][0][0];
				}else{
					tte=te*dp[i][0][1]+to*dp[i][1][1];
					tto=te*dp[i][0][0]+to*dp[i][1][0];
				}
				te=tte%mod;
				to=tto%mod;
				at=p[i].r;
			}
			if((p[a].r-at)%2==!c)ret=(ret+te)%mod;
			else ret=(ret+to)%mod;
			dp[a][b][c]=ret;
		}
	}
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<b;i++){
			int s,t;scanf("%d%d",&s,&t);
			s--;t--;
			p[i]=wolf(min(s,t),max(s,t));
		}
		p[b++]=wolf(0,a-1);
		if(a%2){
			printf("0\n");continue;
		}
		std::sort(p,p+b);
		for(int i=0;i<b;i++){
			int nx=lower_bound(p,p+b,wolf(p[i].r,99999999))-p;
			if(nx>=b)next[i]=-1;
			else next[i]=nx;
			int ni=upper_bound(p,p+b,wolf(p[i].l,p[i].r))-p;
			if(ni>=b||p[ni].l>=p[i].r)in[i]=-1;
			else in[i]=ni;
		}
		
		//for(int i=0;i<b;i++)if((~in[i]&&in[i]<=i)||(~next[i]&&next[i]<=i))printf("%d %d\n",in[i],next[i]);
		for(int i=0;i<b;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)dp[i][j][k]=-1;
		calc(b);
		printf("%d\n",dp[0][0][0]);
	}
}

Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
int xv[]={0,1,1,1,0,-1,-1,-1,0},yv[]={1,1,0,-1,-1,-1,0,1,0};
int main(void){
    vector<long long int> v(10);
    long long int tmp=0;
    int h,w,n,r,c,x,y;
    map<pair<int,int>,int> m;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        cin>>r>>c;
        for(int j=0;j<9;j++){
            x=c+xv[j];
            y=r+yv[j];
            if(m.find({y,x})!= m.end()) {
                m[{y,x}]++;
            }
            else m[{y,x}]=1;
        }
    }
    for(auto z:m){
        if(z.first.first>1&&z.first.first<h&&z.first.second>1&&z.first.second<w){
            v[z.second]++;
        }
    }
    tmp=0;
    for(auto z:v){
        tmp+=z;
    }
    v[0]=(long long int)(h-2)*(w-2)-tmp;
    for(auto z:v){
        cout<<z<<endl;
    }
}


Measured memory_bytes: 56448
import java.util.Scanner;

public class Main {

	/**
	 * Rated for Me
	 * @param 0 ≤ R ≤ 4208
	 */
	public static void main(String... args) {
		try (Scanner sc = new Scanner(System.in)) {
			int r = sc.nextInt();
			if (r < 1200) {
				System.out.println("ABC");
			} else if (r < 2800) {
				System.out.println("ARC");
			} else {
				System.out.println("AGC");
			}
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int equal(char *t,char *p,int i,int plen){
  int j;
  for(j=0;j<plen;j++){
    if(t[i+j]!=p[j]) return 0;
  }
   
  return 1;
}
int main(){
  char t[1000];
  char p[1000];
  int i,j;
  int tlen;
  int plen;
  scanf("%s",t);
  scanf("%s",p);
  tlen=strlen(t);
  plen=strlen(p);
  for(i=0;i<tlen;i++){
    if(equal(t,p,i,plen))printf("%d\n",i);
     
  }
  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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; }

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	int ans=0;
	rep(i,n) {
		cin >> v[i];
		if(v[i] >= k) ans++;
	}

cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
s = str(input())
p = str(input())
Flag = False
for i in range(len(s)):
    a = 0
    if p in s:
        Flag = True
        break
    for j in range(len(p)):
        if s[(i+j) % len(s)] != p[j]:
            Flag = False
            break
        else:
            Flag = True
            a += 1
    if a == len(p):
        break
if Flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5560
a = list(input())
ans = []
for i in range(0,len(a)+1):
    for m in range(i+1,len(a)+1):
        b = a[i:m]
        if len(b) % 2 != 0:
            if b[0:len(b)//2] == b[len(b)//2:-1]:
                ans.append(len(b))
try:ans.pop(len(a))
except:ans=ans
print(max(ans)-1)

Measured memory_bytes: 3064
a, b = map(int, input().split())
 
# aの倍数を順に探索する
# abはa, bの公倍数なので、高々B回で十分。O(B)
lcm = 0
for i in range(1, b+1):
  if (a * i) % b == 0:
    lcm = a * i
    break
  
print(lcm)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	ll dish[n],satis[n],addi[n-1];
	ll i=0,j=0,ans=0;
	for(i=0;i<n;i++){
		cin>>dish[i];
	}
	for(i=0;i<n;i++){
		cin>>satis[i];
	}
	for(i=0;i<n-1;i++){
		cin>>addi[i];
	}
	for(i=0;i<n;i++){
		if(i==0){
			ans=ans+satis[dish[i]-1];
			continue;
		}
		if(dish[i]==dish[i-1]+1){
			ans=ans+satis[dish[i]-1]+addi[dish[i-1]-1];
		}
		else{
			ans=ans+satis[dish[i]-1];
		}
			
	}
	cout<<ans;
}


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

using namespace std;

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

	int a, b, x;
	cin >> a >> b >> x;
	if( a <= x && a + b >= x )cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];
        var S = Console.ReadLine().ToCharArray();

        var index = 0;
        var j = 0;
        var c = S[0] == 'R' ? 'L' : 'R';
        for (var i = 0; i < K; i++)
        {
            index = Array.IndexOf(S, c, j);

            if (index == -1)
            {
                break;
            }
            j = index;
            while (S[j] != S[0])
            {
                S[j] = S[0];
                j++;
                if (j >= S.Length)
                {
                    break;
                }
            }
        }

        var result = 0;
        for (int i = 1; i < N; i++)
        {
            if (S[i - 1] == S[i])
            {
                result++;
            }
        }
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 13792
number = gets.to_i
word = Array.new(number, "0")
for i in 0..number - 1
  word[i] = gets.chomp
end
point = 0
now_word = []
last_word = []

for i in 1..number - 1
  for j in 0..i - 1
    if word[i] == word[j]
      point += 1
    end
  end
  now_word = word[i].chomp.split("")
  last_word = word[i - 1].chomp.split("")
  if now_word[0] != last_word[-1]
    point += 1
  end
end

if point == 0
  print "Yes"
else
  print "No"
end

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


int gcd(int m,int n){
  if(m==n) return m;

  if(m>n) return gcd(m-n,n);
  else
    return gcd(m,n-m);
}



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

  cout <<gcd(a,b)<<endl;
}



Measured memory_bytes: 3112
N, M = map(lambda x: int(x), input().split(" "))

s_c = {}

result = 0
for _ in range(M):
    s, c = map(lambda x: int(x), input().split(" "))
    if s in s_c:
        if s_c[s] != c:
            result = -1
            break
    s_c[s] = c

if N == 3 or N == 2:
    if 1 in s_c and s_c[1] == 0:
        result = -1

if result == -1:
    print(result)
else:
    if N == 3:
        one = 1
        two = 0
        three = 0
        if 1 in s_c:
            one = s_c[1]
        if 2 in s_c:
            two = s_c[2]
        if 3 in s_c:
            three = s_c[3]
        print(one*100+two*10+three)

    elif N == 2:
        one = 1
        two = 0
        three = 0
        if 1 in s_c:
            one = s_c[1]
        if 2 in s_c:
            two = s_c[2]
        print(one*10+two)

    else:
        one = 0
        if 1 in s_c:
            one = s_c[1]
        print(one)





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

using namespace std;

typedef long long ll;

ll func(ll a , ll b , ll x)
{
    ll ret = 0;
    ret += b/x;
    ret -= (a-1LL)/x;

    return ret;
}

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

    ll gc , lc , now , temp , ans;

    gc = __gcd(c,d);
    lc = (c*d) / gc;

    now = 0;
    now += func(a,b,c);
    now += func(a,b,d);
    now -= func(a,b,lc);



    ans = b-a+1;
    ans -= now;

    cout << ans << endl;


    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> cities(N, 0);
 
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    cities[a - 1]++;
    cities[b - 1]++;    
  }
  
  for (auto i = cities.begin(); i != cities.end(); i++) {
	cout << *i << endl;
  }
}


Measured memory_bytes: 3584
#include<stdio.h>

int main()
{
  long long n,m;
  
  scanf("%lld%lld",&n,&m);
  
  long long ans;
  
  if(n>=2&&m>=2)
  {
    ans=(n-2)*(m-2);
  }
  else
  {
    if(n==1&&m!=1)
    {
      ans=m-2;
    }
    else if(m==1&&n!=1)
    {
      ans=n-2;
    }
    else if(n==1&&m==1)
    {
      ans=1;
    }
  }
  printf("%lld\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int l[100005] = {};
vector<vector<int>> g(100005);

int bfs(int i){
  int tmp;
  int rm = g[i].size();
  for(int j= 0;j < rm ;j++){
    tmp = g[i][j];
    if(l[tmp] == 0){
      l[tmp] = 1;
      bfs(tmp);
    }
  }
  return 0;
}




int main() {
  int n,m;
  cin >> n >> m;
  int x,y,z;
  //int c = 1;
  for(int i= 0;i < m;i++){
    cin >> x >> y >> z;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  int c = 0;
  for(int i = 1;i< n+1;i++){
    if(l[i] == 0){
      l[i] = 1;
      c++;
      bfs(i);
    }
  }
  cout << c;
}


Measured memory_bytes: 13648
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int N, K; cin >> N >> K;
	vector<int>P(N), C(N);
	REP(i, N) {
		cin >> P[i];
		P[i]--;
	}
	REP(i, N)cin >> C[i];
	ll ans = -LINF;
	vector<int>cnt(N), sum(N);
	REP(i, N) {
		int pos = i;
		int res = 0;
		REP(_, N) {
			pos = P[pos];
			res += C[pos];
			cnt[i]++;
			if (pos == i)break;
		}
		sum[i] = res;
	}
	REP(i, N) {
		ll res = 0;
		if (K > cnt[i] * 2) {
			if (sum[i] > 0 && K > cnt[i] * 2) {
				ll c = K / cnt[i] - 1;
				res += c * sum[i];
				int rem = K - c * cnt[i];
				if (c > 0)chmax(ans, res);
				int pos = i;
				REP(_, rem) {
					pos = P[pos];
					res += C[pos];
					chmax(ans, res);
				}
			}
			else {
				int pos = i;
				REP(_, min(N, K)) {
					pos = P[pos];
					res += C[pos];
					chmax(ans, res);
				}
			}
		}
		else {
			int pos = i;
			REP(_, K) {
				pos = P[pos];
				res += C[pos];
				chmax(ans, res);
			}
		}
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3788
n,x = map(int,input().split())
A = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    if A[i] <= x:
        ans += 1
        x -= A[i]
        if x == 0:
            break
if ans == n and x>0:
    print(n-1)
else:
    print(ans)


Measured memory_bytes: 2940
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var numArray = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var dest = numArray.OrderBy(a => -a).ToArray();
            var A = 0;
            var B = 0;

            foreach (var item in dest.Select((v, i) => new { v, i })){
                if (item.i % 2 == 0)
                {
                    A += item.v;
                }
                else
                {
                    B += item.v;
                }
            }
            Console.WriteLine(A - B);
        }
    }
}



Measured memory_bytes: 13396
a, b = map(int, input().split())
b_index = b-a
a_index = b_index - 1
get_height = lambda n: n*(n+1)/2

a_height = get_height(a_index)
b_height = get_height(b_index)
snow_height = b_height - b
print(int(snow_height))

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int s,o,i;
	scanf("%d",&o);
	while(o !=0){
	s=1000-o;
	i=0;
	
		while(s>=500){
			s=s-500;
			i++;
		}
		while(s>=100){	
			s=s-100;
			i++;
		}
		while(s>=50){
			s=s-50;
			i++;
		}
		while(s>=10){
			s=s-10;
			i++;
		}
		while(s>=5){
			s=s-5;
			i++;
		}
		while(s>=1) {
			s=s-1;
			i++;
		}
	printf("%d\n",i);
	scanf("%d",&o);
	}			
	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<algorithm>
#define NO return puts("NO"),0
using namespace std;
 
int n,m,f[1000],a,b,c,d,x,y,D[1000],bo[1000],C[1000];
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}
int main(){
    scanf("%d%d",&n,&m);
    
    for (int i=1;i<999;i++) f[i]=i;
    while (n--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if (c==0) x=a;else x=-c;x+=500;
        if (d==0) y=-b;else y=d;y+=500;
        f[gf(x)]=gf(y);
        D[x]++;D[y]--;bo[x]=1;
    }
    for (int i=1;i<500;i++) if (D[i]>0) NO;
    for (int i=501;i<999;i++) if (D[i]<0) NO;
    for (int i=1;i<999;i++)
    if (bo[gf(i)]|=bo[i],D[i]) C[f[i]]=1;
    for (int i=1;i<999;i++)
    if (f[i]==i&&!C[i]&&bo[i]) NO;
    puts("YES");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int n;
	while (cin >> n, n) {
		int ans1, ans2;
		for (int i = 1; i * (i + 1) / 2 <= n; i++) {
			if ((n - i * (i + 1) / 2) % i == 0) {
				ans1 = (n - i * (i + 1) / 2) / i + 1;
				ans2 = i;
			}
		}
		cout << ans1 << ' ' << ans2 << endl;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  string s = "";
  queue<string> que;
  que.push(s);
  while(que.front().size()<N){
    string S=que.front();
    int x = que.front().size();
    set<char> st;
    REP(i,S.size()){
      st.insert(S.at(i));
    }
    int y = st.size();
    que.pop();
    REP(j,x+1){
      if(j<=y){
        que.push(S+char('a'+j));
      }
    }
  }
  
  while(!que.empty()){
    cout << que.front() << endl;
    que.pop();
  }
}

Measured memory_bytes: 9728
import java.util.*;

public class Main
{
    private final static int MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
	int N = Integer.parseInt(in.nextLine());
	double[] arr = new double[N];
	String[] temp = in.nextLine().split(" ");
	for (int i = 0; i < N; i++) {
	    arr[i] = Double.parseDouble(temp[i]);
	}
	double[][] dp = new double[N+1][N+1];
        dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
	    dp[i][0] = dp[i-1][0] * (1 - arr[i-1]);
	    for (int j = 1; j <= i; j++) {
		dp[i][j] += dp[i-1][j-1] * arr[i-1];
		dp[i][j] += dp[i-1][j] * (1 - arr[i-1]);
	    }
	}
	double res = 0;
	for (int i = 0; i <= N; i++) {
	    if (i > N-i) {
		res += dp[N][i];
	    }
	}
	System.out.println(res);
	in.close();
    }
}


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

int main() {
	int n,b,f,r,v; 	//?????±??°,?£?,???,??¨?±?,?????°
	int room[4][3][10];		//?£?,???,??¨?±?
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				room[i][j][k] = 0;
			}
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << room[i][j][k];
				if (k == 9) {
					cout << endl;
				}
			}
			if (j == 2 && i != 3) {
					cout << "####################" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
    public static void main(String[] args) {
	// write your code here
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] a = new int[N];
        for(int i=0;i<N;i++) {
            a[i] = scan.nextInt();
        }
        int ans = 0;
        for(int i=0;i<N;i=i+2){
            if((a[i]%2)!=0) ans++;
        }
        System.out.println(ans);
        }
    }


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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N, x);

  i64 res = 0;
  vector<int> a(N);
  rep(i, N) {
    input(a[i]);
    if (i) {

      if (a[i] + a[i-1] > x) {
        i64 need = a[i] + a[i-1] - x;
        res += need;
        a[i] = max<i64>(0, a[i] - need);
      }
    }
  }

  outl(res);

  return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int A, B, C, D, K;
int ceil(int x, int y){
    return x/y + ((x%y)!=0);
}

bool ok(int x){
    if(x == 0) return 1;
    if(x % (K+1) == 0) x++;

    int Nb = x/(K+1);
    int Na = x - Nb;

    if((A - Na + 1) * 1ll * K >= B - Nb) return 1;
    return 0;
}

int main(){

    ios :: sync_with_stdio(false);
    int T;
    cin >> T;
    FOR(tc,T){
        cin >> A >> B >> C >> D;
        K = ceil(max(A,B), min(A,B)+1);

        int lo = 0, hi = A+B, pos = 0;
        while(lo <= hi){
            int mid = (lo+hi)/2;
            if(ok(mid)){
                pos = mid;
                lo = mid+1;
            }
            else hi = mid-1;
        }

        string ans = "";
        FORU(i, C, D){
            if(i <= pos){
                if(i % (K+1) == 0) ans += "B";
                else ans += "A";
            }
            else{
                if((A+B+1-i) % (K+1) == 0) ans += "A";
                else ans += "B";
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int s, w;
  cin >> s >> w;
  if (w >= s) {
    puts("unsafe");
  } else {
    puts("safe");
  }

  return 0;
}


Measured memory_bytes: 3616
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,k = MI()
a = RI()

L = max(a)

def mycheck(l):
    count = 0
    for i in range(n):
        count += a[i]//l
    return count <= k

lb = 0
ub = L
for i in range(100):
    # print(ub,lb)
    mid = (lb+ub)/2
    # print(mid)
    flag = mycheck(mid)
    # print(flag)
    if flag:
        ub = mid
    else:
        lb = mid

ans = ceil(lb)
print(ans)

Measured memory_bytes: 110516
#include<stdio.h>
int main(void)
{
  int x, y;
  scanf("%d",&x);
  y = x - (x/10)*10;
  switch(y){
    case 2: ;
    case 4: ;
    case 5: ;
    case 7: ;
    case 9: 
      printf("hon\n");
      break;
    case 0: ;
    case 1: ;
    case 6: ;
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default:
      printf("error\n");
      break;
  }
      
  return 0;
}


Measured memory_bytes: 1608
n, k = map(int, input().split())
s = list(input())

if s[k-1] == "A":
    s[k-1] = 'a'
elif s[k-1] == "B":
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

s = ''.join(s)
print(str(s))


Measured memory_bytes: 2940
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

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


const double PI = acos(-1.0);

using namespace std;

template<typename T>
bool isPrime(T n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

template<typename T>
vector<T> allFactors(T n) {
    vector<T> res;
    vector<T> tmp;
    T i = 1;
    while (i*i <= n) {
        if (n % i == 0) {
            res.push_back(i);
            if (n/i != i) tmp.push_back(n/i);
        }
        i++;
    }
    reverse(tmp.begin(), tmp.end());
    for (T j : tmp) {
        res.push_back(j);
    }
    return res;
}

template<typename T>
vector<T> factorization(T n) {
    vector<T> factors;
    for (int d : {2,3,5}) {
        while (n%d == 0) {
            factors.push_back(d);
             n /= d;
        }
    }
    static array<int, 8> increments = {4, 2, 4, 2, 4, 6, 2, 6};
    int i = 0;
    for (long long d = 7; d * d <= n; d += increments[i++]) {
        while (n % d == 0) {
            factors.push_back(d);
            n /= d;
        }
        if (i == 8) i = 0;
    }
    if (n > 1) factors.push_back(n);
    return factors;
}

template<typename T>
bool isPowerOf2(T x) { return x && (!(x & (x - 1))); }

template<typename T>
T factorial(T n) {
    T f = 1;
    for (T i = 2; i <= n; i++) f *= i;
    return f;
}

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

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    T x1, y1;
    T d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

template<typename T>
T mod_inverse(T a, T mod){
    T x, y;
    extgcd(a, mod, x, y);
    return (mod + x % mod) % mod;
}

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

template<typename T>
T digitSum(T number, T mod = 10) {
    int ans = 0;
    while (number) {
        ans += number % mod;
        number /= mod;
    }
    return ans;
}

class CRepsept {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int n;cin>>n;

if (n%2==0 || n%5==0){
    cout<<-1<<"\n";
    return;
}
        int ans=1;
if (n%7==0){
    n/=7;
}
if (n==1) {
            cout<<1;
            return;
        }
        long long t=1;
while (t!=0){
    t=(10*t+1)%n;
    ans++;
}
        cout<<ans;
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    CRepsept solver;
    solver.solve(in, out);
}


Measured memory_bytes: 3644
using System;
 
class Program
{
    static void Main(string[] args)
    {
    	string inputStr;
	string subStr;
	string outStr = System.String.Empty;
    	inputStr = Console.ReadLine();
    	
    	for(int i = 0; i < inputStr.Length; i++){
    		subStr = inputStr.Substring(i, 1);
    		
    		if(Char.IsUpper(subStr, 0)){
    			
    			subStr = subStr.ToLower();
    			
    		}else{
    			
    			subStr = subStr.ToUpper();
    			
    		}
    		
    		outStr = outStr + subStr;
    	}

      Console.WriteLine(outStr);
    }
}


Measured memory_bytes: 9072
#include <iostream>

void Show(int *array, int n){
    for(int i=0; i<n; ++i){
        if(i != n-1){
            std::cout << array[i] << " ";
        }else{
            std::cout << array[i];
        }
    }
    std::cout << std::endl;
}

int main(){
    int n;
    int A[110];

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

    Show(A, n);

    for(int i=1; i<n; ++i){
        int v = A[i];
        int j = i-1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;

        Show(A, n);
    }
}


Measured memory_bytes: 3112
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512

#define ldouble long double
using namespace std;

long long INF = 1e9;

const int N = 300031;

vector<pair<int,int> > by_x,by_y;
int n;
int x[N],y[N];
vector<pair<int,pair<int,int> > > edges;
int w[N];

int get(int x)
{
	if (x==w[x])
		return x;
	return w[x]=get(w[x]);
}

void merge(int a,int b)
{
	a=get(a);
	b=get(b);
	w[a]=b;
}

long long ans;

void add_edge(pair<int,int> p1,pair<int,int> p2){
	edges.push_back(make_pair(abs(p1.first-p2.first),make_pair(p1.second,p2.second)));
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
		by_x.push_back(make_pair(x[i],i));
		by_y.push_back(make_pair(y[i],i));
	}

	sort(by_x.begin(),by_x.end());
	sort(by_y.begin(),by_y.end());
	for (int i=1;i<=n;i++)
	{
		w[i]=i;
	}
	edges.clear();
	for (int i=1;i<by_x.size();i++)
	{
		add_edge(by_x[i-1],by_x[i]);
	}
	for (int i=1;i<by_y.size();i++)
	{
		add_edge(by_y[i-1],by_y[i]);
	}

	sort(edges.begin(),edges.end());
	for (int i=0;i<edges.size();i++)
	{
		int v1=edges[i].second.first;
		int v2=edges[i].second.second;
		v1=get(v1);
		v2=get(v2);
		if (v1==v2)
		{
			continue;
		}
		ans+=edges[i].first;
		merge(v1,v2);
	}

	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 8424
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N,C[20],V[20];
    cin>>N;
    rep(i,N) cin>>V[i];
    rep(i,N) cin>>C[i];
    int ans=0;
    rep(i,N){
        if(V[i]-C[i]>0) ans+=V[i]-C[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n;
    int d[100005]={};
    scanf("%d",&n);
    REP(i,n)scanf("%d",&d[i]);
    sort(d,d+n);
    //REP(i,n)printf("%d\n",d[i]);
    int a,b;
    a=d[n/2-1];
    b=d[n/2];
    int ans=b-a;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
n = gets.to_i
a = gets.split(' ').map(&:to_i)

l = a.max
a.delete(l)

if l.even?
  max = l / 2
  r = a.delete(a[0])
  gap = (max - r).abs
  a.each do |num|
    if (max - num).abs < gap
      r = num
      gap = (max - num).abs
    end
  end
else
  max_l = l / 2
  max_r = max_l + 1
  r = a.delete(a[0])
  if r <= max_l
    gap = max_l - r
  else
    gap = r - max_r
  end
  a.each do |num|
    if num <= max_l
      if max_l - num < gap
        r = num
        gap = max_l - num
      end
    else
      if num - max_r < gap
        r = num
        gap = num - max_r
      end
    end
  end
end
puts "#{l} #{r}"


Measured memory_bytes: 8460
#include <stdio.h>

int main() {
    int sum;
    while (1) {
        sum = 0;
        char num[10000];
        scanf("%s", num);
        for (int i=0; num[i]!='\0'; i++) {
            sum += (num[i] - '0');
        }
        if (sum == 0) {break;}
        printf("%d\n", sum);
    }
    return 0;
}



Measured memory_bytes: 2112
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		ArrayList<Integer> side = new ArrayList<Integer>();

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 3; j++) {
					side.add(sc.nextInt());
				}
				judgeRightTri(side);
				side.clear();
			}
	}

	private static void judgeRightTri(ArrayList<Integer> side) {
		Collections.sort(side, Comparator.reverseOrder());

				if ( Math.pow(side.get(0), 2) == Math.pow(side.get(1), 2) + Math.pow(side.get(2), 2) ) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}
	}

}


Measured memory_bytes: 32828
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n >> m;
    vector <ll> adj[n+1];
    for(i = 0; i < m; i++){
        cin >> x >> y;;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    ll parent[n+1] = {0};
    parent[1] = 1;
    queue <ll> q;
    q.push(1);
    vector <bool> visited(n+1,false);
    visited[1] = true;
    while(!q.empty()){
        x = q.front();
        q.pop();
        //cout << x << "         ";
        for(auto j: adj[x]){
            if(!visited[j]){
                //cout << j << " ";
                parent[j] = x;
                q.push(j);
                visited[j] = true;
            }
        }
        //cout << endl;
    }
    for(i = 2; i <= n; i++){
        if(parent[i] == 0){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(i = 2; i <= n; i++){
        cout << parent[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 13036
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class Solver(object):
    def __init__(self):
        pass

    def solve(self, S):
        ans = {"SUN": 7, "MON": 6, "TUE": 5,
               "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
        print(ans[S])


def main():
    S = input().rstrip()

    solver = Solver()
    solver.solve(S)


if __name__ == "__main__":
    main()

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

#define PrintLn(X) cout << X << endl
#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)
typedef long long ll;

int N, K;
ll x[50];
ll y[50];

ll minX;
ll maxX;
ll minY;
ll maxY;

int main(void)
{
	cin >> N >> K;
	Rep(i, N){
		cin >> x[i] >> y[i];
	}
	ll minS = 1LL << 62;

	Rep(a, N){
		For(b, a, N){
			For(c, b, N){
				For(d, c, N){
					minX = x[a];
					maxX = x[a];
					minY = y[a];
					maxY = y[a];
					if(x[b] < minX) minX = x[b];
					if(x[c] < minX) minX = x[c];
					if(x[d] < minX) minX = x[d];
					if(x[b] > maxX) maxX = x[b];
					if(x[c] > maxX) maxX = x[c];
					if(x[d] > maxX) maxX = x[d];
					if(y[b] < minY) minY = y[b];
					if(y[c] < minY) minY = y[c];
					if(y[d] < minY) minY = y[d];
					if(y[b] > maxY) maxY = y[b];
					if(y[c] > maxY) maxY = y[c];
					if(y[d] > maxY) maxY = y[d];
					ll S = (maxX - minX) * (maxY - minY);
					if(S < minS){
						int count = 0;
						Rep(i, N){
							if(minX <= x[i] && x[i] <= maxX && minY <= y[i] && y[i] <= maxY){
								count++;
							}
						}
						if(count >= K){
							minS = S;
						}
					}
				}
			}
		}
	}
	PrintLn(minS);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int s;
    cin >> s;
    int u;
    int l;
    u = s/100;
    l = s - u * 100;

    if(u <= 12 && l <=12 && u >= 1 && l >= 1){
        cout << "AMBIGUOUS" << endl;
    }else if( (u > 12 && (l <= 12 && l >= 1 )) || (u == 0 && (l <= 12 && l >= 1 ))){
        cout << "YYMM" << endl;
    }else if( ((u <= 12 && u >= 1) && l > 12) || (l == 0 && (u <= 12 && u >= 1 ))){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve(t1, t2, a1, a2, b1, b2):
    if a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2:
        return 'infinity'
    if a1 * t1 + a2 * t2 > b1 * t1 + b2 * t2:
        a1, a2, b1, b2 = b1, b2, a1, a2
    
    at = a1 * t1 + a2 * t2
    bt = b1 * t1 + b2 * t2
        
    ans = 0
    dg = bt - at
    if a1 > b1:
        ans += ((a1 - b1) * t1 - 1) // dg
        ans += (a1 - b1) * t1 // dg + 1
    return ans        
    

t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
print(solve(t1, t2, a1, a2, b1, b2))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
  } else if(s=="Cloudy"){
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3096
N,Y = gets.split(' ').map(&:to_i)
sets = []

(0..N).each do |i|
  (0..N-i).each do |j|
    sets.push([i,j,N-i-j])
  end
end

result = sets.select{|set|
  10000 * set[0] + 5000 * set[1] + 1000 * set[2] == Y
}

if result == []
  print '-1 -1 -1'
else
  print result[0].join(' ')
end

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 26; i++) {
    if (s.find('a' + i) == string::npos) {
      cout << (char) ('a' + i) << '\n';
      return 0;
    }
  }
  cout << "None\n";
  return 0;
}

Measured memory_bytes: 512
#!/usr/bin/ruby
N=gets.to_i
r=0
A=[]
(2*N).times.map{|i|gets.split.map(&:to_i)+[i/N]}.sort.each{|x,y,c|
	if c==0
		A<<y
	else
		k=-1
		ki=-1
		A.each_with_index{|z,i|
			if k<z && z<y
				k=z
				ki=i
			end
		}
		if ki>=0
			A.delete_at(ki)
			r+=1
		end
	end
}
p r


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    int n,A[200001],z=1;
    cin>>n;
    rep(i,n) cin>>A[i];
    rep(i,n) if(A[i]%2==0){
        if(A[i]%3&&A[i]%5) z=0;
    }
    if(z) cout<<"APPROVED";
    else cout<<"DENIED";
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


signed main(void){
  int n,k;cin >> n >> k;
  multiset<int> a;vint ans;
  rep(i,n){
    int t;cin >> t;
    a.insert(t);
  }
  rep(i,n+1){
    if(a.find(i)!=a.end()){
      ans.push_back(a.count(i));
      //cout << ans.back() << endl;
    }
  }
  vfsort(ans,([](int x, int y) -> int{return x>y;}));
  if(ans.size()<k){
    cout << 0 << endl;
    return 0;
  }
  int res=n;
  rep(i,k){
    res-=ans[i];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 10748
#include <iostream>

using namespace std;
/** Problem0107 : Carry a Cheese **/
int main()
{
	int x, y, z, r, n;
	
	while (1) {
		cin >> x >> y >> z;
		if (x == 0 && y == 0 && z==0)
			break;
	
		cin >> n;
		for (int i=0; i<n; i++) {
			cin >> r;
			if (2*r*2*r > x*x+y*y || 4*r*r > x*x+z*z || 4*r*r > y*y+z*z)
				cout << "OK" << endl;
			else
				cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
    	int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(),
    		ans = 3;
    	
    	if(a == b)	ans--;
    	if(b == c)	ans--;
    	if(a == c)	ans--;
    	if((a == b) && (b == c) && (a == c))	ans++;
    	
    	System.out.println(ans);
    }
}

Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, y;
	cin >> n >> y;
	int X = -1, Y = -1, Z = -1;

	for(int i = 0; i <= y / 10000; i++) {
		for(int j = 0; j <= y / 5000; j++) {
			int k = (y - 10000 * i - 5000 * j) / 1000;
			if((i + j + k == n)&&(0 <= k)) {
				X = i;
				Y = j;
				Z = k;
				break;
			}
		}
		if(X != -1) break;
	}

	cout << X << " " << Y << " " << Z << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
s=[l[0]]
for i in range(1,n):
    s.append(min(s[i-1],l[i]))
#print(s)
cnt=0
for i in range(n):
    if s[i]>=l[i]:
      cnt+=1
print(cnt)

Measured memory_bytes: 26012