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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int n, m, q;
unsigned long long ans;
int A[100];
struct xcj{
    int a, b, c, d;
}s[100];
void dfs(int x, int step){
    if (x > m || step > n) return;
    dfs(x+1, step);
    step++;
    A[step] = x;
    if (step == n){
        unsigned long long _ans = 0;
        for (int i = 1; i <= q; i++){
            if (A[s[i].b] - A[s[i].a] == s[i].c){
                _ans += s[i].d;
            }
        }
        ans = max(_ans, ans);
    }
    dfs(x, step);
    dfs(x+1, step);
}
int main(){
    n = read(), m = read(), q = read();
    for (int i = 1; i <= q; i++){
        s[i].a = read(), s[i].b = read(), s[i].c = read(), s[i].d = read();
    }
    dfs(1, 0);
    cout << ans << endl;
    return 0;
}
//g++ C.cpp -o C.exe -lm -Wall

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

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

    sort(x, x + m);

    if(n >= m){
        cout << 0 << endl;
    }else{
        long long ans = 0;
        long long kyo[m - 1];
        for(int i = 0; i < m - 1; i++){
            kyo[i] = x[i + 1] - x[i];
            ans += kyo[i];
        }
        
        sort(kyo, kyo + m - 1, greater<long long>());

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

        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  cout<<fixed<<setprecision(20);
  double l;
  cin>>l;
  double a=l/3.0,b=l/3.0;
  double ans=a*b*(l-a-b);

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline

def main():
    A, B, M = map(int, readline().split())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    ans = min(a) + min(b)
    for _ in range(M):
        x, y, c = map(int, readline().split())
        ans = min(ans, a[x-1] + b[y-1] - c)
    print(ans)


if __name__ == "__main__":
    main()


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

int N,D,ans=0;
vector<int> cnt(13,0);

void dfs(vector<int> v,int now){
    if (now==13){
        sort(v.begin(),v.end());
        int Min=50,n=v.size();
        for (int i=0;i<n;++i){
            int x=abs(v[(i+1)%n]-v[i]);
            Min=min(Min,min(x,24-x));
        }
        ans=max(ans,Min);
        return;
    }
    if (cnt[now]==1){
        vector<int> u=v;
        u.emplace_back(now);
        dfs(u,now+1);
        u.back()*=-1; u.back()+=24;
        dfs(u,now+1);
    } else if (cnt[now]==2){
        vector<int> u=v;
        u.emplace_back(now);
        u.emplace_back(24-now);
        dfs(u,now+1);
    } else dfs(v,now+1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (;N--;) cin >> D,++cnt[D];
    if (cnt[0]){cout << 0 << '\n'; return 0;}
    for (int i=1;i<13;++i)
        if (2<cnt[i]){cout << 0 << '\n'; return 0;}
    vector<int> init={0};
    dfs(init,1);
    cout << ans << '\n';
}

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

int main(){
    vector<int>a(3);
    cin>>a[0]>>a[1]>>a[2];
    int k;
    cin>>k;
    sort(a.begin(),a.end());
    rep(i,k)a[2]*=2;
    cout<<a[0]+a[1]+a[2]<<endl;

}

Measured memory_bytes: 256
n, k = (int(i) for i in input().split())  

if k%2 == 1:
  #a,b,cは全てkの倍数
  #n以下のkの倍数の個数
  s = n // k
  print(s ** 3)
  
else:
  #a,b,cは全てkの倍数 or kで割ってk/2余る数
  #n以下のkの倍数の個数
  s = n // k
  #kで割ってk/2余る数 = k/2の倍数の個数　-  s
  l = n // (k // 2) - s
  ans = s ** 3 + l **3
  print(ans)

Measured memory_bytes: 2940
function main() {
	input = input[0].split(' ');
	a = parseInt(input[0]);
	b = parseInt(input[1]);

	msg = '';
	if(a < b) {
		msg = 'a < b';
	} else if(a > b){
		msg = 'a > b';
	} else if(a == b) {
		msg = 'a == b';
	}

	console.log(msg);
}

var input = "";

process.stdin.resume();
process.stdin.setEncoding("utf-8");
process.stdin.on("data", function(chunk) {
	input += chunk;
});

process.stdin.on("end", function() {
	input = input.split("\n");
	main();
})

Measured memory_bytes: 15604
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    D,G = LI()
    pc = [LI() for _ in range(D)]
    m = [i for i in range(D)]
    ans = INF
    for p in itertools.permutations(m):
        g = G
        cnt = 0
        for i in p:
            if g < pc[i][0] * (i+1) * 100:
                cnt += math.ceil(g/((i+1)*100))
                break
            else:
                cnt += pc[i][0]
                g -= pc[i][0] * (i+1) * 100 + pc[i][1]
            if g <= 0: break
        ans = min(ans,cnt)

    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char> > s(h + 2, vector<char>(w + 2));
    //一回り大きく初期化
    for (int i = 0; i < h + 2; i++) {
        for (int j = 0; j < w + 2; j++) {
            s[i][j] = '.';
        }
    }
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            cin >> s[i][j];
        }
    }

    /*
    for (int i = 0; i < h + 2; i++) {
        for (int j = 0; j < w + 2; j++) {
            cout << s[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            if (s[i][j] == '#') {
                if (s[i + 1][j] == '#' || s[i][j + 1] == '#' || s[i][j - 1] == '#' || s[i - 1][j] == '#') {
                    continue;
                }
                else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	int tmp = 0, k = 0;
	while(n > tmp){
		k++;
		tmp += k;
	}
	n = tmp - n;

	int countDown = k;
	int close = k;
	string ans;
	rep(i,k){
		if(countDown <= n){
			n -= countDown;
			close--;
			ans += '(';
		}
		countDown--;
		ans += ')';
	}
	rep(i,close){
		ans += '(';
	}
	cout << ans << endl;
}



Measured memory_bytes: 3340
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<LL> place;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        if(i!= 0) place.push_back(place[i-1] + tmp);
        else place.push_back(tmp);
    }
    for(int i=0; i<N; i++){
        place.push_back(place[N-1] + place[i]);
    }

    LL ans = 0;
    for(int i=0; i<N; i++){
        LL riso = place[i] + place[N-1]/3;
        auto itr1b = lower_bound(place.begin(), place.end(), riso);
        auto itr1a = itr1b; itr1a--;

        riso = place[i] + place[N-1]*2/3;
        auto itr2b = lower_bound(place.begin(), place.end(), riso);
        auto itr2a = itr2b; itr2a--;

        ans = max(ans, min(min(*itr2a-*itr1a,*itr1a-place[i]),place[i]-*itr2a+place[N-1]));
        ans = max(ans, min(min(*itr2a-*itr1b,*itr1b-place[i]),place[i]-*itr2a+place[N-1]));
        ans = max(ans, min(min(*itr2b-*itr1a,*itr1a-place[i]),place[i]-*itr2b+place[N-1]));
        ans = max(ans, min(min(*itr2b-*itr1b,*itr1b-place[i]),place[i]-*itr2b+place[N-1]));
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4980
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int d, t, s; s3(d, t, s);
    int takes = d/s + (d%s?1:0);
    if(takes <= t){
        p("Yes");
    }else{
        p("No");
    }
}

class ADontBeLate {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    ADontBeLate solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3648
from fractions import gcd
A, B, C, D = map(int, input().split())
if(A % C == 0):
    c_div = (B // C) - (A // C) + 1
else:
    c_div = (B // C) - (A // C + 1) + 1
if(A % D == 0):
    d_div = (B // D) - (A // D) + 1
else:
    d_div = (B // D) - (A // D + 1) + 1
cd_lcm = (C * D) // gcd(C, D)
if(A % cd_lcm == 0):
    cd_div = (B // cd_lcm) - (A // cd_lcm) + 1
else:
    cd_div = (B // cd_lcm) - (A // cd_lcm + 1) + 1
print((B - A) - (c_div + d_div - cd_div) + 1)

Measured memory_bytes: 5344
use proconio::input;

macro_rules! chmin {
    ($min_v: expr, $v: expr) => {
        if $v < $min_v {
            $min_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        x: i64,
        n: usize,
        p: [i64; n],
    };
    let mut min_a_i = x;
    let mut ans = 0;
    for i in 0..=101 {
        if p.contains(&i) {
            continue;
        }
        let a_i = (x - i as i64).abs();
        if chmin!(min_a_i, a_i) {
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(void) {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        int count2 = 0, count5 = 0;
        for (int i = 1; i <= n; i++) {
            int temp = i;
            while (temp % 2 == 0) {
                count2++;
                temp /= 2;
            }
            while (temp % 5 == 0) {
                count5++;
                temp /= 5;
            }
        }
        cout << min(count2, count5) << endl;
    }
}

Measured memory_bytes: 1160
program main
      implicit none
      character(200000) :: t
      integer :: i, tlen

      read *, t
      tlen = len_trim(t)

      do i = 1, tlen
        if (t(i:i) == "?") then
            t(i:i) = "D"
        end if
      end do

      print '(a)', t(1:tlen)

end program main


Measured memory_bytes: 3260
#include <stdio.h>
#include <string.h>
int main(void){
    int j,o,n,i,s_y=0,s_c=0,b;char you[101],cpu[101];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",you,cpu);
        if (strcmp(you,cpu)==0){s_y++,s_c++;continue;}
        for(j=0;you[j]||cpu[j];j++){
            if (you[j] > cpu[j]){s_y+=3;break;}
            else if (you[j] < cpu[j]){s_c+=3;break;}        
            else if (you[j] && !cpu[j]){s_y+=3;break;}
            else if (!you[j] && !cpu[j]){s_c+=3;break;}
        }
    }
    printf("%d %d\n",s_y,s_c); 
    return 0;
} 



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

int n, cnt, a, x;
bool vis[10];

void update(int x){
	if(x<400){
		vis[0] = 1;
	} else if(x < 800){
		vis[1] = 1;
	} else if(x < 1200){
		vis[2] = 1;
	} else if(x < 1600){
		vis[3] = 1;
	} else if(x < 2000){
		vis[4] = 1;
	} else if(x < 2400){
		vis[5] = 1;
	} else if(x < 2800){
		vis[6] = 1;
	} else if(x < 3200){
		vis[7] = 1;
	} else {
		a++;
	}
}

int main(){
	memset(vis, 0, sizeof(vis));
	scanf("%d", &n);
	cnt = 0;
	a = 0;
	for(int i=1; i<=n; i++){
		scanf("%d", &x);
		update(x);
	}
	for(int i=0; i<8; i++){
		cnt += vis[i];
	}
    printf("%d %d\n", max(1, cnt), cnt+a);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 12, M = 1e3 + 5;
int dp[M][(1 << N)], a[M], c[M], n, m;

int solve(int idx, int mask){
	if(idx == m){
		if(mask != (1 << n) - 1)
			return 1e8 + 5;
		else
			return 0;
	}
	int &ans = dp[idx][mask];
	if(~ans)
		return ans;
	return ans = min(solve(idx + 1, mask), solve(idx + 1, mask | c[idx]) + a[idx]);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int b;
		cin >> a[i] >> b;
		for(int j = 0; j < b; j++){
			int cc;
			cin >> cc;
			cc--;
			c[i] |= (1 << cc);
		}
	}
	memset(dp, -1, sizeof dp);
	int ans = solve(0, 0);
	if(ans > 1e8)
		ans = -1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 19800
#include<iostream>
#include<vector>

using namespace std;
using ll=long long;
int solve(){
    int n;cin>>n;
    vector<int> h(n);
    for(auto & a:h)cin>>a;
    int ret = h[0];
    for(int i=1;i<n;++i){
        ret += max(0,h[i]-h[i-1]);
    }
    return ret;
}
int main(){
    cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	double l;
	cin >> l;
	double x, y, z;
	x = y = z = l/3;
	printf("%.10f\n", x*y*z);
	return 0;
}

Measured memory_bytes: 256
// きさま！ 見ているなッ！

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;

	return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<string> S(N);
    for ( int64_t i = 0; i < N; ++i){
        string T;
        cin >> T;
        sort(T.begin(),T.end());
        S.at(i) = T;
    }
    
    sort(S.begin(),S.end());
    
    int64_t ans = 0;
    int64_t counter = 1;
    for ( int64_t i = 0; i < N-1; ++i){
        //cout << counter << ans << endl;
        if ( S.at(i) == S.at(i+1) ){
            counter += 1;
        } else {
            ans = ans + counter * ( counter - 1 )/2;
            counter = 1;
        }
    }
    ans = ans + counter * ( counter - 1 )/2;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5760
//ring.cpp
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s,p;
    int n1,n2,i,j,count,flag;
    flag=0;
    cin>>s;
    cin>>p;
    n1=(int)(s.length());
    n2=(int)(p.length());
    for ( i = 0; i < n1; i++)
    {
        count=0;
        for ( j = 0; j < n2; j++)
        {
            if (s[(i+j)%n1]==p[j]) count++;
        }
        if (count==n2)
        {
            flag=1;
            break;
        }
    }
    if (flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
	int n, m;
	while(cin >> n){
		string s, s1;
		cin >> s;
		int x = n / 2;
		bool f = true;
		for(int i = 0; i < x; i++){
			if(s[i] != s[i+x]){
				f = false;
				break;
			}
		}
		if(f && n % 2 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long money=100000;
  for(int i=0;i<n;i++){
    money=(1.05*money);
    if(money%1000!=0){
    money=money/1000;
    money++;
    money=money*1000;
  }
  }
 
  cout<<money<<endl;
  return 0;
}

Measured memory_bytes: 2996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int n = s.length();

            HashMap<Integer, Integer> dp = new HashMap<>();
            dp.put(0, 0);
            int code = 0;
            int mask = (1 << 26) - 1;
            int last = 0;
            for (char _c : s.toCharArray()) {
                int c = _c - 'a';
                code ^= 1 << c;

                int cdp = Integer.MAX_VALUE;
                if (dp.containsKey(code)) {
                    cdp = dp.get(code) + 1;
                }
                for (int i = 0; i < 26; ++i) {
                    int nCode = code ^ (1 << i);
                    if (dp.containsKey(nCode)) {
                        cdp = Math.min(cdp, dp.get(nCode) + 1);
                    }
                }
                if (!dp.containsKey(code) || cdp < dp.get(code)) {
                    dp.put(code, cdp);
                }
                last = cdp;
            }
            out.println(last);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 96704
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var hwk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hwk[0];
        var w = hwk[1];
        var k = hwk[2];
        var c = Enumerable.Repeat(0, h).Select(_ => Console.ReadLine()).ToArray();
        int res = 0;
        for (int i = 0; i < (1 << h); i++)
        {
            for (int j = 0; j < (1 << w); j++)
            {
                var newc = c.Select(x => x.ToArray()).ToArray();
                for (int y = 0; y < h; y++)
                {
                    if ((i >> y & 1) == 1)
                    {
                        for (int x = 0; x < w; x++)
                        {
                            newc[y][x] = '.';
                        }
                    }
                }
                for (int x = 0; x < w; x++)
                {
                    if ((j >> x & 1) == 1)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            newc[y][x] = '.';
                        }
                    }
                }
                if (newc.Sum(x => x.Count(y => y == '#')) == k)
                {
                    res++;
                }
            }
        }
        Console.WriteLine(res);
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


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

    vector<int> num_even(pow(10, 5) + 1);
    vector<int> num_odd(pow(10, 5) + 1);

    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (i % 2 == 0) {
            num_even[tmp] += 1;
        } else {
            num_odd[tmp] += 1;
        }
    }

    vector<int>::iterator max_even_it = max_element(num_even.begin(), num_even.end());
    vector<int>::iterator max_odd_it  = max_element(num_odd.begin(),  num_odd.end());

    int maxind_even = distance(num_even.begin(), max_even_it);
    int maxind_odd  = distance(num_odd.begin(), max_odd_it);

    int maxnum_even = *max_even_it;
    int maxnum_odd  = *max_odd_it;

    int ans = 0;
    if (maxind_even != maxind_odd) {
        cout << n - (maxnum_even + maxnum_odd) << endl;
    } else {

        num_even[maxind_even] = 0;
        num_odd[maxind_odd]   = 0;

        vector<int>::iterator max2_even_it = max_element(num_even.begin(), num_even.end());
        vector<int>::iterator max2_odd_it  = max_element(num_odd.begin(),  num_odd.end());

        int maxind2_even = distance(num_even.begin(), max2_even_it);
        int maxind2_odd  = distance(num_odd.begin(), max2_odd_it);

        int maxnum2_even = *max2_even_it;
        int maxnum2_odd  = *max2_odd_it;

        cout << min(n - (maxnum_even + maxnum2_odd), n - (maxnum2_even + maxnum_odd)) << endl;
    }

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string n,m;
    cin >> n >> m;
    int a,b;
    cin >> a >> b;
    string l;
    cin >> l;
    if(l == n){
        a--;
    }else{
        b--;
    }
    cout << a << endl;
    cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a[3][3];
    for (int i=0; i<3; i++)
        for (int j=0; j<3; j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        int b;
        cin >> b;
        for (int j=0; j<3; j++) {
            for (int k=0; k<3; k++) {
                if (b == a[j][k]) a[j][k] = -1;
            }
        }
    }

    bool ans = false;
    for (int i=0; i<3; i++) {
        bool f = true;
        for (int j=0; j<3; j++) {
            if (a[i][j] >= 0) f = false;
        }
        if (f) ans = true;
    }

    for (int i=0; i<3; i++) {
        bool f = true;
        for (int j=0; j<3; j++) {
            if (a[j][i] >= 0) f = false;
        }
        if (f) ans = true;
    }

    if (a[0][0]<0 && a[1][1]<0 && a[2][2]<0) ans = true;
    if (a[0][2]<0 && a[1][1]<0 && a[2][0]<0) ans = true;


    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static boolean[] prime = new boolean[1300000];
	static int n;
	public static void main(String[] args) {
		make_prime();
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;
		return true;
	}
	
	static void solve(){
		if(prime[n]){
			System.out.println(0);
		}else{
			int up = 0, down = 0;
			for(int i = n; !prime[i]; i++){
				up++;
			}
			for(int i = n; !prime[i]; i--){
				down++;
			}
			System.out.println(up + down);
		}
	}

	
	static void make_prime(){
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for(int i = 2; i < prime.length; i++){
			if(prime[i]){
				for(int j = 2*i; j < prime.length; j += i){
					prime[j] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 14000
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  8 10:17:39 2018

@author: maezawa
"""

import math
from itertools import permutations

#フロイド・ワーシャル
def warshall_floyd(glath):
	
	for k in range(len(glath)):
		for i in range(len(glath)):
			for j in range(len(glath[i])):
				if glath[i][j] > glath[i][k] + glath[k][j]:
                                   glath[i][j] = glath[i][k] + glath[k][j]
                                   glath[j][i] = glath[i][k] + glath[k][j]				
	return glath

N, M ,R= [int(x) for x in str(input()).split()]  #グラフの大きさ 
r=[int(x) for x in str(input()).split()]
graph=[[float("inf")]*N for i in range(N)]


for i in range(M):
	a,b,c=[int(x) for x in str(input()).split()]
	#if a in r and b in r:
	graph[a-1][b-1]=c
	graph[b-1][a-1]=c

#all_cost=warshall_floyd(select_graph)
all_cost=warshall_floyd(graph)


max_count=float("inf")
for i in permutations(r):
        cost=0
        for j in range(len(i)-1):                
                cost+= all_cost[i[j]-1][i[j+1]-1]       
        max_count=min(max_count,cost)

print(max_count)    
  


Measured memory_bytes: 4660
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let mut s: Vec<u32> = Vec::new();
    for _ in 0..n {
        s.push(parse_line().unwrap());
    }
    let mut ans = s.iter().sum();

    if ans % 10 == 0 {
        s.sort();
        if let Some(i) = s.iter().position(|&x| x % 10 != 0) {
            ans -= s[i];
        } else {
            ans = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N;
LL x[50], y[50];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> x[i] >> y[i];

	map<pair<LL, LL>, int> mp;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(i == j) continue;
			mp[MP(x[i]-x[j], y[i]-y[j])]++;
		}
	}
	
	int ans = 0;
	for(auto itr=mp.begin(); itr!=mp.end(); itr++) ans = max(ans, itr->second);
	cout << N-ans << endl;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        int max = Math.min(a,b);
        int min = Math.max(0,a+b-n);
        System.out.print(Integer.toString(max)+" "+Integer.toString(min));
    }
}


Measured memory_bytes: 23764
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] a) throws IOException {
		Scanner scan = new Scanner(System.in);
		String out = "";
		List<Integer> box = new ArrayList<Integer>();
		 for(int i = 0;i < 5;i++){
			 int put = scan.nextInt();
			 box.add(put);
		 }
		 Collections.sort(box, Comparator.reverseOrder());
		for(int i = 0; i < 5;i++){
			int show = box.get(i);
			out = out + show + " ";
		}
		System.out.println(out.trim());
		
	}
}

Measured memory_bytes: 25956
s = input()
def serch(s):
  position_C = s.find("C")
  if position_C == -1:
    return False
  else:
    position_F = s.rfind("F")
    if position_F == -1:
      return False
    elif position_C < position_F:
      return True
    else:
      return False

if serch(s) == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 2) {
		cout << "3" << endl;
	}
	else if (a == 1 && b == 3) {
		cout << "2" << endl;
	}
	else if (a == 2 && b == 1) {
		cout << "3" << endl;
	}
	else if (a == 2 && b == 3) {
		cout << "1" << endl;
	}
	else if (a == 3 && b == 1) {
		cout << "2" << endl;
	}
	else cout << "1" << endl;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
	int N;
	int A[210];
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	int cnt=0;
	while (true){
		bool odd=false;
		for(int i=0;i<N;i++){
			if(A[i]%2!=0)odd=true;
		}
		if(odd)break;
		for(int i=0;i<N;i++){
			A[i]=A[i]/2;
		}
		cnt++;
	}
	
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;


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

	int n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n) cin >> a[i];

	sort(a.rbegin(), a.rend());
	ll ans = 0;

	rep(i, 0, n / 2) {
		ans += a[i];
	}
	rep(i, 0, (n + 1) / 2 - 1) ans += a[i + 1];

	cout << ans;
	return 0;
}

Measured memory_bytes: 4780
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h == 0 && w == 0)break;
			else calc(h, w);
			
		}
	}
	public void calc(int w, int h){
		String[][] donut = new String[w][h];
		for(int i = 0; i < w; i++){
			String line = sc.next();
			for(int j = 0; j < h; j++){
				donut[i][j] = line.substring(j, j+1);
			}
		}
		
		
		int x[] = {0, 1, 1, 1, 0,-1,-1,-1};
		int y[] = {1, 1, 0,-1,-1,-1, 0, 1};
		String max = "";
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				for(int k = 0; k < 8; k++){
					String s = donut[i][j];
					int nx = i + x[k];
					int ny = j + y[k];
					if(nx >= w) nx = 0;
					if(nx < 0) nx = w-1;
					if(ny >= h) ny = 0;
					if(ny < 0) ny = h-1;
					while(!(nx == i && ny == j)){
						s += donut[nx][ny];
						if(map.containsKey(s)){
							if(max.length() < s.length()) max = s;
							else if(max.length() == s.length() && s.compareTo(max) < 0) max = s;
						}
						else if(max.length() < s.length()) map.put(s, 1);
						else if(max.length() == s.length() && s.compareTo(max) < 0) map.put(s, 1);
						
						nx += x[k];
						ny += y[k];
						if(nx >= w) nx = 0;
						if(nx < 0) nx = w-1;
						if(ny >= h) ny = 0;
						if(ny < 0) ny = h-1;
					}	
				}
			}
			System.gc();
		}
		if(max.equals("")) System.out.println(0);
		else System.out.println(max);
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 95692
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<a/b<<endl;
  cout<<a%b<<endl;
  
  double c=a;
  double d=b;
  cout<<fixed<<setprecision(10)<<c/d<<endl;
  
  return 0;
}


Measured memory_bytes: 3264
#include<iostream>
#include<cmath>
#include<numeric>
#include<array>
#include<vector>
#include<sstream>
using namespace std;

#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()

template <typename T>
void putv(vector<T>& V){
	cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

int main(){
	int N,M,C;
	cin >> N >> M >> C;
	vector<int> B = getv<int>(M);
	vector<vector<int>> A;
	for(int i=0; i<N; ++i)
		A.emplace_back(getv<int>(M));

	int sum;
	int cntr = 0;
	rep(i,N){
		sum = 0;
		rep(j,M)
			sum += A[i][j] * B[j];
		sum += C;
		if(sum > 0)
			cntr++;
	}
	cout << cntr << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
s = input()
n = len(s)
mod = [0] * (n+1)

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % 2019
        x = x ** 2 % 2019
        n //= 2

    return K * x % 2019

rui = 0
for i in range(n):
    rui = (int(s[n-1-i]) * pow_k(10, i) + rui) % 2019
    mod[n-1-i] = rui
    
b = Counter(mod)
c = list(b.values())
c.sort(reverse = True)

ans = 0
for i in c:
    if i > 1:
        ans += i * (i-1) // 2
    else:
        break

print(ans)

Measured memory_bytes: 70676
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

W,a,b = I()
if a >= b:
    print(max(0,a-b-W))
else:
    print(max(0,b-a-W))

Measured memory_bytes: 9872
N, M = map(int,input().split())
A_B = [list(map(int, input().split())) for i in range(N)]

#日数ごとの集合を作る
jobs = {m: [] for m in range(1, M + 1)}
for ab in A_B:
  if ab[0] in jobs:
    jobs[ab[0]].append(ab[1])
#print(jobs)

#日数の少ない仕事からループして最適解を見つける
import heapq
q = []
ans = 0
#仕事にかかる日数のループであって経過日のループではない
for m in range(1, M + 1):
    for b in jobs[m]:
      #qには小さい順で格納される
      heapq.heappush(q, -b)
    #print(q)
    #qが空でないとき
    if len(q) > 0:
      #現時点での日数以下の仕事で一番稼げるものを取り出す
      neg_b = heapq.heappop(q)
      ans += -neg_b

print(ans)

Measured memory_bytes: 48276
import Control.Monad

fill [x, _, 1] (xl, xr, yb, yt) = (max x xl, xr, yb, yt)
fill [x, _, 2] (xl, xr, yb, yt) = (xl, min x xr, yb, yt)
fill [_, y, 3] (xl, xr, yb, yt) = (xl, xr, max y yb, yt)
fill [_, y, 4] (xl, xr, yb, yt) = (xl, xr, yb, min y yt)

calc (xl, xr, yb, yt) = max 0 (xr-xl) * max 0 (yt-yb)


main = map read . words <$> getLine >>= \[w,h,n] -> replicateM n (map read . words <$> getLine) >>= print . calc . foldr fill (0, w, 0, h)

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int s, n, t;
	
	while(cin >> n){
		s = 100000;
		for(int i = 1; i <= n; i++){
			s += (s*0.05);
			t = s % 1000;
			if(t != 0){
				s = s - t + 1000;
			}
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N, K;
	int price[2000];
	cin >> N >> K;
	int minp = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> price[i];
	}
	sort(price, price + N);
	for (int j = 0; j < K; j++)
	{
		minp = price[j] + minp;
	}
	cout << minp << endl;
	return 0;
}

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 2005;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b;
	cin >> a >> b;
	cout << (a-1) *(b-1) << endl;
}


Measured memory_bytes: 384
H, W = map(int, input().split())
list = []
for i in range(H):
    list.append(input())

new_list = []

H_del = []
W_del = []

#削除する行列の探索
for i in range(H):
    if list[i] == '.'*W:
        W_del.append(i)

for i in range(W):
    H_stock = ''
    for j in range(H):
        H_stock += list[j][i]
        if H_stock == '.'*H:
            H_del.append(i)

#削除する行列を除いた行列を再作成
for i in range(H):
    if i not in W_del:
        W_list = ''
        for j in range(W):
            if j not in H_del:
                W_list += list[i][j]
        new_list.append(W_list)

#答えを表示
for i in range(len(new_list)):
    print(new_list[i])

Measured memory_bytes: 3064
n, k = map(int, input().split())
p = list(map(int, input().split()))

num_li = [0]*n
for i in range(n):
    num_li[i] = (p[i]+1)/2

num = sum(num_li[:k])
ans = num
for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num, ans)

print(ans)


Measured memory_bytes: 25604
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    long long int a, b, c;
    cin >> a >> b >> c;
    if (c-a-b > 2 * sqrtl(a*b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []s = sc.next().toCharArray();
		int p = s.length;
		int []t = new int [p];
		
		for(int i = 0; i< p;i++) {
			if(s[i] == '0') {
				t[i] = 0;
			}
			if(s[i] == '1') {
				t[i] = 1;
			}
		}
		int count = 0;
		for(int i = 0 ; i < p-1 ; i++) {
			if(t[i] + t[i+1] == 0) {
				t[i+1] = 1;
				count++;
			}
			if(t[i] + t[i+1] == 2) {
				t[i+1] = 0;
				count++;
			}
			
		}
		System.out.println(count);
		
	}

}


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

using F = double;

struct Point {F x, y;};

const F PI = acos(-1);
const F INF = 1e9;

int N;
vector<Point> P;

F tune(auto a) {
  while(a  < 0) a += PI;
  while(PI < a) a -= PI;
  return a;
}

F projection(auto p, auto a) {
  return p.x * sin(a) + p.y * cos(a);
}

tuple<F, F, F> coefficient(auto a) {
  vector<pair<F, int>> lx;
  for(auto i = 0; i < P.size(); ++i) lx.emplace_back(projection(P[i], a) - 1, i);
  sort(begin(lx), end(lx));

  vector<pair<int, int>> shadow;
  shadow.emplace_back(lx.front().second, lx.front().second);
  for(auto i: lx) {
    auto rx = projection(P[shadow.back().second], a) + 1;
    if(rx < i.first) shadow.emplace_back(i.second, i.second);
    else             shadow.back().second = i.second;
  }

  F A = 0, B = 0, C = 0;
  for(auto s: shadow) {
    auto l = P[s.first];
    auto r = P[s.second];
    A += r.x - l.x;
    B += r.y - l.y;
    C += 1   - -1;
  }
  return make_tuple(A, B, C);
}

vector<F> solve() {
  vector<F> angle = {0, PI};
  for(auto j = 0; j < N; ++j) for(auto i = 0; i < j; ++i) {
    auto dx = P[i].x - P[j].x;
    auto dy = P[i].y - P[j].y;
    auto d = hypot(dx, dy);
    auto a = atan2(dy, dx);
    angle.emplace_back(tune(-a));
    angle.emplace_back(tune(asin(2 / d)  - a));
    angle.emplace_back(tune(asin(-2 / d) - a));
  }
  sort(begin(angle), end(angle));
  angle.erase(unique(begin(angle), end(angle)), end(angle));

  F a_min = INF, a_max = -INF;
  F s_min = INF, s_max = -INF;
  for(auto i = 1; i < angle.size(); ++i) {
    auto low  = angle[i - 1];
    auto high = angle[i];
    auto middle = (low + high) / 2;

    F a, b, c;
    tie(a, b, c) = coefficient(middle);

    for(auto i: {low, tune(PI / 2 - atan2(b, a))}) if(low <= i && i <= high) {
      auto s = a * sin(i) + b * cos(i) + c;
      if(s_min > s) {
        s_min = s;
        a_min = i;
      }
      if(s_max < s) {
        s_max = s;
        a_max = i;
      }
    }
  }

  return {a_min, a_max};
}

int main() {
  while(cin >> N, N) {
    P = vector<Point>(N);
    for(auto& i: P) cin >> i.x >> i.y;

    for(auto i: solve()) cout << setprecision(15) << fixed << i << endl;
  }
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
int main(){
long n,m;
  cin>>n>>m;
  vector<long>a(m);
  for(int i=0;i<m;i++)cin>>a[i];
  long c=0;
  for(int i=0;i<m;i++)c+=a[i];
  if(c>n)cout<<-1<<endl;
  else cout<<n-c<<endl;
}

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

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<long long> P(A), Q(B), R(C);
	vector<pair<long long, int> > V;
	for (int i = 0; i < A; i++) cin >> P[i], V.push_back({ P[i], 0 });
	for (int i = 0; i < B; i++) cin >> Q[i], V.push_back({ Q[i], 1 });
	for (int i = 0; i < C; i++) cin >> R[i], V.push_back({ R[i], 2 });
	sort(V.begin(), V.end(), greater<pair<long long, int> >());
	long long AC = 0, BC = 0, CC = 0, ANS = 0;
	for (int i = 0; i < A + B + C; i++) {
		pair<long long, int> P = V[i];
		if (P.second == 0) {
			if (AC < X) ANS += P.first, AC++;
		}
		if (P.second == 1) {
			if (BC < Y) ANS += P.first, BC++;
		}
		if (P.second == 2) {
			ANS += P.first, CC++;
		}
		if (AC + BC + CC == X + Y) {
			cout << ANS << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 12908
import sys

N,P = map(int,input().split())

if N == 1:
    print (P)
    sys.exit()

lis = []
dic = {}

i = 1
while True:

    flag = True
    now = 1
    if i > 1:
        for j in range(N):
            now *= i
            if now > P:
                flag = False
                break
        if not flag:
            break

    flag = True
    for j in lis:
        if i % j == 0:
            flag = False
            break
    
    if flag and i != 1:
        lis.append(i)
        dic[i] = 0

        while P % i == 0:
            P //= i
            dic[i] += 1

    i += 1


ans = 1
#print (dic)

for i in dic:

    if dic[i] != 0:
        ans *= i ** (dic[i]//N)

print (ans)


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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll x,y;
    cout << max(a*c,max(a*d,max(b*c,b*d))) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    char N[4];
    int num=0;
    for(int i=0;i<4;i++){
        cin>>N[i];
        if(N[i]=='+'){
            num++;
        }else{
            num--;
        }
    }
    cout<<num<<endl;
    return 0;
}

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

def f(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                    pf[j] = pf.get(j, 0) + 1
                    i //= j
    return pf

ans = 1
for v in f(n).values():
    ans *= (v + 1)
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int H, N;
  cin >> H >> N;
  int sum=0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> vec[i];
    sum += vec[i];
  }
  if (sum >= H)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
import bisect
import math

def main():
    n = int(input())
    l_s = list(sorted(map(int, input().split(' '))))

    ans = 0

    for c in range(2, n):
        for b in range(1, c):
            idx = bisect.bisect_right(l_s, l_s[c] - l_s[b])
            idx = min(b, idx)
            ans += b - idx
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int[][] a = new int[n+2][n+2];
		for (int i=1; i<=n; i++) {
			for (int j=1; j<=n; j++) {
				a[i][j] += in.nextInt();
				a[i+1][j] += a[i][j];
				a[i][j+1] += a[i][j];
				a[i+1][j+1] -= a[i][j];
			}
		}


		int[][] dp = new int[n+2][n+2];

		for (int i=0; i<=n+1; i++) {
			dp[i][0] = Integer.MIN_VALUE;
			dp[0][i] = Integer.MIN_VALUE;
		}

		for (int i=1; i<=n; i++) {
			for (int j=1; j<=n; j++) {
				dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);

				for (int k=i-1; k>=0; k--) {
					for (int l=j-1; l>=0; l--) {
						dp[i][j] = Math.max(dp[i][j], a[i][j] - a[k][j] - a[i][l] + a[k][l]);
					}
				}
			}
		}

		out.println(dp[n][n]);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 43028