akhauriyash/Code-Regression huggingface dataset:
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

struct UnionFind
{
    vector<int> par;
    vector<int> siz;
    UnionFind(int n) : par(n), siz(n, 1)
    {
        rep(i, n) par[i] = i;
    }
    int root(int x)
    {
        while (par[x] != x) x = par[x] = par[par[x]];
        return x;
    }
    bool unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }
    int same(int x, int y)
    {
        return root(x) == root(y);
    }
};

void solve()
{
    IN(n, m, k);
    UnionFind uf(n);
    ll s[n];
    rep(i, n)
    {
        s[i] = 0;
    }
    rep(i, m)
    {
        IN(a, b);
        --a;
        --b;
        uf.unite(a, b);
        --s[a];
        --s[b];
    }
    rep(i, n)
    {
        s[i] += uf.siz[uf.root(i)];
    }
    rep(i, k)
    {
        IN(a, b);
        --a;
        --b;
        if (uf.same(a, b))
        {
            --s[a];
            --s[b];
        }
    }
    rep(i, n)
    {
        cout << s[i] - 1 << " ";
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 2432
from collections import deque
H, W = map(int, input().split())
A = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]
L = []
for i in range(H):
    for j in range(W):
        if A[i][j]: L.append((i, j))
def BFS():
    Q = deque(L)
    D = [[-1] * W for _ in range(H)]
    for i, j in L:
        D[i][j] = 0
    while Q:
        i, j = Q.popleft()
        for di, dj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            ni, nj = i+di, j+dj
            if 0 <= ni < H and 0 <= nj < W:
                if D[ni][nj] == -1:
                    D[ni][nj] = D[i][j] + 1
                    Q.append((ni, nj))
    return D

print(max([max(a) for a in BFS()]))

Measured memory_bytes: 113512
#include <stdio.h>

int main() {
    int n,k, eq=0;
    scanf("%d %d", &n, &k);
    eq= (100*(10-n));
    if (n <= 10)
        printf("%d", eq+k);
    else
        printf("%d", k);
    printf("\n");
    

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string L[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main(void){
    int n; cin >> n;
    for(string in; n-- && cin >> in; cout << endl){
        int cur = 0, cnt = 0;
        rep(i, in.size()){
            if(in.at(i) - '0' == cur) cnt++;
            else{
                if(in.at(i) == '0'){
                    cout << L[cur].at((cnt + L[cur].size()) % L[cur].size());
                }
                cur = in.at(i) - '0';
                cnt = 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long[] Solve(int N, long[] A)
        {
            var ans = new long[N];
            for (int i = 1; i < N; ++i)
            {
                ans[i] = A[i - 1] * 2 - ans[i - 1];
            }
            long x = (A[N - 1] * 2 - ans[N - 1]) / 2;
            for (int i = 0; i < N; ++i)
            {
                ans[i] += (i % 2 == 0) ? x : -x;
            }
            return ans;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            long[] A = ReadLongs();
            Console.WriteLine(string.Join(" ", Solve(N, A)));
        }
    }
}


Measured memory_bytes: 31104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            double N = in.nextInt();
            out.printf("%.10f", Math.ceil(N / 2) / N);
        }

    }
}



Measured memory_bytes: 23764
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  int al,bl,cl,ac,bc,cc,ans,mi=1e9;
  for(int bit=0;bit<(1<<16);bit++){
    al=bl=cl=ac=bc=cc=0;
    for(int i=0;i<n;i++){
      if((bit&(1<<2*i))>0 && (bit&(1<<(2*i+1)))>0){
        al+=A[i];
        ac++;
      }
      else if((bit&(1<<2*i))==0 && (bit&(1<<(2*i+1)))>0){
        bl+=A[i];
        bc++;
      }
      else if((bit&(1<<2*i))>0 && (bit&(1<<(2*i+1)))==0){
        cl+=A[i];
        cc++;
      }
    }
    if(ac==0 || bc==0 || cc==0) continue;
    else if(0<cl && cl<=bl && bl<=al){
      ans=(ac+bc+cc-3)*10+abs(a-al)+abs(b-bl)+abs(c-cl);
      mi=min(mi,ans);
    }
  }
  
  cout<<mi<<endl;
  
  return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    cin >> s;
    string t = "";
    for (int i = 0; i < s.size(); i += 2) {
        t += s[i];
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    
    while (1) {
        int n, s[1000] = {}, m = 0; double x = 0;
        cin >> n;
        if (n == 0) break;
        for (int i = 0;i < n;i++) {
            cin >> s[i];
            m += s[i];
        }
        for (int i = 0; i < n;i++) {
            x += pow(s[i] - 1. * m / n, 2);
        }
        double y = sqrt(x / n);
        printf("%.6f\n", y);
    }
}


Measured memory_bytes: 3224
f_1 = {1,3,5,7,8,10,12}
f_2 = {4,6,9,11}
 
x, y = map(int, input().split())
if (x in f_1) and (y in f_1):
  print("Yes")
elif (x in f_2) and (y in f_2):
  print("Yes")
else:
  print("No")

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

int make_sita(int x) {
  int ans = x - (x/100)*100;
  return ans;
}

int main() {
  int x;
  cin >> x;
  
  int sita = x - (x/100)*100;
  int syaku = x/100;
  
  int ans = 1;
  for (int i=5; i>=1; i--) {
    int maisu = sita/i;
    sita = sita - maisu * i;
    syaku -= maisu;
    if (syaku < 0) {
      ans = 0;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
string s;
cin >>s;
s[5] = ' ';
s[13] = ' ';
cout << s << endl;








  
 
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        long answer = 1;
        if (N % 2 == 0) {
            for (int i = 0; i < N / 2; i++) {
                if (A[2*i] == 1 + 2 * i && A[2*i+1] == 1 + 2 * i) {
                    answer = answer * 2 % 1000000007;
                    continue;
                }
                answer = 0;
                break;
            }
        } else {
            for (int i = 0; i < (N-1) / 2; i++) {
                if (A[2*i+1] == 2 * (i+1) && A[2*i+2] == 2 * (i+1)) {
                    answer = answer * 2 % 1000000007;
                    continue;
                }
                answer = 0;
                break;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 52148
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int N;
double a,b,c,d;
double EPS = 1e-3;
double EPS2 = 1e-9;
 
double func(double x){
    return a*x*x*x + b*x*x + c*x + d;
}
 
int pl,mn;
 
bool is_zero(double x){
    if(abs(x) < EPS) return true;
    return false;
}
 
bool fis_zero(double x){
    if(abs(x) < EPS2) return true;
    return false;
}
 
void add(double x){
    if(is_zero(x)) return;
    if(x > 0) pl++;
    else if(x < 0) mn++;
    return;
}
 
void bisearch(double x, double y){
    if(func(y) < func(x)) swap(x,y);
    if(fis_zero(func(x))){ add(x); return;}
    if(fis_zero(func(y))){ add(y); return;}
    double mid;
    int ct = 0;
    rep(i,100){
        mid = (x+y)/2;
        if(fis_zero(func(mid))) break;
        if(func(mid) > 0) y = mid;
        else if(func(mid) < 0) x = mid;
        ct++;
    }
    if(ct == 100) return;
    add(mid);
    return;
}
 
int main(){
    int N;
    cin >> N;
    rep(i,N){
        cin >> a >> b >> c >> d;
        b /= a, c /= a, d /= a, a = 1;
        pl = 0, mn = 0;
        double D = b*b - 3*a*c;
        double xl,xs;
         
        if(D < 0) bisearch(-10000,10000);
        else{
            xs = (-b-sqrt(D))/(3*a);
            xl = (-b+sqrt(D))/(3*a);
            bisearch(-10000,min(xs,xl));
            bisearch(min(xs,xl),max(xs,xl));
            bisearch(max(xs,xl),10000);
        }
         
        cout << pl << " " << mn << endl;
    }
     
}


Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
  int i,n;
  double j=0,b=0,B=0;
  cin >> n;
  double x[n];
  string u[n];
  rep(i,n)cin >> x[i] >> u[i];

  rep(i,n){
      if(u[i]=="JPY"){
          j += x[i];
      }

      else if(u[i]=="BTC"){
          b += x[i];
      }
  }
  B = b*380000;
  cout << j+B << endl;






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    bool f=false;
    if(S[0]==S[1] && S[1]==S[2] && S[2]==S[3]){
    }else if(S[0]==S[1]){
        if(S[2]==S[3]) f=true;
    }else if(S[0]==S[2]){
        if(S[1]==S[3]) f=true;
    }else if(S[0]==S[3]){
        if(S[1]==S[2]) f=true;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3124
import sys
sys.setrecursionlimit(10**7)
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
visited = [[False]*w for _ in range(h)]

def dfs(y,x):
    visited[y][x] = True
    blk, wht = 0,0
    for dy,dx in zip((-1,1,0,0),(0,0,-1,1)):
        ny,nx = y+dy, x+dx
        if (not (0<=ny<h)) or (not (0<=nx<w)) or visited[ny][nx]:
            continue
        if s[y][x]!=s[ny][nx]:
            nb,nw = dfs(ny,nx)
            blk += nb
            wht += nw
    if s[y][x]=='#':
        blk += 1
    else:
        wht += 1
    return blk, wht

ans = 0
for i in range(h):
    for j in range(w):
        if not visited[i][j]:
            blk, wht = dfs(i,j)
            ans += blk*wht
print(ans)

Measured memory_bytes: 195060
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        double b = sc.nextDouble();
        int c = (int)Math.round(100*b);
        System.out.println((long)(a*c)/100);
    }
}

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

int main() {
	int n;cin>>n;
	double ans=0;
	for(int i=0;i<n;i++){
		double x;cin>>x;
		string u;cin>>u;
		if(u[0]=='J'){
			ans+=x;
		}else{
			ans+=x*380000;
		}
	}
	cout<<setprecision(10);
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N,H[100];
    cin >> N;

    rep(i,N){
        cin >> H[i];
    }

    int count=0;
    for(int i=0;i<N;i++){
        bool dekai=true;
        for(int j=0;j<i;j++){
            if(H[j] > H[i]){
                dekai=false;
                break;
            }
        }
        if(dekai){
            count++;
        }
    }

    cout << count <<endl;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	FOR(i,0,n)cin >> a[i];
	FOR(i,0,n)cin >> b[i];
	FOR(i,0,n)cin >> c[i];
	sort(ALL(a));
	sort(ALL(c));
	ll ans = 0;
	FOR(i,0,n){
		ll aCount = lower_bound(ALL(a), b[i]) - a.begin();
		int cCount = c.end() - upper_bound(ALL(c), b[i]);
		//cout << aCount << " * " << cCount << " = " << aCount*cCount << "\n";
		ans += aCount * cCount;;
	}
	ANS(ans);
	return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
const double PI=3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



ll n;
double dp[310][310][310];
double rec(ll i, ll j, ll k){
  if(dp[i][j][k] >= 0) return dp[i][j][k];
  if( !(i|j|k) ) return 0.0; 

  double res = 0.0;
  if(i > 0) res += rec(i-1, j, k)*i;
  if(j > 0) res += rec(i+1, j-1, k)*j;
  if(k > 0) res += rec(i, j+1, k-1)*k;
  res += n;
  res *= 1.0 / (i + j + k);

  return dp[i][j][k] = res;
};

int main() {


  cout<<fixed<<setprecision(10);

  cin>>n;
  ll a,b,c;
  a = b = c = 0;
  rep(i,n){
    ll x; cin>>x;
    if(x==1) a++;
    if(x==2) b++;
    if(x==3) c++;
  }

  memset(dp, -1, sizeof(dp));

  cout<<rec(a,b,c)<<endl;

}

//


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

int main( void )
{
    int a,b;
    cin >> a >> b;
    
    if ( a == 1 )
        a += 13;
    if ( b == 1 )
        b += 13;
    
    if ( a > b )
        cout << "Alice" << endl;
    else if ( b > a )
        cout << "Bob" << endl;
    else if ( a == b )
        cout << "Draw" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
int H[1000010], V[1000010];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		int a; cin >> a; a--;
		H[a]++;
	}
	rep(i, 0, M) {
		int a; cin >> a; a--;
		V[a]++;
	}
	int sh = 0, sv = 0, cross = 0;
	ll res = 1;
	rer(i, N * M, 0) {
		if(H[i] >= 2 || V[i] >= 2) {
			cout << 0 << "\n"; return;
		}
		else if(H[i] && V[i]) {
			sh++;
			sv++;
			cross++;
		}
		else if(H[i]) {
			MUL(res, sv);
			sh++;
			cross++;
		}
		else if(V[i]) {
			MUL(res, sh);
			sv++;
			cross++;
		}
		else {
			MUL(res, max(sh * sv - cross, 0));
			cross++;
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n;
	cin>>n;
	vector<double> p(n+1);
	for(int i=1;i<=n;i++) cin>>p[i];
	vector<vector<double>> dp(n+1,vector<double>(n+1));
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
		for(int j=1;j<=i;j++){
			dp[i][j]=(dp[i-1][j]*(1-p[i]));
			dp[i][j]+=(dp[i-1][j-1]*p[i]);
		}
	}
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++) ans+=dp[n][i];
	cout<<setprecision(10)<<fixed<<ans;
	
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
 
}

Measured memory_bytes: 70656
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((int)Math.ceil((a + b) / 2.0));
    }
}

Measured memory_bytes: 21844
class Dice:
    def __init__(self, top, front, right, left, rear, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.rear = rear
        self.bottom = bottom
    def print(self):
        '''print top of dice'''
        print(self.top)
    def north(self):
        self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
    def south(self):
        self.top, self.front, self.bottom, self.rear = \
            self.rear, self.top, self.front, self.bottom
    def east(self):
        self.top, self.right, self.bottom, self.left = \
            self.left, self.top, self.right, self.bottom
    def west(self):
        self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top
    def clockwise(self):
        self.front, self.right, self.rear, self.left = \
            self.right, self.rear, self.left, self.front
    def ccw(self):
        self.front, self.right, self.rear, self.left = \
            self.left, self.front, self.right, self.rear
    def __eq__(self, other):
        # top, front, bottom, rear, left, right をこの順で上面にする回転パターン
        pattern = ['', 'N', 'N', 'N', 'E', 'EE']
        tmp = Dice(other.top, other.front, other.right, other.left, other.rear, other.bottom)
        for i in pattern:
            if i == 'N':
                tmp.north()
            elif i == 'E':
                tmp.east()
            elif i == 'EE':
                tmp.east()
                tmp.east()
            else:
                pass
            if self.top != tmp.top or self.bottom != tmp.bottom:
                continue
            for j in range(4):
                if self.front == tmp.front and self.right == tmp.right and \
                   self.rear == tmp.rear and self.left == tmp.left:
                    return True
                tmp.clockwise()
        return False

n = int(input())
dice = []
for i in range(n):
    d = list(map(int, input().split()))
    dice.append(Dice(d[0], d[1], d[2], d[3], d[4], d[5]))

for i in range(n-1):
    for j in range(i+1, n):
        if dice[i] == dice[j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

};

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

    UnionFind uf(n);

    rep(i, q) {
        int query;
        cin >> query;
        if (query == 0) {
            int x, y;
            cin >> x >> y;
            uf.connect(x, y);
        } else {
            int x, y;
            cin >> x >> y;
            cout << (uf.root(x) == uf.root(y)) << endl;
        }
    }


}



Measured memory_bytes: 3144
require 'set'
h,w = gets.split.map(&:to_i)
ab = (1..h).map{gets.split.map(&:to_i)}
h.times{|i|
  gets.split.map(&:to_i).each.with_index{|b,j|
    ab[i][j] = (ab[i][j] - b).abs
  }
}
zero = 1 << 10000

dp = (1..h).map{(1..w).map{nil}+[0]}+[(1..w).map{0}]
max = ab.map(&:max).max

dp[0][-1] = dp[-1][0] = zero

(0...h).each{|th|
  abth = ab[th]
  dpth = dp[th]
  dpth1 = dp[th-1]
  (0...w).each{|tw|
    d = abth[tw]
    s = dpth1[tw] | dpth[tw-1]
    dst = (s << d) | (s >> d) 
    dpth[tw] = dst
  }
}
ans = dp[h-1][w-1]
p (0..max).find{|i|
  ans & (zero << i) > 0 ||
  ans & (zero >> i) > 0
}

Measured memory_bytes: 32124
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        for r in xyh:
            if r[2] > 0:
                ch = r[2] + abs(r[0] - cx) + abs(r[1] - cy)
                break
        j = False
        for r in xyh:
            if r[2] != max((ch - abs(r[0] - cx) - abs(r[1] - cy)),0):
                j = True
                break
        if not j:
            print(cx,cy,ch)



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end(),greater<int>());
    ll ans = a[0];
    n-=2;
    for (int i = 1; n; i++) {
        ans += a[i] * min(2, n);
        n -= min(2, n);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N; cin>>N;
    ll SUM=0;
    priority_queue<P> Q;
    priority_queue<P> MIN;
    rep(i,N){
        string S; cin>>S;
        ll a=0;
        ll count=0;
        rep(j,S.size()){
            if(S[j]=='(') count++;
            else count--;
            a=min(count,a);
        }
        if(count>=0) Q.push(mp(a,count));
        else {
            ll COUNT=0, A=0;
            for(int j=S.size()-1;j>=0;j--){
                if(S[j]==')') COUNT++;
                else COUNT--;
                A=min(A,COUNT);
            }
            MIN.push(mp(A,COUNT));
        }
        SUM+=count;
    }
    bool able=true;
    if(SUM!=0) able=false;
    if(able){
        ll y=0;
        while(!Q.empty()){
            ll count=Q.top().second, a=Q.top().first;
            Q.pop();
            if(a+y<0) {
                able=false;
                break;
            }
            else y+=count;
        }
        y=0;

        while(!MIN.empty()){
            ll count=MIN.top().second, a=MIN.top().first;
            MIN.pop();
            if(a+y<0) {
                able=false;
                break;
            }
            else y+=count;
        }
        

    }
    if(able) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    
}



Measured memory_bytes: 18916
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;
 
#define MAX_N 200000
 
using namespace std;
 
int par[MAX_N];
int rnk[MAX_N];
long long int diff[MAX_N];
 
// 初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rnk[i] = 0;
        diff[i] = 0;
    }
}
 
// x の親を返す
P find(int x){
    P p;
    if(par[x] == x){
        p.first = x;
        p.second = 0;
        return p;
    }
    p = find(par[x]);
    diff[x] += p.second;
    p.second = diff[x];
    par[x] = p.first;
    return p;
}
 
// x と y を併合する
bool unite(int x, int y, int z){
    P px = find(x);
    P py = find(y);
    int x_par = px.first;
    int y_par = py.first;
    if(x_par == y_par){
    	return diff[x] - diff[y] == z;
    }
    
    if(rnk[x_par] < rnk[y_par]){
        par[x_par] = y_par;
        diff[x_par] = diff[y_par] - px.second + py.second + z;
    }else{
        par[y_par] = x_par;
        diff[y_par] = diff[x_par] + px.second - py.second - z;
        if(rnk[x_par] == rnk[y_par]){
            rnk[x_par]++;
        }
    }
	return true;
}
 
// x, y が同じグループか判定
bool same(int x, int y){
    P px = find(x);
    P py = find(y);
    int x_par = px.first;
    int y_par = py.first;
    return (x_par == y_par);
}

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_N];
long long int val[200000];

void func(int n, long long int num){
	
	if(val[n] > -INF){
		return;
	}
	
	val[n] = num;
	
	for(int i = 0; i < G[n].size(); i++){
		func(G[n][i].to, G[n][i].cost - num);
	}
}

int main(){
	
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		long long int u, v, s;
		cin >> u >> v >> s;
		u--;
		v--;
		edge e;
		e.cost = s;
		e.to = u;
		G[v].push_back(e);
		e.to = v;
		G[u].push_back(e);
	}
	
	init(n);
	bool flag = true;
	
	for(int i = 0; i < n; i++){
		if(G[i].size() >= 2){
			edge es = G[i][0];
			for(int j = 1; j < G[i].size(); j++){
				edge e = G[i][j];
				bool ret = unite(es.to, e.to, es.cost - e.cost);
				flag = (flag && ret);
			}
		}
	}
	
	if(!flag){
		cout << 0 << endl;
		return 0;
	}
	
	flag = true;
	
	for(int i = 0; i < n; i++){
		flag = (flag && same(0, i));
	}
	
	if(flag){
		bool ff = true;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < G[i].size(); j++){
				int p1 = G[i][j].cost + (diff[i] - diff[G[i][j].to]);
				int p2 = G[i][j].cost - (diff[i] - diff[G[i][j].to]);
				//cout << p1 / 2 << " " << p2 / 2 << endl;
				if(p1 <= 0 || p2 <= 0){
					ff = false;
				}
			}
		}
		if(ff){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
		return 0;
	}
	
	
	for(int i = 0; i < n; i++){
		val[i] = -INF;
	}
	
	func(0, 0);
	long long int a1 = INF, a2 = INF;
	
	for(int i = 0; i < n; i++){
		if(same(0, i)){
			a1 = min(a1, val[i]);
		}else{
			a2 = min(a2, val[i]);
		}
	}
	
	cout << max(0LL, a1 + a2 - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 13952
import Data.Array (array, elems)
import Data.List (groupBy, sort)
import Control.Monad (forM_)

toSWithPad n x = replicate (n-l) '0' ++ s where
  s = show x
  l = length s

toC [x,y] = (x,y)
tw f x = f (f x)

gp :: [(Int,Int)] -> [[((Int,Int),Int)]]
gp = groupBy (\x y->fst (fst x)==fst (fst y)) . sort . flip zip [0..]

fi cs = go 1 cs where
  go n [] = []
  go n (((pref,year),i):cs) = (i,(pref,n)) : go (n+1) cs

solv n m cs = elems $ array (0,m-1) $ concat [fi cs'| cs' <- gp cs]

main = do
  [n,m] <- map read . words <$> getLine
  cs <- map (toC . map read . words) . lines <$> getContents :: IO [(Int,Int)]
  forM_ (solv n m cs) $ 
    \(pref,n) -> putStr (toSWithPad 6 pref) >> putStrLn (toSWithPad 6 n)


Measured memory_bytes: 95612
H, W = map(int, input().split())
a = ["#"] * (H + 2)

for i in range(W + 1):
    a[0] += "#"
    a[H + 1] += "#"

for i in range(1, H + 1):
    a[i] += "".join(input().split()) + "#"

for i in range(H + 2):
    print(a[i])

Measured memory_bytes: 3060
n = int(input())
x = input()
 
# 元のpopcount
original_pop_count = x.count('1')
# 反転して-1count
one_pop_count = original_pop_count - 1
# 反転して+1count
zero_pop_count = original_pop_count + 1
 
# ±1それぞれにおける余り
if one_pop_count == 0:
  one_mod = 0
else:
  one_mod = int(x, 2) % one_pop_count
zero_mod = int(x, 2) % zero_pop_count
 
# f の前計算 
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i//2] + i % 2
    f[i] = f[i % pop_count[i]] + 1
 
# pow2 の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
    zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count
    
# n-1, n-2, ,, 0
for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            # - 2^i % 2
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt] + 1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        # + 2^i % 2
        nxt %= zero_pop_count
        print(f[nxt] + 1)

Measured memory_bytes: 80548
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & (-x))

using namespace std;




int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    vector <int> arr(n + 1);
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    vector <int> sol;
    for(i = 1; i <= n; i++) {
        int j = 1, cnt = 0, last = -1;
        while(j <= n) {
            if(arr[j] != 0) {
                cnt++;
                if(arr[j] == cnt) {
                    last = j;
                }
            }
            j++;
        }
        if(last == -1) {
            break;
        }
        sol.push_back(arr[last]);
        arr[last] = 0;
    }
    if(sol.size() == n) {
        reverse(sol.begin(), sol.end());
        for(auto it : sol) {
            cout << it << "\n";
        }
    }
    else {
        cout << -1;
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    scanf("%d %d",&n,&x);
    vector<int> koor;
    koor.push_back(x);
    for(int a=0;a<n;a++){
        scanf("%d",&x);
        koor.push_back(x);
    }
    sort(koor.begin(),koor.end());
    int gcd=0,st;
    int nol=koor[0];
    for(int a=0;a<=n;a++){
        koor[a]-=nol;
    }
    for(int a=1;a<=n;a++){
        gcd=__gcd(gcd,koor[a]);
    }
    printf("%d\n",gcd);
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

ull gcd(ull a, ull b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ull lcm(ull a, ull b)
{
   return a * b / gcd(a, b);
}

int main() {
	ull A, B, C, D;
	cin >> A >> B >> C >> D;

	ull total = B - A + 1;

	ull x = B / C - (A-1) / C;
	ull y = B / D - (A-1) / D;
	ull E = lcm(C, D);
	// printf("E %i\n", E);
	ull z = B / E - (A-1) / E;

	// printf("x, y, z = %i, %i, %i\n", x, y, z);

	cout << total - (x + y - z) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	char s[4000];
	long long int r=0,g=0,b=0,sum,dis=0;
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			r+=1;
		}else if(s[i]=='G'){
			g+=1;
		}else{
			b+=1;
		}
	}
	sum=r*g*b;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			if(s[i]!=s[j]){
				if(2*j-i<n&&s[2*j-i]!=s[j]&&s[2*j-i]!=s[i]){
					dis+=1;
				}
			}
		}
	}
	printf("%lld",sum-dis);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	double t, x; cin >> t >> x;
	printf("%.10f", (t / x));
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  
  int N;
  cin >> N;
  
  
  int a, b, c;
  
  c = N % 10;
  b = ((N - c) % 100) / 10;
  
  a = (N - b*10 - c) / 100;
  
  string ans = "No";
       
  if (a == 7 || b == 7 || c == 7) {
    ans = "Yes";
  }     
  
  cout << ans << endl;
  

}

Measured memory_bytes: 3620
// AOJ 2214: Warp Hall
// 2018.1.7 bal4u@uu

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

#define M 1000000007

typedef struct { int a, b, c, d; } T;
T warp[1002];

int fact[200001];
int dp[1002];

int cmp(T *a, T *b) { if (a->a - b->a) return a->a - b->a; return a->b - b->b; }

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int egcd(int a, int b, int *x, int *y)
{
	int d;
	if (b == 0) { *x = 1; *y = 0; return a; }
	d = egcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}
     
int inv(int a)
{
	int x, y;
	egcd(a, M, &x, &y);
	x %= M; if (x < 0) x += M;
	return x;
}
     
int comb(int n, int k)
{
	long long a = fact[n];
	a = a * inv(fact[n-k]) % M;
	a = a * inv(fact[k]) % M;
	return (int)a;
}
     
int calc(int a, int b, int c, int d)
{
	if (c < a || d < b) return 0;
	return comb(c-a + d-b, c-a);
}
     
int main()
{
	int n, m, k, i, j, a, b;
	T *p, *q;

	fact[0] = 1;
	for (i = 1; i <= 200000; i++) fact[i] = (long long)fact[i-1] * i % M;

	while (n = in()) {
		n--, m = in()-1, k = in();

		for (p = warp, i = 0; i < k; i++, p++)
			p->a = in()-1, p->b = in()-1, p->c = in()-1, p->d = in()-1;
		p->a = n, p->b = m, p->c = n+1, p->d = m+1;
		qsort(warp, k, sizeof(T), cmp);

		memset(dp, 0, sizeof(dp));
        for (p = warp, i = 0; i <= k; i++, p++) {
            dp[i] = comb(p->a + p->b, p->b);
            for (q = warp, j = 0; j < i; j++, q++) {
				a = calc(q->c, q->d, p->a, p->b);
				b = calc(q->a, q->b, p->a, p->b);
				a -= b; if (a < 0) a += M;
				a = (long long)a * dp[j] % M;
				dp[i] += a; if (dp[i] >= M) dp[i] -= M;
			}
		}
		printf("%d\n", dp[k]);
	}
	return 0;
}


Measured memory_bytes: 2552
N = int(input())
#A = list(map(int,input().split()))
B = list(map(int,input().split()))
#C = list(map(int,input().split()))
#[A, B] = list(map(int,input().split()))
#N = 3
#A = [1, 2]
#B = [0,153,10,10,23]
B = [10**6]+B+[10**6]
ans=0
for i in range(len(B)-1):
    ans += min(B[i],B[i+1])
print(ans)

Measured memory_bytes: 3060