akhauriyash/Code-Regression huggingface dataset:
// AOJ 1047 Crop Circle
// 2018.3.7 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP p; double r; } C;

#define PI2     6.283185307179586476925286766559
#define EPS     1e-8
#define EQ(a,b) (fabs((a)-(b))<EPS)
PP d2p(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return vabs(vsub(p1, p2)); }

int intersectCC(C c1, C c2, PP *p1, PP *p2)
{
	double x1 = c1.p.x, y1 = c1.p.y, r1 = c1.r;
	double x2 = c2.p.x, y2 = c2.p.y, r2 = c2.r;
	double d = dist(d2p(x1, y1), d2p(x2, y2));
	double w, n, x, y, p, q;
	double u, v;

	u = r1+r2, v = fabs(r1-r2);

	if ((fabs(d-u) > EPS && d >= u) || fabs(v-d) > EPS && d <= v) return 0;
	w = ((r1*r1 - r2*r2)/d + d) / 2;
	n = sqrt(r1*r1 - w*w);
	x = x1 + (x2-x1)*w / d;
	y = y1 + (y2-y1)*w / d;
	p = (y2-y1)*n / d;
	q = (x2-x1)*n / d;

	p1->x = x+p, p2->x = x-p;
	p1->y = y-q; p2->y = y+q;
	if (fabs(d-u) <= EPS) return 1;
	if (d == r1+r2) return 1;
	return 2;
}

int n;
typedef struct { PP p; double a; } T;
T tbl[102][202]; int hi[102];
C   c[102]; char f[102];

double angle(PP p, PP p0) { return atan2(p.y - p0.y, p.x - p0.x); }
int cmp(T *a, T *b) { if (EQ(a->a, b->a)) return 0; if (a->a <= b->a) return -1; return 1; }

int overlap(double *len, int id, int a, int b)
{
	int i;
	double ah, a1 = tbl[id][a].a, a2 = tbl[id][b].a;
	PP p0;

	ah = 0.5*(a1+a2);
	p0.x = c[id].p.x + c[id].r * cos(ah), p0.y = c[id].p.y + c[id].r * sin(ah);
	for (i = 0; i < n; i++) if (f[i] && i != id) {
		if (dist(p0, c[i].p) < c[i].r) return 1;
	}
	*len = c[id].r * (a2-a1);
	return 0;
}

int main()
{
	int i, j, k;
	PP p1, p2;
	double ans, a;

	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) {
			scanf("%lf%lf%lf", &c[i].p.x, &c[i].p.y, &c[i].r);
		}
		memset(f, 1, n);
		for (i = 0; i < n; i++) if (f[i]) for (j = 0; j < n; j++) if (f[j] && i != j) {
			if (c[i].r >= c[j].r && dist(c[i].p, c[j].p) <= c[i].r-c[j].r) f[j] = 0;
		}

		memset(hi, 0, n << 2);
		for (i = 0; i < n; i++) if (f[i]) {
			for (j = 0; j < n; j++) if (f[j] && j != i) {
				if (intersectCC(c[i], c[j], &p1, &p2) == 2) {
					k = hi[i]++, tbl[i][k].p = p1, tbl[i][k].a = angle(p1, c[i].p);
					k = hi[i]++, tbl[i][k].p = p2, tbl[i][k].a = angle(p2, c[i].p);
				}
			}
			qsort(tbl[i], hi[i], sizeof(T), cmp);
		}

		ans = 0;
		for (i = 0; i < n; i++) if (f[i]) {
			if (hi[i] == 0) ans += c[i].r * PI2;
			else {
				tbl[i][hi[i]] = tbl[i][0], tbl[i][hi[i]].a += PI2;
				for (j = 1; j <= hi[i]; j++) {
					if (!overlap(&a, i, j-1, j)) ans += a;
				}
			}
		}
		printf("%.12lf\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2576
#!/usr/bin/env ruby
STDIN.readline()
as = []
while (lines = STDIN.gets) do
  as << lines.strip.to_i
end
def make_tree(as, n)
  index = (0...as.size).bsearch{|i| as[i] >=  n} || as.size
  as.insert(index, n)
end
def trained?(as)
  # puts "as: #{as}"
  s = []
  l = 1
  while true
    make_tree(s, l)
    l = as[l-1]
    # puts "#{s}, #{l}"
    return s.length if l == 2
    return nil if s.bsearch{|n| n == l}
  end
end

n = trained?(as)
puts "#{n ? n : -1}"


Measured memory_bytes: 3764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)0.4e6 + 5

int cnt[MAX] = { 0,0 };

signed main(void)
{
	int i, j, k, l;
	rep(i, 200) REP(j, i, 200) REP(k, j, 200) REP(l, k, 200) {
		int c = i*i + j*j + k*k + l*l;
		if (c < MAX) ++cnt[c];
	}
	while (1) {
		int n;
		cin >> n;
		if (n == 0) break;
		cout << cnt[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
   int num[N];
    for(int i=0;i<N;i++){
        cin>>num[i];
    }
    sort(num,num+N);
    int suma=0;
    int sumb=0;
    if(N%2==0){
        for(int i=0;i<N;i+=2){
            sumb=sumb+num[i];
        }
        for(int i=1;i<N;i+=2){
            suma=suma+num[i];
        }
        cout<<suma-sumb;
    }
    else{
        for(int j=0;j<N;j+=2){
            suma=suma+num[j];
        }
        for(int j=1;j<N;j+=2){
            sumb=sumb+num[j];
        }
        cout<<suma-sumb;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	if n == "a" || n == "b" || n == "c" || n == "d" || n == "e" || n == "f" || n == "g" || n == "h" || n == "i" || n == "j" || n == "k" || n == "l" || n == "m" || n == "n" || n == "o" || n == "p" || n == "q" || n == "r" || n == "s" || n == "t" || n == "u" || n == "v" || n == "w" || n == "x" || n == "y" || n == "z" {
		fmt.Println("a")
		return
	}
	fmt.Println("A")
}

Measured memory_bytes: 1768
n = int(input())
p = list(map(int,input().split(" ")))
counter = 0
for i in range(1,n-1):
    if (p[i]>p[i-1] and p[i+1]>p[i]) or (p[i]>p[i+1] and p[i-1]>p[i]):
        counter += 1
print(counter)



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

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<string,int> S;

    for(int i=0; i<N; i++){
        string s; cin >> s;
        if(S.count(s)){
            S.at(s)++;
        }else{
            S[s] = 1;
        }
    }

    int m=0;
    for(auto p : S){
        auto v = p.second;
        if(v > m){
            m = v;
        }
    }
    for(auto p :S){
        auto k = p.first;
        auto v = p.second;
        if(v == m)
            cout << k << endl;
    }

}

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

struct tree{
  vector<vector<int>> G,son,ancestor;
  vector<int> depth,parent;
  queue<int> que;
  int root=-1;
  bool made_lca=false;

  tree(int n):G(n),son(n),parent(n,-1),depth(n,-1),ancestor(n){
    for(int i=0;i<n;i++)ancestor[i].resize(30);
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  inline void reset_root(){
    root=-1;
    fill(depth.begin(),depth.end(),-1);
    fill(parent.begin(),parent.end(),-1);
    for(auto &p:ancestor)for(int &q:p)q=-1;
    for(auto &p:son)p.resize(0);
    made_lca=false;
  }

  void have_root(int r){
    reset_root();
    root=r;
    que.push(r);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:G[p]){
        if(parent[p]==q)continue;
        son[p].push_back(q);
        parent[q]=p;
        que.push(q);
      }
    }
  }

  void set_depth(){
    assert(~root);
    depth[root]=0;
    que.push(root);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:son[p]){
        depth[q]=depth[p]+1;
        que.push(q);
      }
    }
  }

  inline void make_lca(){
    assert(~root);
    if(depth[root]<0)set_depth();
    for(int i=0;i<G.size();i++)ancestor[i][0]=parent[i];
    for(int j=1;j<30;j++)
      for(int i=0;i<G.size();i++)
        if(~ancestor[i][j-1])
          ancestor[i][j]=ancestor[ancestor[i][j-1]][j-1];
    made_lca=1;
  }

  int lca(int u,int v){
    if(!made_lca)make_lca();
    if(depth[u]>depth[v])swap(u,v);
    int diff=depth[v]-depth[u],cnt=0;
    while(diff){
      if(diff&1)v=ancestor[v][cnt];
      cnt++;
      diff>>=1;
    }
    if(u==v)return u;
    for(int k=28;k>=0;k--)
      if(ancestor[u][k]!=ancestor[v][k])
        u=ancestor[u][k],v=ancestor[v][k];
    return ancestor[u][0];
  }
};
typedef pair<int,int> P;
int used[223456];

signed main(){
  int n,k;cin>>n>>k;
  tree t(n);
  int ans=0;
  int a;cin>>a;if(a>1)ans++;
  for(int i=1;i<n;i++){
    int u;cin>>u;u--;
    t.add_edge(i,u);
  }
  t.have_root(0);
  t.set_depth();
  priority_queue<P> que;
  queue<int> Q;
  for(int i=0;i<n;i++)if(!t.son[i].size())que.push(P(t.depth[i],i));
  while(que.size()){
    P p=que.top();que.pop();
    int idx=p.second;
    if(used[idx]){
      int tmp=t.parent[idx];
      if(t.depth[tmp]>k&&!used[tmp])que.push(P(t.depth[tmp],tmp));
      continue;
    }
    used[idx]=1;
    for(int i=0;i<k-1;i++){
      if(!idx)break;
      Q.push(t.parent[idx]);
      while(Q.size()){
        int b=Q.front();Q.pop();
        for(int q:t.son[b]){
          if(used[q])continue;
          used[q]=1;
          Q.push(q);
        }
      }
      idx=t.parent[idx];used[idx]=1;
    }
    if(idx&&t.parent[idx]){
      ans++;
      idx=t.parent[idx];
      if(t.depth[idx]>k)que.push(P(t.depth[idx],idx));
    }
  }
  cout<<ans<<endl;
}


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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

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

	int mx = max(a,b);
	vector<int> c;
	for (int i = 1; i <= mx; i++) {
		if(a%i==0 && b%i==0) c.push_back(i);
	}

	sort(c.rbegin(), c.rend());

	cout << c[k-1] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    bool ok = 1;
    int H = in(),W = in(),A = in(),B = in();
    if(W - A < A)ok = 0;
    if(H - B < B)ok = 0;
    string one = "",two = "";
    REP(i,W){
        if(i < A){
            one += '1';
            two += '0';
        }else{
            one += '0';
            two += '1';
        }
    }
    REP(i,H){
        if(i < B){
            cout << one << "\n";
        }else{
            cout << two << "\n";
        }
    }
}

Measured memory_bytes: 1280
k,t=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==1:
  print(k-1)
else:
  if k%2==0:
    print(max(0,(max(l)-k//2)*2-1))
  else:
    print(max(0,(max(l)-k//2-1)*2))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int,int> Entry;

bool cmp(const Entry &e1, const Entry &e2) {
    if(e1.first != e2.first) return e1.first > e2.first;
    return e1.second < e2.second;
}

int main() {
    while(true) {
        int N, M;
        cin >> N >> M;
        if(!N && !M) break;

        vector<Entry> cnt(M);
        for(int i = 0; i < M; ++i) {
            cnt[i].first = 0;
            cnt[i].second = i+1;
        }
        while(N--) {
            for(int i = 0; i < M; ++i) {
                int f;
                cin >> f;
                if(f == 1) cnt[i].first++;
            }
        }
        sort(cnt.begin(), cnt.end(), cmp);
        for(int i = 0; i < M-1; ++i) {
            cout << cnt[i].second << ' ';
        }
        cout << cnt[M-1].second << endl;
    }
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a+b) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque


def main():
    N, M, *AB = map(int, sys.stdin.buffer.read().split())
    
    g = [[] for _ in range(N + 1)]

    for A, B in zip(*[iter(AB)] * 2):
        g[A].append(B)
        g[B].append(A)

    queue = deque([1])
    d = [0] * (N + 1)
    d[0] = 1
    d[1] = 1

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if not d[i]:
                d[i] = v
                queue.append(i)

    if all(d):
        print("Yes")
        print("\n".join(map(str, d[2:])))
    else:
        print("No")


if __name__ == '__main__':
	main()

exit()


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

typedef long long LL;
int INF=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(false);
    
    LL A,B,C,D,E,F;
    LL ans1=0,ans2=0;
    double tmp,LD=-1;
    cin>>A>>B>>C>>D>>E>>F;
    
    for(int a=0;a*A*100<=F;a++){
        for(int b=0;a*A*100+b*B*100<=F;b++){
            for(int c=0;a*A*100+b*B*100+c*C<=F;c++){
                for(int d=0;a*A*100+b*B*100+c*C+d*D<=F;d++){
                    if(c*C+d*D>(a*A+b*B)*E) break;
                    tmp=(1.0)*(c*C+d*D)/(a*A*100+b*B*100+c*C+d*D);
                    if(LD<tmp) {LD=tmp;ans1=(a*A*100+b*B*100+c*C+d*D);ans2=(c*C+d*D);}
                }
            }
        }
    }
    
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for B - Maximum Difference
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Sort(sort.IntSlice(A))

	fmt.Println(A[N-1] - A[0])
}


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

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int l[100005], r[100005];

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        l[i + 1] = gcd(l[i], a[i]);
    }
    for (int i = n - 1; i >= 0; i--) {
        r[i] = gcd(r[i + 1], a[i]);
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = max(ans, gcd(l[i], r[i + 1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
 
int main()
{
    double cx = 0, cy = 0, r = 0;
    int q = 0;
    double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
 
    cin >> cx >> cy >> r >> q;
 
    for (int i = 0; i < q; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
 
        double a = 0, b = 0, s = 0, t = 0, u = 0,
            v1 = 0, v2 = 0, w1 = 0, w2 = 0;
 
        if (x1 == x2) {
            v1 = x1;
            v2 = x2;
            w1 = cy - sqrt(r * r - (x1 - cx) * (x1 - cx));
            w2 = cy + sqrt(r * r - (x1 - cx) * (x1 - cx));
        }
        else {
            a = (y2 - y1) / (x2 - x1);
            b = (x2 * y1 - x1 * y2) / (x2 - x1);
 
            s = a * a + 1;
            t = a * b - a * cy - cx;
            u = cx * cx + (b - cy) * (b - cy) - r * r;
 
            v1 = (-t - sqrt(t * t - s * u)) / s;
            v2 = (-t + sqrt(t * t - s * u)) / s;
            w1 = a * v1 + b;
            w2 = a * v2 + b;
        }
 
        cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(8)
             << v1 << " " << w1 << " " << v2 << " " << w2 << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3272
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>T(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	vector<int>P(M);
	vector<int>X(M);
	for (int i = 0; i < M; i++) {
		cin >>P[i] >> X[i];
	}
	for (int i = 0; i < M; i++) {
		cout << sum - T[P[i] - 1] + X[i] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=b*d;
	
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	cout<<ans<<endl;}

Measured memory_bytes: 3632
#include <stdio.h>


char str[102];

int solve(){
	int stack[101]={};
	int i,p=0;
	for(i=0;str[i]!='.';i++){
		switch(str[i]){
			case '(':
				p++;
				stack[p]=1;
				break;
			case ')':
				if(stack[p]==1){
					p--;
				}else{
					return 1;
				}
				break;
			case '[':
				p++;
				stack[p]=2;
				break;
			case ']':
				if(stack[p]==2){
					p--;
				}else{
					return 1;
				}
				break;
		}
	}
	if(p==0){
		return 0;
	}else{
		return 1;
	}
}

int main(void){
	while(fgets(str,102,stdin),str[0]!='.'){
		if(!solve()){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 524
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				String buf = br.readLine();
				StringTokenizer st = new StringTokenizer(buf);
				double x[] = new double[3];
				double y[] = new double[3];
				for (int j=0;j<3;j++) {
					x[j] = Double.parseDouble(st.nextToken());
					y[j] = Double.parseDouble(st.nextToken());
				}

				double d1 = x[1]-x[0];
				double d2 = y[1]-y[0];
				double d3 = x[2]-x[0];
				double d4 = y[2]-y[0];

				double midx[] = new double[2];
				double midy[] = new double[2];
				midx[0] = mid(x[0],x[1]);
				midy[0] = mid(y[0],y[1]);
				midx[1] = mid(x[0],x[2]);
				midy[1] = mid(y[0],y[2]);

				double a,b,c,d,e,f;
				if (d2==0) {
					a = 1.0;
					b = 0.0;
					c = midx[0];
				} else {
					a = d1/d2;
					b = 1.0;
					c = a*midx[0]+midy[0];
				}
				if (d4==0) {
					d = 1.0;
					e = 0.0;
					f = midx[1];
				} else {
					d = d3/d4;
					e = 1.0;
					f = d*midx[1]+midy[1];
				}

				double det1 = (double)a*e-b*d;
				double det2 = (double)c*e-b*f;
				double det3 = (double)a*f-c*d;
				if (det1 == 0.000) System.out.println("解なしor解がたくさん");
				else {
					String cx = String.format("%.3f",(double)Math.round((det2/det1)*1000)/1000);
					String cy = String.format("%.3f",(double)Math.round((det3/det1)*1000)/1000);
					String r = String.format("%.3f",(double)Math.round(dist(det2/det1,det3/det1,x[0],y[0])*1000)/1000);
					System.out.println(cx+" "+cy+" "+r);
				}
			}
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}

	public static double mid(double p1,double p2) {
		return (p1+p2)/2;
	}

	public static double dist(double sx,double sy,double ex,double ey) {
		return Math.sqrt(Math.pow(ex-sx,2)+Math.pow(ey-sy,2));
	}
}

Measured memory_bytes: 17024
import math
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    a=LIST()
    ans=1
    a=sorted(a)
    for i in a:
        ans*=i
        if ans>10**18:
            ans=-1
            break
    print(ans)
if __name__ == '__main__':
    do()

Measured memory_bytes: 22524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(3*N);
  for(int i=0;i<3*N;i++){
      cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int64_t sum=0;
  for(int i=1;i<2*N;i+=2){
    sum+=A.at(i);
  }
  cout << sum << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    
    int b[100004]={0};
    for (int i=0; i<N; i++) {
        b[a[i]]++;
    }
    int max=0;
    for (int i=0; i<N; i++) {
        int y;
        if (a[i]==0) {
            y=b[a[i]]+b[a[i]+1];
        }else{
            y=b[a[i]+1]+b[a[i]]+b[a[i]-1];
        }
        if (y>max) {
            max=y;
        }
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <stdio.h>
#include <string>
#include<algorithm>
using namespace std;
 
long long zet(long long inp){
    if(inp>0){
        return inp;
    }else{
        return -inp;
    }
}

int main(){
    long long N,K;
    cin >> N >> K;
    long long x[N];
    long long i;
    long long c=0;
    long long m;
    for(i=0;i<N;i++){
        scanf("%lld",&x[i]);
        m=min(x[i],zet(K-x[i]));
        c+=2*m;
    }
    cout << c <<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int dp[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++) dp[i] = i;
	for (int i = 6; i <= n; i *= 6)
	{
		for (int j = i; j <= n; j++)
		{
			dp[j] = min(dp[j], dp[j - i] + 1);
		}
	}
	for (int i = 9; i <= n; i *= 9)
	{
		for (int j = i; j <= n; j++)
		{
			dp[j] = min(dp[j], dp[j - i] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

Measured memory_bytes: 4056
//每一次操作：对总和-1
//总和充分大时
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
ll a[55];
int main(){
	int n;
	ll x,sum=0LL;
	scanf("%d",&n);
	rep(k,n){
		scanf("%lld",&a[k]);
		sum+=a[k];
	}
	ll ap=0LL;
	multiset<ll> St;
	//Ai-P*n+max(0,(S-(ap+P)-(Ai-P*n)-(n-1)*(n-1))/2)<n
	//Ai-n<n*P and 2*Ai-2*P*n+S-(ap+P)-(Ai-P*n)-(n-1)*(n-1)<2*n Ai+S-ap-n*n-1<(n+1)P
	//P=max((a[k]+ap)/n,(a[k]+S-n*n-1))
	rep(k,n){
		ll P=max((a[k]+ap)/n,(sum+a[k]-n*n-1)/(n+1));
		ap+=P;
		a[k]-=P*(n+1);
		St.insert(a[k]);
	}
	while(*(St.rbegin())>=ll(n)-ap){
		ll out=*(St.rbegin());
		St.erase(St.find(out));
		out-=ll(n+1);
		St.insert(out);
		ap++;
	}
	printf("%lld\n",ap);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll N, M;
ll A[100010];
ll sum;
map<int, ll> mp;
int main(){
    cin >> N >> M;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= N; i++){
        sum += A[i];
        sum %= M;
        mp[sum]++;
    }
    ll ans = 0;
    for(auto& u : mp){
        if(u.first == 0) ans += u.second;
        ans += u.second * (u.second - (ll)1) / (ll)2;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	int n = s.size();
	if(n == 1){
		cout << k/2 << endl;
	}else if(n == 2){
		if(s[0] == s[1]){
			cout << k << endl;
		}else{
			cout << 0 << endl;
		}
	}else{
		bool same = true;
		for(int i(1);i<n;++i){
			if(s[i-1] != s[i]) same = false;
		}
		if(same){
			cout << (n*k)/2 << endl;
		}else{
			if(s[0] != s[n-1]){
				ll cnt1(1), cnt2(0);
				for(int i(1);i<n;++i){
					if(s[i-1] == s[i]){cnt1++;}
					if(s[i-1] != s[i] && cnt1 >= 2){
						cnt2 += cnt1/2;
						cnt1 = 1;
					}
				}
				if(cnt1 >= 2) cnt2 += cnt1/2;
				cout << k*cnt2 << endl;	
			}else{
				int l,r;
				ll cnt(2);
				for(int i(1);i<n;++i){
					if(s[i] != s[0]){
						l = i;
						break;
					}
					cnt++;
				}
				for(int i(n-2);i>=0;--i){
					if(s[i] != s[n-1]){
						r = i;
						break;
					}
					cnt++;
				}
				ll ans = (k-1) * (cnt/2);
				ans += l/2;
				ans += (n-1-r)/2;
				if(l != r){
					ll cnt1(1),cnt2(0);
					for(int i(l);i<=r;++i){
						if(s[i-1] == s[i]){cnt1++;}
						if(s[i-1] != s[i] && cnt1 >= 2){
							cnt2 += cnt1/2;
							cnt1 = 1;
						}
					}
					if(cnt1 >= 2) cnt2 += cnt1/2;
					ans += k*cnt2;
				}
				cout << ans << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100010;
int t,ok,l[15],r[15],a[15];
void dfs(int i,int x,int y){
	if(i==11){ok=1;return;}
	if(a[i]>l[x]){
		l[x+1]=a[i];
		dfs(i+1,x+1,y);
	}
	if(a[i]>r[y]){
		r[y+1]=a[i];
		dfs(i+1,x,y+1);
	}
}
int main()
{
	cin>>t;
	while(t--){
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		for(int i=1;i<=10;i++)cin>>a[i];
		ok=0;
		dfs(1,0,0);
		if(ok==1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()
    N = len(S)

    if S != S[::-1]:
        print("No")
        return

    tmp = S[:(N - 1) // 2]
    if tmp != tmp[::-1]:
        print("No")
        return

    tmp = S[(N + 3) // 2 - 1:]
    if tmp != tmp[::-1]:
        print("No")
        return

    print("Yes")


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 15;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;

ll n, k;
ll ans = 0;

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    for (ll ch = k; ch <= n + 1; ch++)
    {
        ll mn = ch * (ch - 1) / 2;
        ll mx = (n + n - ch + 1) * ch / 2;
        ans = (ans + mx - mn + 1) % MOD;
    }
    cout << ans;
}


Measured memory_bytes: 3648
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for (j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

int main() {
  int i, q;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  q = partition(0, n - 1);

   for (i = 0; i < n; i++) {
     if (i) printf(" ");
     if (i == q) printf("[");
     printf("%d", A[i]);
     if (i == q) printf("]");
   }
   printf("\n");

   return 0;
}


Measured memory_bytes: 2172
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x,ans=0;
  cin >> a >> b >> c >> x;
  for(int i=0; i<=a; i++) {
    for(int j=0; j<=b; j++) {
      if(x-i*500-j*100>=0&&(x-i*500-j*100)%50==0&&x-i*500-j*100<=c*50) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll h;
    cin>>h;
    int po=log2(h)+1;
    cout<<(1ll<<po)-1<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3756
n, m = map(int, input().split())
alist = list(map(int, input().split()))

crit = 1/4/m * sum(alist)

count = 0

for a in alist:
    if a >= crit:
        count += 1

# print(count)

if count >= m:
    print('Yes')
else:
    print('No')

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a>12){
		cout << b;
	}
	else if(a<=12 && a>=6){
		cout << b/2;
	}
	else{
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (void) {

  int N;
  int A[100010];
  int i;
  int check[100010] = {0};
  int flag = 1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    check[A[i]]++;
  }

  /*
  for(i=0;i<N;i++){
    printf("i:%d %d\n",i,check[i]);
  }
  */
  
  if(N%2==0){
    for(i=0;i<N;i++){
      if(flag && i%2==0 && check[i]!=0){
	flag = 0;
	break;
      }
      if(flag && i%2==1 && check[i]!=2){
	flag = 0;
	break;
      }
    }
  } else {
    for(i=0;i<N;i++){
      if(flag && i==0 && check[i]!=1){
	flag = 0;
	break;
      }
      if(flag && i%2==1 && check[i]!=0){
	flag = 0;
	break;
      }
      if(flag && i>0 && i%2==0 && check[i]!=2){
	flag = 0;
	break;
      }
      //printf("i:%d flag:%d\n",i,flag);
    }
  }

  long int ans;
  if(flag){
    for(ans=1,i=0;i<N/2;i++){
      ans = ans * (long)2;
      ans %= 1000000007;
    }
  } else {
    ans = 0;
  }

  printf("%ld\n",ans);
	

  return 0;
}


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

const int MAXSIZE = 100000;
const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_nDept(END), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  rvoNod.resize(MAXSIZE, oNod);

  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod> &rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    if (cnrvoNod[i].m_nDept == END)  break;
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 5748
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct Tyouten{
  double x;
  double y;
  struct Tyouten *next;
}Tn;

Tn *an, *bn, *cn;

void Ball(Tn* p,Tn* q){
  Tn *xn, *yn, *zn;
  xn=(Tn*)malloc(sizeof(Tn));
  xn->x=(q->x - p->x)/3.0+p->x;
  xn->y=(q->y - p->y)/3.0+p->y;
  yn=(Tn*)malloc(sizeof(Tn));
  yn->x=(q->x - p->x)/3.0*2+p->x;
  yn->y=(q->y - p->y)/3.0*2+p->y;
  zn=(Tn*)malloc(sizeof(Tn));
  zn->x=1/sqrt(3.0)* ((q->x - p->x) * cos(M_PI/6.0)-(q->y - p->y)*sin(M_PI/6.0))+p->x;
  zn->y=1/sqrt(3.0)* ((q->x - p->x) * sin(M_PI/6.0)+(q->y - p->y)*cos(M_PI/6.0))+p->y;
  p->next=xn;
  xn->next=zn;
  zn->next=yn;
  yn->next=q;
  cn=q;
}

int main(void){
  int i,n;
  scanf("%d",&n);

  an=NULL;
  bn=NULL;
  an=(Tn*)malloc(sizeof(Tn));
  an->x=0;
  an->y=0;
  bn=(Tn*)malloc(sizeof(Tn));
  bn->x=100;
  bn->y=0;
  cn=an;
  an->next=bn;
  bn->next=NULL;

  for(i=0;i<n;i++){
    cn=an;
    while(cn!=bn)
      Ball(cn,cn->next);
  }
  cn=an;
  while(cn!=NULL){
    printf("%.8f %.8f\n",cn->x,cn->y);
    cn=cn->next;
  }
  return 0;
}



Measured memory_bytes: 2108
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for pattern in combinations_with_replacement(range(1, M + 1), N):
    tmp_ans = 0
    pattern = list(pattern)
    for a, b, c, d in X:
        if pattern[b - 1] - pattern[a - 1] == c:
            tmp_ans += d
    ans = max(ans, tmp_ans)

print(ans)

Measured memory_bytes: 9112
n=int(input())
l=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l2=[]
  if l1[1]==0:
    l2=["0" for j in range(n)]
  else:
    for j in range(n):
      if j+1 in l1[2:]:
        l2.append("1")
      else:
        l2.append("0")
  print(" ".join(l2))


Measured memory_bytes: 5604
#include<stdio.h>
#include<math.h>


#define MAX 999999


int Primes[ MAX + 1 ] ;


int IsPrime( int n )
{
	if( n < 2 )
	{
		return 0 ;
	}

	else if( n == 2 )
	{
		return 1 ;
	}

	else if( n % 2 == 0 )
	{
		return 0 ;
	}

	else
	{
		int i = 3 ;
		for( ; i <= sqrt( n ) ; i += 2 )
		{
			if( n % i == 0 )
			{
				return 0 ;
			}
		}
	}

	return 1 ;
}

int main( void )
{
	int i ;
	for( i = 1 ; i <= MAX ; ++i )
	{
		Primes[ i ] += IsPrime( i ) + Primes[ i - 1 ] ;
	}

	int N ;
	while( scanf( "%d" ,&N ) != EOF )
	{
		printf( "%d\n" ,Primes[ N ] ) ;
	}

	return 0 ;
}


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

vector<int> a(100001, -1);

int dp(int b) {
	if (!b) return 0;
	if (a[b] != -1) return a[b];
	vector<int> c;
	if (1 <= b) c.push_back(dp(b - 1) + 1);
	for (int i = 6; i <= b; i *= 6) c.push_back(dp(b - i) + 1);
	for (int i = 9; i <= b; i *= 9) c.push_back(dp(b - i) + 1);
	a[b] = *min_element(c.begin(), c.end());
	return a[b];
}

int main() {
	int N;
	cin >> N;
	cout << dp(N);
}

Measured memory_bytes: 9984
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;

int main()
{
	int n,sum=0;
    cin>>n;
    int a[n*2];
    rep(i,n*2)cin>>a[i];
    sort(a,a+n*2);
    rep(i,n*2) sum+=a[i],i++;
    cout<<sum<<endl;
	
    return 0;
}


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

int main(){
 	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	
	vector<int> xcity(N);
	vector<int> ycity(M);
  for(int i = 0; i< N;i++)
    cin >> xcity[i];
  for(int i = 0; i< M;i++)
    cin >> ycity[i];
  
  
	bool war = true;
	for(int z = X+1;z <= Y; z++){
		bool ok = true;
		for(int i=0;i<N;i++)
		{
			if(z <= xcity[i] ) {
				ok = false;
				break;
			}
		}
		if(!ok)
			continue;
		for(int i=0;i<M;i++)
		{
			if(z > ycity[i] ) {
				ok = false;
				break;
			}
		}
		if(ok)
		{
			war = false;
			break;
		}
	}
	cout << (war? "War" :  "No War") << endl;
}



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

using namespace std;

string sign=".<>^v";
const int N=1e3+10;

int n,m;
int ans[N][N];

bool DP(int n1,int n2,int dx,int dy){
        if (!n1&&!n2) return 1;

        if (dx>=min(4,n)) return 0;
        if (dy>=min(4,m)) return DP(n1,n2,dx+1,0);
        int px=1+dx,py=m-dy;
        if (n1&&py<m&&!ans[px][py]&&!ans[px][py+1]){
                ans[px][py]=1;
                ans[px][py+1]=2;
                if (DP(n1-1,n2,dx,dy+1)) return 1;
                ans[px][py]=ans[px][py+1]=0;
        }
        if (n2&&px>=2&&!ans[px-1][py]&&!ans[px][py]){
                ans[px-1][py]=3;
                ans[px][py]=4;
                if (DP(n1,n2-1,dx,dy+1)) return 1;
                ans[px-1][py]=ans[px][py]=0;
        }
        return DP(n1,n2,dx,dy+1);
}
int main(){
        int u1,u2;
        cin>>n>>m>>u1>>u2;
        if (2*(u1+u2)>n*m){
                cout<<"NO";
                return 0;
        }
        int flip=0;
        if (n%2==0){
                flip=1;
                swap(n,m);
                swap(u1,u2);
                for(int i=1;i<=2;i++) swap(sign[i],sign[i+2]);
        }
        if (n&1){
                for(int i=1;i<=m-1&&u1;i+=2){
                        ans[n][i]=1;
                        ans[n][i+1]=2;
                        u1--;
                }
        }
        if (m&1){
                for(int i=n;i>=2&&u2;i-=2){
                        ans[i][m]=4;
                        ans[i-1][m]=3;
                        u2--;
                }
        }
        for(int xa=n-(n%2);xa>=2;xa-=2)
                for(int ya=2;ya<=m&&(u1>=2||u2>=2);ya+=2){
                        if (u1>=2){
                                ans[xa-1][ya-1]=ans[xa][ya-1]=1;
                                ans[xa-1][ya]=ans[xa][ya]=2;
                                u1-=2;
                        }else{
                                u2-=2;
                                ans[xa-1][ya-1]=ans[xa-1][ya]=3;
                                ans[xa][ya-1]=ans[xa][ya]=4;
                        }
                }
        if (u1>2||u2>2||!DP(u1,u2,0,0)){
                cout<<"NO";
                return 0;
        }
        if (flip){
                for(int i=1;i<N;i++)
                        for(int j=i;j<N;j++) swap(ans[i][j],ans[j][i]);
                swap(n,m);
        }
        
        cout<<"YES\n";
        for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++)
                        cout<<sign[ans[i][j]];
                cout<<'\n';
        }
}


Measured memory_bytes: 5248
kuku = [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81]
if int(input()) in kuku:
    print('Yes')
else:
    print('No')

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

int main(){
  int n,x1,x2,y1,y2,z1,z2,w1,w2,x,y,z,w;

  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
      x=x1*x2 + y1*y2*(-1) + z1*z2*(-1) + w1*w2*(-1);
      y=x1*y2 + y1*x2 + z1*w2 + w1*z2*(-1);
      z=x1*z2 + y1*w2*(-1) + z1*x2 + w1*y2;
      w=x1*w2 + y1*z2 + z1*y2*(-1) + w1*x2;
      
      cout << x << ' ' << y << ' ' << z << ' ' << w << '\n';
    }
  }
  return 0;
}



Measured memory_bytes: 3024
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 2200000 
#define MAXCARDS 100000

long long alNumber[MAXCARDS];
long long alTimes[MAXCARDS];
char sInput[MAX_STRING];
int compare(long long*a,long long*b);
	int main() {

	char* psInput;
	long long l=0;
	int i=0;
	int j=0;
	long long lTemp2=0;
	long long lKinds=0;
	long long  lCardsNumber =0;
	long long  lMax = 0;
	long long  lTop = 0;
	long long  lSecond = 0;
	long long  lSquare = 0;
	long long  lTarget=0;
	long long  lFound=0;
	long long  lAnswer=0;
	long long  lTimes=0;
	long long  lNumber=0;
	long long  lBefore=0;
	long long  lCount=0;
	int nFlag=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
/*	for (i=0;i<lCardsNumber;i++){
//		alNumber[i]=0;
		alTimes[i]=0;
	}*/
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		alNumber[i]=atol(psInput);
		psInput = strtok(NULL," ");
	}
    qsort(alNumber, lCardsNumber, sizeof(long long),
        (int (*)(const void *, const void *))compare
    );

	for (i=lCardsNumber-1;i>=0;i--){
		lNumber=alNumber[i];
		nFlag=0;
		if (lBefore==lNumber){
			lCount++;
			nFlag=1;
		} 
		if (nFlag==0||i==0) {
			if(lCount>=4&&lSquare==0){
				lSquare=lBefore;
			}
			if(lCount>=2){
				if(lTop==0){
					lTop=lBefore;
				} else if (lSecond==0) {
					lSecond=lBefore;
				}
			}
			lBefore = lNumber;
			lCount=1;
		}
		if (lSquare>0||(lTop>0&&lSecond>0)){
			break;
		}
	}
	lAnswer=lTop*lSecond;
	if (lAnswer<lSquare*lSquare){
			lAnswer=lSquare*lSquare;
	}
	printf("%ld\n",lAnswer);

    return 0;
}

int compare(long long*a,long long*b){
    unsigned long long v=*b-*a;
    return v?(v>>63<<1)-1:0;
}

Measured memory_bytes: 2684
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
	string s;
	ll a = 0;
	cin >> s;
	s += " ";
	ll ans = 0;
	rep(i,s.size()) {
		if (s[i] == 'A') {
			a++;
		} else if (s[i] == 'B' && s[i + 1] == 'C') {
			ans += a;
			i++; 
		} else {
			a = 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 832
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long lint;

void test_case() {
    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int q=1;
    //cin >> q;
    while(q--) {
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3640