akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()

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

    int cx = 0, cy = 0, ct=0;
    bool ans = true;
    REP(i, N) {
        int x, y, t;
        cin >> t >> x >> y;

        int rest = (t-ct) - (abs(cx-x) + abs(cy-y));
        if (rest < 0 || rest % 2 == 1) {
            ans = false;
        }

        cx = x;
        cy = y;
        ct = t;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool good(int n){
//	cout<<trunc(sqrt(n)) * trunc(sqrt(n))<<endl;
	return (n == trunc(sqrt(n)) * trunc(sqrt(n)));
}
int main(){
	int t; cin>>t;
	
	while(!good(t)){
		t--;
	}
	cout<<t<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,ax[5]={2,3,5,7,11};
int n,a[N],tot,sum,lim,b=2*3*5*7*11;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=30000;i++)
	{
		int flag=0;
		for(int j=0;j<5;j++)if(i%ax[j]==0)flag=1;
		if(flag)a[++tot]=i,sum+=i;
		if(tot==n-1){lim=i+1;break;}
	}
	if(__gcd(sum,b)==1)
	{
		for(int i=lim;i<=30000;i++)
		{
			int flag=0;
			for(int j=0;j<5;j++)if(i%ax[j]==0)flag=1;
			if(flag&&__gcd(sum-a[tot]+i,b)>1){sum+=i-a[tot];a[tot]=i;break;}
		}
	}
	int c=(sum/b+1)*b;
	for(int i=1;i<n;i++)printf("%d ",a[i]);
	int tmp=c-sum;
	while(tmp<=a[tot])tmp+=b;
	printf("%d\n",tmp);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>

using namespace std;

#define N 3
#define N2 9

struct Puzzle {
	int f[N2];
	int space;
	string path;

	bool operator < (const Puzzle &p) const {
		for(int i=0;i<N2;i++){
			if(f[i] == p.f[i]) continue;
			return f[i] > p.f[i];
		}
		return false;
	}
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
	for(int i=0;i<N2;i++){
		if(p.f[i] != (i+1)){
			return false;
		}
	}
	return true;
}


string bfs(Puzzle s){
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u,v;
	s.path = "";
	Q.push(s);
	V[s] = true;

	while(!Q.empty()){
		u = Q.front(); Q.pop();
		if(isTarget(u)) return u.path;
		int sx = u.space / N;
		int sy = u.space % N;
		for(int r=0;r<4;r++){
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if(tx<0 || ty<0 || tx >=N || ty >= N) continue;
			v = u;
			swap(v.f[u.space],v.f[tx*N+ty]);
			v.space = tx * N +ty;
			if(!V[v]){
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	
	return "unsolvable";
}

		

int main(void){
	
	int i;
	Puzzle in;
	string ans;

	for(i=0;i<N2;i++){
		scanf("%d",&in.f[i]);
		if(in.f[i] == 0){
			in.f[i] = N2;
			in.space = i;
		}
	}

	ans = bfs(in);
	printf("%lu\n",ans.size());

	return 0;

}















Measured memory_bytes: 30624
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void

#define bl putchar(' ')
#define ed putchar('\n')

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
priority_queue <double,vector<double>,greater<double> > q;
int n;
int main()
{
	read(n);double temp;
	for(rei i=1;i<=n;++i) cin>>temp,q.push(temp);
	int T=n-1;
	while(T--)
	{
		double m1=q.top();q.pop();
		double m2=q.top();q.pop();
		q.push((m1+m2)/2);
	}
	cout<<q.top();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MATRIX_MAX 101
int main(){
	unsigned long A[MATRIX_MAX][MATRIX_MAX];
	unsigned long B[MATRIX_MAX][MATRIX_MAX];
	unsigned long C[MATRIX_MAX][MATRIX_MAX];
	int row;
	int share;
	int col;
	int i, j, k;
	
	for(i = 0;i < MATRIX_MAX;i++){
		for(j = 0;j < MATRIX_MAX;j++){
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
		}
	}
	
	scanf("%d %d %d", &row, &share, &col);
	
	for(i = 0;i < row;i++){
		for(j = 0;j < share;j++){
			scanf("%d", &A[i][j]);
		}
	}
	
	for(i = 0;i < share;i++){
		for(j = 0;j < col;j++){
			scanf("%d", &B[i][j]);
		}
	}
	

	for(i = 0;i < row;i++){
		for(j = 0;j < col;j++){
			for(k = 0;k < MATRIX_MAX;k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0;i < row;i++){
		for(j = 0;j < col - 1;j++){
			printf("%ld ", C[i][j]);
		}
		printf("%ld\n", C[i][col - 1]);
	}
	
	return 0;
}




Measured memory_bytes: 2080
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int s;
	int l, h;
	bool hm, lm;
	hm = false;
	lm = false;

	scanf("%d", &s);

	h =  s/100;
	l =  s%100;

	if (1 <= h && h <= 12) hm = true;
	if (1 <= l && l <= 12) lm = true;

	if (!hm && !lm) {
		printf("NA\n");
	}
	if (hm && lm) {
		printf("AMBIGUOUS\n");
	}
	if (hm && !lm) {
		printf("MMYY\n");
	}
	if (!hm && lm) {
		printf("YYMM\n");
	}

	return 0;
}


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


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int cnt = 0;
  for (int i=0; i<N;) {
    int n = A[i];
    int j = i + 1;
    int c = 0;
    while (true) {
      if (n == A[j]) {
        ++c;
      } else {
        i = j;
        break;
      }
      ++j;
    }
    if (c % 2 == 0) {
      ++cnt;
    }
  }
  cout << cnt << endl;
}

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

int main(){
    string S;
    long long k;
    cin >> S >> k;
    char last_seen = '0';
    char first = S[0];
    char last = S[S.size()-1];
    long long cont = 0;
    long long cont_ini = 0;
    long long cont_last = 0;
    int i = 0;
    while(i<S.size()){
        if(S[i] == first) cont_ini++;
        else break;
        i++;
    }
    i = S.size()-1;
    while(i>=0){
        if(S[i] == last) cont_last++;
        else break;
        i--;
    }
    if(cont_ini == S.size()){
        cout << (S.size()*k)/2 << "\n";
        return 0;
    }
    for(int i = cont_ini; i<S.size()-cont_last; i++){
        if(S[i] == last_seen){
            last_seen = '0';
            cont++;
        }
        else last_seen = S[i];
    }
    if(first != last){
        long long res = (cont_last/2 + cont_ini/2)*k + (cont)*k;
        cout << res << "\n";
        return 0;
    }
    else{
        long long res = ((cont_last + cont_ini)/2)*(k-1); //intersecciones
        res += cont*k;
        res += cont_ini/2 + cont_last/2;
        cout << res << "\n";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	rep(i, 0, Q) {
		int x; cin >> x;
		int ans(0), sum(0), l(0);
		rep(j, 0, N) {
			sum += a[j];
			while (sum > x)sum -= a[l++];
			ans += j - l + 1;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 1e9;
	rep(i,n){
		int a, cnt = 0;
		cin >> a;
		while(a%2 == 0){
			a /= 2;
			++cnt;
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

// fmt.Scan is high cost
func main() {
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, 1024)
	sc.Buffer(buf, 200020)
	var s string
	sc.Scan()
	s = sc.Text()
	a, z := -1, -1
	for i := 0; i < len(s); i++ {
		if a == -1 && s[i] == 'A' {
			a = i
		}
		if s[i] == 'Z' {
			z = i
		}
	}
	fmt.Println(z - a + 1)
}


Measured memory_bytes: 1280
n,k = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

length = len(format(a[-1],'b'))
string = '0'+str(length)+'b'

ans = 0
while True:
	k_length = len(format(k,'b'))
	if length < k_length:
		ans += n * (2**(k_length - 1))
		k -= 2**(k_length - 1)
	else:
		break

l = [0 for _ in range(length)]

for i in range(len(a)):
	tmp = tuple(format(a[i],string))
	for j in range(length):
		if tmp[j] == '0':
			l[j] += 1

res = '0b'
num = 0
tmp = 2 ** length
for i in range(len(l)):
	tmp //= 2
	if l[i] > n // 2 and num + tmp <= k:
		res = res + '1'
		num += tmp
	else:
		res = res + '0'

x = int(res,2)

for i in range(len(a)):
	ans += x ^ a[i]
print(ans)


Measured memory_bytes: 14620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

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

    void compute() {
        int N = scanner.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            a.add(scanner.nextInt());
        }
        a.sort((o1, o2) -> o1 - o2);
        a.add(-2);

        List<Integer> nList = new ArrayList<>();
        int prev = -2, current = 0;
        for (int ai : a) {
            if (prev == ai) {
                current++;
            } else {
                nList.add(current);
                if (prev + 1 != ai) {
                    nList.add(0);
                    nList.add(0);
                }
                current = 1;
            }
            prev = ai;
        }
        nList = nList.subList(3, nList.size());

        int max = 0;
        for (int i = 0; i < nList.size() - 2; i++) {
            int c = nList.get(i) + nList.get(i + 1) + nList.get(i + 2);
            max = max > c ? max : c;
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 53368
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
  char ch[12];
  cin>>ch;
  int i=0;
  int max=0;
  
  while(ch[i])
  {
    int current=0;
    while(ch[i]=='A'||ch[i]=='T'||ch[i]=='G'||ch[i]=='C')
    {
      i++;
      current++;
    }
    if(max<current)
      max=current;
    i++;
  }
   cout<<max; 
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  float x[N];
  string u[N];
  float sum=0;
  
  for (int i=0;i<N;i++){
    cin>>x[i]>>u[i];
    if (u[i]=="JPY"){
        sum=sum+x[i];
    }
    else sum=sum+x[i]*380000;
  }
  cout<<setprecision(15)<<sum<<endl;
  return 0;
}
    

Measured memory_bytes: 256
n=int(input())
cnt=[0]*n

for a in range(1, n+1):
    for b in range(a, n+1):
        if a*b <= n-1:
                if a==b:
                    cnt[a*b]+=1
                else:
                    cnt[a*b]+=2
        if a*b > n:
            break


print(sum(cnt))

Measured memory_bytes: 76056
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

typedef long long ll;


int main() {
	ll A, B, C;
	ll K;

	cin >> A >> B >> C;
	cin >> K;

	if (K & 1)cout << B - A << endl;
	else cout << A - B << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2 * 10**5)
mod = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    dp = [0] * (K + 1)
    dp[0] = 1
    for i in range(N):
        acc = [0]
        for x in dp:
            acc.append((acc[-1] + x) % mod)
        dp_ = []
        for j in range(K+1):
            dp_.append((acc[j+1] - acc[max(0, j-A[i])] + mod) % mod)
        dp = dp_
    print(dp[K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 135028
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}

int main(){
	int N,Y;
	cin >>N>>Y;
	Y /= 1000;
	for(int a=0; a<=N; a++){
		for(int b=0;b<=N-a; b++){
			if(9*a+4*b == Y-N){
				cout << a << ' ' << b << ' ' << N-a-b << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vector<tuple<string, ll, ll>> a;
  rep(i,n){
    string x;
    ll y;
    cin >> x >> y;
    a.pb(mt(x, 100 - y, i + 1));
  }
  sort(all(a));
  rep(i,n){
    cout << get<2>(a[i])<<"\n";
  }
  cout << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=10000000000000000000
for i in range(0,N-K+1):
    ls=(x[i])
    rs=(x[i+K-1])
    if(ls>0 and rs>0):
        ans=min(ans,rs)
    elif(ls<0 and rs<0):
        ans=min(ans,abs(ls))
    else:
        ans=min(abs(ls)+rs+min(abs(ls),rs),ans)

print(ans)

Measured memory_bytes: 14224
### constant

W = 100
H = 50
D = 30

V = W * H * D

### classes

class SECT
  attr_accessor :xl, :xr, :hl, :hr, :am, :wh, :min_h

  def initialize(xl, xr, hl, hr, am)
    @xl = xl
    @xr = xr
    @hl = hl.to_f
    @hr = hr.to_f
    @am = am.to_f
    @wh = 0.0
    @min_h = (@hl < @hr) ? @hl : @hr
  end

  def dh
    @am / ((@xr - @xl) * D)
  end

  def dt_full
    return Float::INFINITY if @am == 0.0
    (@min_h - @wh) / dh()
  end

  def merge(sct)
    if @min_h != sct.min_h || @wh != sct.wh
      p ['Error', self, sct]
    end
    @xr = sct.xr
    @hr = sct.hr
    @am += sct.am
    @min_h = (@hl < @hr) ? @hl : @hr
  end
end

### main

dn = gets.to_i

dn.times do
  n = gets.to_i
  brds = [[0, H]] + n.times.map{gets.split.map(&:to_i)} + [[W, H]]

  scts = []
  for i in (0..n)
    b0x, b0h = brds[i]
    b1x, b1h = brds[i + 1]
    scts << SECT.new(b0x, b1x, b0h, b1h, 0.0)
  end

  m = gets.to_i
  m.times do
    fi, ai = gets.split.map(&:to_i)
    for sct in scts
      if sct.xl <= fi && fi <= sct.xr
        sct.am += ai
        break
      end
    end
  end
  #p scts

  l = gets.to_i
  ovs = []
  for i in (0...l)
    xi, ti = gets.split.map(&:to_i)
    ovs << [ti, xi, i]
  end
  ovs.sort!
  #p ovs

  t0 = 0.0
  ohs = []

  while ! ovs.empty?
    min_dt = Float::INFINITY
    min_i = nil

    for i in (0...scts.length)
      dt_fi = scts[i].dt_full
      if min_dt > dt_fi
        min_dt = dt_fi
        min_i = i
      end
    end
    #p scts
    #p [min_dt, min_i]

    t1 = t0 + min_dt

    while ! ovs.empty? && ovs[0][0] <= t1
      ti, xi, i = ovs.shift

      for j in (0...scts.length)
        sctj = scts[j]
        if sctj.xl <= xi && xi <= sctj.xr
          ohs[i] = sctj.wh + sctj.dh * (ti - t0)
          break
        end
      end
    end
    break if ovs.empty?

    t0 = t1

    for i in (0...scts.length)
      scti = scts[i]
      if i == min_i
        scti.wh = scti.min_h
      else
        scti.wh = scti.wh + scti.dh * min_dt
      end
    end

    if scts.length == 1
      scts[0].am = 0.0
      next
    end

    min_sct = scts[min_i]
    if min_sct.hl < min_sct.hr
      sct0 = scts[min_i - 1]
      if min_sct.min_h == sct0.min_h && sct0.wh == sct0.min_h
        sct0.merge(min_sct)
        scts.delete_at(min_i)
      else
        sct0.am += min_sct.am
        min_sct.am = 0.0
      end
    else
      sct1 = scts[min_i + 1]
      if min_sct.min_h == sct1.min_h && sct1.wh == sct1.min_h
        min_sct.merge(sct1)
        scts.delete_at(min_i + 1)
      else
        sct1.am += min_sct.am
        min_sct.am = 0.0
      end
    end
  end

  ohs.each{|oh| puts "%.6f" % oh}
end

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

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

int main(){
	int a, b;
	cin>>a>>b;
	int c[a];
	rep(i, a){
		cin>>c[i];
	}
	int d = 0;
	rep(i, a){
		if(c[i] >= b)
			d++;
	}
	cout<< d <<endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

class UF{
private:
	vector<int> root;

public:
	UF(int n){
		root = vector<int>(n, -1);
	}

	int getRoot(int x){
		if(root[x] == -1) return x;
		else return root[x] = getRoot(root[x]);
	}

	void update(int x, int y){
		x = getRoot(x);
		y = getRoot(y);
		if(x == y) return;
		if(x > y) swap(x, y);
		root[y] = x;
	}

};

int main()
{
	int n, m;
	cin >> n >> m;
	UF uf(n);
	for(int i = 0; i < m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		uf.update(x, y);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i == uf.getRoot(i)){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
while(True):
    sc = input().split()
    a = int(sc[0])
    b = int(sc[2])
    op = sc[1]
    if(sc[1] == '+'):
        print(a + b)
    if(sc[1] == '-'):
        print(a - b)
    if(sc[1] == '*'):
        print(a * b)
    if(sc[1] == '/'):
        print(a // b)
    if(sc[1] == '?'):
        break


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

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

int main(void) {
    int n, l, sum_l = 0, max_l = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> l;
        sum_l += l;
        max_l = max(max_l, l);
    }
    
    cout << (sum_l - max_l > max_l? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.reverse()
for i, elem in enumerate(a):
    if i > 0:
        print(" ", end = "")   # i が 0 より大きいとき、つまり最初の要素ではないとき空白を出力
    print(elem, end = "")
print()   # 改行を出力



Measured memory_bytes: 5620
N = gets.to_i
f = Array.new(N){Array.new(10)}
N.times do |i|
  f[i] = gets.chomp.split(" ").map(&:to_i)
end
p = Array.new(N){Array.new(11)}
N.times do |i|
  p[i] = gets.chomp.split(" ").map(&:to_i)
end
max = -1000000000
[0,1].repeated_permutation(10).each do |x|
  next if !x.include?(1)
  num = Array.new(N,0)
  sum = 0
  N.times do |i|
    10.times do |j|
      num[i] += 1 if x[j] == f[i][j] && x[j] == 1
    end
    sum += p[i][num[i]]
  end
  max = sum if max < sum
end
puts max

Measured memory_bytes: 14896
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
bool is_palindrom(string s) {
	string t = s;
	reverse(s.begin(), s.end());
	return s == t;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ld l;
	cin >> l;
	cout << l / 3 * l / 3 * l / 3 << '\n';
 	return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = []
P = [0]*N
for q in range(Q):
	A.append(int(input()))

for q in range(Q):
	P[A[q]-1] += 1
	
for n in range(N):
	if K - (Q - P[n]) > 0:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 8660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int K, i;
  string s;
  
  cin >> K;
  s="ACL";
  rep(i,K-1) s+="ACL";
  
  cout << s;
}

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

int main() {
	
	int n;
	cin >> n;
	string ans = "No";
	if(n%10 == n/100) ans = "Yes";
	cout << ans << endl;	
	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<long> v(n);
  rep(i,n)cin>>v[i];
  bool b=true;
  for(int i=n-1;i>0;i--){
    if(v[i-1]-v[i]>1)b=false;
    else if(v[i-1]-v[i]==1)v[i-1]--;
  }
  if(b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
int main()
{
	int n, s;
	s = 0;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	for (int i = 0; i < n-1; i++)
		s += a[i];
	if (a[n-1] < s)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,K;
    cin >> N >> K;
    vi A(N);
    in(N,A);
    sort(all(A));
    int ans = 0;
    rep(i,K) ans += A[i];
    
    cout << ans << endl;
    

    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        break;
      }
      else if (j == W - 1) {
        for (int k = 0; k < W; k++) {
          a.at(i).at(k) = '%';
        }
      }
    }
  }
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (a.at(j).at(i) == '#') {
        break;
      }
      else if (j == H - 1) {
        for (int k = 0; k < H; k++) {
          a.at(k).at(i) = '%';
        }
      }
    }
  }
  for (int i = 0; i < H; i++) {
    int A = 0;
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) != '%') {
        cout << a.at(i).at(j);
        A = 1;
      }
    }  
    if (A == 1) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
vector<vector<char>> s;
vector<vector<int>> ans;
int h, w;
int num = 1;
void cut(int k, int hs, int ws, int hf, int wf)
{
    // cout << " " << num << endl;
    if (k == 1)
    { //色塗り
        repi(i, hf, hs)
        {
            repi(j, wf, ws)
            {
                ans[i][j] = num;
            }
        }
        num++;
    }
    else
    { //切り分け
        //横割り
        int cnt = 0;
        repi(i, hf, hs)
        {
            repi(j, wf, ws)
            {
                if (s[i][j] == '#')
                {
                    cnt++;
                }
            }
            if (cnt >= k / 2 && cnt < k)
            {
                cut(cnt, hs, ws, i + 1, wf);
                cut(k - cnt, i + 1, ws, hf, wf);
                return;
            }
        }
        //縦割り
        cnt = 0;
        repi(j, wf, ws)
        {
            repi(i, hf, hs)
            {
                if (s[i][j] == '#')
                {
                    cnt++;
                }
            }
            if (cnt >= k / 2 && cnt < k)
            {
                cut(cnt, hs, ws, hf, j + 1);
                cut(k - cnt, hs, j + 1, hf, wf);
                return;
            }
        }
    }
}
int main()
{
    int k;
    cin >> h >> w >> k;
    s.resize(h, vector<char>(w));
    ans.resize(h, vector<int>(w));

    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            cin >> s[i][j];
        }
    }

    cut(k, 0, 0, h, w);

    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            cout << ans[i][j] << ((j + 1) % w ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <map>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

#define MAX_N 200000

template<size_t N>
class UnionFind {
    int par[N];

public:
    UnionFind() {
        for (int n = 0; n < N; n++) par[n] = n;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        par[x] = y;
    }
};

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

    int N, K, L;
    cin>>N>>K>>L;
    UnionFind<MAX_N+1> uf1, uf2;

    for (int k = 0; k < K; k++) {
        int p, q;
        cin>>p>>q;
        uf1.unite(p, q);
    }

    for (int l = 0; l < L; l++) {
        int r, s;
        cin>>r>>s;
        uf2.unite(r, s);
    }

    map<pair<int, int>, int> comp;
    for (int n = 1; n <= N; n++) {
        auto p = make_pair(uf1.root(n), uf2.root(n));
        if (comp.count(p) == 0) comp[p] = 1;
        else comp[p]++;
    }

    for (int n = 1; n <= N; n++) {
        auto p = make_pair(uf1.root(n), uf2.root(n));
        if (n == N) cout<<comp[p]<<endl;
        else cout<<comp[p]<<" ";
    }
    
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

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

  int n;
  cin >> n;
  vector<int> arr(n);
  REP(i, n) cin >> arr.at(i);
  int nswap = 0;
  REP(i, n) {
    int minj = i;
    FOR(j, i, n) {
      if (arr.at(minj) > arr.at(j))
        minj = j;
    }
    if (minj != i) {
      swap(arr.at(minj), arr.at(i));
      nswap++;
    }
  }
  REP(i, n) cout << (i ? " " : "") << arr.at(i);
  cout << endl << nswap << endl;

  return 0;
}


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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::array<int, 3> values;
  std::cin >> values[0] >> values[1] >> values[2];
  std::sort(values.begin(), values.end());
  std::cout << (values[0] == values[2] ? "Yes" : "No") << std::endl;
  return 0;
}


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

int greatest_divisor(int a,int b){
    if(a > b){
        while((a % b) !=0){
            int t = a%b;
            a = b;
            b = t;
        }
        return b;
    }else{
       while((b % a) !=0){
            int t = b%a;
            b = a;
            a = t;
        }
        return a; 
    }
}

int main(){
    int n,a,b;
    cin>>n;
    int count = 0;
    for(int i = 0;i<n;i++){
        int temp = 0;
        cin>>temp;   
        int res = 0;
        if(temp %6 != 1 && temp % 6 != 5 && temp > 6){
              continue;
        }
        int s;
        if(temp > 10){
            s = int(sqrt(temp)) + 2;
        }else{
            s = temp; 
        } 
        for(int j = 2;j < s;j++){
          
          if(greatest_divisor(temp,j) == 1){
              continue;
          }else{
              res = 1;
              break;
          }
        }
        if(res == 0){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3092
input_line = gets.chomp.split(" ")
n = input_line[0].to_i
train_cost_1 = input_line[1].to_i
car_cost_all = input_line[2].to_i
train_cost_all = train_cost_1 * n
if train_cost_all > car_cost_all then
  puts car_cost_all
else
  puts train_cost_all
end

#puts n,a,b

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

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

	while(n!=0){
		cout << nums[n-1];
		if(n!=1)
			cout << " ";
		n--;
	}
	cout << "\n";
}


Measured memory_bytes: 3116
# -*- coding: utf-8 -*-

def main():
    # # 整数の入力
    # a = int(input())
    # スペース区切りの整数の入力
    a, b = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))

    if a % 2 != 0 and b % 2:
        print("Odd")
    else:
        print("Even")

main()


Measured memory_bytes: 2940
n,k=map(int,input().split())
r,s,p=map(int,input().split())
q=str(input())
mukou=[0]*n
ans=0

for i in range(n):
  if i>=k:
    if q[i]==q[i-k] and mukou[i-k]==0:
      mukou[i]=1

for i in range(n):
  if mukou[i]==0:
    if q[i]=="r": ans+=p
    elif q[i]=="s": ans+=r
    else:
      ans+=s
      
print(ans)

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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述
    string S;
    cin >> S;

    bool ans = true;

    REP(i,S.length()){
        if(i % 2 == 0 && S[i] == 'L') ans = false;
        else if(i % 2 == 1 && S[i] == 'R') ans = false;
    }

    if(ans == true) cout << "Yes" << "\n";
    else cout << "No" << "\n";

return 0;
}

Measured memory_bytes: 256
function Main(input) {
    
	var r;
	
	input = input.split("\n");
	
	var line = input[0].split(" ");
	
	r = parseInt(line[0], 10) + parseInt(line[1], 10)
	
	
	if(r >= 10)
	    r = "error"
	
    
	console.log(r);
    
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N = int(input())
A = [int(input()) for x in range(N)]
A.sort()

a = [1, -1]
listA = [0 for x in range(N)]
listB = [0 for x in range(N)]
for i in range(1, N):
    listA[i] += a[i % 2]
    # ビット反転　~
    listA[i - 1] += a[~(i % 2)]

    listB[i - 1] += a[i % 2]
    listB[i] += a[~(i % 2)]

listA.sort()
listB.sort()
listA = [x * y for (x, y) in zip(listA, A)]
listB = [x * y for (x, y) in zip(listB, A)]

ans = max(sum(listA), sum(listB))

print(ans)

Measured memory_bytes: 15692
//
// Created by corol

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio();
    cin.tie(0);
    int n;
    cin >>n;
    string a="",b="";
    for (int i=0;i<n/2;i++) {
        char c;
        cin >> c;
        a+=c;
    }
    for (int i=n/2;i<n;i++) {
        char c;
        cin >> c;
        b+=c;
    }
    cout << (a==b ? "Yes" :"No");
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. \n";
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main(void) {

  while (true) {
    string txt;
    cin >> txt;
    if (txt=="-") break;

    int m;
    cin >> m;

    for (int i=0; i<m; i++) {
      int n;
      cin >> n;
      txt = txt.substr(n) + txt.substr(0,n);
    }
    cout << txt << endl;
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
 
int main(){
    lli a, b, c;
    cin >> a >> b >> c;
    lli tmp = c - a - b;
    if (tmp > 0 && 4*a*b < (tmp*tmp) ){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import operator
for e in iter(input,'0'):
    target = [[*map(int,input().split())]for _ in[0]*int(e)]
    bx, by = min(target)
    target = {(x - bx, y - by) for x, y in target}
    max_tx = max(map(operator.itemgetter(0), target))
    b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
    max_sx = max(map(operator.itemgetter(0), b))
    lim_x = max_sx - max_tx
    for x,y in b:
        if x > lim_x:continue
        for u,v in target:
            if (x + u, y + v) not in b:break
        else:
            print(x - bx, y - by)
            break


Measured memory_bytes: 6104
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(r: int):
    print(r**2)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
A, B = map(int, input().split())

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m, n):
    return int(m*n/gcd(m, n))

print(lcm(A, B))

Measured memory_bytes: 3060
//============================================================================
// Name        : kurk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {

	int a,b,c;

	cin>>a>>b>>c;

	if(a<b&&b<c){

		cout <<  "Yes" << endl;

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



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

int main(){
  long long a, b; cin >> a >> b;
  if (a==1||b==1){
    if(a*b==1) cout << 1 << endl;
    else cout << a*b - 2 << endl;
  } else cout << (a-2)*(b-2) << endl;
}

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

int main(void) {
    string s;
    cin >> s;
    long k;
    cin >> k;

    for(long i=0; i<s.size(); i++) {
        long c = (26 - (s[i]-'a')) % 26;
        if(c <= k)
            s[i] = 'a', k -= c;
    }
    {
        long i = s.size()-1;
        s[i] = ((s[i]-'a'+k)%26) + 'a';
    }
    cout << s << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;

int n;
int x[110], y[110], h[110];

int main(){
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> h[i];
	for (int i = 0; i < n; i++)if (h[i] != 0)swap(x[i], x[0]), swap(y[i], y[0]), swap(h[i], h[0]);
	for (int cx = 0; cx <= 100; cx++){
		for (int cy = 0; cy <= 100; cy++){
			bool flag = 1;
			int H = h[0] + abs(x[0] - cx) + abs(y[0] - cy);
			for (int i = 0; i < n; i++)if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0))flag = 0;
			if (flag)printf("%d %d %d\n", cx, cy, H);
		}
	}
}


Measured memory_bytes: 384
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int co=0;
    rep(a,10){
      rep(b,10){
	rep(c,10){
	  if(n-a-b-c>=0&&n-a-b-c<10)co++;
	}
      }
    }
    cout<<co<<endl;
  }

} 

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

int main(){
    int ans=0, a=0, b=0, c=0;
    char tmp;
    vector<char> S(50, 0);
    string T;
    bool flag=true;
    cin >> T;
    for(int i=0; i<T.size(); i++){
	tmp = T[i]-'a';
	S[tmp]++;
    }
    for(int i=0; i<S.size(); i++){
	if(S[i]%2 == 1)
	    flag = false;
    }
    cout << (flag? "Yes": "No")<< endl;

    
}


Measured memory_bytes: 256
//Name: Unit Converter
//Level: 2
//Category: 文字列
//Note:

/*
 * 数値を文字列として読み、指数表記に直す。
 * そのあと補助単位を処理する。
 *
 * オーダーは O(|S|)。
 */
#include <iostream>
#include <string>
#include <map>

using namespace std;

void solve() {
    map<string,int> dict;

    dict["yotta"] = 24;
    dict["zetta"] = 21;
    dict["exa"] = 18;
    dict["peta"] = 15;
    dict["tera"] = 12;
    dict["giga"] = 9;
    dict["mega"] = 6;
    dict["kilo"] = 3;
    dict["hecto"] = 2;
    dict["deca"] = 1;
    dict["deci"] = -1;
    dict["centi"] = -2;
    dict["milli"] = -3;
    dict["micro"] = -6;
    dict["nano"] = -9;
    dict["pico"] = -12;
    dict["femto"] = -15;
    dict["ato"] = -18;
    dict["zepto"] = -21;
    dict["yocto"] = -24;

    string num, prefix, unit;
    cin >> num >> prefix;
    if(dict.count(prefix)) {
        cin >> unit;
    } else {
        unit = prefix;
        prefix = "";
    }

    int e;
    string real;
    auto dot = num.find_first_of('.');
    if(dot == string::npos) {
        e = (int)num.size() - 1;
        real = num;
    } else {
        string int_part = num.substr(0, dot);
        if(int_part != "0") {
            real += int_part;
            real += num.substr(dot+1);
            e = (int)dot - 1;
        } else {
            auto first = num.find_first_not_of('0', dot+1);
            real = num.substr(first);
            e = (int)dot - first;
        }
    }
    e += dict[prefix];
    cout << real[0];
    if(real.size() > 1) {
        cout << '.' << real.substr(1);
    }
    cout << " * 10^" << e << ' ' << unit << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <stdlib.h>

int compare( const void* a, const void* b);

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);

  int arr[N];
  for(int i = 0; i < N; i++)
    scanf("%d", &arr[i]);

  qsort(arr, N, sizeof(int), compare);

  int ans = 0;
  for(int i = 0; i < K; i++)
    ans += arr[i];

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

  return 0;
}

int compare( const void* a, const void* b) {
  int int_a = * ( (int*) a );
  int int_b = * ( (int*) b );

  if ( int_a == int_b ) return 0;
  else if ( int_a < int_b ) return -1;
  else return 1;
}

Measured memory_bytes: 1708
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    vs <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let vmin = V.minimum vs
        vmax = V.maximum vs
    mv <- MV.replicate (vmax - vmin + 3) 0 :: IO (MV.MVector (PrimState IO) Int)
    V.forM_ vs $ \i -> do
        MV.unsafeModify mv succ (i - vmin)
        MV.unsafeModify mv succ (i + 1 - vmin)
        MV.unsafeModify mv succ (i + 2 - vmin)
    v <- V.unsafeFreeze mv
    print $ V.maximum v


Measured memory_bytes: 5244
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
const LL MOD = 1000000000+7; 
int cnt[1002][1002];
int sum[1002];
int main() 
{ 
    int n;  cin >> n;
    for(int i=1;i<=n;i++)
    {
        int t = i;
        for(int j=2;j<=i;j++)
        {
            while(t%j==0)
            {
                t /= j;
                cnt[i][j]++;
            }
            if(t<j) break;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=2;j<=i;j++)
        {
            sum[j] += cnt[i][j];
        }
    }
    LL res = 1;
    for(int i=1;i<=n;i++)
    {
        res *= (sum[i]+1);
        res %= MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 3968
S = input()
l = m1 = m2 = r = 0
ans = [0] * len(S)
S += 'R'
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        m1 = i
        m2 = i + 1
    if S[i] == 'L' and S[i+1] == 'R':
        r = i + 1
        n = r - l
        if n % 2 == 0:
            ans[m1] = ans[m2] = n // 2
        elif (m1 - l) % 2 == 0:
            ans[m1], ans[m2] = n // 2 + 1, n // 2
        else:
            ans[m1], ans[m2] = n // 2, n // 2 + 1
        l = r
print(*ans)


Measured memory_bytes: 48188
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000009
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    ll n,i,j,k,l,o;
    string s;
    cin>>s;l=0;
    n=s.size();k=0;
    rep(i,0,n-1)
    {
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G')
        k++;
        else
        k=0;
        l=max(k,l);
    }cout<<l;
    return 0;
}


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

using namespace std;
#define int long long
#define N 100005
int a, b, c, n, m, s, t, res, from[N], to[N], cnt;
signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	cin >> b;
	for(int i = 1; i < m; i++)
	{
		a = b;
		cin >> b;
		from[i] = min(a, b);
		to[i] = max(a, b);
	}
	sort(from + 1, from + m);
	sort(to + 1, to + m);
	s = t = 1;
	res = cnt = 0;
	for(int i = 1; i < n; i++)
	{
		cin >> a >> b >> c;
		while(i == from[s])
		{
			cnt++;
			s++;
		}
		while(i == to[t])
		{
			cnt--;
			t++;
		}
		res += min(cnt * a, cnt * b + c);
	}
	cout << res << '\n';
	
}

Measured memory_bytes: 4756
N, M = map(int, input().split())
leng = [set() for i in range(N+1)]
res = 0
for _ in range(M):
  a,b = map(int, input().split())
  leng[a].add(b)
  leng[b].add(a)
def check(arr):
  for i in range(N-1):
    if arr[i+1] not in leng[arr[i]]:
      return False
  return True

import itertools
for i in itertools.permutations([x for x in range(2,N+1)]):
  if check([1]+list(i)):
    res += 1
print(res)

Measured memory_bytes: 9120
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = Counter(A)

    B = []
    for a, b in D.items():
        if b >= 4:
            B.append(a)
            B.append(a)
        elif b >= 2:
            B.append(a)

    B.append(0)
    B.append(0)

    B = sorted(B)[::-1]
    print(B[0] * B[1])


main()


Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll r; cin>>r;
	double ans=2*3.14*r;
	printf("%0.20f",ans);
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3812
#include <iostream>
#include <math.h>
using namespace std;
long long gcd(long long a,long long b){
	if(!b)return a;
	return gcd(b,a%b);
}
int main(){
	long long a,b,g,t,ans=1,tt;
	cin>>a>>b;
	g=gcd(a,b);
	t=g;int ss=sqrt(t);
	for(int i=2;i<=ss;i++){
		if(!(g%i)){
			while(!(g%i))g/=i;
			ans++;
		}
	}
	if(g!=1)ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256