akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*てんぷれぞーん！*/
static const int INF = 2147483647;
static const long long llINF = 9223372036854775807;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/*t y p o っ て 知 っ て る ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
#define int ll
#define INF llINF
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
/*てんぷれぞーんしゅーりょー！*/

static const int MAX_V = 114514;
vector<edge> G[MAX_V];
int d[MAX_V],V; //dはKを始点とした最短距離を記録

void print(){
    /*for(int i=0;i<V;i++) printf("%lld ",d[i]);
    printf("\n");*/
    //debug用の関数でしたが、今は無が入っています
}

void dijkstra(int s){
    pq<P,vector<P>,greater<P> > que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(P(0,s));
    print();

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
        print();
    }
}

signed main(){
    scanf("%lld",&V);
    for(int i=0;i<V-1;i++){
        int a,b,c;
        scanf("%lld %lld %lld",&a,&b,&c);
        a--; b--;   //0-indexに
        edge tmp;
        tmp.to = a; tmp.cost = c;
        G[b].pb(tmp);
        tmp.to = b;
        G[a].pb(tmp);
    }

    int q,k;
    scanf("%lld %lld",&q,&k);
    dijkstra(k-1);  //0-indexをわするるな
    for(int i=0;i<q;i++){
        int start,goal;
        scanf("%lld %lld",&start,&goal);
        start--; goal--;    //0-index!!!!!!!!!!!!!
        int ans = d[start] + d[goal];
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 9204
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i,h;cin>>n;
	//Eかんたん こっち500点(Dは800)
	vector<pair<int,int>>a(1<<n);
	vector<pair<int,int>>b(1<<n);
	for(i=0;i<(1<<n);i++){cin>>a[i].fir;a[i].sec=i;b[i].sec=-1;}
	//上位二つを持つだけ 簡単すぎて感嘆!
	for(h=0;h<n;h++){
		for(i=0;i<(1<<n);i++){
			if(i&(1<<h)){continue;}
			int t=i+(1<<h);
			if(a[i].sec!=a[t].sec&&a[i].sec!=b[t].sec&&b[t]<a[i]){
				b[t]=a[i];
				if(a[t]<b[t]){swap(a[t],b[t]);}
			}
			if(b[i].sec!=a[t].sec&&b[i].sec!=b[t].sec&&b[t]<b[i]){
				b[t]=b[i];
				if(a[t]<b[t]){swap(a[t],b[t]);}
			}
		}
	}
	llint ans=0;
	for(i=1;i<(1<<n);i++){
		maxeq(ans,a[i].fir+b[i].fir);
		cout<<ans<<endl;
	}
	return 0;
}

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

// Description: ????????????
// Verifyed: various problem 
using namespace placeholders;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y; is >> x >> y,p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline P vec(L l){return l.t-l.s;}
auto sdot = bind(sgn,bind(dot,_1,_2,_3));
auto sdet = bind(sgn,bind(det,_1,_2,_3));

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/vec(l)); return (1-u)*l.s+u*l.t;}

//reflection verify AOJ CGL_1_B
P refl(L l,P p){return 2.0L*proj(l,p)-p;}

// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a,P b) {
	if(sdet(o,a,b) > 0) return LEFT;    // counter clockwise
	if(sdet(o,a,b) < 0) return RIGHT;   // clockwise
	if(sdot(o,a,b) < 0) return BACK;    // b--base--a on line
	if(sgn(norm(a-o)-norm(b-o)) < 0) return FRONT;   // base--a--b on line
	return ON; // base--b--a on line  semnet determination betwenn a and b 
}

int main(void){
	P a,b,p;
	int n;
	cin >> a >> b >> n;
	rep(i,n){
		cin >> p;
		int res=ccw(a,b,p);
		if(res==LEFT) cout << "COUNTER_CLOCKWISE" << endl;
		if(res==RIGHT) cout << "CLOCKWISE" << endl;
		if(res==BACK) cout << "ONLINE_BACK" << endl;
		if(res==FRONT) cout << "ONLINE_FRONT" << endl;
		if(res==ON) cout << "ON_SEGMENT" << endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    
    for(int bit = 0; bit < (1 << (n-1)); bit++){
        int tmp = s[0] - '0';
        for(int i = 0; i < n-1; i++){
            if(bit & (1 << i)){
                tmp += s[i+1] - '0';
            }else{
                tmp -= s[i+1] - '0';
            }
        }
        if(tmp == 7){
            cout << s[0];
            for(int i = 0; i < n-1; i++){
                if(bit & (1 << i)){
                    cout << '+' << s[i+1];
                }else{
                    cout << '-' << s[i+1];
                }
            }
            cout << "=7" << endl;
            break;
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cout<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

typedef vector<int> vi;

bool mirror(char x, char y) {
  if (x == 'i' and y == 'i') return true;
  if (x == 'w' and y == 'w') return true;
  if (x == '(' and y == ')') return true;
  if (x == ')' and y == '(') return true;
  return false;
}

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

  string s; cin >> s;
  int ans = 0;
  rep (i, s.size() / 2) {
    if (not mirror(s[i], s[s.size()-1-i])) ++ans;
  }
  if (s.size() %2 == 1)
    if (not mirror(s[s.size()/2], s[s.size()/2])) ++ans;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1188
N, M, C = map(int, raw_input().split())
B = map(int, raw_input().split())
ans = 0

for i in xrange(N):
    A = map(int, raw_input().split())
    tmp = C
    for j in xrange(M):
        tmp += A[j] * B[j]
    if tmp > 0:
        ans += 1

print ans


Measured memory_bytes: 2692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] div = str.split(" ");
		int a = Integer.parseInt(div[0]);
		int b = Integer.parseInt(div[1]);
		int c = Integer.parseInt(div[2]);
		if (a < b && b < c)
		{
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24204
#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>

using namespace std;

#define mod 1000000007

int main()
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int H, W, D;
    cin >> H >> W >> D;

    int N = H * W;

    vvll A(H, vll(W));
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    vector<pair<int, int>> pos(N);
    rep(i, H)
    {
        rep(j, W)
        {
            pos[A[i][j]] = make_pair(i, j);
        }
    }

    vvll cost(D, vll(N / D + 1));
    rep(d, D)
    {
        rep(i, N / D)
        {
            int next = D * (i + 1) + d;
            if (next >= N) break;
            auto p = pos[D * i + d];
            auto q = pos[next];
            cost[d][i + 1] = cost[d][i] + abs(p.first - q.first) + abs(p.second - q.second);
        }
    }

    int Q;
    cin >> Q;

    rep(_, Q)
    {
        int L, R;
        cin >> L >> R;
        L--;
        R--;

        int d = L % D;
        int l = L / D;
        int r = R / D;

        cout << cost[d][r] - cost[d][l] << endl;
    }

    return 0;
}

Measured memory_bytes: 9372
using System;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long ans = 0;
        if (inp[0] == 1) ans = inp[1];
        else
            for (long i = 1; i <= Math.Pow(inp[1], 1.0 / inp[0]) + 0.001; i++)
            {
                if (inp[1] % Math.Pow(i, inp[0]) == 0) ans = i;
            }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
import sys
INF = float("inf")


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):

    for i in range(1000):
        A = str(i)
        if len(A) != N:
            continue
        flag = True
        for ss, cc in zip(s, c):
            if int(A[ss-1]) != cc:
                flag = False
                break

        if flag == True:
            print(A)
            return
    print(-1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int ar[3];
	for (int i = 0; i < 3; i++)
		cin >> ar[i];
	sort(ar, ar + 3);
	cout << ar[0] + ar[1];
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e15;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long double A,B;
    cin >> A >> B;
    ll ans = A*B;
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3772
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
w_list = []
for i in range(M):
    a, b, c = map(int, input().split())
    w_list.append(a_list[a - 1] + b_list[b - 1] - c)

print(min(min(w_list), min(a_list) + min(b_list)))

Measured memory_bytes: 18612
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

ll n, m;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    if(n == 1 && m == 1) cout << 1 << endl;
    else if(n == 1) cout << max(0LL, m-2) << endl;
    else if(m == 1) cout << max(0LL, n-2) << endl;
    else cout << (n-2)*(m-2) << endl;
    return 0;
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n,d;
    cin >> n >> d;
    int k = (n+2*d)/(2*d+1);
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	vector<int> a(3);

	for(auto &e:a)
		cin>>e;

	sort(a.begin(), a.end());

	cout<<abs(a[0]-a[1])+abs(a[2]-a[1])<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

int n;
struct node {
    double x,y;
}a[10];

double dist(node aa,node bb) {
    return sqrt((aa.x - bb.x) * (aa.x - bb.x) + (aa.y - bb.y) * (aa.y - bb.y));
}

bool vis[10];
int b[10];
double sum;

void dfs(int step) {
//    cout << step << "->" << n << endl;
    if(step == n + 1) {
        for(int i = 1 ; i <= n ; i++) {
//            cout << b[i] << " ";
            if(i == n) continue;
            sum += dist(a[b[i]],a[b[i+1]]);
//            printf("%lf\n",dist(a[b[i]],a[b[i+1]]));
        }
//        cout << endl;
        return ;
    }
    for(int i = 1 ; i <= n ; i++) {
        if(!vis[i]) {
            b[step] = i;
            vis[i] = true;
            dfs(step+1);
            vis[i] = false;
        }
    }
}

int main() {
    while(~scanf("%d",&n)) {
        for(int i = 1 ; i <= n ; i++) {
            scanf("%lf%lf",&a[i].x,&a[i].y);
        }
        sum = 0;
        memset(vis,false,sizeof(vis));
        dfs(1);
        double y = 1.0;
        for(int i = 1 ; i <= n ; i++) {
            y *= i * 1.0;
        }
//        printf("%lf %lf\n",sum,y);
        printf("%.10lf\n",sum/y);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int read()
{
    char c=getchar();
    int d=0;
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9'){d=(d<<3)+(d<<1)+(c^48);c=getchar();}
    return d;
}

#define MAXN 50
#define INF 10086

int n;
string s;
int a[27];
int minn[MAXN+1];

int main()
{
    n=read();
	for(int i=1;i<=26;i++)minn[i]=INF;
    for(int i=1;i<=n;i++)
    {
		for(int j=1;j<=26;j++)a[j]=0;
        getline(cin,s);
        for(auto j:s)a[j-'a'+1]++;
		for(int j=1;j<=26;j++)minn[j]=min(minn[j],a[j]);
    }
    for(int i=1;i<=26;i++)
		for(int j=1;j<=minn[i];j++)putchar('a'+i-1);
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_5_A_ExhaustiveSearch
{
    class Program
    {
        static int n;
        static int[] A = new int[100010];
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(input[i]);
            }
            var q = int.Parse(Console.ReadLine());
            var m = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            for (int i = 0; i < q; i++)
            {
                if (Solve(0, m[i]))
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
        }

        static bool Solve(int i, int m)
        {
            if (m == 0)
            {
                return true;
            }
            if (i >= n)
            {
                return false;
            }

            bool res = Solve(i + 1, m) || Solve(i + 1, m - A[i]);
            return res;
        }
    }
}



Measured memory_bytes: 18684
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int colors[][] = {
				{0,   0,   0},
				{0,   0,   255},
				{0,   255,   0},
				{0,   255,   255},
				{255,   0,   0},
				{255,   0,   255},
				{255,   255,   0},
				{255,   255,   255},
		};
		String[] names = 
			{
				"black" , "blue" , "lime" , "aqua" , "red" , "fuchsia" , "yellow" , "white"
			};
		
		while (true) {
			String str = sc.next();

			if("0".equals(str)){
				break;
			}
			
			int r = Integer.parseInt(str.substring(1, 3), 16);
			int g = Integer.parseInt(str.substring(3, 5), 16);
			int b = Integer.parseInt(str.substring(5, 7), 16);
			
			double min = Integer.MAX_VALUE;
			int min_num = -1;
			for(int i = 0; i < 8; i++){
				double d = Math.sqrt((colors[i][0] - r)*(colors[i][0] - r) + (colors[i][1] - g)*(colors[i][1] - g) + (colors[i][2] - b)*(colors[i][2] - b));
				if(min > d){
					min = d;
					min_num = i;
				}
			}
			
			System.out.println(names[min_num]);
		}

	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int a[200005];

int main(void){
  int N,i,num,first,second;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  for(i=0,first=0,second=0;i<N;i++){
    fgets(str,sizeof(str),stdin);
    a[i]=atoi(str);
    if(first<=a[i]){
      second=first,first=a[i];
    }else if(second<a[i]){
      second=a[i];
    }
  }
  
  for(i=0;i<N;i++){
    if(a[i]==first){
      printf("%d\n",second);
    }else{
      printf("%d\n",first);
    }
  }
  
  
  return 0;
  
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin>>a>>b;
  vector<char>moji_a(a.size()),moji_b(b.size());
  for(int i=0;i<a.size();i++){
    moji_a[i]=a[i];
  }
  for(int i=0;i<b.size();i++){
    moji_b[i]=b[i];
  }
  sort(a.begin(),a.end());
  sort(b.rbegin(),b.rend());
  if(b[0]-a[0]>0){
    cout<<"Yes"<<endl;
    return 0;
  }else if(b.size()>a.size()){
    bool hantei=true;
    for(int i=0;i<a.size();i++){
      if(a[i]!=b[i]){
        hantei=false;
        break;
      }
    }
    if(hantei==true){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ki = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = in.readLine.split(" ").map(_.toInt)

  val ans = dfsEnum(2, n)
  println(ans)

  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    val graph = Array.fill(m)(mu.ListBuffer.empty[Int])
    val enum = Array.ofDim[Boolean](n)
    var ret = 0

    // initialize
    for {
      i <- 0 until m
      j <- ki(i)(0) to 1 by -1
    } (ki(i)(j) - 1) +=: graph(i)
  
    def evalute():Unit = {
      val res = (0 until m)
        .map(i => graph(i).count(enum(_)) % 2 == p(i))
        .forall(b => b)

      if(res) ret += 1
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(b <- List(false, true)) {
          enum(cnt) = b
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }

}

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

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

  vector<int> d(n);
  for (int i = 0; i < n; i++){
    cin >> d.at(i);
  }

  sort(d.begin(), d.end());

  cout << d.at(n/2) - d.at(n/2 - 1) <<endl;

}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	var s string
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			fmt.Scan(&s)
			if s == "snuke" {
				fmt.Printf("%c%d\n", j+'A', i+1)
				return
			}
		}
	}
}


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

int main(){
  int n, m;
  cin >> n >> m;
  string s[n+2];
  
  for(int i = 1; i < n+1; i++){
    cin >> s[i];
    s[i] = "#"+s[i]+"#";
    //cout << s[i] << endl;
  }
  
  string defa;
  
  for(int i = 0; i < n+2; i++){
    if(i == 0 || i == n+1){
      for(int j = 0; j < m + 2; j++){
        cout << "#";
      }
    }
    else {
      cout << s[i];
    }
    cout << endl;
  }
}
    

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static int A[],B[];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next());
		A=new int[n];
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int begin=Integer.parseInt(in.next()),end=Integer.parseInt(in.next()),t=Integer.parseInt(in.next());
			swap(begin,end,t);
		}
		for(int i=0;i<n-1;i++)System.out.print(A[i]+" ");
		System.out.println(A[n-1]);
	}
	
	static void swap(int begin,int end,int t) {
		for(int k=0;k<end-begin;k++) {
			int tt=A[begin+k];
			A[begin+k]=A[t+k];
			A[t+k]=tt;
		}
	}

}


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

int main() {
  char s[100000];
  scanf("%s", s);
  
//1thが0
  int a=0;
  for (int i = 0; s[i]!='\0'; i++) {
      if(i%2==0&&s[i]!='0') a++;
      if(i%2!=0&&s[i]!='1') a++; 
  }
//1thが1
  int b=0;
  for (int i = 0; s[i]!='\0'; i++) {
      if(i%2==0&&s[i]!='1') b++;
      if(i%2!=0&&s[i]!='0') b++; 
  }
  cout << min(a, b) << endl;
}

Measured memory_bytes: 384
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    int a[10];
    int cnt;
    void op()
    {
        sort(a,a+3);
        if (a[1]-a[0]==1 && a[2]-a[0]==1) {a[1]++;a[2]++;cnt++;return;}
        a[0]++;
        if (a[1]-a[0]<=1 && a[2]!=a[1]) {if (a[2]-a[0]==1 && a[2]-a[1]==2) a[0]++;else a[1]++;}
        else a[0]++;
        cnt++;
    }    
    void opb()
    {
        sort(a,a+3);
        a[0]+=2;
        cnt++;
    }
int main(){
    cin>>a[0]>>a[1]>>a[2];
    while (a[0]!=a[1] || a[1]!=a[2] || a[0]!=a[2]){
           op();
           if (a[0]==a[1] && a[1]==a[2] && a[0]==a[2]) break;
           opb();
    }
    cout<<cnt<<endl; 
    return 0;
}

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

int main(){
  string str, com, p;
  int q, a, b;

  cin >> str >> q;
  for ( int t = 0; t < q; t++ ){
    cin >> com >> a >> b;
    if ( com == "print" ){
      cout << str.substr(a, b-a+1) << endl;
    } else if ( com == "reverse" ){
      string tmp = str.substr(a, b-a+1);
      int n = tmp.size();
      for ( int i = 0; i < n; i++ ) str[i+a] = tmp[n-i-1];
    } else if ( com == "replace" ){
      cin >> p;
      str = str.replace(a, b-a+1, p);
    }
  
}

return 0;
}


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

int Depth(int);
int Sibling(int);
int Height(int);
void print(int);

typedef struct{
  int p;
  int l;
  int r;
}node;
 
node tree[MAX];
int height[MAX];
 
int main(){
 
  int n, i, id,  left, right, root;
 
  scanf("%d", &n);
 
  for( i=0; i<n; i++)
    tree[i].p = -1;
 
  for( i=0; i<n; i++){
    scanf("%d %d %d", &id, &left, &right);
    tree[id].l = left;
    tree[id].r = right;
 
    if( left != -1 ) tree[left].p = id;
    if( right != -1 ) tree[right].p= id;
  }
 
  for( i=0; i<n; i++)
    if( tree[i].p == -1 ) root = i;
 
  Height(root);
 
  for( i=0; i<n; i++)
    print(i);

  return 0;
}
 
int Depth(int u){
  int d = 0;

  while( tree[u].p != -1 ){
    u = tree[u].p;
    ++d;
  }
 
  return d;
}
 
int Sibling(int u){
  int temp = tree[u].p;
 
  if( temp == -1 ) return -1;
  if( tree[temp].l != u && tree[temp].l != -1 ) return tree[temp].l;
  if( tree[temp].r != u && tree[temp].r != -1 ) return tree[temp].r;
 
  return -1;
}
 
int Height(int u){
  int h1 = 0, h2 = 0;
 
  if( tree[u].l != -1 )    h1 = Height(tree[u].l) + 1;
  if( tree[u].r != -1 )    h2 = Height(tree[u].r) + 1;
 
  return height[u] = ( h1 > h2 ? h1 : h2 );
}

void print(int u){
  int deg = 0;
  printf("node %d: parent = %d, ", u, tree[u].p);
  printf("sibling = %d, ", Sibling(u));
 
  deg = 0;
  if( tree[u].l != -1 ) deg++;
  if( tree[u].r != -1 ) deg++;
 
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth(u));
  printf("height = %d, ", height[u]);
 
  if( tree[u].p == -1 ) printf("root");
  else if( tree[u].l == -1 && tree[u].r == -1 ) printf("leaf");
  else printf("internal node");
 
  printf("\n");
}

Measured memory_bytes: 608
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	while (scanf("%d %c %d", &a, &op, &b)) {
		if(op == '?') {
			break;
		}
		switch(op) {
			case '+': printf("%d\n", a+b);
				break;
			case '-': printf("%d\n", a-b);
				break;
			case '*': printf("%d\n", a*b);
				break;
			case '/': printf("%d\n", a/b);
				break;
		}
	}
}


Measured memory_bytes: 2100
INF = 10**10

def solve(x,y,i,j)
  x = -x unless i.zero?
  y = -y unless j.zero?
  x<=y ? i+j+y-x : INF
end

x,y=gets.split.map &:to_i
p [0,1].map{|i|[0,1].map{|j|solve(x,y,i,j)}.min}.min


Measured memory_bytes: 1788
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k;
string s, res;
deque<II> a;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    cin >> s;
    char ch = s[0];
    int cnt = 1;
    FOR(i,1,n-1) {
        if (s[i] == ch) cnt++;
        else {
            a.push_back(II(ch-'A', cnt));
            ch = s[i];
            cnt = 1;
        }
    }
    a.push_back(II(ch-'A', cnt));
    
    int stat = 0;
    while (k) {
        int firstChar = a.front().FI;

        if (a.front().SE == 1) a.pop_front();
        else {
            II p = a.front();
            a.pop_front();
            p.SE--;
            a.push_front(p);
        }

        int realFirstChar = firstChar;
        if (stat) realFirstChar = 1-realFirstChar;

        if (realFirstChar == 0) {
            // A
            II p = II(1-firstChar, 1);
            if (SZ(a) && a.front().FI == p.FI) {
                II q = a.front();
                a.pop_front();
                q.SE++;
                a.push_front(q);
            } else {
                a.push_front(p);
            }
        } else {
            // B
            stat = 1-stat;
            II p = II(firstChar, 1);
            if (SZ(a) && a.back().FI == p.FI) {
                II q = a.back();
                a.pop_back();
                q.SE++;
                a.push_back(q);
            } else {
                a.push_back(p);
            }
        }

        if (SZ(a) > 1 && a.back().SE == 1) {
            int realLastChar = a.back().FI;
            if (stat) realLastChar = 1-realLastChar;
            if (realLastChar == 0 && SZ(a) > 1) {
                a.pop_back();
                if (a.back().SE == 1) a.pop_back();
                else {
                    II p = a.back();
                    a.pop_back();
                    p.SE--;
                    a.push_back(p);
                }
            }
        }
        k--;

        if (SZ(a) == 1 && a.front().SE == 1 && k % 2 == 0) break;
        if (SZ(a) == 0) break;
    }

    while (SZ(a)) {
        II p = a.front();
        a.pop_front();
        // cout << p.FI << ' ' << p.SE << endl;
        if (stat) p.FI = 1-p.FI;
        
        FOR(i,1,p.SE) res += char('A' + p.FI);
    }
    while (SZ(res) < n) res += "BA";
    cout << res;
    return 0;
}


Measured memory_bytes: 5248
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		if ( a == b )
			System.out.println(c);
		else if ( a == c )
			System.out.println(b);
		else if ( b == c )
			System.out.println(a);
	}
}

Measured memory_bytes: 21844
program atcoder
    implicit none
    integer(8) :: n,k,i,ans,t
    integer(8) q(3_8**10+6)
    integer true(3_8**10+6)    
    read*,n
    ans = 0
    i = 1
    q(i) = 0
    true(i) = 0
    do while(i>0)
      k = q(i)
      t = true(i)
      i = i - 1
      if(k<=n .and. t==7)then
        ans = ans + 1
      endif
      if(k*10<=n)then
        i = i+1
        q(i) = k*10 + 3
        true(i) = or(t,1)
        i = i+1
        q(i) = k*10 + 5
        true(i) = or(t,2)
        i = i+1
        q(i) = k*10 + 7
        true(i) = or(t,4)
      endif
    enddo
    write(*,'(I0)')ans
!----------------------functions--------------------------
contains

end program atcoder

Measured memory_bytes: 256
import collections

sa = collections.deque(input())
sb = collections.deque(input())
sc = collections.deque(input())


tmp = "a"
while True:
    if tmp == "a":
        try:
            tmp = sa.popleft()
        except(IndexError):
            print("A")
            exit()
    elif tmp == "b":
        try:
            tmp = sb.popleft()
        except(IndexError):
            print("B")
            exit()
    else:
        try:
            tmp = sc.popleft()
        except(IndexError):
            print("C")
            exit()
    


Measured memory_bytes: 3316
a, b, c, k = map(int, input().split())

if a>k:
    print(1*k)
elif (k-a) < b:
    print(1*a)
elif (k-a-b) < c:
    print(1*a-1*(k-a-b))
else:
    print(1*a-1*c)

Measured memory_bytes: 9184
import math
import heapq

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

num = 0
i = 0
comp = 0
for i in range(N):
	if A[i] == B[i]:
		comp += 1
	elif A[i] > B[i]:
		print(-1)
		exit()
i = 0

while comp < N:
	loc = i % N
	loc_plus = (i + 1) % N
	loc_minus = (i - 1) % N
	if B[loc] >= B[loc_plus] and B[loc] >= B[loc_minus] and A[loc] < B[loc]:
		big = max(B[loc_minus], B[loc_plus])
		if big <= A[loc]:
			if (B[loc] - A[loc]) % (B[loc_minus] + B[loc_plus]) == 0:
				comp += 1
				num += (B[loc] - A[loc]) // (B[loc_minus] + B[loc_plus])
				B[loc] = A[loc]
			else:
				print(-1)
				exit()
		else:
			n = math.ceil((B[loc] - big + 1)/(B[loc_minus] + B[loc_plus]))
			num += n
			B[loc] -= n*(B[loc_minus] + B[loc_plus])
			if B[loc] < A[loc]:
				print(-1)
				exit()
			elif B[loc] == A[loc]:
				comp += 1
		if B[loc_plus] > B[loc_minus]:
			i = loc_plus
		else:
			i = loc_minus
	elif (B[loc] < B[loc_plus] or B[loc] < B[loc_minus]) and A[loc] < B[loc]:
		if B[loc_plus] >= B[loc_minus]:
			loc_next = loc_plus
		else:
			loc_next = loc_minus
		if B[loc_next] == A[loc_next]:
			print(-1)
			exit()
		else:
			i = loc_next
	elif A[loc] == B[loc]:
		i += 1
	#print(B, num, loc)
print(num)

Measured memory_bytes: 130712
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int main(){
  string s;
  int n,m,cost[301],d[3][301];
  int dp[301];
  
  while(cin >> n >> m){
    
    int maxi = 0;
    for(int i=0;i<n;i++){
      cin.ignore();
      getline(cin,s);
      cin >> cost[i] >> d[0][i] >> d[1][i] >> d[2][i];
    }
    
    for(int k = 0;k < 3;k++){
      memset(dp,0,sizeof(dp));
      for(int i = 0;i < n;i++){
	for(int j = m;j > 0;j--){
	  if(j - cost[i] >= 0) dp[j - cost[i]] = max(dp[j] + d[k][i],dp[j - cost[i]]);
	}
      }
      maxi = max(maxi,*max_element(dp,dp + m + 1));
    }
    cout << maxi << endl;
  }
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
using ll = long long;

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

Measured memory_bytes: 3632
# coding:utf-8
def main():
    a = int(input())
    lists= [int(input()) for _ in range(a)]

    temp = lists.copy()
    first = max(temp)
    temp.remove(first)
    second = max(temp)

    for i in range(a):
        if lists[i] == first:
            print(second)
        else:
            print(first)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 14076
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9+7;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
long long fact(long long n)
{
    if(n==1)
        return 1;
    return n * fact(n-1);
}
pair<int ,char>p;
pair<int ,char>p1;
pair<int ,char>p2;
int main(){
    long long n=lld(),m=lld();
    m/=2;

    if(n<=m){
        printf("%lld",n+(m-n)/2);
    }
    else{
        printf("%lld\n",m);
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int> pii;

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

  vector<int> cnt(n+10, 0);
  int ones = 0, border = 0;
  rep(i,n){
    int x;
    cin >> x;
    if(x >= n+10){
      ones++;
      cout << "Yes" << endl;
    }else{
      if( cnt[0] or (x <= border and ones-x > 0) ){
	cout << "No" << endl;
      }else{
	cout << "Yes" << endl;
	cnt[x]++;
	while(cnt[x] == 2){
	  cnt[x] = 0; ones--;
	  x--; cnt[x]++;
	}
	ones++;
	//cout << x << " " << border << endl;
	while(cnt[border+1]) border++;
      }
    }
  }
}

Measured memory_bytes: 4636
const inputText = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(/\s/)
  .map((i) => parseInt(i, 10));

const a = inputText[0];
const b = inputText[1];
const c = inputText[2];
const d = inputText[3];

if (a + b < c + d) {
  console.log("Right");
} else if (a + b > c + d) {
  console.log("Left");
} else {
  console.log("Balanced");
}

Measured memory_bytes: 21064
// written at 18:11 on 12 Feb 2017 
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector> 
#include <utility>
#include <bitset>

#define IOS std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
// #define __DEBUG__
#ifdef __DEBUG__
	#define DEBUG(...) printf(__VA_ARGS__)
#else
	#define DEBUG(...)
#endif
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".ans", "w", stdout);
#define resetfile() freopen("/dev/tty", "r", stdin); freopen("/dev/tty", "w", stdout); system("more " filename".ans");
#define rep(i, j, k) for (int i = j; i < k; ++i)
#define irep(i, j, k) for (int i = j - 1; i >= k; --i)

using namespace std;

template <typename T>
inline T sqr(T a) { return a * a;};

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int > Pii;

const double pi = acos(-1.0);
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = 2e2 + 10;
const double EPS = 1e-10;

int W, H, N;
double X[MAX_N], Y[MAX_N], th[MAX_N];

int main(int argc, char const *argv[])
{
	while (scanf("%d%d%d", &W, &H, &N), N) {
		rep(i, 0, 2 * N) scanf("%lf%lf", X + i, Y + i);
		X[2 * N] = W; Y[2 * N] = 0;
		X[2 * N + 1] = W; Y[2 * N + 1] = H;
		vector<double> v;
		rep(i, 0, 2 * N + 2) rep(j, i + 1, 2 * N + 2) {
			if (fabs(X[i] - X[j]) < EPS) continue;
			double tmp = Y[i] - X[i] * (Y[i] - Y[j]) / (X[i] - X[j]);
			if (tmp < 0 || tmp > H) continue;
			v.push_back(tmp);
		}
		v.push_back(0); v.push_back(H);
		sort(v.begin(), v.end());
		double ret = 0;
		rep(i, 0, v.size() - 1) {
			if (v[i + 1] - v[i] < EPS) continue;
			double mid = (v[i] + v[i + 1]) / 2;
			rep(j, 0, 2 * N + 2) th[j] = atan2(Y[j] - mid, X[j]);
			sort(th, th + 2 * N + 2);
			// if (th[N] < -pi / 2 + EPS) th[N] += EPS;
			// if (th[N + 1] < -pi / 2 + EPS) th[N + 1] += EPS;
			// if (th[N] > pi / 2 - EPS) th[N] -= EPS;
			// if (th[N + 1] > pi / 2 - EPS) th[N + 1] -= EPS;
			double L = max(0., mid + W * tan(th[N]));
			double R = min((double)H, mid + W * tan(th[N + 1]));
			ret += max(0.0, R - L) * (v[i + 1] - v[i]);
		}
		printf("%.12f\n", ret / H / H);
	}
	return 0;
}

Measured memory_bytes: 3712
#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;
  string s; cin>>s;
  if(n%2==1)cout<<"No";
  else{
    string ans="Yes";
    rep(i,n/2){
      if(s.at(i)!=s.at(i+n/2)){
        ans="No";break;
      }
    }
    cout<<ans;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,c,d[35][35],p[505][505],cnt[3][30];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=c;i++)for(int j=1;j<=c;j++)cin>>d[i][j];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		int a;
		cin>>a;
		cnt[(i+j)%3][a]++;
	}
	long long ans=2e9;
	for(int i=1;i<=c;i++)for(int j=1;j<=c;j++)for(int k=1;k<=c;k++)
	{
		if(i==j||j==k||i==k)continue;
		long long tot=0;
		for(int l=1;l<=c;l++)tot+=cnt[0][l]*d[l][i]+cnt[1][l]*d[l][j]+cnt[2][l]*d[l][k];
		ans=min(ans,tot);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int a[15][1010];
int main(void)
{
    sync;
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=1;i<=h;++i)
        for(int j=1;j<=w;++j)
        {
        	char ch;
            cin>>ch;
            a[i][j]=ch-'0';
        }
    int res=0x7fffffff;
    for(int i=0;i<(1<<(h-1));++i)
    {
        vector<int>pos;
        pos.push_back(0);
        for(int j=1;j<h;++j)
            if(i&1<<(j-1))
                pos.push_back(j);
        pos.push_back(h);
        int now=pos.size()-2;
        vector<int>cnt(pos.size()-1,0);
        for(int j=1;j<=w;++j)
        {
            bool ok=true;
            vector<int>cntc(pos.size()-1,0);
            for(int x=0;x<(int)cnt.size();++x)
            {
                for(int y=pos[x]+1;y<=pos[x+1];++y)
                    cntc[x]+=a[y][j];
                if(cntc[x]>k)
                    goto label_end;
                if(cnt[x]+cntc[x]>k)
                    ok=false;
            }
            if(ok)
            {
                for(int x=0;x<(int)cnt.size();++x)
                    cnt[x]+=cntc[x];
            }
            else
            {
                cnt=cntc;
                ++now;
            }
        }
        res=min(res,now);
        label_end:;
    }
    cout<<res<<endl;
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    vector<ll> sumV(N, 0);
    REP(i, N)
    {
        cin >> V[i];
        if (i == 0) sumV[i] = V[i];
        else sumV[i] = sumV[i - 1] + V[i];
    }

    ll ans = 0;
    for (ll i = 0; i <= K; ++i)
    {
        for (int j = 0; j <= min(i, N); ++j)
        {
            for (int k = 0; k <= min(i, N) - j; ++k)
            {
                priority_queue<ll, vector<ll>, greater<ll>> q;
                REP(p, j) q.push(V[p]);
                REP(p, k) q.push(V[N - 1 - p]);
                ll currentSum = 0;
                if (j != 0) currentSum += sumV[j - 1];
                if (k != N) currentSum += sumV[N - 1] - sumV[N - 1 - k];
                else currentSum += sumV[N - 1];
                ans = max(ans, currentSum);
                REP(l, i - (j + k))
                {
                    if (!q.empty())
                    {
                        ll v = q.top();
                        q.pop();
                        currentSum -= v;
                        ans = max(ans, currentSum);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int N,M;
int ans = 0;

void dfs(Graph &G, set<int> &S, int i) {
    
    if (S.size()==N) {
        ans++;
        return;
    }

    else {
        for(auto j: G[i]){
            if (!S.count(j)) {
                S.insert(j);
                dfs(G,S,j);
                S.erase(j);
            }            
        }

    }

}

int main (){
    
    cin >> N >> M;
    Graph G(N);

    int a,b;
    rep(i,0,M) {
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    set<int> S;
    S.insert(0);
    dfs(G,S,0);
    cout << ans << endl;
}




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

int main()
{
    string s,t;
    cin>>s>>t;
    ll n = s.length();
    ll m = t.length();

    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++)    dp[i][0] = 0;
    for(ll i=0;i<=m;i++)    dp[0][i] = 0;

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            if(s[i-1] == t[j-1])
                dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
        }
    }

    string ans;
    ll i=n;
    ll j=m;

    while(i>0 && j>0)
    {
        if(dp[i][j] == dp[i-1][j])  i--;
        else if(dp[i][j] == dp[i][j-1])  j--;
        else if(s[i-1] == t[j-1])
        {
            ans += s[i-1];
            i--;
            j--;
        }
    }
    for(ll i=ans.length()-1;i>=0;i--)
        cout<<ans[i];
    return 0;
}


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

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int ng = 0, ok = 1<<30; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		int m = (ok + ng) / 2;
		int c = 0;
		rep(i, N) c += (A[i] - 1) / m;
		if(c <= K) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


Measured memory_bytes: 4056
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct X
{
	char n;int w,l;
} X;

X P[11];
int N,i,j,t;

int cmp(const void *a,const void *b)
{
	X *x=(X*)a;
	X *y=(X*)b;
	return x->w==y->w?x->l>y->l:y->w-x->w;
}

int main()
{
	for(;scanf("%d\n",&N),N;)
	{
		memset(P,0,sizeof(P));
		for(i=0;i<N;i++)
		{
			scanf("%c",&P[i].n);
			for(j=0;j<N-1;j++)
			{
				scanf("%d",&t);
				if(t==0)P[i].w++;
				else if(t==1)P[i].l++;
			}
			getchar();
		}
		qsort(P,N,sizeof(X),cmp);
		for(i=0;i<N;i++)printf("%c\n",P[i].n);
	}
	return 0;
}

Measured memory_bytes: 616
#include <stdio.h>
int main(void){

    long int n,m=0,a=0,r=0,c=0,h=0;
  	long int count=0;
    scanf("%ld",&n);
    for(int i=0;i<n;i++){
        char s[11];
        scanf("%s",s);
        if(s[0] == 'M') ++m;
        if(s[0] == 'A') ++a;
        if(s[0] == 'R') ++r;
        if(s[0] == 'C') ++c;
        if(s[0] == 'H') ++h;
    }
    count = (m*a*(r+c+h) + m*r*(c+h) + a*r*(c+h) + (m+a+r)*c*h);
    printf("%ld",count);
    return 0;
}

Measured memory_bytes: 128