akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace killme
{
    public static class Program
    {
        public static void Main()
        {
            Console.ReadLine();

            var ret = 1.0 / Console.ReadLine()
                .Split(' ')
                .Select(x => double.Parse(x))
                .Select(x => 1.0 / x)
                .Sum();

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < 50000; i++)
    {
        double a = i * 1.08;
        int b = a;
        if(b==n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
#print(ab)
ab.sort()
#print(ab)
for i in range(n):
  k = k-ab[i][1]
  if k <= 0:
    print(ab[i][0])
    exit()

Measured memory_bytes: 27640
#include <stdio.h>
#define c 1000000000

int main(void)
{
	int xa,xb,xc,ya,yb,yc;
	long long int S;
	scanf("%lld",&S);
	xa = 0,ya = 0,xb = c;yb = 1;
	
	
	yc = S/c;
	yc++;
	xc = yc*c-S;
	
	
	if(S/c==c&&S%c==0)
	{
		printf("0 0 1000000000 0 0 1000000000");
		return 0;
	}
	printf("%d %d %d %d %d %d",xa,ya,xb,yb,xc,yc);
	
	return 0;
}




Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int n;
	int i;
	int debt;
	debt = 100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		debt *= 1.05;
		if(debt%1000>0){
			debt = (debt/1000 + 1) * 1000;
		}

	}
	printf("%d\n",debt);
	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  ll N;
  in(N);
  ll mn = 1e18;
  rep(i, 1, (int)sqrt(N) + 1) {
    ll b = N / i;
    if (i * b == N) mn = min(mn, i + b - 2);
  }
  print(mn);
}


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

int main() {
	char S[4]; cin >> S;

	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') cnt++;
	}

	cout << 700 + (cnt * 100) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n;
    cin>>n;
    cout<<180*(n-2);
}

Measured memory_bytes: 256
# まとめるクエリと判定クエリがある
# ランク 木の高さ
# 根はparent[x] = x
# 例題:https://atc001.contest.atcoder.jp/tasks/unionfind_a
class UnionFind
  attr_accessor :parent, :size

  def initialize(n)
    @parent = Array.new(n, &:itself)
    @size = []
    n.times do |i|
      @size[i] = 1
    end
  end

  def unite(x,y)
    x,y = root(x),root(y)
    return if x==y

    x,y = y,x if @size[x] < @size[y]
    @size[x] += @size[y]
    @parent[y] = x
  end

  def same_group?(x, y)
    root(x) == root(y)
  end

  def root(x)
    return x if @parent[x] == x

    @parent[x] = root(@parent[x])
  end

  # グループ数
  def count_group
    # 値と根が一致するものの数がグループ数
    @parent.map.with_index.count{ |n, i| n == i }
    # @parent.map.with_index.count(&:==)
  end

  # 特定のグループに所属する要素数
  def size(x)
    return @size[root(x)]
  end
end




N,M = gets.chomp.split.map(&:to_i)

uf = UnionFind.new(N)

M.times do |i|
  x, y, z = gets.chomp.split.map(&:to_i)


  uf.unite(x-1,y-1)
end

p uf.count_group




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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int X[max(a,b)];
    int count = 0;
    for(int i = min(a,b); 0 < i; i--){
        if(a % i == 0 && b % i == 0){
            count += 1;
        }
        if(count == k){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}



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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int dp[3005][3005];
int main()
{
    string s,t;
    cin >> s >> t;
    int sl = s.length();
    int tl = t.length();

    for (int i = 1; i <= sl; i++)
    {
        for (int j = 1; j <= tl; j++)
        {
            if(s[i-1] == t[j-1])dp[i][j]=dp[i-1][j-1]+1;
            chmax(dp[i][j], dp[i - 1][j]);
            chmax(dp[i][j], dp[i][j-1]);
        }
    }
    //cout << dp[sl][tl] << endl;
    int si, ti;
    si = sl;
    ti = tl;
    string ans = "";
    while(si > 0 && ti > 0)
    {
        if(dp[si][ti] == dp[si][ti - 1])
        {
            ti--;
        }
        else if (dp[si][ti] == dp[si - 1][ti])
        {
            si--;
        }
        else if (dp[si][ti] == dp[si - 1][ti - 1] + 1)
        {
            ans = s[si - 1] + ans;
            si--;
            ti--;
        }
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  bool hantei_1=true;
  bool hantei_2=true;
  cin>>S;
  rep(i,S.size()){
    if(i%2==0){
      if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
        hantei_1=true;}
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
        hantei_1=true;}
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
def get_wa(n):
    ans = 0
    while True:
        if n == 0:
            break
        else:
            ans += n % 10
            n = n //10
    return ans
tmp = N / get_wa(N)

if math.ceil(tmp) == math.floor(tmp):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def warshall_floyd(d, n):
    # d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
a = [list(map(int, input().split())) for _ in range(H)]
n = 10

d = warshall_floyd(c, n)

ans = 0
for i in range(H):
    for j in range(W):
        s = a[i][j]
        if s == 1 or s == -1:
            continue
        ans += d[s][1]
print(ans)


Measured memory_bytes: 3444
#include <stdio.h>
int main(){
	
	int A,B;
	
	scanf ("%d %d" , &A, &B);
	
	if (B%A == 0){
		printf("%d" , A + B);
	}
	else{
		printf("%d" , B - A);
	}
	
	return 0;
}

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

int main(){
    int N, M, X, buf;
    cin >> N >> M >> X;
    vector<bool> A(N+1, false);
    for(int i = 1; i <= M; ++i){
        cin >> buf;
        A[buf] = true;
    }
    buf = 0;
    for(int i = X; i > 0; --i){
        if(A[i]) ++buf;
    }
    int ans = buf;
    buf = 0;
    for(int i = X; i < N; ++i){
        if(A[i]) ++buf;
    }
    ans = min(ans, buf);
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  ll N,A[5],ans;
  cin>>N;
  for(int i=0;i<5;i++) cin>>A[i];
  sort(A,A+5);
  if(N%A[0]==0) ans=N/A[0];
  else ans=N/A[0]+1;
  cout<<ans+4<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mr make_pair
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
int main(){
	int x;
	cin>>x;
	cout<<(x-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

struct heavy_light_decomposition{
	struct node{
		int chainid, index;
	};
	struct chain{
		int parchain, parnode, depth, length;
	};

	int n;
	vector<node> nodes;
	vector<chain> chains;
	vector<int> size, par;
	vector<vector<int>> G;

	heavy_light_decomposition(int _n):n(_n){
		G.resize(n);
		size.resize(n);
		par.resize(n);
	}
	void add_edge(int a, int b){
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	void build(int root = 0){
		stack<int> in, out;
		in.push(root);
		par[root] = -1;
		// set parent
		while (!in.empty()){
			int v = in.top(); in.pop();
			out.push(v);
			for (auto &e : G[v]){
				if (e == par[v]) continue;
				par[e] = v;
				in.push(e);
			}
		}
		// calculate size
		while (!out.empty()){
			int v = out.top(); out.pop();
			size[v] = 1;
			for (auto &e : G[v]){
				if (e == par[v]) continue;
				size[v] += size[e];
			}
		}
		decomposition(root);
	}

	void decomposition(int root){
		nodes.assign(n, { -1, -1 });
		stack<int> in;
		in.push(root);
		while (!in.empty()){
			int v = in.top(); in.pop();
			int &cid = nodes[v].chainid;
			if (cid < 0){
				int pid = par[v];
				int pcid = pid < 0 ? -1 : nodes[par[v]].chainid;
				cid = chains.size();
				chains.push_back({ pcid, pid, pcid < 0 ? 0 : chains[pcid].depth + 1, 1 });
			}
			nodes[v].index = chains[cid].length++;

			pair<int, int> heavy(-1, -1);
			for (auto &e : G[v]){
				if (e == par[v]) continue;
				heavy = max(heavy, make_pair(size[e], e));
			}
			if (heavy.first < 0) continue;
			for (auto &e : G[v]){
				if (e == par[v]) continue;
				if (heavy.second == e) nodes[e].chainid = cid;
				in.push(e);
			}
		}
	}

	int chain(int v){
		return nodes[v].chainid;
	}

	int lca(int u, int v){
		while (chain(u) != chain(v)){
			int &x = (chains[chain(u)].depth > chains[chain(v)].depth ? u : v);
			x = chains[chain(x)].parnode;
		}
		return nodes[u].index < nodes[v].index ? u : v;
	}
};

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

	int n;
	cin >> n;

	heavy_light_decomposition hld(n);

	rep(i, n){
		int k;
		cin >> k;
		rep(j, k){
			int ch;
			cin >> ch;
			hld.add_edge(i, ch);
		}
	}

	hld.build();

	int q;
	cin >> q;
	while (q--){
		int u, v;
		cin >> u >> v;
		cout << hld.lca(u, v) << '\n';
	}
}

Measured memory_bytes: 10992
N=int(input())
S,T=map(str,input().split())
l=[]
a,b=0,0
for i in range(N*2):
    if (i+1)%2!=0:
        l.append(S[a])
        a+=1
    else:
        l.append(T[b])
        b+=1
print(''.join(l))  

Measured memory_bytes: 9040
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int maxlength,i,Rmax=-999999999,Rmin;//注意Rmax下西限的设置
	cin >> maxlength;
	int* R = (int*)malloc(sizeof(int) * maxlength);
	for (i = 0; i < maxlength; i++)
	{
		cin >> R[i];
		if (i == 0)
			Rmin = R[0];
		else {
			Rmin = min(Rmin, R[i-1] );
			R[i - 1] = R[i] - Rmin;
			Rmax = max(Rmax, R[i - 1]);
		}	
	}
	cout << Rmax<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int odd = (n+1) /2;
  //ceil(a/b) = (a+b-1) /b
  double ans = (double)odd/n;
  printf("%.10f\n", ans);
  
 
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    ll sum;
    sum=0;
    ll x=0;
    for(int i = 0; i < n; i+=2)
    {
        sum += a[i];
        if(sum<=0){
            x += abs(1-sum);
            sum=1;
        }
        if(i+1>n-1) break;
        sum += a[i+1];
        if(sum>=0){
            x += abs(-1-sum);
            sum = -1;
        }
    }
    sum=0;
    ll y=0;
    for(int i = 0; i < n; i+=2)
    {
        sum += a[i];
        if(sum>=0){
            y += abs(-1-sum);
            sum = -1;
        }
        if(i+1>n-1) break;
        sum += a[i+1];
        if(sum<=0){
            y += abs(1-sum);
            sum = 1;
        }
    }
    
    cout << min(x, y) << endl;
    
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

class Dinic():
    def __init__(self, source, sink):
        self.G = defaultdict(lambda:defaultdict(int))
        self.sink = sink
        self.source = source

    def add_edge(self, u, v, cap):
        self.G[u][v] = cap
        self.G[v][u] = 0

    def bfs(self):
        level = defaultdict(int)
        q = [self.source]
        level[self.source] = 1
        d = 1
        while q:
            if level[self.sink]:
                break
            qq = []
            d += 1
            for u in q:
                for v, cap in self.G[u].items():
                    if cap == 0:
                        continue
                    if level[v]:
                        continue
                    level[v] = d
                    qq += [v]
            q = qq
        self.level = level

    def dfs(self, u, f):
        if u == self.sink:
            return f
        for v, cap in self.iter[u]:
            if cap == 0 or self.level[v] != self.level[u] + 1:
                continue
            d = self.dfs(v, min(f, cap))
            if d:
                self.G[u][v] -= d
                self.G[v][u] += d
                return d
        return 0

    def max_flow(self):
        flow = 0
        while True:
            self.bfs()
            if self.level[self.sink] == 0:
                break
            self.iter = {u: iter(self.G[u].items()) for u in self.G}
            while True:
                f = self.dfs(self.source, INF)
                if f == 0:
                    break
                flow += f
        return flow

n = I()
A = LI()
score = 0
s = 0
t = n + 1
dinic = Dinic(s, t)
for i in range(1, n + 1):
    if A[i - 1] > 0:
        score += A[i - 1]
        dinic.add_edge(s, i, 0)
        dinic.add_edge(i, t, A[i - 1])
    else:
        dinic.add_edge(s, i, -A[i - 1])
        dinic.add_edge(i, t, 0)
    ret = i
    while ret + i <= n:
        ret += i
        dinic.add_edge(i, ret, INF)


print(score - dinic.max_flow())

Measured memory_bytes: 44652
import math
n,d = list(map(int,input().split()))
x = []
result = 0
def func(i,j):
        pythagoras= 0
        for k in range(d):
                pythagoras += (i[k]-j[k])*(i[k]-j[k])
        if math.sqrt(pythagoras)%1 == 0:
                return True
        else:
                return False

for i in range(n):
        x.append(list(map(int,input().split())))
for i in range(n):
        for j in range(i+1,n):
                if func(x[i],x[j]): 
                        result += 1
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for(int i= 0; i < S.length(); i++)
	{
		if(S[i] == 'o')
		{
			ans++;
		}
	}
	if (S.length() < 15)
	{
		ans += 15 - S.length();
		if(ans >= 8)
		{
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else
	{
		if(ans >= 8)
		{
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	

	return 0;
}



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

int main() {
	//入力
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
	}

	//計算
	vector<int> dp(n);
	dp[0] = 0;
	for (int i = 1;i < n;++i) {
		dp[i] = INT_MAX;
		for (int j = 1;j <= k;++j) {
			if (j <= i) {
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}

	//答え
	int ans = dp[n - 1];
	cout << ans << endl;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n, a, b; cin >> n >> a >> b;
  cout << min(a*n, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
    int h,n;
    cin>>h>>n;
    int a[n],sum=0,temp=h;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if((h-sum)<=0)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}


Measured memory_bytes: 640
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5 5 5
.#...
.##..
.....
.....
.....
---+/

void main(string[] args) {
  long H, W, K;
  readf(" %d %d %d ", &H, &W, &K);

  auto S = new string[H];
  foreach (ref s; S) s = readln.chomp;

  long[][] ans;
  ans.length = H;
  foreach (ref x; ans) x.length = W;

  long index = 0;
  long sty;
  foreach (y; 0..H) {
    long stx;
    foreach (x; 0..W) {
      if (S[y][x] == '#') {
        ans[y][stx..x+1] = ++index;
        stx = x+1;
      }
    }
    if (stx != 0) {
      ans[y][stx..$] = index;
      foreach (y2; sty..y) {
        ans[y2][] = ans[y][];
      }
      sty = y+1;
    }
  }

  if (sty < H) {
    foreach (y; sty..H) {
      ans[y][] = ans[sty-1][];
    }
  }

  foreach (i, row; ans) {
    foreach (j, cell; row) {
      if (j != 0) " ".write;
      cell.write;
    }
    writeln;
  }
}


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

int main(){ 
int n;
cin>>n;
int ans;
vector<double> v(n);
for(int i=0; i<n; i++){
cin>>v[i];
}
sort(v.begin(), v.end());
for(int i=0; i<n-1; i++){
v[i+1]=(v[i]+v[i+1])/2;
}
cout<<v[n-1]<<endl;
}


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

const int WordsNum = 4;
string words[WordsNum] = { "dream", "dreamer", "erase", "eraser" };

int main()
{
    string s;
    cin >> s;
    
    int len = s.length();
    for (int i = 0; i < WordsNum; i++)
    {
        // len - 1 しておかないと最初に見付けたところが永遠に見つかってしまう
        auto pos = s.rfind(words[i], len - 1);
        
//        printf("len=%d, pos=%lu\n", len, pos);
        
        // npos は発見できなかった場合の返り値
        // len - pos == u[i].length() は文末から見つかったことを示す
        if (pos != string::npos && len - pos == words[i].length())
        {
            // サイズ分減らす
            len -= words[i].length();
            
            // for 文やり直し (ループ最後で 0 になる)
            i = -1;
            
            // 分解終了
            if (len <= 0)
            {
                break;
            }
        }
    }
    
    printf("%s\n", (len == 0) ? "YES" : "NO");
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modt[100002], imodt[100002];

int n, in[100001];
int samel, samer;

ll modpow(ll a, ll b) {
	ll x = 1,times = a;
	while (b > 0) {
		if (b & 1)x *= times;
		times *= times;
		x %= MOD;
		times %= MOD;
		b >>= 1;
	}
	return x;
}

ll comb(ll n, ll r) {
	if (r > n)return 0;
	//cout << n << " " << r << endl;
	ll ans = modt[n];
	ans = (ans * imodt[r]) % MOD;
	ans = (ans * imodt[n - r]) % MOD;
	return ans;
}

int main() {
	modt[0] = 1;
	modt[1] = 1;
	for (int i = 2; i <= 100001; i++) {
		modt[i] = modt[i - 1] * i;
		modt[i] %= MOD;
		//cout << modt[i] << endl;
	}
	
	//for (int i = 100001; i >= 0; i--)imodt[i] = modpow(modt[i], 1000000005);

	imodt[100001] = modpow(modt[100001], 1000000005);
	for (int i = 100000; i >= 0; i--) {
		imodt[i] = imodt[i + 1] * (i + 1);
		imodt[i] %= MOD;
	}
	
	cin >> n;
	for (int i = 1; i <= n + 1; i++) {
		int a;
		cin >> a;
		if (in[a - 1] != 0) {
			samel = in[a - 1] - 1, samer = i - 1;
		}
		else {
			in[a - 1] = i;
		}
	}
	for (int i = 1; i <= n + 1; i++) {
		if (i == 1)cout << n << endl;
		else {
			ll ans = comb(n + 1, i);
			ans %= MOD;
			ans -= comb(samel + (n - samer), i - 1);
			ans += MOD;
			ans %= MOD;
			//cout << i << " " << j << " " << comb(samel, j) * comb(n - samer + 1, i - 1 - j) << endl;
			cout << ans << endl;
		}
	}
	return 0;
}

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

int main(){
  int n, a, b, s;
  cin >> n;
  vector<pair<int, int>> c(n);
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    c[i].first = a + b;
    c[i].second = a - b;
  }
  sort(c.begin(), c.end());
  s = 1;
  b = c[0].first;
  for(int i = 1; i < n; i++){
    if(c[i].second >= b){
      s++;
      b = c[i].first;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

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

  int n = s.size();

  vector<int> v(n, 0);

  int lc = 0;
  int rc = 0;
  int i = 0;
  while(i < n){
    if(s[i] == 'R'){
      rc++;
      if(s[i+1] == 'L'){
        v[i] = (rc+1)/2;
        v[i+1] = rc/2;
        rc = 0;
        int j = i+1;
        while(s[j] == 'L' && j < n){
          lc++;
          j++;
        }
        v[i] += lc/2;
        v[i+1] += (lc+1)/2;
        lc = 0;
        i = j;
        continue;
      }
      i++;
    }
  }

  REP(i, n) cout << v[i] << " ";
  cout << endl;
  return 0;
}

// RRRLLL  003300

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
signed main() {
  int n ; cin >> n ; int cnt = 0 ;
  int k ; cin >> k ;
  std::vector< int > v ;
  for(register int i = 1 ; i <= n ; i ++) {
    int x ;cin >> x ;
    v.push_back(x) ;
  }
  for(auto x : v)
    if(x >= k) cnt ++ ;
  cout << cnt << endl ;
  return 0 ;
}


Measured memory_bytes: 892
#include <stdio.h>

int main()
{
  int i, j, k, l, cnt = 0;
  int n[100], x[100];

  for (i = 0; i < 100; i++) {
    scanf("%d %d", &n[i], &x[i]);
    if (n[i] == 0 && x[i] == 0) {
      break;
    }
  }

  for (i = 0; i < 100; i++) {
    if (n[i] == 0 && x[i] == 0){
      break;
    }
    for (j = 1; j <= n[i] - 2; j++) {
      for (k = j + 1; k <= n[i] - 1; k++) {
        for (l = k + 1; l <= n[i]; l++) {
          if (x[i] == j + k + l) {
            cnt++;
          }
        }
      }
    }
    printf("%d\n", cnt);
    cnt = 0;
  }

  return 0;
}

Measured memory_bytes: 600
N=int(input())
A,B,C=[[int(i) for i in input().split()] for j in range(3)]
manzoku=0
prev=0
for n,a in enumerate(A):
  b=a-1
  if n!=0:
    if b==prev+1:
      manzoku+=C[b-1]
  manzoku+=B[b]
  prev=b
print(manzoku)

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

int main(){
    int N,M;
    cin>>N>>M;
    ll INF = 1e14;
    vector<vector<ll>> graph(N,vector<ll>(N,INF));
    vector<vector<ll>> prev(N,vector<ll>(N,INF));
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        graph[a][b] = graph[b][a] = c;
        prev[a][b] = i;
        prev[b][a] = i;
    }

    for(int k = 0;k < N;k++){
        for(int i = 0;i < N;i++){
            for(int j = 0;j < N;j++){
                if(graph[i][j]>graph[i][k] + graph[k][j]){
                    graph[i][j] = graph[i][k] + graph[k][j];
                    prev[i][j] = prev[k][j];
                }
                
            }
        }
    }
    // for(int i = 0;i < N;i++){
    //     for(int j = 0;j < N;j++){
    //         cout << graph[i][j] << " ";
    //     }
    //     cout<<endl;
    // }
    vector<bool> used(M,false);
    int cnt = M;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(prev[i][j] == INF || used[prev[i][j]])continue;
            used[prev[i][j]] = true;
            cnt--;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl r(3, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    if(a % 4 == 0)
      r[2]++;
    else if(a % 2 == 0)
      r[1]++;
    else
      r[0]++;
  }
  cout << (r[0] <= r[2] + n % 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3644
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,n,i,j,ii
    integer(int32), allocatable:: ans(:,:)
    integer(int32), allocatable:: a(:), color(:)
    logical,allocatable:: painted(:,:)

    read*, h,w
    allocate(ans(w,h))
    allocate(painted(w,h), source=.false.)
    read*, n
    allocate(a(n))
    allocate(color(w*h))
    read*, a(:)
    ii=1

    do i=1,n
        do j=1,a(i)
            color(ii) = i
            ii=ii+1
        end do
    end do
    call paint(1,1,0,1)
    do i=1,h
        print'(*(i0,1x))', ans(:,i)
    end do

contains
    recursive subroutine paint(x,y,n,i)
        integer(int32):: dx(0:3)=[0,1,0,-1], dy(0:3)=[1,0,-1,0]
        integer(int32):: x,y,n, nn
        integer(int32):: i
        if (i > h*w) return
        ans(x,y) = color(i)
        painted(x,y) = .true.
        if (is_range(x+dx(n), 1, w) .and. is_range(y+dy(n), 1, h)) then
            nn = n
            if (painted(x+dx(nn),y+dy(nn))) nn = mod(n+1,4)
            call paint(x+dx(nn), y+dy(nn), nn, i+1)
        else
            nn = mod(n+1,4)
            if (is_range(x+dx(nn), 1, w) .and. is_range(y+dy(nn), 1, h)) then
                call paint(x+dx(nn), y+dy(nn), nn, i+1)
            end if
        end if
    end subroutine

    function is_range(val, fst, lst) result(ret)
        integer(int32):: val, fst, lst
        logical:: ret
        ret = fst <= val .and. val <= lst
    end function
end program main

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<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(int argc, char const *argv[]) {
  int s, w; cin >> s >> w;
  if (s <= w) puts("unsafe");
  else
    puts("safe");
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int n;
int a[100010];
map<int,int> mp;
long long ans=1;
int p=0;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	mp[-1]=3;
	for(int i=1;i<=n;i++)
	{
		int x=mp[a[i]-1];
		if(x>=4)
		{
			cout<<0<<endl;
			return 0;
		}
		if(a[i]==0) p++;
		ans*=(long long)x,ans%=mod;
		mp[a[i]]++,mp[a[i]-1]--;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




int main()
{
	string S, T;
	cin >> S >> T;

	Vi ns(26), nt(26);
	for (auto& c : S) {
		++ns[c - 'a'];
	}
	for (auto& c : T) {
		++nt[c - 'a'];
	}
	sort(ns.begin(), ns.end());
	sort(nt.begin(), nt.end());

	bool ans = true;
	for (int i = 0; i < 26; ++i) {
		if (ns[i] != nt[i]) {
			ans = false;
			break;
		}
	}

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

Measured memory_bytes: 776
using System;

namespace B___OddString
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = "";
            for (var i = 0; i < s.Length; i+=2)
            {
                ans += s.Substring(i, 1);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 34772
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n >= m:
    print(0)
    exit()
sub = [0]*(m-1)
for i in range(m-1):
    sub[i] = x[i+1]-x[i]
sub.sort()

ass = 0
for i in range(m-n):
    ass += sub[i]
print(ass)


Measured memory_bytes: 52904
s=input()
s=s[::-1]
f=0
l=['dream' ,'dreamer', 'erase','eraser']
l=[c[::-1] for c in l]
while(f==0):
    if(s[:7] in l):
        s=s[7:]
    elif(s[:6] in l):
        s=s[6:]
    elif(s[:5] in l):
        s=s[5:]
    else:
        f=1
if(len(s)==0):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 78128
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

c = [[int(x) for x in input().split()] for _ in range(3)]

flag = 1

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if c[0][0] - a1 == c[1][0] - a2 and c[1][0] - a2 == c[2][0] - a3:
                if c[0][1] - a1 == c[1][1] - a2 and c[1][1] - a2 == c[2][1] - a3:
                    if c[0][2] - a1 == c[1][2] - a2 and c[1][2] - a2 == c[2][2] - a3:
                        flag = 0

if flag:
    print('No')
else:
    print('Yes')



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;



int main(){
    int n;
    cin>>n;
    vint p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    int j=n/2;
    cout<<p[j]-p[j-1]<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string.h>
#include <queue>
#include <string>
#define P pair<int,int>
using namespace std;
bool field[12][12];
bool visited[12][12];
bool input()
{
	bool failed=false; string str[12];
	for(int i=0;i<12;i++) { if(cin.eof()) failed=true; cin >> str[i];}
	if(failed) return false;
	for(int i=0;i<12;i++) for(int j=0;j<12;j++)
		field[i][j]=str[i][j]-'0';
	return true;
}
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
bool isIn(int x,int y)
{
	if(x>=0 && x<=11 && y>=0 && y<=11) return true;
	return false;
}
int main() {
	while(input())
	{
		memset(visited,false,sizeof(visited));
		queue<P> q; int cnt=0;
		for(int i=0;i<12;i++)
		{
			for(int j=0;j<12;j++)
			{
				if(visited[i][j] || !field[i][j]) continue;
				visited[i][j]=true;
				q.push(P(i,j)); cnt++;
				while(!q.empty())
				{
					int a=q.front().first, b=q.front().second; q.pop();
					for(int k=0;k<4;k++)
					{
						if(isIn(a+dx[k],b+dy[k]) && !visited[a+dx[k]][b+dy[k]]
							&& field[a+dx[k]][b+dy[k]]==field[i][j])
						q.push(P(a+dx[k],b+dy[k])),visited[a+dx[k]][b+dy[k]]=true;
					}
				}
			}
		}
		cout << cnt << '\n' ;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,l;
  cin >> n >> l;
  int sum=0,ans=100000;
  rep(i,n){
    sum+=l+i;
  }
  int a=1000000;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(j==i){
        continue;
      }
      count+=l+j;
    }
    if(a>abs(sum-count)){
      ans=count;
      a=abs(sum-count);
    }
  }
  cout << ans;
}

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

struct Point{double x, y;};

void koch(int n, Point a, Point b){
    if(n==0) return;
    Point s, t, u;
    double th = M_PI*60.0/180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1, t, b);
}

int main(){
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


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

struct Node {
  int parent, left, right;
};

int getSibling(Node nodes[], int i) {
  if (nodes[i].parent != -1) {
    int parent_i = nodes[i].parent;
    if (nodes[parent_i].left == i) {
      return nodes[parent_i].right;
    } else {
      return nodes[parent_i].left;
    }
  }
  return -1;
}

int getDegree(Node nodes[], int i) {
  int degree = 0;
  if (nodes[i].left != -1) degree++;
  if (nodes[i].right != -1) degree++;
  return degree;
}

int getDepth(Node nodes[], int i) {
  int depth = 0;
  if (nodes[i].parent == -1) return 0;
  else depth += getDepth(nodes, nodes[i].parent);
  return ++depth;
}

int getHeight(Node nodes[], int i) {
  int height = 0;
  if (nodes[i].left != -1 && nodes[i].right != -1) {
    height += max(getHeight(nodes, nodes[i].left),
                  getHeight(nodes, nodes[i].right));
  } else if (nodes[i].left != -1) {
    height += getHeight(nodes, nodes[i].left);
  } else if (nodes[i].right != -1) {
    height += getHeight(nodes, nodes[i].right);
  } else {
    return 0;
  }
  return ++height;
}

int main() {
  int n;
  cin >> n;
  Node nodes[n];
  for (int i = 0; i < n; i++) {
    nodes[i].parent = -1;
  }
  for (int i = 0; i < n; i++) {
    int index, left, right;
    cin >> index;
    cin >> left;
    cin >> right;
    nodes[index].left = left;
    nodes[index].right = right;
    if (left != -1) {
      nodes[left].parent = index;
    }
    if (right != -1) {
      nodes[right].parent = index;
    }
  }
  // print
  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    int parent = nodes[i].parent;
    cout << "parent = " << parent << ", ";
    cout << "sibling = " << getSibling(nodes, i) << ", ";
    int degree = getDegree(nodes, i);
    cout << "degree = " <<  degree << ", ";
    cout << "depth = " << getDepth(nodes, i) << ", ";
    cout << "height = " << getHeight(nodes, i) << ", ";
    if (parent == -1) cout << "root";
    else if (degree == 0) cout << "leaf";
    else cout << "internal node";
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
import math

def main():

    A, B, C, D = map(int, input().split())

    t = math.ceil(A / D)
    a = math.ceil(C / B)

    if t >= a:
        ans = 'Yes'

    else:
        ans = 'No'


    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9148
#include <iostream>
using namespace std;
int main() {
    int n,count=0;
    cin>>n;
    int a[n];
    for (int i = 0; i < n ; i++) {
        cin>>a[i];
        if (a[i]%2!=0 && (i+1)%2!=0)
            count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [[s for s in input()] for _ in range(H)]

    ans = 0
    for i in range(H):
        for j in range(W):
            s = S[i][j]
            if s == '#':
                continue
            INF = 1000000000
            field = [[INF for _ in range(W)] for _ in range(H)]
            que = queue.Queue()
            que.put((i, j))
            field[i][j] = 0
            while not que.empty():
                ci, cj = que.get()
                d = ((0, 1), (1, 0), (-1, 0), (0, -1))
                for di, dj in d:
                    ni = ci + di
                    nj = cj + dj
                    if (ni < 0 or H <= ni or nj < 0 or W <= nj):
                        continue
                    if S[ni][nj] == '#':
                        continue
                    if field[ni][nj] > field[ci][cj] + 1:
                        field[ni][nj] = field[ci][cj] + 1
                        que.put((ni, nj))
            res = 0
            for k in range(H):
                for l in range(W):
                    if field[k][l] != INF:
                        res = max(res, field[k][l])
            ans = max(res, ans)

    print(ans)


Measured memory_bytes: 63316
N,M,X = map(int, input().split())

C = []
A = []
for _ in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

#bit全探索
ans = float('inf')
for i in range(2**N):
    ac = [-1]*N
    total = [0]*M
    temp = 0
    flg = 0
    for j in range(N):
        if (i>>j)&1:
            ac[j] = 1
    for n in range(N):
        if ac[n]==1:
            temp += C[n]
            for m in range(M):
                total[m] = total[m] + A[n][m]
    for m in range(M):
        if total[m]<X:
            flg = 1
    if flg==0:
        ans = min(ans, temp)
if ans==float('inf'):
    print(-1)
else:
    print(ans)

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    string x;
    cin >> x;
    if (x[0] == x[1] || x[1] == x[2] || x[2] == x[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if( x==1 ) {
			System.out.println( "0" );
		}
		else if(x==0){
			System.out.println( "1" );
		}
		else {
			System.out.println( "ng" );
		}				
		sc.close();
	}
}

Measured memory_bytes: 35620
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_N = 1e5 + 6;

vector<int> edg[MAX_N];
bool visit[MAX_N];

int dfs(int id) {
    visit[id]=1;
    int ret=0;
    for (int i:edg[id]) {
        if (!visit[i]) ret ^= (dfs(i)+1);
    }
    return ret;
}

int main () {
    int n;
    scanf("%d",&n);
    for (int i=1;n>i;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    int ret=dfs(1);
    if (ret==0) puts("Bob");
    else puts("Alice");
}



Measured memory_bytes: 8960
#include<iostream>

using namespace std;

int main(void){
	int a, b;
	int c = 0;
	cin >> a;
	for (int i = 1; i<10; i++){
		for (int ii = 1; ii<10; ii++){
			if (i*ii == a){
				c = 1;

			}
		}
	}
	if (c == 1){
		cout << "Yes" << endl;
	}
	else{ 
		cout << "No" << endl; 
	}
}

Measured memory_bytes: 256
while 1:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    g=[map(float,raw_input().split()) for _ in xrange(n)]
    dp=[[0.0]*n for _ in xrange(m)]
    for j in xrange(n):
        dp[0][j]=1.0
    for i in xrange(m-1):
        for j in xrange(n):
            for k in xrange(n):
                dp[i+1][j]=max(dp[i+1][j],dp[i][k]*g[k][j])
    print("%.2f" % round(max(dp[m-1]),2))

Measured memory_bytes: 6864
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;

int main()
{
	scanf("%d", &n);
	ll wyn=0;
	for (int i=1; i<=n; i++)
	{
		ll x=n/i;
		ll y=x*(x+1)/2;
		wyn+=y*i;
		//~ debug() << i << " " << x << " " << y;
	}
	printf("%lld\n", wyn);
	return 0;
}


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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

signed main()
{
    string S; cin >> S;

    int N = S.size();

    int J = 0, O = 0, I = 0;

    int ans = 0;

    rep(i, N) {
        if (S[i] != 'J') {J=O=I=0;continue;}
        while (S[i] == 'J') {
            J++;
            i++;
            O = I = 0;
        }
        if (S[i] != 'O') {J=O=I=0;i--;continue;}
        while (S[i] == 'O') {
            O++;
            i++;
            I = 0;
        }
        if (S[i] != 'I') {J=O=I=0;i--;continue;}
        while (S[i] == 'I') {
            I++;
            i++;
            if (O <= J && O <= I) ans = max(ans, O);
        }
        J=O=I=0;
        i--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    memset(f,0,sizeof f);
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(i=0;i<N;i++)
vector<int> length(3);

int main(void){
  int i;
  FOR(i,3) cin >> length[i];
  sort(length.begin(),length.end());
  cout << (length[0] * length[1])/2 << endl;
  return 0;
}

Measured memory_bytes: 256