akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int a,b,m;
  int money = 0;
  cin >> a >> b >> m;
  vector<int>A(a);
  vector<int>B(b);
  for(int i=0;i<a;i++) cin >> A[i];
  for(int i=0;i<b;i++) cin >> B[i];
  money = *min_element(All(A)) + *min_element(All(B));

  for(int i=0;i<m;i++){
    int x,y,c;
    cin >> x >> y >> c;
    money = min(money,A[x-1]+B[y-1]-c);
  }
  cout<< money <<endl;



}


Measured memory_bytes: 1024
# n = gets.chomp.split(" ")
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
i = 0
while 1 do
  if i%2==0
    c-=b
  else
    a-=d
  end
  break if a <= 0 || c <= 0
  i += 1
end

if i%2==0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#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 test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int p[] = { -1, 1};

void solve() {
	int k, n;
	cin >> k >> n;
	int a;
	si s;
	rep(i, 0, n - 1) cin >> a, s.in(a);
	rep(d, 0, k) {
		rep(i, 0, 1) {
			int x = k + p[i] * d;
			if (s.count(x) == 0) {
				cout << x;
				return;
			}
		}
	}
}

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


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

	// test
	solve();

	return 0;
}

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

int main(){
    int N; cin>>N;
    set<int> A;

    int ans=0;
    rep(i,N){
        int a; cin>>a;
        if(A.count(a)){
            A.erase(a);
            ans--;
        }else{
            A.insert(a);
            ans++;
        }
    }
    cout << ans << endl;


    // vector<int> A(1e9+1,0);

    // int ans=0;
    // rep(i,N){
    //     int a; cin>>a;
    //     if(A[a]==0){
    //         A[a]=1;
    //         ans++;
    //     }else if(A[a]==1){
    //         A[a]=0;
    //         ans--;
    //     }
    // }

    // // int ans=0;
    // // for(int x:A){
    // //     ans += x;
    // // }
    // cout << ans << endl;
}


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


int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c'){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		ArrayDeque<Long> list = new ArrayDeque<>();
		long ele = 0;

		for (int i = 0; i < n; i++) {
			switch (sc.next()) {
			case "insert":
				ele = Integer.parseInt(sc.next());
				list.offerFirst(ele);
				break;
			case "delete":
				ele = Long.parseLong(sc.next());
				list.remove(ele);
				break;
			case "deleteFirst":
				list.pollFirst();
				break;
			case "deleteLast":
				list.pollLast();
				break;
			}
		}

		PrintWriter out = new PrintWriter(System.out);

		for (int i = 0; i < list.size();) {
			out.print(list.pollFirst());
			out.print(list.size() == 0 ? "" : " ");
		}
		out.println();
		out.flush();
	}
}



Measured memory_bytes: 334452
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin >> a >> b;
    if(a == b)
    {
        cout << "EQUAL";
    }
    else if(a.size() > b.size())
    {
        cout << "GREATER";
    }
    else if(a.size() < b.size())
    {
        cout << "LESS";
    }
    else if(a > b)
    {
        cout << "GREATER";
    }
    else
    {
        cout << "LESS";
    }
    
    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 a, b, c;
    cin >> a >> b >> c;

    if (a % 2 == 0 && a == b && b == c && c == a) {
        cout << -1 << endl;
        return;
    }

    i64 ans = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        i64 na = (b + c) / 2;
        i64 nb = (c + a) / 2;
        i64 nc = (a + b) / 2;
        a = na, b = nb, c = nc;
        ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    ll r = 0;
    ll t = 1;
    for (int i = 0; i <= n; i++) {
        r += t;
        t -= a[i];
        s -= a[i];
        if (t < 0) {
            cout << -1 << endl;
            exit(0);
        }
        t = min(t * 2, s);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3932
def main():
    s = input()
    sr = s[::-1]

    N = int(len(s))
    s1 = s[:int((N-1)/2)]
    s1r = s1[::-1]
    s2 = s[int((N+1)/2):]
    s2r = s2[::-1]

    # print(s1)
    #     # print(s1r)
    #     # print(s2)
    #     # print(s2r)
    #     # # return

    for i in range(len(s)-1):
        if s[i] != sr[i]:
            print("No")
            return

    for i in range(len(s1)-1):
        if s1[i] != s1r[i]:
            print("No")
            return

    for i in range(len(s2)-1):
        if s2[i] != s2[i]:
            print("No")
            return

    print("Yes")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int n, k, dp[5][5][123], a[123];
signed main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int x, y; cin >> x >> y;
		a[x] = y;
	}
	dp[2][1][1] = (a[1] != 2 && a[1] != 3);
	dp[3][2][1] = (a[1] != 1 && a[1] != 3);
	dp[1][3][1] = (a[1] != 1 && a[1] != 2);
	for (int i = 2; i <= n; i++) {
		if (a[i] != 2 && a[i] != 3) {
			dp[1][1][i] = 000000000000000 + dp[2][1][i - 1] + dp[3][1][i - 1]; dp[1][1][i] %= 10000;
			dp[2][1][i] = dp[1][2][i - 1] + dp[2][2][i - 1] + dp[3][2][i - 1]; dp[2][1][i] %= 10000;
			dp[3][1][i] = dp[1][3][i - 1] + dp[2][3][i - 1] + dp[3][3][i - 1]; dp[3][1][i] %= 10000;
		}
		if (a[i] != 1 && a[i] != 3) {
			dp[1][2][i] = dp[1][1][i - 1] + dp[2][1][i - 1] + dp[3][1][i - 1]; dp[1][2][i] %= 10000;
			dp[2][2][i] = dp[1][2][i - 1] + 000000000000000 + dp[3][2][i - 1]; dp[2][2][i] %= 10000;
			dp[3][2][i] = dp[1][3][i - 1] + dp[2][3][i - 1] + dp[3][3][i - 1]; dp[3][2][i] %= 10000;
		}
		if (a[i] != 1 && a[i] != 2) {
			dp[1][3][i] = dp[1][1][i - 1] + dp[2][1][i - 1] + dp[3][1][i - 1]; dp[1][3][i] %= 10000;
			dp[2][3][i] = dp[1][2][i - 1] + dp[2][2][i - 1] + dp[3][2][i - 1]; dp[2][3][i] %= 10000;
			dp[3][3][i] = dp[1][3][i - 1] + dp[2][3][i - 1] + 000000000000000; dp[3][3][i] %= 10000;
		}
	}
	int ans = 0;
	for (int i = 1; i <= 4; i++)for (int j = 1; j <= 3; j++) { ans += dp[i][j][n]; ans %= 10000; }
	cout << ans << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1000000007;

int main(){
    int N,u,v;cin>>N>>u>>v;
    u--;v--;
    vector<vector<int>> G(N);
    rep(i,N-1){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int dist1[N];
    rep(i,N)dist1[i]=inf;
    dist1[u]=0;
    queue<int> que;
    que.push(u);
    while(!que.empty()){
        int p=que.front();
        que.pop();
        for(auto nu:G[p]){
            if(dist1[p]+1<dist1[nu]){
                dist1[nu]=dist1[p]+1;
                que.push(nu);
            }
        }
    }
    int dist2[N];
    rep(i,N)dist2[i]=inf;
    dist2[v]=0;
    que.push(v);
    while(!que.empty()){
        int p=que.front();
        que.pop();
        for(auto nv:G[p]){
            if(dist2[p]+1<dist2[nv]){
                dist2[nv]=dist2[p]+1;
                que.push(nv);
            }
        }
    }
    int ans=0;
    rep(i,N){
        if(dist1[i]>dist2[i])continue;
        else ans=max(ans,dist2[i]-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
using Int = long long;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<bool> map((H+2)*(W+2)); // 0 = black, 1 = white
    vector<bool> seen((H+2)*(W+2));
    int count = 0;
    for (int y = 1; y <= H; y++) {
        for (int x = 1; x <= W; x++) {
            char c;
            cin >> c;
            if (c == '.') {
                map[(W+2)*y+x] = 1;
                count++;
            }
        }
    }
    queue<pair<int, int>> Q;
    Q.push(make_pair((W+2)*1+1, 1));
    int d[4] = { +1, -1, W+2, -(W+2) };
    int goal = (W+2)*H+W;
    int dist = 0;
    while (!Q.empty()) {
        int pos, cnt;
        tie(pos, cnt) = Q.front();
        Q.pop();
        if (seen[pos]) continue;
        seen[pos] = true;
        if (pos == goal) {
            dist = cnt;
            break;
        }
        for (int i = 0; i < 4; i++) {
            int next = pos + d[i];
            if (map[next]) Q.push(make_pair(next, cnt+1));
        }
    }
    cout << (dist == 0 ? -1 : count - dist) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d , min_bus, min_train;

    cin >> a >> b >> c >> d;

    min_train = min(a,b); min_bus = min(c,d);

    cout << min_train + min_bus << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    set<string> st;
    string s;
    char c = '1';
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> s;
        st.insert(s);
        if (i != 0 && (s[0] != c || st.size() != i + 1)) {
            flag = false;
        }
        c = s[s.length()-1];
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		if(X < 0) X *= -1;
		
		long k1 = X / D;
		if(k1 >= K){
			Console.WriteLine(X - K * D);
			return;
		}
		
		long k2 = k1 + 1;
		long v1 = X - k1 * D;
		long v2 = Math.Abs(X - k2 * D);
		
		long rest = K - k1;
		Console.WriteLine(rest % 2 == 0 ? v1 : v2);
		
		
	}
	long X,K,D;
	public Sol(){
		var d = rla();
		X = d[0]; K = d[1]; D = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define all(a) a.begin(), a.end()
// #define int long long
#define ll long long
#define vi vector<int>
#define mod 998244353
#define mod1 1000000007
#define endl "\n"
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)
#define testcase  int t; cin>>t; while(t--) 
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

using namespace std;

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

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


   
 /*************************************************************************/

vi ar[100010];
int vis[100010],dist[10001];
/*
vi a;
int n,m;
*/
int solve()
{
    
    return 0;
}

int cc;
/*
void dfs(int node )
{
	vis[node]=1;
	cc++;
	for(int child : ar[node])
	{
		if(vis[child]==0)
		{
			dfs(child);			
		}		
	}
}
*/

int32_t main()
{
	FIO
    // testcase
	{
        string s1,s2,ans="";
        cin>>s1>>s2;
        int n=s1.length(),m=s2.length();
        vector<vector<int>>dp(n+1,vector<int>(m+1));
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                if(i==0 || j==0)
                    dp[i][j] = 0;
                else if(s1[i-1]==s2[j-1])
                    	dp[i][j] = dp[i-1][j-1] + 1;
                else 
                    dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
        
        // int ind = dp[n][m]+1;
        /*
        cout<<dp[n][m]<<endl;
        loop(i,0,n+1)
        {
        	loop(j,0,m+1)
        		cout<<dp[i][j]<<" ";
        	cout<<endl;
        }
        */
        int i=n ,j=m ;
        while(i>0 && j>0)
        {
        	if(s1[i-1] == s2[j-1])
        	{
        		ans += s2[j-1];
        		// cout<<i<<" "<<j<<endl;
        		i--;j--; 
        	}
        	else if(dp[i-1][j] >= dp[i][j-1])
    			i--;
        	else
        		j--;
        			
        }
    	reverse(ans.begin(),ans.end());
        cout<<ans<<endl;
    }
    return 0;
}




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

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

signed main(){
  int n, m;
  int field[51][51];
  int a, b;
  m0(field);
  
  cin >> n >> m;

  rep(i, m){
    cin >> a >> b;
    field[a][b]++;
    field[b][a]++;
  }

  REP(i, 1, n+1){
    int sum = 0;
    rep(j, n+1) sum += field[i][j];
    cout << sum << endl;
  }

}


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

using namespace std;

int main()
{
    int n, k, x[110] = {};
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> x[i];

    sort(x, x + n);

    int ans = 0;
    for (int i=0; i<n; i++) {
        ans += 2 * min(x[i], abs(k - x[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,m = $stdin.gets.split.map(&:to_i)
ary = [0]*(n+2)
result = [0]
m.times do |i|
  l,r = $stdin.gets.split.map(&:to_i)
  ary[l]+=1
  ary[r+1]-=1
end
(1..n+1).each do |i|
  result[i] = result[i-1]+ary[i]
end
puts result.count(m)

Measured memory_bytes: 3524
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin>>n;
    int v[n],c[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    int payoff[n];
    for(int i=0;i<n;i++){
        payoff[i]=v[i]-c[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(payoff[i]>0)sum+=payoff[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int fac[100100], fac_inv[100100];
const int mod = 1000000007;

int pow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)res *= a;
        a *= a;
        res %= mod;
        a %= mod;
        b /= 2;
    }
    return res;
}

int inv(int x) {
    return pow(x, mod - 2);
}

void calc() {
    fac[0] = 1;
    fac_inv[0] = 1;
    for (int i = 1; i < 100100; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        fac_inv[i] = inv(fac[i]);
    }
}

int C(int n, int r) {
    return fac[n] * fac_inv[r] % mod * fac_inv[n - r] % mod;
}

int H(int n, int r) {
    return C(n + r - 1, r);
}

int suminv[100100];
int A[100100];

signed main() {
    calc();
    int N;
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    for (int len = 1; len <= N; ++len) {
        suminv[len] = suminv[len - 1] + inv(len);
        suminv[len] %= mod;
    }
    int ans = 0;
    rep(j, N) {
        int p = suminv[j + 1] + suminv[N - j] - 1;
        p %= mod;
        ans += A[j] * p;
        ans %= mod;
    }
    ans *= fac[N];
    ans %= mod;
    if (ans < 0)return 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int i;

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

	int N,A,B;
	string S;
	cin >> N >> A >> B >> S;

	vector<int>v(N);
	int x=0,y=0;
	for(i=0;i<N;i++){
		if(S[i]=='a'){
			if(A+B>x+y){
				v[i]=1;
				x++;
			}else{
				v[i]=0;
			}
		}
		else if(S[i]=='b'){
			if(A+B>x+y && B>y){
				v[i]=1;
				y++;
			}else{
				v[i]=0;
			}
		}
		else{
			v[i]=0;
		}
	}

	for(i=0;i<N;i++){
		if(v[i]==1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	
	if (A >= K) {
		ans = K;
	}
	else {
		K -= A;
		if (B >= K) {
			ans = A;
		}
		else{
			K -= B;
			ans = A - K;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        double[] p = new double[n];
        int count = 0;
        for(String s : in.nextLine().trim().split("\\s")){            
            p[count++] = Double.parseDouble(s);
        }
        in.close();
        
        double[][] dp = new double[n+1][n+1];
        dp[0][0] = 1;
        // System.out.println(dp[1][1]);
        for(int i = 1; i <= n; i++){
            dp[i][0] = dp[i-1][0] * (1-p[i-1]);
            for(int j = 1; j <= i; j++){
                dp[i][j] += dp[i-1][j-1] * p[i-1];
                dp[i][j] += dp[i-1][j] *(1-p[i-1]);
                // System.out.println(dp[i][j]);
            }
        }
        double res = 0;
        for(int i = (n/2)+1; i <= n; i++){
            res += dp[n][i];
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 131892
import sys
I=sys.stdin.readlines()
N,Q=map(int,I[0].split())
S=I[1][:-1]
query=[]
for i in range(Q):
  query.append(list(I[i+2].split()))
  if query[i][1]=='L':
    query[i][1]=-1
  else:
    query[i][1]=1
L,R,M,X=0,N+1,0,0
while R>L:
  M=(L+R+1)//2
  if M==0:
    R=M
    break
  if M==N+1:
    L=M
    break
  X=M-1
  for i in range(Q):
    if query[i][0]==S[X]:
      X+=query[i][1]
    if X==-1 or X==N:
      break
  if X==-1:
    L=M
  else:
    R=min(M,R-1)
P=[1]*(N+2)
for i in range(R+1):
  P[i]=0
L,R=0,N+1
while R>L:
  M=(L+R)//2
  if M==0:
    R=M
    break
  if M==N+1:
    L=M
    break
  X=M-1
  for i in range(Q):
    if query[i][0]==S[X]:
      X+=query[i][1]
    if X==-1 or X==N:
      break
  if X==N:
    R=M
  else:
    L=max(L+1,M)
for i in range(R,N+2):
  P[i]=0
print(sum(P))

Measured memory_bytes: 129804
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<bool> red(N);
	vector<int> num(N, 1);
	red[0] = true;
	for (auto i = 0; i < M; ++i)
	{
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		if (red[x])
		{
			red[y] = true;
		}
		++num[y];
		--num[x];
		if (num[x] <= 0)
		{
			red[x] = false;
		}
	}

	auto result = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (red[i])
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 640
n = int(input())
lengths = [int(i) for i in input().split()]

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if lengths[i] < lengths[j] + lengths[k]: 
                if lengths[j] < lengths[k] + lengths[i]: 
                    if lengths[k] < lengths[i] + lengths[j]:
                        if lengths[i] != lengths[j]:
                            if lengths[j] != lengths[k]:
                                if lengths[k] != lengths[i]:
                                    ans += 1
                
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e4+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n;
vector<int> v[maxN];
int c[maxN];
int ans[maxN];
int fa[maxN];
int tot = 0;
void dfs(int x)
{
	ans[x] = c[++tot];
	for(auto y:v[x])
	{
		if(fa[x] == y) continue;
		fa[y] = x;
		dfs(y);
	}
}
int main()
{
	scanf("%d",&n);
	
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int sum = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		sum += c[i];
	}
	sort(c+1,c+1+n);
	sum -= c[n];
	reverse(c+1,c+1+n);
	dfs(1);
	cout<<sum<<endl;
	for(int i=1;i<n;i++)
	{
		printf("%d ",ans[i]);
	}
	printf("%d\n",ans[n]);
	return 0;
}


Measured memory_bytes: 1408
x=int(input())

coin_1=0
coin_5=0
coin_500=0

def registar(nyukin,coin):
    oturi=nyukin-coin*int(nyukin/coin)
    return oturi,int(nyukin/coin)

x,coin_500=registar(x,500)
#print(coin_500)
x,coin_5=registar(x,5)
x,coin_1=registar(x,1)

#print(coin_500,coin_5,coin_1)
uresisa=coin_500*1000+coin_5*5
print(uresisa)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int t = 'A'-'a';
int main(){
	int n,k;
	cin >>n>>k;
	string s;
	cin >> s;
	s[k-1]-=t;
	cout <<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;

int main()
{	
	ll r,x,d;
	cin>>r>>d>>x;
	ll cnt=10;
	while(cnt>0)
	{
		cnt--;
		x=(r*x)-d;
		cout<<x<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n;
	float x1,x2,x3,x4;
	float y1,y2,y3,y4;
	float a1,a2;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		a1 = (y2-y1)/(x2-x1);
		a2 = (y4-y3)/(x4-x3);
		if(a1==a2)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c; cin >> c;
	if ('A' <= c && c <= 'Z') cout << 'A' << '\n';
	else cout << 'a' << '\n';
	return 0;
}

Measured memory_bytes: 3612
a = int(input())
card = list(map(int, input().split()))
card.sort(reverse=True)
Alice_card = []
Bob_card = []
for i in range(a):
    if i % 2 == 0:
        Alice_card.append(card[i])
    else:
        Bob_card.append(card[i])

Alice_point = sum(Alice_card)
Bob_point = sum(Bob_card)
Point = Alice_point - Bob_point
print(Point)


Measured memory_bytes: 3060
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


a,b = m()

kkk = gcd(a,b)

kkk = prime_decomposition(kkk)

kkk = set(kkk)

print(len(kkk)+1)



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

ll ans=0;
void dfs(ll cur,vector<vector<ll>> &adj,vector<ll> &vis){
  vis[cur]=1;
  for(auto v:adj[cur])
    if(!vis[v])
      dfs(v,adj,vis);
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<vector<ll>> adj(n+1);
  for(ll i=1;i<=m;i++){
     ll t1,t2,t3;
     cin>>t1>>t2>>t3;
     adj[t1].push_back(t2);
     adj[t2].push_back(t1);
  }
  vector<ll> vis(n+1);
  for(ll i=1;i<=n;i++)
    if(!vis[i]){
      ans++;
      dfs(i,adj,vis);
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 13988
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int N,M,Q;
	cin>>N>>M>>Q;
	
	vector<vector<int>> V(M+Q,vector<int>(4));
	
	for(int i=0;i<M;i++){
		int l,r;
		cin>>l>>r;
		V[i][0]=r;
		V[i][1]=0;
		V[i][2]=l;
		V[i][3]=0;
	}
	
	for(int i=M;i<M+Q;i++){
		int l,r;
		cin>>l>>r;
		V[i][0]=r;
		V[i][1]=1;
		V[i][2]=l;
		V[i][3]=i-M;
	}
	
	vector<int> ans(Q);
	
	sort(V.begin(),V.end());
	vector<int> cnt(N+1,0);
	
	for(int i=0;i<M+Q;i++){
		if(V[i][1]==0){
			cnt[V[i][2]]++;
			continue;
		}
		int a = 0;
		for(int j=V[i][2];j<=N;j++){
			a += cnt[j];
		}
		ans[V[i][3]]=a;
	}
	
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double hour, minute;
    double pi =3.141592653589793;
    hour = 2 * pi * (h/12 +(m/60/12));
    minute = 2 * pi * (m/60);
    double ans;
    ans = a*a + b*b - 2*a*b*cos(hour - minute);
    ans = sqrt(ans);
    printf("%.12f", ans);
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
string S;
cin>> S;
if(S[5]=='1'){
    cout <<"TBD";
    return 0;
}
S=S[6];
int k=stoi(S);
for(int i=1;i<5;i++){
    if(k==i){
        cout <<"Heisei";
        return 0;
    }
}
cout <<"TBD";
return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

ans = 0

if A_list[0] > B_list[0]:
  ans += B_list[0] 
  A_list[0] -= B_list[0]
  B_list[0] = 0

if A_list[N] > B_list[N-1]:
  ans += B_list[N-1] 
  A_list[N] -= B_list[N-1] 
  B_list[N-1] = 0
  
for i in range(1, N):    
  if A_list[i] > B_list[i-1] + B_list[i]:
    ans += B_list[i-1] + B_list[i]
    A_list[i] -= B_list[i-1] + B_list[i]
    B_list[i-1] = 0
    B_list[i] = 0

#####    
if A_list[0] > B_list[0]:
  ans += B_list[0]
  B_list[0] = 0
else:
  ans += A_list[0]
  B_list[0] -= A_list[0]
  

for i in range(1, N):
  if A_list[i] > B_list[i-1] + B_list[i]:
    ans += B_list[i-1] + B_list[i]
    B_list[i-1] = 0
    B_list[i] = 0
  else:
    ans +=  A_list[i]
    if A_list[i] > B_list[i-1]:
      B_list[i] = B_list[i]  - (A_list[i] - B_list[i-1])

if A_list[N] > B_list[N-1]:
  ans += B_list[N-1]
else:
  ans += A_list[N]

print(ans)

Measured memory_bytes: 18752
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
      
N, M = map( int, input().split() )
uf = UnionFind( N )
for i in range( M ):
  a, b, z = map( int, input().split() )
  uf.union( a - 1, b - 1 )
print( uf.group_count() )

Measured memory_bytes: 7856
// atcoder/cf16-final/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    p.resize(n, -1);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[a] += p[b];
      p[b] = a;
    } else {
      p[b] += p[a];
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (p[a] < 0) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return -p[find(n)];
  }
private:
  vector<int> r, p;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    UnionFind uf(n+m);
    for (int i = 0; i < n; ++i) {
      int k;
      cin >> k;
      vec<int> v(k);
      cin >> v;
      each (j, v) uf.unite(i, n + j - 1);
    }
    for (int i = 0; i < n+m; ++i) {
      uf.find(i);
    }

    bool f = true;
    for (int i = 0; i < n; ++i) {
      f = f && uf.same(0, i);
    }
    cout << (f ? "YES" : "NO") << endl;
  }

  return 0;
}


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

int main(){
  int N, K; cin >> N >> K;
  int ans = 0;
  while(N != 0) {
    N /= K;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
N = int(input())
A = intlist(input().split())
M = 1

A.sort()
if A[0] == 0:
    M = 0
else:
    for i in range(N):
        M = M * A[i]
        if M > 10**18:
            M = -1
            break
print(M)

Measured memory_bytes: 84840
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		sc.close();

		System.out.println(a1 + a2 + a3 >= 22 ? "bust" : "win");
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <unordered_set>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<string> s;
  for (int i = 0; i < N; ++i) {
    string tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 17644
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()

s = 0
for i in range(n):
    s += 1/a[i]
print("{:.14f}".format(1/s))


Measured memory_bytes: 3060
list=[]
for i in input().split():
    if i=='+':
        list[len(list)-2]=int(list[len(list)-2])+int(list[len(list)-1])
        list.pop()
    elif i=='-':
        list[len(list)-2]=int(list[len(list)-2])-int(list[len(list)-1])
        list.pop()
    elif i=='*':
        list[len(list)-2]=int(list[len(list)-2])*int(list[len(list)-1])
        list.pop()
    else:
        list.append(i)
print(list[0])




Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long dp[5001][5001];
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    long long ans=0;
    dp[1][0]=1;
    int i,j;
    for(i=2 ; i<=n ; i++){
        int k=min(i-1,n-i+2);
        long long t=0;
        for(int l=0 ; l<k ; l++){
            t=0;
            for(j=l ; j<n ; j+=k){
                t+=dp[i-1][j];
                t%=m;
                dp[i][j]+=t;
                dp[i][j]%=m;
            }
        }
    }
    for(i=0 ; i<n ; i++)ans=(ans+dp[n][i]*(n-i))%m;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
#define l_ength size
#define ws meow
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int ss[2048][2048];
int ws[2048][2048];

int fss( int bx, int by, int ax, int ay ){
	return ss[bx][by]-ss[ax][by]-ss[bx][ay]+ss[ax][ay];
}
int fws( int bx, int by, int ax, int ay ){
	return ws[bx][by]-ws[ax][by]-ws[bx][ay]+ws[ax][ay];
}

int main(){
	int n, k; cin >> n >> k;
	int sanz = 0, wanz = 0;
	for( int i = 0; i < n; ++i ){
		int x, y; cin >> x >> y;
		char c; cin >> c;
		if( c == 'B' ){
			++ss[x%(2*k)+1][y%(2*k)+1];
			++sanz;
		} else {
			++ws[x%(2*k)+1][y%(2*k)+1];
			++wanz;
		}
	}
	for( int j = 0; j <= 2*k; ++j ){
		for( int i = 0; i < 2*k; ++i ){
			ss[i+1][j] = ss[i][j] + ss[i+1][j];
			ws[i+1][j] = ws[i][j] + ws[i+1][j];
		}
	}
	for( int j = 0; j <= 2*k; ++j ){
		for( int i = 0; i < 2*k; ++i ){
			ss[j][i+1] = ss[j][i] + ss[j][i+1];
			ws[j][i+1] = ws[j][i] + ws[j][i+1];
		}
	}
	int ans = 0;
	for( int i = 0; i < k; ++i ){
		for( int j = 0; j < k; ++j ){
			int sum = 0;
			int x1 = i, y1 = j, x2 = i+k, y2 = j+k;
			sum += fss(x2, y2, x1, y1) + fss(x1, y1, 0, 0) + fss(x2, 0, 2*k, y1) + fss(x1, 2*k, 0, y2) + fss(2*k, 2*k, x2, y2);
			sum += (wanz) - ( fws(x2, y2, x1, y1) + fws(x1, y1, 0, 0) + fws(x2, 0, 2*k, y1) + fws(x1, 2*k, 0, y2) + fws(2*k, 2*k, x2, y2) );
			ans = max(ans, sum);
		}
	}
	for( int i = 0; i < k; ++i ){
		for( int j = 0; j < k; ++j ){
			int sum = 0;
			int x1 = i, y1 = j, x2 = i+k, y2 = j+k;
			sum += fws(x2, y2, x1, y1) + fws(x1, y1, 0, 0) + fws(x2, 0, 2*k, y1) + fws(x1, 2*k, 0, y2) + fws(2*k, 2*k, x2, y2);
			sum += (sanz) - ( fss(x2, y2, x1, y1) + fss(x1, y1, 0, 0) + fss(x2, 0, 2*k, y1) + fss(x1, 2*k, 0, y2) + fss(2*k, 2*k, x2, y2) );
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 33152
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; ++i) {
            int number = scanner.nextInt();
            if (number % 2 == 0 && ((number % 5 != 0) && (number % 3 != 0))) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 23764
import Control.Monad

main :: IO ()
main = do
  [l,a,b,c,d] <- replicateM 5 readLn
  print $ l - (max (a ` div` c + (min 1 (a `mod` c) )) (b ` div` d + (min 1 (b `mod` d) )))
  
  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define BE(c) c.begin(),c.end()
#define PB push_back
#define F first
#define S second
#define BEB(s) s
using namespace std;
int main(){
	double x,h;
	while(1){
		cin>>x>>h;
		if(!x&&!h)break;
		printf("%.6f\n",sqrt((x/2)*(x/2)+h*h)*x*2+x*x);
		
	}
	return 0;
}

Measured memory_bytes: 1236
n = gets.chomp.to_i

require 'prime'

class Integer
  def my_divisor_list
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

ans = []
n.my_divisor_list.each do |i|
  s, a = n.divmod(i)
  if a == 0
    ans.push(s-1 + i-1)
  end
end
p ans.min

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

    ll sum = 0;
    rep(i,n-1){
        int j = i+1;
        if(a[j] < a[j-1]){
            ll diff = a[j-1] - a[j];
            sum += diff;
            a[j] += diff;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4784
N, M = map(int, input().split())
A = set()

dp = []
for i in range(N + 1):
    dp.append(None)

for _ in range(M):
    a = int(input())
    A.add(a)

dp.append(0)
dp[N] = 1

for i in range(N - 1, -1, -1):
    if i in A:
        dp[i] = 0
        continue
    dp[i] = dp[i + 1] + dp[i + 2]

# print('dp', dp)
print(dp[0] % 1000000007)


Measured memory_bytes: 460056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> a(N+1);
    vector<int> d(N+1, -1);
    d[1] = 0;
    rep1(i,N) cin >> a[i];
    int t = 1;
    bool il = false;
    while (K > 0) {
        --K;
        int n = a[t];
        if (d[n] == -1 || il) {
            d[n] = d[t] + 1;
        } else {
            int len = d[t] - d[n] + 1;
            K %= len;
            il = true;
        }
        t = n;
    }
    cout << t << endl;
}

Measured memory_bytes: 4852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		Arrays.sort(ia);
		int d = ia[2] - ia[0];
		int e = ia[2] - ia[1];
		int ans = 0;
		ans += d / 2;
		d %= 2;
		ans += e / 2;
		e %= 2;
		if (d > 0 && e > 0) {
			ans++;
			d--;
			e--;
		}
		if (d > 0 || e > 0) {
			ans += 2;
		}
		pln(ans);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21332
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] input = new int[n][3];
		for (int i = 0; i < n; i++) {
			input[i][0] = sc.nextInt();
			input[i][1] = sc.nextInt();
			input[i][2] = sc.nextInt();
		}
		Arrays.sort(input, new Comparator<int[]>() {
		public int compare(int[] a, int[] b) {
			return b[2] - a[2];
		}
		});
		boolean flag = true;
		int[][] py = new int[101][101];
		for (int k = 0; k < n; k++) {
			if (flag) {
				for (int i = 0; i <= 100; i++) {
					for (int j = 0; j <= 100; j++) {
						py[i][j] = abs(input[k][0], i) + abs(input[k][1], j) + input[k][2];
					}
				}
				flag = false;
			} else {
				for (int i = 0; i <= 100; i++) {
					for (int j = 0; j <= 100; j++) {
						if (input[k][2] == 0) {
							if (py[i][j] > abs(input[k][0], i) + abs(input[k][1], j) + input[k][2]) {
								py[i][j] = 0;
							}
						} else {
							if (py[i][j] != abs(input[k][0], i) + abs(input[k][1], j) + input[k][2]) {
								py[i][j] = 0;
							}
						}
					}
				}
			}
		}
		
		int max = 0;
		int maxX = 0;
		int maxY = 0;
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++){
				if (py[i][j] >= max) {
					max = py[i][j];
					maxX = i;
					maxY = j;
				}
			}
		}
		System.out.println(maxX + " " + maxY + " " + max);
	}
	
	public static int abs(int a, int b) {
		if (a > b) {
			return a - b;
		} else {
			return b - a;
		}
	}
}

Measured memory_bytes: 22856