akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  int i;
  int check = 0;
  for(i = 0; i < min(s.size(), t.size()); i++)
  {
    if(s.at(i) < t.at(i))
    {
      check = 1;
      break;
    }
    else if(s.at(i) > t.at(i))
    {
      check = 2;
      break;
    }
  }
  if(check == 0 && s.size() < t.size())
  {
    check = 1;
  }
  else if(check == 0 && s.size() >= t.size())
  {
    check = 2;
  }
  if(check == 1) cout << "Yes" << endl;
  else if(check == 2) cout << "No" << endl;
}

Measured memory_bytes: 256
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
      let mut iter = $s.split_whitespace();
      let mut next = || { iter.next().unwrap() };
      input_inner!{next, $($r)*}
  };
  ($($r:tt)*) => {
      let stdin = std::io::stdin();
      let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
      let mut next = move || -> String{
          bytes
              .by_ref()
              .map(|r|r.unwrap() as char)
              .skip_while(|c|c.is_whitespace())
              .take_while(|c|!c.is_whitespace())
              .collect()
      };
      input_inner!{next, $($r)*}
  };
}

macro_rules! input_inner {
  ($next:expr) => {};
  ($next:expr, ) => {};

  ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
      let $var = read_value!($next, $t);
      input_inner!{$next $($r)*}
  };
  ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
      let mut $var = read_value!($next, $t);
      input_inner!{$next $($r)*}
  };
}

macro_rules! read_value {
  ($next:expr, ( $($t:tt),* )) => {
      ( $(read_value!($next, $t)),* )
  };

  ($next:expr, [ $t:tt ; $len:expr ]) => {
      (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
  };

  ($next:expr, chars) => {
      read_value!($next, String).chars().collect::<Vec<char>>()
  };

  ($next:expr, usize1) => {
      read_value!($next, usize) - 1
  };

  ($next:expr, $t:ty) => {
      $next().parse::<$t>().expect("Parse error")
  };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
  input!{
    a:i64,
    b:i64,
  }
  if a >= 10 || b >= 10 { println!("-1"); return;}
  println!("{}", a*b);
}


fn is_prime(x:i64) -> bool {
  if x == 2 {return true;}
  if x < 2 || x % 2 == 0 {return false;}
  let mut j = 3;
  while j <= (x as f64).sqrt() as i64 {
      if x % j == 0 {
          return false;
      }
      j += 2;
  }
  true
}


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

using namespace std;

int main() {
	double a, b, d, c, h;
	const double pi = 3.1415926;

	cin >> a >> b >> d;
	h = b * sin(d * pi / 180.0);
	c = sqrt(a * a + b * b - 2 * a * b * cos(d * pi / 180.0));

	cout << fixed << setprecision(6) << a * h / 2 << endl
		<< fixed << setprecision(6) << a + b + c << endl
		<< fixed << setprecision(6) << h << endl;

	return 0;
}


Measured memory_bytes: 3432
import math
a, b, h, m = map(int, input().split())

s = (60*h+m)/360*math.pi
l = m/30*math.pi
sx = a*math.sin(s)
sy = a*math.cos(s)
lx = b*math.sin(l)
ly = b*math.cos(l)
print(math.sqrt(((sx-lx)**2+(sy-ly)**2)))

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  
  int n; cin >> n;
  int a[n]; rep(i,n) cin >> a[i];
  set<int> set;
  rep(i,n){
    set.insert(a[i]);
  }
  if(set.size() == n) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 10368
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-10 21:00:49
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  int k, x; cin >> k >> x;

  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    map<int,int> cnt;
    rep(i,n-1){
        int a;
        cin >> a;
        cnt[a]++;
    }
    rep1(i,n){
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13008
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
#define N 3005
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}
int n,mo;LL S[N][N],C[N][N],ans,tmp;
LL qp1(LL x,LL y) {
    LL res=1;
    for(;y;y>>=1,x=x*x%mo)
	if(y&1) res=res*x%mo;
    return res;
}
LL mmod(LL x,LL y) {
    LL res=x*y;
    return res>=(mo-1)?res%(mo-1)+(mo-1):res;
}
LL qp2(LL x,LL y) {
    LL res=1;
    for(;y;y>>=1,x=mmod(x,x))
	if(y&1) res=mmod(res,x);
    return res;
}
int main()
{
    n=gi(),mo=gi();
    S[0][0]=1;
    for(int i=1;i<=n+1;++i)
	for(int j=1;j<=i;++j)
	    S[i][j]=S[i-1][j-1]+S[i-1][j]*j%mo,S[i][j]>=mo?S[i][j]-=mo:0;
    C[0][0]=1;
    for(int i=1;i<=n;++i) {
	C[i][0]=C[i][i]=1;
	for(int j=1;j<i;++j)
	    C[i][j]=C[i-1][j]+C[i-1][j-1],C[i][j]>=mo?C[i][j]-=mo:0;
    }
    for(int i=0;i<=n;++i) {
	tmp=0;
	for(int j=0;j<=i;++j) {
	    tmp+=S[i+1][j+1]*qp1(2,(n-i)*j)%mo;
	    tmp>=mo?tmp-=mo:0;
	}
	tmp=tmp*C[n][i]%mo*qp1(2,qp2(2,n-i))%mo;
	if(i&1) ans+=mo-tmp; else ans+=tmp;
	ans>=mo?ans-=mo:0;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int N,W;
int w[102];
int v[102];
long long dp[102][100005];

long long solve(int i , int value)
{
    if(i==N)
    {
        if(value!=0)
            return 1e9+1;
        else return 0;
    }
    if(value<0)
        return 1e9+1;

    long long &res = dp[i][value];
    if(~res)
        return res;
    res = solve(i+1 , value);
    res = min(solve(i+1 , value-v[i]) + w[i],res);

    return res;

}

int main()
{

    memset(dp , -1 , sizeof(dp));
    cin>>N>>W;
    int values = 0;
    for(int i=0; i<N; i++)
    {
        cin>>w[i]>>v[i];
        values+=v[i];
    }

    int ans=0;
    for(int i=0; i<=100000; i++)
        if(solve(0 , i) <= W)
            ans = i;
    cout<<ans;

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	int next_num = 1, idx = 0, cnt = 0;
	while(idx < n){
		if(a[idx] == next_num){
			next_num++;
		}else{
			cnt++;
		}
		idx++;
	}

	if(cnt == n) cout << -1 << endl;
	else cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h, w, H, W;
	cin >> H >> W >> h >> w;

	int res = H * W - h * W - H * w + h * w;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    map<char, ll> mp;
    for (char c : S) {
        mp[c]++;
    }

    bool ok = mp.size() == 2;
    for (auto p : mp) {
        if (p.second != 2) {
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//067A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b=0;
    cin >> a >> b;
    if (a%3==0 or b%3==0 or (a+b)%3==0){
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    ll sum = 0;
    REP(i,0,n){
    	cin>>arr[i];
    	sum += arr[i];	
    } 
    ll ct = 0;
    REP(i,0,n){
    	if(arr[i] >= (float)(sum)/(4*m))
    		ct++;
    }
    if(ct >= m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const string temp = "+-*";
const int64 INF = 1LL << 62;

string S;
int level[256];

bool inc(int depth, char c)
{
  return(temp.find(c) != string::npos && level[c] == depth);
}

int64 F(int& idx, int depth)
{
  int64 val;
  if(depth == 3) {
    if(isdigit(S[idx])) {
      val = 0;
      while(idx < S.size() && isdigit(S[idx])) {
        val = val * 10 + S[idx++] - '0';
      }
    } else {
      ++idx;
      val = F(idx, 0);
      ++idx;
    }
  } else {
    val = F(idx, depth + 1);
    while(idx < S.size() && inc(depth, S[idx])) {
      char op = S[idx++];
      int64 y = F(idx, depth + 1);
      if(op == '+') val += y;
      else if(op == '-') val -= y;
      else val *= y;
    }
  }
  return(val);
}


int main()
{ 
  cin >> S;
  int ptr = 0;
  int64 ret = F(ptr, 0);
  for(int& i = level['+'] = 0; i < 3; i++) {
    for(int& j = level['-'] = 0; j < 3; j++) {
      for(int& k = level['*'] = 0; k < 3; k++) {
        int idx = 0;
        ret = max(ret, F(idx, 0));
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1200
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	sum := 0
	for i := 0; i < n; i++ {
		sum += nextInt()
	}

	fmt.Println(sum - n)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1816
function main(input) {
	const [d, n] = input.trim().split(" ").map(n => Number(n));
  	const num = n === 100 ? n + 1 : n;
  	const result = (100 ** d) * num;
  	console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> psum(n);
    int sum = 0;
    rep(i,0,a.size()){
        cin>>a[i];
        sum += a[i];
        psum.pb(sum);
    }
    int ans = inf;
    rep(i,0,psum.size()){
        ans = min(ans,abs(psum[i] - sum + psum[i]));
    }
    cout<<ans<<endl;


}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
<?php
 
fscanf(STDIN, "%d %d", $x, $y);
 
if (($x * 4) < $y) {
	echo("No");
    exit;
}

if (($y % 2) == 1) {
	echo("No");
    exit;
}

if (($x * 2) > $y) {
	echo("No");
    exit;
}

$z = $y - 2 *$x;

if (($z / 2) <= $x) {
  	echo("Yes");
    exit;
}
echo("No");




Measured memory_bytes: 16212
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int A = scan.nextInt();
                int B = scan.nextInt();
                int C = scan.nextInt();
                int K = scan.nextInt();
                
                int ans = 0;
                int mai = K;
                while(mai>0){
                    for(int i=A;i>0;i--){
                        ans = ans+1;
                        mai--;
                        if(mai<=0){
                             System.out.println(ans);
                             System.exit(0);
                        }
                    }
                    for(int i=B;i>0;i--){
                        mai--;
                        if(mai<=0){
                             System.out.println(ans);
                             System.exit(0);
                        }
                    }
                    for(int i=C;i>0;i--){
                        ans = ans-1;
                        mai--;
                        if(mai<=0){
                             System.out.println(ans);
                             System.exit(0);
                        }
                    }
                }
               
        }
}

Measured memory_bytes: 35844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL long long
#define lowbit(x) ((x)&-(x))
using namespace std;
const int MAX = 300010;
struct segment
{
    int l,r;
    bool operator < (const segment&a)
    {
        return r-l < a.r-a.l;
    }
}seg[MAX];
int N,M,v[MAX],s[MAX<<2],lazy[MAX<<2];
void pushup(int rt)
{
    s[rt] = s[rt<<1] + s[rt<<1|1];
}
void pushdown(int rt,int l)
{
    if (lazy[rt])
    {
        s[rt<<1] += lazy[rt]*(l-(l>>1));
        s[rt<<1|1] += lazy[rt]*(l>>1);
        lazy[rt<<1] += lazy[rt];
        lazy[rt<<1|1] += lazy[rt];
        lazy[rt] = 0;
    }
}
void update(int L,int R,int p,int l,int r,int rt)
{
    if (L <= l && r <= R)
    {
        s[rt] += p*(r-l+1);
        lazy[rt] += p;
        return ;
    }
    pushdown(rt,r-l+1);
    int m = (l+r)>>1;
    if (L <= m) update(L,R,p,l,m,rt<<1);
    if (m < R) update(L,R,p,m+1,r,rt<<1|1);
    pushup(rt);
}
int query(int L,int R,int l,int r,int rt)
{
    if (L <= l && r <= R) return s[rt];
    pushdown(rt,r-l+1);
    int m = (l+r)>>1, sum = 0;
    if (L <= m) sum += query(L,R,l,m,rt<<1);
    if (m < R) sum += query(L,R,m+1,r,rt<<1|1);
    return sum;
}
int main(void)
{
    while (~scanf("%d%d",&N,&M))
    {
        for (int i=0;i<N;i++) scanf("%d%d",&seg[i].l,&seg[i].r);
        sort(seg,seg+N);
        //memset(s,0,sizeof(s));
        //memset(v,0,sizeof(v));
        int d, lim = sqrt(N)*M*sqrt(log2(M));
        //printf("lim = %d\n",lim);
        for (d=1;d*d<=M;d++)
        {
            for (int i=0;i<N;i++) if (seg[i].r/d > (seg[i].l-1)/d) v[d]++;
        }
        int i=0;
        for (;d<=M;d++)
        {
            for (;i<N && seg[i].r-seg[i].l+1<=d;i++)
            {
                update(seg[i].l,seg[i].r,1,1,M,1);
                //printf("l = %d, r = %d\n",seg[i].l,seg[i].r);
                //for (int j=1;j<=M;j++) printf("%d ",query(j,j,1,M,1)); puts("");
            }
            for (int j=1;j*d<=M;j++) v[d] += query(j*d,j*d,1,M,1);
            v[d] += N-i;
        }
        for (int i=1;i<=M;i++) printf("%d\n",v[i]);
    }
    return 0;
}


Measured memory_bytes: 5632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() { 
    println!("{}", {
        input!{
            s: chars,
        }
        s.iter().zip(s.iter().rev()).filter(|&(&a, &b)| a != b).count() / 2
    });
}


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

class Main {

	public static int JosephsPotato (int n, int m) {

		int cnt = 0;
		int move = m;
		int mod = n + 1;
		int[] player = new int[n + 1];
		boolean[] isLose = new boolean[n + 1];

		// 初期化処理
		for (int i = 1; i < player.length; i++) {
			player[i] = i;
			isLose[i] = false;
		}

		int point = 0; // 開始地点の設定（= 1）

		while (true) {

			int j = 1;
			int p = 0;
			int index = 0;
			while (true) {
				if ((point + j) % mod == 0) {
					j++;
					continue;
				}
				if (isLose[(point + j) % mod] == false) {
					p++;
					if (p == move) {
						index = (point + j) % mod;
						break;
					}
				}
				j++;
			}
			isLose[index] = true; // 輪から抜ける
			cnt++;
			point = index;
			if (cnt == n - 1) break;

		}

		// 唯一抜けていないプレイヤーが勝者
		for (int i = 1; i < player.length; i++) {
			if (!isLose[i]) return i;
		}

		return -1;

	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

		ArrayList<Integer> ans = new ArrayList<Integer>();

		while (true) {

			StringTokenizer st = new StringTokenizer(br.readLine()," ");

			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			if (n == 0 && m == 0) break;
			ans.add(JosephsPotato(n, m));

		}

		for (int a : ans)
			System.out.println(a);

	}

}

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

using namespace std;

 long long gcd  ( long long a, long long b) {
    while (b) {
        a %= b;
        swap (a, b);
    }
    return a;
}


long long lcm (long long a, long long b) {
    return a / gcd (a, b) * b;
}
int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    long long d = 1;
    for (int i = 0; i < n; i++) {
        d = lcm(d, a[i]);
    }
    cout << d << "\n";
    return 0;
}

Measured memory_bytes: 256
s=input()
a=[]
b=[]
for i in s:
    a.append(i)

for j in a:
    if j not in b:
        b.append(j)

c=[]
for k in b:
    c.append(a.count(k))

if c.count(2)>=2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  string s;
  cin >> s;
  bool ok = false;
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    ok = true;
  } else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) {
    ok = true;
  } else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
    ok = true;
  }
  if(ok) {
    cout << "Yes" << endl;

  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val sc: Scanner = new Scanner(input)
    val n = sc.nextInt
    val s = sc.next.toCharArray
    var rSum = s.drop(1).count(_ == 'E')
    var lSum = 0
    var min = rSum
    for (i <- 1 until n) {
      if (s(i) == 'E') {
        rSum = rSum - 1
      }
      if (s(i - 1) == 'W') {
        lSum = lSum + 1
      }
      min = Math.min(rSum + lSum, min)
    }
    min.toString
  }

  val tests = List(
    """5
      |WEEWW""".stripMargin -> """1""",
    """12
      |WEWEWEEEWWWE""".stripMargin -> """4""",
    """8
      |WWWWWEEE""".stripMargin -> """3"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

int main(){
    int N;
    cin >> N;
    int M = 0;
    int M2 = 0;
    int num;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        if (a >= M2){
            if (a > M){
                M = a;
                num = i;
            }
            else{
                M2 = a;
            }
        }
    }
    for (int i = 0; i < N; i++){
        if (i != num){
            cout << M << endl;
        }
        else {
            cout << M2 << endl;
        }

    }
}

Measured memory_bytes: 1664
sx, sy, tx, ty = map(int,input().split())
dx = tx - sx
dy = ty - sy
print("D" + "R"*(dx+1) + "U"*(dy+1) + "L" + "D"*(dy)+ "L"*(dx) + "U" * dy + "R"*dx + "U"+"L"*(dx+1)+"D"*(dy+1) +"R")



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)

int N, B[64], C[64];
string A[64], D[64][64];
int g[64][64], cf[64], ct[64];
int dp[1<<20];

int solve() {
    const int n = N / 2, m = N - n;
    const int nn = 1<<n, mm = 1<<m;
    memset(cf, 0, sizeof(cf));
    memset(ct, 0, sizeof(ct));
    rep (i, n) rep (j, n) if (g[i][j]) cf[i] |= 1<<j;
    rep (i, m) rep (j, m) if (g[i+n][j+n]) cf[i+n] |= 1<<j;
    rep (i, m) rep (j, n) if (g[i+n][j]) ct[i] |= 1<<j;
    rep (i, nn) dp[i] = -INF;
    rep (b, nn) {
        if (b&1) {
            bool ok = true;
            rep (i, n) if (b&(1<<i) && b&cf[i]) { ok = false; break; }
            if (ok) {
                int s = 0;
                rep (i, n) if (b&(1<<i)) s += B[i];
                dp[b] = max(dp[b], s);
            }
        }
        rep (i, n) dp[b|(1<<i)] = max(dp[b|(1<<i)], dp[b]);
    }
    int ans = 0;
    rep (b, mm) {
        bool ok = true;
        rep (i, m) if (b&(1<<i) && b&cf[i+n]) { ok = false; break; }
        if (!ok) continue;
        int s = 0;
        rep (i, m) if (b&(1<<i)) s += B[i+n];
        int z = 0;
        rep (i, m) if (b&(1<<i)) z |= ct[i];
        ans = max(ans, dp[nn-1-z] + s);
    }
    return ans;
}

int main() {
    for (;;) {
        cin >> N;
        if (N == 0) return 0;
        map<string, int> of;
        rep (i, N) {
            cin >> A[i] >> B[i] >> C[i];
            of[A[i]] = i;
            rep (j, C[i]) cin >> D[i][j];
        }
        memset(g, 0, sizeof(g));
        rep (i, N) rep (j, C[i]) g[i][of[D[i][j]]] = 1;
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 5472
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int n,k;
ll R,s,P;
string t;
ll memo[2000005][4];
ll solve(int i,int last)
{
    if(i >= n)
        return 0 ;
    ll &ret = memo[i][last];
    if(ret != -1)
        return ret;
    ret = 0;
    ll temp = 0;
    if(last == 1)
    {
        if(t[i] == 's')
            temp = R;

    }
    if(last == 2)
    {
        if(t[i] == 'r')
            temp+=P;
    }
    if(last == 3)
    {
        if(t[i] == 'p')
            temp+=s;
    }
    if(last != 1)
    ret = max(ret , solve(i+k,1));
    if(last != 2)
    ret = max(ret , solve(i+k,2));
    if(last != 3)
    ret = max(ret , solve(i+k,3));
    ret += temp;
    return ret;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    cin>>n>>k;
    cin>>R>>s>>P;
    cin>>t;
    ll ans = 0;
    for(int i=0; i<k; i++)
    {
        ans+= max(solve(i,1),max(solve(i,2),solve(i,3)));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 67584
class dice2():
    def __init__(self,men1,men2,men3,men4,men5,men6):
        self.men=[men1,men2,men3,men4,men5,men6]
        
    def find_num_rside(self,top,front):
        t=self.men.index(top)+1
        f=self.men.index(front)+1
        if [t,f] in [[1,2],[2,6],[6,5],[5,1]]:
            return self.men[3-1]#3
        elif  [t,f] in [[5,6],[6,2],[2,1],[1,5]]:
            return self.men[4-1]#4
        elif [t,f] in [[4,2],[2,3],[3,5],[5,4]]:
            return self.men[1-1]#1
        elif  [t,f] in [[5,3],[3,2],[2,4],[4,5]]:
            return self.men[6-1]#6
        elif  [t,f] in [[1,3],[3,6],[6,4],[4,1]]:
            return self.men[5-1]#5
        elif  [t,f] in [[4,6],[6,3],[3,1],[1,4]]:
            return self.men[2-1]#2
        
mn=list(map(int,input().split()))
q=int(input())

d=dice2(*mn)

for i in range(q):
    top, front=list(map(int,input().split()))
    ans=d.find_num_rside(top, front)
    print(ans)

Measured memory_bytes: 7804
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct S{int a,b,c,d;};
bool operator<(S a,S b){
  if(a.a!=b.a)return a.a<b.a;
  if(a.b!=b.b)return a.b<b.b;
  if(a.c!=b.c)return a.c<b.c;
  return a.d<b.d;
}
bool operator==(S a,S b){
  return a.a==b.a && a.b==b.b && a.c==b.c && a.d==b.d;
}
signed main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<int> A(X),B(Y),C(Z);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  for(int &i:C)cin>>i;
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  priority_queue<S> Q;
  Q.push(S{A[X-1]+B[Y-1]+C[Z-1],X-1,Y-1,Z-1});
  S n{-1,-1,-1,-1};
  for(int i=0;i<K;){
    S a=Q.top();
    Q.pop();
    if(a==n)continue;
    n=a;
    if(a.b)Q.push(S{a.a-A[a.b]+A[a.b-1],a.b-1,a.c,a.d});
    if(a.c)Q.push(S{a.a-B[a.c]+B[a.c-1],a.b,a.c-1,a.d});
    if(a.d)Q.push(S{a.a-C[a.d]+C[a.d-1],a.b,a.c,a.d-1});
    cout<<a.a<<endl;
    i++;
  }
}

Measured memory_bytes: 3780
import math

N = int(input())

route_N = math.sqrt(N)

# a+b-2 minimum
# a*b = N 

ans = 10e+12

for a in range(1,int(route_N)+1):
    if N%a ==0:
        ans = min(ans,a+(N/a)-2)

print(int(ans))




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

#define ll   long long

ll fact(ll n)
{
    if(n > 1)
        return (n*fact(n - 1))%1000000007;
    else
        return 1;
}

ll npr(ll n,ll r)
{
    return (fact(n))%1000000007/fact(n-r);
}

int main()
{
    string s1,s2;
    cin>>s1;
    cin>>s2;
    reverse(s2.begin(),s2.end());
    if(s1==s2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
	char c[7];
    scanf("%s",c);
	if(c[2]==c[3]&&c[4]==c[5])puts("Yes");else puts("No");
    return 0;
}

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

int partion(vector<int> &a,int p, int r){
    int x=a[r],i=p-1,j=p;
    for(;j<r;j++){
        if(a[j]<=x){
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

int main(){
    int N;
    cin >>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int x=partion(a,0,N-1);
    for(int i=0;i<N;i++){
        if(i==x){
            cout<<"["<<a[i]<<"]";
        }
        else cout<<a[i];
        if(i!=N-1)cout<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

//dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main ()
{
    int N,W;cin>>N>>W;
    vector<int> weight(N),value(N);
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    REP(i,N){
        cin>>weight[i]>>value[i];
    }
    REP(i,N){
        REP(sum_w,W+1){
            if(sum_w - weight[i]>=0){
                chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
            }
            chmax(dp[i+1][sum_w],dp[i][sum_w]);
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 80256
n, k = map(int, input().split())
li = [int(input())for _ in range(n)]
li.sort()
min_sa = 99999999999999999999999999999
for i in range(n-k+1):
    min_sa = min(abs(li[i]-li[i+k-1]), min_sa)
print(min_sa)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  vector<int> c(n);

  for (int i = 0; i < n - 1; i++) {
    c[a[i] - 1]++;
  }

  rep(i, n) { printf("%d\n", c[i]); }

  return 0;
}

Measured memory_bytes: 4836
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;
using ll = long long int;

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

  if (X >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  int ans = a*x + b*y;
  repd(i,1,max(x,y)+1){
    int aa = ans - a - b + 2*c;
    if(i > x)aa += a;
    if(i > y)aa += b;
    ans = min(ans, aa);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = input()
papers = [int(x) for x in input().split()]
out = 0

for i in papers:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            out = 1
            break

if out == 0:
    print("APPROVED")
else:
    print("DENIED")


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t b, w;
    cin >> b >> w;

    constexpr auto M = 1000000007L;
    constexpr auto K = 200001L;

    vector<int64_t> fact(K, 1L), inv_fact(K, 1L), inv(K, 1L),
            inv_pow2(K - 1, 1L);
    for (auto i : irange(2L, K)) {
        fact[i] = fact[i - 1] * i % M;
        inv[i] = (M - inv[M % i] * (M / i) % M) % M;
        inv_fact[i] = inv_fact[i - 1] * inv[i] % M;
        inv_pow2[i - 1] = inv_pow2[i - 2] * inv[2] % M;
    }

    auto combi = [&](int64_t n, int64_t m) {
        if (m > n) {
            return 0L;
        }
        return fact[n] * inv_fact[m] % M * inv_fact[n - m] % M;
    };

    int64_t p_no_black = 0, p_no_white = 0;
    for (auto i : irange(1L, b + w + 1)) {
        p_no_black += combi(i - 2, b - 1) * inv_pow2[i - 1] % M;
        p_no_black %= M;
        p_no_white += combi(i - 2, w - 1) * inv_pow2[i - 1] % M;
        p_no_white %= M;
        auto p_both_left = (1 + (M - p_no_black) + (M - p_no_white)) % M;

        cout << (p_no_white + p_both_left * inv[2]) % M << "\n";
    }
}

Measured memory_bytes: 8448
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
const int INF = 0x3f3f3f3f;

const int maxn = 10240;

struct edge {
	int to, dis, cost;
	edge(int t, int d, int c) : to(t), dis(d), cost(c) {}
};


typedef pair<int, int> p;
priority_queue<p, vector<p>, greater<p> > q;
vector<edge> g[maxn];

int N, M;

void read_in() {
	//scanf("%d%d", &N, &M);
	for(int i = 1; i <= N; i++)
		g[i].clear();

	int from, to, dis, cost;
	for(int i = 1; i <= M; i++) {
		scanf("%d%d%d%d", &from, &to, &dis, &cost);
		g[from].push_back(edge(to, dis, cost));
		g[to].push_back(edge(from, dis, cost));
	}
}

int solve() {
	q.push(p(0, 1));

	const int INF = 0x7777777;
	int d[maxn];

	for(int i = 2; i <= N; i++) 
		d[i] = INF;
	d[1] = 0;

	while( !q.empty() ) {
		p t = q.top();
		q.pop();

		int to = t.second, dis = t.first;
        if(d[to] < dis) continue;
		for(unsigned int i = 0; i < g[to].size(); i++) {
			edge To = g[to][i];
			if(d[To.to] > d[to] + To.dis)
				d[To.to] = d[to] + To.dis,
				q.push(p(d[To.to], To.to));
		}
	}
	//show(d);
    int ans = 0;

    for(int i = 2; i <= N; i++) {
        int tmp = INF;

        for(int j = 0; j < g[i].size(); j++) {
            edge e = g[i][j];
            if(d[e.to] + e.dis == d[i] and e.cost < tmp)
                tmp = e.cost;
        }
        ans += tmp;
    }

    return ans;
}

int main() {
	while(scanf("%d %d", &N, &M) and N) {
		read_in();
		printf("%d\n", solve());
	}
	return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] = 'a' + s[k-1] - 'A';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
program main
integer N
integer,allocatable,dimension(:)::a,b,c
integer,allocatable,dimension(:,:)::DP

read*,N
allocate(a(n),b(n),c(n))
allocate(DP(0:n,3))
do i=1,N
  read*,a(i),b(i),c(i)
end do

DP(0,:)=0
do i=1,N
  DP(i,1)=max(DP(i-1,2),DP(i-1,3))+a(i)
  DP(i,2)=max(DP(i-1,3),DP(i-1,1))+b(i)
  DP(i,3)=max(DP(i-1,1),DP(i-1,2))+c(i)  
end do

print"(I0)",max(DP(N,1),DP(N,2),DP(N,3))
end

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int cost = 0;

		if (A >= 13) {
			cost = B ;
		} else if ( 6 <=A && A<= 12) {
			cost = B/2;
		} else {
			cost = 0;
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 23764
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
ld p[3000];
ld dp[3000][3000];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			dp[i + 1][j + 1] += dp[i][j] * p[i];
		}
	}
	ld ans = 0;
	for (int i = (n / 2) + 1; i <= n; ++i)
		ans += dp[n][i];
	cout.setf(ios::fixed);
	cout.precision(20);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 139136
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h = h2-h1;
    int m = m2 - m1;
    int l = h*60+m;
    int ans = l - k;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N;
    cin >> N;
    // 各桁（2^0~2^59）の１の数を数える
    vector<LLONG> oneNums(60);
    for (int i = 0; i < N; ++i)
    {
        LLONG Ai;
        cin >> Ai;
        for (int digit = 0; digit < 60; ++digit)
        {
            if (Ai % 2 == 1)
            {
                ++oneNums[digit];
            }
            Ai /= 2;
        }
    }
    LLONG sum = 0;
    LLONG base = 1;
    for (int digit = 0; digit < 60; ++digit)
    {
        LLONG oneNum = oneNums[digit];
        sum += ((oneNum * (N - oneNum)) % MOD) * (base % MOD);
        sum = sum % MOD;
        base *= 2;
    }
    cout << sum << endl;
}


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

//貪欲に

int main(){

    string str; cin >> str;
    vector<long long> c(100, 0);
    for(int i = 0; i < str.size(); i++){
        c[(int)str[i] - 'a']++;
    }

    long long n = str.size();
    
    if(n % 2 == 0) n =  n / 2 *(n - 1);
    else n = (n - 1) / 2 * n;

    for(int i = 0; i < 30; i++){
        if(c[i] % 2 == 0) n -= c[i] / 2 * (c[i] - 1);
        else n -= (c[i] - 1) / 2 * c[i];
    }

    cout << n + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    int N,M,C,A[100][100],B[100],i,j,s[100]={0},k=0;

    scanf("%d%d%d",&N,&M,&C);

    for(i=0;i<M;i++){
        scanf("%d",&B[i]);
    }

    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
                scanf("%d",&A[i][j]);
            s[i]=s[i]+A[i][j]*B[j];
        }
        if(s[i]+C>0){
            k++;
        }
    }

    printf("%d",k);
return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

ll count_amida(ll line) {
    if (line <= 1) return 1;
    ll interval = line - 1;
    ll dp[20][2]; //[i][0]...i番目に引かない [i][1]...i番目に引く
    dp[0][0] = 1, dp[0][1] = 0;

    rep(i, interval) {
        dp[i + 1][0] = dp[i][0] + dp[i][1];
        dp[i + 1][1] = dp[i][0];
    }
    return dp[interval][0] + dp[interval][1];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, k;
    cin >> h >> w >> k;
    ll dp[110][10] = {};
    dp[0][0] = 1;

    rep(i, h + 1) rep(pos, w) {
        //そのまま下ろす
        dp[i + 1][pos] += dp[i][pos] * count_amida(pos) % MOD * count_amida(w - 1 - pos);
        dp[i + 1][pos] %= MOD;
        //左に移動
        if (pos != 0) {
            dp[i + 1][pos - 1] += dp[i][pos] * count_amida(pos - 1) % MOD * count_amida(w - 1 - pos);
            dp[i + 1][pos - 1] %= MOD;
        }
        //右に移動
        if (pos != w - 1) {
            dp[i + 1][pos + 1] += dp[i][pos] * count_amida(pos) % MOD * count_amida(w - 1 - pos - 1);
            dp[i + 1][pos + 1] %= MOD;
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, X;

    cin >> N >> X;
    int L[N];
    for ( int i = 0; i < N; i ++ ) cin >> L[i];

    int c = 0;
    int i;
    for ( i = 0; i < N; i ++ ) {
        c += L[i];
        if ( c > X ) break;
    }

    cout << i + 1 << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int A, B, C, X, Y;
        A = in.nextInt(); B = in.nextInt(); C = in.nextInt(); X = in.nextInt(); Y = in.nextInt();
       int sum = 0;
        while( X > 0 && Y > 0) {
            if(C * 2 < (A + B)) {
               sum += 2*C;
            } else {
                sum+= (A+B);
            }
            X--; Y--;
        }
        while(X > 0){
           if(A > (2*C)) sum+=(2*C);
           else sum+=A;

           X--;
        }

        while(Y > 0) {
            if(B > (2*C)) sum+=(2*C);
            else sum+=B;

            Y--;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    a, b = LI()
    print(max(a+b, a-b, a*b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  immutable N = readln.chomp.to!long;
  long res;

  foreach (i; 1..N.to!real.sqrt.to!long+1) {
    if (N / i == i) {
      continue;
    }
    if (N % i == 0) {
      immutable t = N / i - 1;
      if (N % t) {
        res += t;
      }
    }
  }
  res.writeln;
}


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

int sum[111];

int main(){
  int N; cin>>N;
  int W[N];
  for(int i=0;i<N;i++){
    cin>>W[i];
    sum[i+1]=sum[i]+W[i];
  }
  int ans=1e9;
  for(int i=1;i<N;i++){
    ans=min(ans,abs(sum[i]-(sum[N]-sum[i])));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
h = LI()
ab = [LI() for _ in range(m)]
m = [0]*n
for a,b in ab:
    m[a-1] = max(m[a-1], h[b-1])
    m[b-1] = max(m[b-1], h[a-1])
ans = 0
for i in range(n):
    if m[i] < h[i]:
        ans += 1   
print(ans)

Measured memory_bytes: 92228