akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

    int k;
    cin >>k;
    
    int r[k],c[k];
    for(int i=0;i<k;i++){
        cin >> r[i];
        cin >> c[i];
    }

    int o[8]={0,1,2,3,4,5,6,7};
    int a[8]={};

    do{
        int d=0;
        for(int i=0;i<k;i++){
            if(o[r[i]]==c[i])d++;
        }
        if(d!=k)continue;

        long long int e=1;
        for(int i=0;i<7;i++){
            for(int j=i+1;j<8;j++){
                e=e*(i-j-o[i]+o[j])*(i+o[i]-j-o[j]);
            }
        }

        if(e!=0){
            for(int i=0;i<8;i++)a[i]=o[i];
            break;
        }
    }while(next_permutation(o,o+8));

    vector<string> t(8);


    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            if(a[i]==j)t[i].push_back('Q');
            else t[i].push_back('.');
        }
    }

    for(int i=0;i<8;i++)cout << t[i] << endl;


}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;

const ll blk = 40000;
ll n, k;
ll dpb[102][blk+10];
ll dps[102][blk+10];
ll sumb[102][blk+10];
ll sums[102][blk+10];
const ll mod = 1e9 + 7;
ll sq;
int main()
{
        cin >> n >> k;
        if(n==1){
                cout << "1\n"; return 0;
        }
        for(ll i=1;i<=n;i++){
                if(i*i > n){
                        sq = i-1;
                        break;
                }
        }
        for(ll i=1;i<=sq;i++) {
                dps[1][i]=1;
                sums[1][i] = dps[1][i];
                if(i) sums[1][i] += sums[1][i-1];
        }
        for(ll i=sq ;i>=1;i--) {
                if(i <= sq) dpb[1][i] = (n/i) - (n/(i+1));
                //else dpb[1][i] = (n/i);
                if(i == (n/i)) dpb[1][i] = 0;
                sumb[1][i] = sumb[1][i+1] + dpb[1][i];

        }
        for(ll i=2;i<=k;i++){

                for(ll j=1;j<=sq;j++) {
                        dps[i][j] = (sums[i-1][sq] + sumb[i-1][j])%mod;
                        sums[i][j] = (sums[i][j-1] + dps[i][j])%mod;
                }
                for(ll j=sq;j>=1;j--) {
                        dpb[i][j] = (sums[i-1][j] * ((n/j) - (n/(j+1))))%mod;
                        if(j == (n/j)) dpb[i][j] = 0;
                        sumb[i][j] = (sumb[i][j+1] + dpb[i][j])%mod;
                }

        }
        ll ans = 0;
        for(ll i=1;i<=sq;i++) {
                ans = (ans + dps[k][i])%mod;
                ans = (ans + dpb[k][i])%mod;
        }
        cout<<ans <<endl;
        return 0;
}


Measured memory_bytes: 126848
#include<cstdio>
using namespace std;

long long A[100000];
long long B[100000];

int N;

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%lld%lld", A+i, B+i);
    }

    long long incr = 0;
    for(int i = N-1; i >= 0; --i) {
        A[i]+=incr;
        if(A[i] == 0) continue;
        long long target = ((A[i]-1)/B[i]+1)*B[i];
        incr += target-A[i];
    }
    printf("%lld\n", incr);
    return 0;
}


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

using namespace std;

int main() {
    int n;  cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;  cin >> x;
        if ((i & 1) && (x & 1)) ans++;
    }
    cout << ans;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

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

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

    long long n, a, b;
    cin >> n >> a >> b;

    if(a > b){
        cout << 0 << endl;
        return 0;
    }

    long long ans = (b * (n - 1) + a) - (b + a * (n - 1)) + 1;
    cout << max(0LL, ans) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    string s;
    cin >> s;
    string cfes = "CODEFESTIVAL2016";
    int cnt = 0;
    for (int i=0; i<s.size(); i++){
        if (cfes[i] != s[i])cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	map<string, int> value;

	value["SUN"] = 0;
	value["MON"] = 1;
	value["TUE"] = 2;
	value["WED"] = 3;
	value["THU"] = 4;
	value["FRI"] = 5;
	value["SAT"] = 6;

	string S;
	cin >> S;

	cout << 7 - value[S];

	return 0;
}


Measured memory_bytes: 3504
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/9/ALDS1_9_B
# heapの完全二分木としての表現は二分探索木のときとルールが違いのでこんがらがらないように注意
# 詳しくはP233と238の図
# 勉強にはなるが解くだけならpythonのライブラリでok
from heapq import heapify, heappop, heappush, heappushpop
N = input()
H = [-x for x in map(int, input().split())]

heapify(H)
print('', *[-x for x in H])



Measured memory_bytes: 63632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//参考: https://pyteyon.hatenablog.com/entry/2019/03/11/200000
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll find(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return find(x) == find(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[find(x)];
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll,ll>>pairs(M);
    for(ll i=0; i<M; i++){
        ll xi, yi;
        cin >> xi >> yi;

        xi--;
        yi--;
        pair<ll,ll>p;
        p.first=xi;
        p.second=yi;
        pairs[i] = p;
    }
    vector<ll>Fubens(M);
    Fubens[M-1] = (N * (N-1)) / 2;
    UnionFind uf(N);
    uf.init(N);
    for (ll i=M-2; i >= 0; i--){
        pair<ll,ll>p;
        p = pairs[i+1];
        if(not uf.issame(p.first, p.second)){
            Fubens[i] = Fubens[i+1] - uf.size(p.first) * uf.size(p.second);
        }
        else Fubens[i] = Fubens[i+1];
        uf.unite(p.first, p.second);
    }
    for (ll i=0; i<M; i++){
        cout << Fubens[i] << endl;
    }
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define P pair<int, int>
struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int a;
	cin >> a;
	if(a == 7 || a == 5 || a == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<vector<PII> > VVPII;
typedef priority_queue<PII, vector<PII>, greater<PII> > PQPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};

//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int INF = (int) 10e9;

int solve(int n, int m){
	VVPII node(n);
	vector<bool> done(n, false);
	REP(i, m){
		int from, to, cost;
		cin >> from >> to >> cost;
		node[from].PB(MP(cost, to));
		node[to].PB(MP(cost, from));
	}
	PQPII q;
	VI costs(n, INF);
	costs[0] = 0;
	q.emplace(0, 0);
	int result = 0;
	while(!q.empty()){
		int w = q.top().first, u = q.top().second;
		q.pop();
		if(costs[u] < w) continue;
		result += w;
		for(PII p : node[u]){
			if(p.first < costs[p.second] && !done[p.second]){
				done[u] = true;
				costs[p.second] = p.first;
				q.emplace(p.first, p.second);
			}
		}
	}
	return result;
}

int main(int argc, char const *argv[])
{
	for(int n, m; cin >> n >> m, n | m;){
		cout << solve(n, m) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
n=int(input())
a=list(map(int,input().split()))
# if n==1:
#   print(1)
#   exit(0)
for i in range(n):
  if 1<=a[i]<=399:
    a[i]="gray"
  elif 400<=a[i]<=799:
    a[i]="brown"
  elif 800<=a[i]<=1199:
    a[i]="green"
  elif 1200<=a[i]<=1599:
    a[i]="lightblue"
  elif 1600<=a[i]<=1999:
    a[i]="blue"
  elif 2000<=a[i]<=2399:
    a[i]="yellow"
  elif 2400<=a[i]<=2799:
    a[i]="orange"
  elif 2800<=a[i]<=3199:
    a[i]="red"
  elif 3200<=a[i]:
    a[i]="free"
# print(a)
from collections import Counter
c=Counter(a)
ans=len(c)
free=c["free"]

v_min=ans
v_max=ans
if free>0:
  v_min-=1
if free>0:
  v_max+=free-1
if free==n:
  v_min=1
print(v_min,v_max)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[] xi = new int[N];
        for(int i = 0; i < N; i++){
            xi[i] = sc.nextInt();
        }
        
        int hydrationCount = 0;
        while(notAllZero(xi)){
            hydrate(xi);
            hydrationCount++;
        }
        
        System.out.println(hydrationCount);
    }
    public static boolean notAllZero(int[] xi){
        for(int i = 0; i < xi.length; i++){
            if(xi[i] != 0) return true;
        }
        return false;
    }
    public static void hydrate(int[] xi){
        final int N = xi.length;
        int l = 0;
        int r = xi.length - 1;
        l = findIndexOfL(xi, l, r);
        r = findIndexOfR(xi, l, r);
        for(int j = l; j <= r; j++){
            xi[j]--;
        }
    }
    public static int findIndexOfL(int[] xi, int l, int r){
        for(int k = l; k <= r; k++){
            if(k < r){
                if(xi[k] == 0 && xi[k+1] != 0) return k+1;
            }
        }
        return l;
    }
    public static int findIndexOfR(int[] xi, int l, int r){
        for(int k = l; k <= r; k++){
            if(0 < k){
                if(xi[k] == 0 && xi[k-1] != 0) return k-1;
            }
        }
        return r;
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N; cin >> N;
    vector<int> P(N); REP(i, N) cin >> P[i];

    int cnt = 0;
    int min_num = P[0];
    for(int i = 0; i < N; ++i) {
        if(min_num >= P[i]) {
            cnt++;
            min_num = P[i];
        } else {
            continue;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  int n,i;
  cin>>n>>i;
  cout<<n-i+1<<endl;
}

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

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

    int k;
    cin >> k;

    vector<long long int> v = {1,2,3,4,5,6,7,8,9};
    int start = 0, end = 9;

    if(k<=end){
        cout << v[k-1] << endl;
        return 0;
    }

    for(int i=2; ; i++){
        int s = start, e = end;
        // cout << "my start and end: " << s << ", " << e << endl;
        for(int j = s; j<e; j++){
            int num = v[j]%10;
            if(num-1>=0){
                v.push_back(10*v[j] + num-1);
                end++;
                if(k==end){
                    cout << v[end-1] << endl;
                    return 0;
                }
            }

            v.push_back(10*v[j]+num);
            end++;
            if(k==end){
                cout << v[end-1] << endl;
                return 0;
            }

            if(num+1 <=9){
                v.push_back(10*v[j] + num+1);
                end++;
                if(k==end){
                    cout << v[end-1] << endl;
                    return 0;
                }
            }
        }
        // for(int i= s; i<end; i++) cout << v[i] << " ";
        // cout << endl;
        start = e;
    }
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

const ll MOD = 1e9 + 7;

ll Mod(ll a, ll mod) {
    return (a%mod + mod)%mod;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if (n & 1) {
            res = res*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

ll modinv(ll a, ll mod) {
    ll x, y;
    extGCD(a, mod, x, y);
    return Mod(x, mod);
}

ll nCr_mod(ll n, ll r, ll mod) {
    if ( n == r || n == 1 ) {
        return 1;
    }

    r = min(r, n-r);
    if ( r == 1 ) {
        return n;
    } else {
        ll n_to_n_r = n;
        ll r_to_1 = r;
        rep2(i, r-1) {
            n_to_n_r *= n-i;
            n_to_n_r %= mod;
            r_to_1 *= r-i;
            r_to_1 %= mod;
        }
        // r_to_1 = pow_mod(r_to_1, mod-2, mod);
        r_to_1 = modinv(r_to_1, MOD);
        return n_to_n_r*r_to_1%mod;
    }
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
/*
    if ( n == 2 ) {
        cout << 0 << endl;
        return 0;
    }*/
    ll ans = pow_mod(2, n, MOD)-1;
    ans = Mod(ans-nCr_mod(n, a, MOD), MOD);
    ans = Mod(ans-nCr_mod(n, b, MOD), MOD);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
d = []
for i in range(n):
    d.append(abs(x[i]-y[i]))
print(sum(d))
print(sum(list(map(lambda x:x**2,d)))**(1/2))
print(sum(list(map(lambda x:x**3,d)))**(1/3))
print(max(d))


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

struct point{
    ll x, y;
};

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll n; cin >>n;
    vi h(n);
    for(int i = 0;i < n; i++) cin >> h[i]; h.push_back(10000000000);

    ll dis_max = -1; //max移動
    ll dis = 0;
    
    for(int i = 0; i < n; i++){
            if(h[i]>= h[i+1]){
                dis++;
            }
            else{
                dis_max = max(dis_max, dis);
                dis = 0;
                
            }
    }
    cout << dis_max << endl;
}

Measured memory_bytes: 1024
n=int(input())
c=input()
if "R" not in c or "W" not in c:print(0);exit()
rcnt=[0]*(n+1)
wcnt=[0]*(n+1)
for i in range(n):
    if c[i]=="W":
        wcnt[i+1]=wcnt[i]+1
        rcnt[i+1]=rcnt[i]
    else:
        rcnt[i+1]=rcnt[i]+1
        wcnt[i+1]=wcnt[i]
ans=n+100
for i in range(n):
    cw=wcnt[i+1]
    cr=rcnt[-1]-rcnt[i+1]
    ans=min(ans,cw+cr-min(cr,cw))
ans=min(ans,wcnt[-1])
print(ans)

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

int main() {
    int c, n, m, x, y, z, w;
    int ans = 0;
    cin >> n >> m;
    vector<queue<int>> f(n, queue<int>{});
    vector<bool> d(n, false);
    queue<int> q;

    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        f[x-1].emplace(y-1);
        f[y-1].emplace(x-1);
    }
    for (int i = 0; i < n; i++) {
        if (!d[i]) {
            // cout << "original start " << i << endl;
            c = 0;
            q.emplace(i);
            while(q.size() > 0) {
                z = q.front();
                q.pop();
                // cout << "start " << z << endl;
                if (!d[z]) {
                    while(f[z].size() > 0) {
                        w = f[z].front();
                        f[z].pop();
                        q.emplace(w);
                    }
                    d[z] = true;
                    c++;
                }
            }
            // cout << c << endl;
            if (c > ans) {
                ans = c;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 142592
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n,dp[maxn],head[maxn],cnt;
struct edge{int to,next;
}e[maxn<<1];
vector<int>vec[maxn];
bool cmp(const int &a,const int &b)
{
	return dp[a]>dp[b];
}
void add(int x,int y)
{
	e[cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt++;
}
void dfs(int u,int pre)
{
	for(int i=head[u];i;i=e[i].next)
	{
		if(e[i].to==pre)continue;
		dfs(e[i].to,u);
	}
	if(vec[u].size())
	{
	  int now=1;
		sort(vec[u].begin(),vec[u].end(),cmp);
		for(int i=0;i<vec[u].size();++i)
		{
			dp[u]=max(dp[u],dp[vec[u][i]]+now);now++;
		}
	}
}
int main()
{
	cnt=1;
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
	{
		int x;scanf("%d",&x);
		add(x,i);add(i,x);vec[x].push_back(i);
	}
	dfs(1,0);
	printf("%d\n",dp[1]);
}


Measured memory_bytes: 17408
a, b = map(int, input().split())

a0 = -(-25*a // 2)
a1 = 25*(a+1) // 2
b0 = -(-10*b // 1)
b1 = -(-10*(b+1) / 1)

if a0 <= b0 and b0 < a1:
    print(b0)
elif b0 <= a0 and a0 < b1:
    print(a0)
else:
    print(-1)


Measured memory_bytes: 3060
while line = gets
  a, b, c, d, e, f = line.split.map(&:to_f)
  boo = a * d
  bb = (boo / a) * b
  cc = (boo / a) * c
  ee = (boo / d) * e
  ff = (boo / d) * f
  x = bb - ee
  w = cc - ff
  if ((a != 0) && (d != 0))
    v = w / x
    an = c - b * v
    ans = an / a
  else
    if (a == 0)
      v = c / b
      an = f - e * v
      ans = an / d
    else
      v = f / e
      an = c - b * v
      ans = an / a
    end
  end
  printf("%.3f %.3f\n", ans, v)
end

Measured memory_bytes: 8724
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n, q;
const int SIZE = 10010;
class Unionfind{
    public:
        int par[SIZE], cnt[SIZE];
        void init(int n){
        	for (int i = 0; i < n; ++i){
        		par[i] = i;
        		cnt[i] = 1;
        	}
        }
        int find(int x){
        	if(par[x] == x) return x;
        	return par[x] = find(par[x]);
        }
        void unite(int x, int y){
        	x = find(x);
        	y = find(y);
        	if(x == y) return;
        	if(cnt[x] < cnt[y]) swap(x, y);
        	par[y] = x;
        	cnt[x] += cnt[y];
        }
        bool same(int x, int y){
        	return find(x) == find(y);
        }
        int get(int x, int y){
        	if(same(x, y)){
        		return cnt[x];
        	}else{
        		return cnt[x] + cnt[y];
        	}
        }
};


int main(void){
	int n, q; cin >> n >> q;
	Unionfind uf;
	uf.init(n + 1);

	rep(i, q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			uf.unite(x, y);
		}else{
			if(uf.same(x, y)){
				printf("1\n");
			}else{
				printf("0\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[100005];
int visited[100005];
void bfs(int a)
{
    queue<int>q;
    q.push(a);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        visited[u]=1;
        for(int i=0;i<adj[u].size();i++)
        {
            int v=adj[u][i];
            if(visited[v]==0)
            {
                visited[v]=1;
                q.push(v);
            }
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    memset(visited,0,sizeof(visited));
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);

    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            cnt++;
            bfs(i);
        }
    }
    cout<<cnt-1<<endl;
}


Measured memory_bytes: 9212
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

int main(void)
{
	int n;
	scanf("%d", &n);
	printf("%d",1 -  n);
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct{
  int id,depth,type,degree,height; //type:0,root,1,internal node, 2,leaf
  int parent;
  int left,right;
}treenode;
treenode a[25];
int H[25];
int findsiblings(int id){
  if(a[id].parent == NIL) return NIL;
  if(a[a[id].parent].left != id && a[a[id].parent].left != NIL)  return a[a[id].parent].left;
  if(a[a[id].parent].right != id && a[a[id].parent].right != NIL)  return a[a[id].parent].right;
  return NIL;
}
int ansdepth(int id){
  int cnt = 0;
  while(a[id].parent != NIL){
    cnt++;
    id = a[a[id].parent].id;
  }
  return cnt;
}
int ansheight(int id){
  int h1=0,h2=0;

  if(a[id].left!=NIL)
    h1=ansheight(a[id].left)+1;
  if(a[id].right!=NIL)
    h2=ansheight(a[id].right)+1;

  return H[id]=( h1>h2 ? h1 : h2 );
}
int main(){
  int n,d,i,j,k,id,l,r;
  int cnt = 1;
  char ttype[3][20] = {"root","internal node","leaf"};
  scanf("%d",&n);
  for(i =0;i <n; i++) a[i].parent = NIL;
  for(i =0;i < n;i++){
    scanf("%d",&id);
    a[id].left = a[id].right;
    a[id].id = id;
    a[id].depth = 0;
    scanf("%d%d",&l,&r);
    a[id].left = l;
    a[id].right = r;
    if(l != NIL) a[l].parent = id;
    if(r != NIL) a[r].parent = id;
  }
  for(i =0;i < n;i++){
    a[i].degree = 0;
    if(a[i].left != NIL) a[i].degree++;
    if(a[i].right != NIL) a[i].degree++;

    if(a[i].parent == NIL)  a[i].type = 0;
    else if(a[i].left != NIL||a[i].right!= NIL)  a[i].type = 1;
    else a[i].type = 2;
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",a[i].id,a[i].parent,findsiblings(i),a[i].degree,ansdepth(i),ansheight(i),ttype[a[i].type]);
  }
  return 0;
}



Measured memory_bytes: 2104
k = int(input())
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(s[k - 1])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

bool m[5001][5001] = {};
bool in(int x,int y){
    if(x >= 0 && x <= 5000 && y >= 0 && y <= 5000)return true;
    else return false;
}

/*----------------------------------------------------------------*/
signed main(){

    int n;
    string s;
    cin >> n >> s;

    set<string> st[4];
    st[0].insert("");

    rep(i,n){
        for(int j = 3;j >= 1;j--){
            for(auto x:st[j-1]){
                string t = x;
                t += s[i];
                st[j].insert(t);
            }
        }
    }
    cout << st[3].size() << endl;


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://sumitrust2019.contest.atcoder.jp/tasks/sumitb2019_d

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  bool flag = false;
  
  while (N) {
    if (N%10 == 7) {
      flag = true;
      break;
    }

    N/=10;
  }
  
  cout << (flag ? "Yes" : "No") << endl;

  return 0;
}


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

 int main(){
 string S, T;
 cin >> S >> T;
 int N = S.size(), ans = 0;
 for(int i = 0; i < N; ++i){
 if(S[i] != T[i]) ++ans;
 }
 cout << ans << endl;
 }


Measured memory_bytes: 3860
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (N, i) = get!(i64, i64);

    let ans = N - i + 1;

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;
import java.lang.Math;

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

        int n = sc.nextInt();
        boolean ans = false;

        for (int i = 0; i <= n / 4; i++) {
            for (int j = 0; j <= n / 7; j++) {
                if (4 * i + 7 * j == n) {
                    ans = true;
                }
            }
            if (ans) {
                break;
            }
        }
        System.out.println(ans ? "Yes":"No");
    }
}

Measured memory_bytes: 21844
#include <string>
#include <bitset>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{    
    int n;cin>>n;
    if (n==1 ){cout<<1;}
    else if(1<n && n<4){cout<<2;}
    else if(3<n && n<8){cout<<4;}
    else if(7<n && n<16){cout<<8;}
    else if(15<n && n<32){cout<<16;}
    else if(31<n && n<64){cout<<32;}
    else {cout<<64;}
    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int ok = -2e18;
    Int ng = 2e18 + 1;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            if (a[i] < 0) {
                Int l = i;
                Int r = n;
                while (abs(r - l) > 1) {
                    Int m = (r + l) / 2;
                    if (a[i] * a[m] <= mid) {
                        r = m;
                    }
                    else {
                        l = m;
                    }
                }
                cnt += n - r;
            }
            else {
                Int l = i;
                Int r = n;
                while (abs(r - l) > 1) {
                    Int m = (l + r) / 2;
                    if (a[i] * a[m] <= mid) {
                        l = m;
                    }
                    else {
                        r = m;
                    }
                }
                cnt += l - i;
            }
        }
        if (cnt < k) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    dump(ng);
    return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

n = int(input()) 
arr = list(map(int, input().split()))
arr = sorted(arr)
cnt = 0

for i in range(n-2):
  for j in range(i, n-1):
    for k in range(j, n):
      ai, aj, ak = arr[i], arr[j], arr[k]
      if ai != aj and aj != ak and ak < ai + aj:
        cnt += 1

print(cnt)

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int n;
    cin >> n;
    for(int i = 0; i <= 60000; i++){
        if((int)(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

ll solve(ll n){

    ll ans = LLONG_MAX;
    ll k = 0;
    for(ll i = 1;i*i<=n;i++){

        k = 0;

        if(n%i == 0){
            k += (i-1);
            k += ((n/i)-1);


            ans = min(ans,k);

        }


    }

    return ans;

}

int main(){

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

    ll t = 1;
    //cin>>t;

    while(t--){
    	ll n;
    	cin>>n;

    	cout<<solve(n)<<endl;
    }


}


Measured memory_bytes: 256
N = input()
N = list(N)
# N = int(N)
# print(N)

ab = N[0] + N[1]
cd = N[2] + N[3]

# ab = int(ab)
# cd = int(cd)

if N[0] == 0:
  ab = ab.zfill(2)

if N[2] == 0:
  cd = cd.zfill(2)

# print(ab)
# print(cd)


if ab == "00" and cd == "00":
  print("NA")  

elif ab == "00" and int(cd) > 12:
  print("NA")  

elif int(ab) > 12 and cd == "00":
  print("NA")  

elif int(ab) > 12 and int(cd) > 12:
  print("NA")  

elif 13 > int(ab) > 0 and 13 > int(cd) > 0:
  print("AMBIGUOUS")

elif ab == "00" and 0 < int(cd) < 13:
  print("YYMM")

elif int(ab) > 12 and int(cd) < 13:
  print("YYMM")

elif 13 > int(ab) > 0 and int(cd) > 12:
  print("MMYY")

elif 0 < int(ab) < 13 and cd =="00":
  print("MMYY")


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

sortedA = sorted(A, reverse=True)
alip = sum(sortedA[i] for i in range(len(sortedA)) if i % 2 == 0)
bobp = sum(sortedA[i] for i in range(len(sortedA)) if i % 2 == 1)
diff = alip - bobp
print(diff)

Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;

int main() {
  string s;
  cin >> s;
  vector<string> y(8);
  y[7] = "SUN";
  y[6] = "MON";
  y[5] = "TUE";
  y[4] = "WED";
  y[3] = "THU";
  y[2] = "FRI";
  y[1] = "SAT";
  y[0] = "uuu";
  rep(i, 8) {
    if (y[i] == s) {
      cout << i << endl;
    }
  }
      
}

Measured memory_bytes: 256
/*
https://beta.atcoder.jp/contests/abc085/tasks
*/
#include<iostream>
#include<algorithm> //sort
using namespace std;
typedef long long ll;

main(){
  int n,H,m=0;
  cin>>n>>H;
  int a,b[n],ans=0;
  for(int i=0;i<n;i++){
    cin>>a>>b[i];
    if(m<a) m=a;
  }
  sort(b,b+n,[](const int& x, const int& y){return (x>y);} );

  for(int i=0;i<n&&H>0;i++){
    ans++; H-=max(m,b[i]);
  }
  if(H>0) ans+=(H+m-1)/m;
  cout<<ans<<"\n";
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
M = 10**6 + 1

counts = [0 for _ in range(M)]
for a in A:
  counts[a] += 1

integers = [0,0] + [1 for _ in range(M-2)]
max_count = 0
for i in range(M):
  if integers[i] >= 1:
    count = 0
    for j in range(i,M,i):
      count += counts[j]
      integers[j] = 0
    max_count = max(max_count,count)

if max_count == N:
  answer = 'not coprime'
elif max_count >= 2:
  answer = 'setwise coprime'
else:
  answer = 'pairwise coprime'

print(answer)

Measured memory_bytes: 217188
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		ArrayList<String> al = new ArrayList<String>(Arrays.asList(sc.nextLine().split("[ |\\,|\\.]")));

		for(int i=al.size()-1;i>=0;i--){
			int len = al.get(i).length();
			if(len < 3 || 6 < len){
				al.remove(i);
			}
		}

		System.out.println(al.toString().replaceAll("\\[|,|\\]",""));
	}
}

Measured memory_bytes: 12000
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
total = sum(a)
for i in range(n):
    if a[i] >= b[i]:
        a[i] = a[i] - b[i]
        b[i] = 0
    else:
        b[i] = b[i] - a[i]
        a[i] = 0
    if a[i+1] >= b[i]:
        a[i+1] = a[i+1] - b[i]
        b[i] = 0
    else:
        b[i] = b[i] - a[i]
        a[i+1] = 0
print(total-sum(a))

Measured memory_bytes: 19004
#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>
#include<bits/stdc++.h>
using namespace std;
int n,m,r,ts[222],dp[222][222],ans=1e9;
int main()
{
	cin>>n>>m>>r;
	for(int i=0;i<r;i++)
	{
		cin>>ts[i];
	}
	for(int i=0;i<210;i++)
	{
		for(int j=0;j<210;j++)
		{
			dp[i][j]=1e9;
		}
	}
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		dp[a][b]=c;
		dp[b][a]=c;
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
			}
		}
	}
	sort(ts,ts+r);
	do
	{
		int cnt=0;
		for(int i=0;i<r-1;i++)
		{
			cnt+=dp[ts[i]][ts[i+1]];
		}
		ans=min(ans,cnt);
	}
	while(next_permutation(ts,ts+r));
	cout<<ans<<endl;
	return 0;
}

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

long long N;

int main(){

  cin >> N;
  vector<long long> B(N);
  
  for (int i = 1; i < N; i++){
  cin >> B.at(i);
  }
  
  long long sum = 0;
  for (int i = 1; i < N; i++){
    if (i == 1) sum = sum + B.at(i);
      else sum = sum + min(B.at(i),B.at(i-1));
    }
  sum = sum + B.at(N-1);
  
  cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) if(s[i]=='9') {
        cout << "Yes" << endl;
        return 0;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ld = long double;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
ld ex[1001];
ld calc(int x) {
    if (ex[x] == -1) {
        ex[x] = 0;
        eFOR(i, 1, x)ex[x] += ld(i) / ld(x);
    }
    return ex[x];
}
template<class T> T sum(vector<T>& a, int l, int r) {
    if (l == 0)return a[r];
    return a[r] - a[l - 1];
}
template<class T> void acc(vector<T>& a) {
    FOR(i, 1, a.size())a[i] += a[i - 1];
}
int main() {
    init();
    eFOR(i, 0, 1000)ex[i] = -1;

    int n, k; cin >> n >> k;
    vector<ld> p(n);
    FOR(i, 0, n) {
        int in; cin >> in;
        p[i] = calc(in);
    }
    acc(p);
    ld ans = 0;
    FOR(i, 0, n - k + 1)chmax(ans, sum(p, i, i + k - 1));
    cout << ans << "\n";
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = c;
    for (int i = 0; i < m; i++) {
      int a;
      cin >> a;
      tmp += b[i] * a;
    }
    if (tmp > 0) {
      ans++;
    }
  }
  cout << ans << '\n';
  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);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String string = sc.next();
		if (string.matches("[0-9]{"+A+"}-[0-9]{"+B+"}")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}




Measured memory_bytes: 39316
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 998244353;

LL F[333333];

LL inv(LL a) {
  LL res = 1;
  int b = MOD - 2;
  while (b) {
    if (b&1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b /= 2;
  }
  return res;
}

LL C(int N, int K) {
  LL result = F[N] * inv(F[K]) % MOD * inv(F[N-K]) % MOD;
  return result;
}

int main() {
  // ios_base::sync_with_stdio(0);

  F[0] = 1;
  FOR(i,1,333333) F[i] = F[i-1] * i % MOD;

  int N;
  LL A, B;
  LL K;
  scanf("%d%lld%lld%lld", &N, &A, &B, &K);

  LL result = 0;
  REP(a,N+1) {
    if (K >= a * A && (K - a*A) % B == 0 && (K - a*A) / B <= N) {
      int b = (K - a * A) / B;

      result += C(N,a) * C(N,b) % MOD;
    }
  }

  printf("%lld\n", result % MOD);
}


Measured memory_bytes: 2816
#include <cstdio>
#include <iostream>
using namespace std;
using ui = unsigned int;
using ul = unsigned long;
#pragma GCC optimize("Ofast")
#define loop(i, n) for (ui i = 0; i < n; i++)
ul bit[550010];
ui N;
inline ul sum(ui x)
{
    ul ret = 0;
    while (x > 0)
    {
        ret += bit[x];
        x -= x & -x;
    }
    return ret;
}
inline ul sum(ui l, ui r)
{
    return sum(r + 1) - sum(l);
}
inline void add(ui i, ul x)
{
    i++;
    while (i <= N)
    {
        bit[i] += x;
        i += i & -i;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ui Q;
    cin >> N >> Q;
    loop(i, N)
    {
        ul A;
        cin >> A;
        bit[i + 1] = A;
    }
    for (ui i = 1; i < N; i++)
        bit[i + (i & -i)] += bit[i];
    loop(i, Q)
    {
        ui a, b, c;
        cin >> a >> b >> c;
        if (a == 0)
            add(b, c);
        else
            cout << sum(c) - sum(b) << "\n";
    }
    return 0;
}


Measured memory_bytes: 8264
#include<iostream>
#include<stdio.h>
#include<math.h>
#define PI (3.14159265)
using namespace std;

int main() {
	double x = 0,y = 0;
	double sdeg = 0;
	double dis,deg;

	while ( scanf( "%lf,%lf", &dis, &deg ), dis + deg ){
		x -= dis * sin( sdeg );
		y += dis * cos( sdeg );
		
		deg = deg * PI / 180.0;
		sdeg -= deg;
	}
	cout << (int)x << endl << (int)y << endl;
	
	return 0;
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define FOR(i,a,n) for(ll i=a;i<=n;i++)
#define ROF(i,n,a) for(ll i=n;i>=a;i--)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int r; cin>>r;
    cout<<(2*3.14*r)<<endl;
   return 0; 
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int X, N;
    cin >> X >> N;
    if (N == 0) {
        cout << X << "\n";
        return 0;
    }
    int p[N];
    bool is_contain[105]{};
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        is_contain[p[i]] = true;
    }
    int v = 10000;
    int ans = 0;
    for (int i = 0; i < 102; i++) {
        if (!is_contain[i]) {
            int t = abs(X - i);
            if (t < v) {
                ans = i;
                v = t;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
# Your code here!
N,Y=map(int,input().split())
man=Y//10**4

for i in range(man+1)[::-1]:
    temp=i
    yo=(Y-i*10**4)//10**3
    for j in range(yo//5+1):
        if (temp+j+yo-5*j)==N:
            print(temp,j,yo-5*j)
            exit()
            
print(-1,-1,-1)
    
    

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type edge struct {
	to, weight int
}

type node struct {
	edgeList []edge
	dist     int
}

func main() {
	sc.Split(bufio.ScanWords)
	INF := int(math.Pow10(10))

	N, M, P := scanInt(), scanInt(), scanInt()
	G := make([]node, N)
	for i := 0; i < N; i++ {
		G[i].dist = -INF
	}
	G[0].dist = 0

	for i := 0; i < M; i++ {
		a, b, c := scanInt(), scanInt(), scanInt()
		G[a-1].edgeList = append(G[a-1].edgeList, edge{to: b - 1, weight: c - P})
	}

	// N回きっかりで止めてしまうと、1→Nまでの道のりのどこかで更新されたときを弾いてしまう
	for i := 1; i <= 2*N; i++ {
		updated := false
		for j := 0; j < N; j++ {
			if G[j].dist == -INF {
				continue
			}
			for _, e := range G[j].edgeList {
				if newWeight := G[j].dist + e.weight; G[e.to].dist < newWeight {
					G[e.to].dist = newWeight
					if i >= N {
						G[e.to].dist = INF
					}
					if e.to == N-1 {
						updated = true
					}
				}
			}
		}
		if updated && i >= N {
			fmt.Println(-1)
			return
		}
	}

	if ans := G[N-1].dist; ans < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, p;
vector <pair <int, int> > dv;
signed main()
{
	cin >> n >> p;
	for(int i = 2; i <= sqrt(p); i++)
	{
		int cnt = 0;
		while(p % i == 0)
		{
			p /= i;
			cnt++;
		}	
		if(cnt != 0)
			dv.push_back({i, cnt});
	}
	if(p > 1)
		dv.push_back({p, 1});
	int res = 1;
	for(auto x : dv)
	{
		int fac = x.first, pw = x.second;
		// cout << fac << ' ' << pw << '\n';
		for(int i = 1; i <= pw/n; i++)
		{
			res = res * fac;
		}
	}
	cout << res;
}

Measured memory_bytes: 256