akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int hanbetu=0,n;
    cin>>n;
    int sum=0,a,b=-1,c=0;
    rep(i,n){
        cin>>a;
        if(a==b){
            cerr<<"enter"<<endl;
            c++;
        }else{
            cerr<<"enter"<<endl;
            sum+=c/2;
            b=a;
            c=1;
        }
    }
    sum+=c/2;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        //配列の要素数に対応する数字を格納
        //グループ0:0
        //グループ1：1,3,5,7,8,10,12
        //グループ2：4,6,9,11
        //グループ3：2
        int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
        
        //同じグループに属するか判定して結果を出力
        if(a[x] == a[y]){
                System.out.println("Yes");
        }else{
                System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 35540
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec

getIntList = map read . words <$> getLine
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c
main = do
  
  [n,k] <- getIntList
  psl <- getIntList 
  csl <- getIntList 
  let ps = Vec.fromList (map (+(-1)) psl)
  let cs = Vec.fromList csl

  --ダブリングなら可能?
  let (_,_,ans) = Vec.unzip3(solve n k ps cs)
  putStrLn (show(maximum (Vec.toList ans)))

solve:: Int->Int->Vec.Vector Int ->Vec.Vector Int -> Vec.Vector(Int,Int,Int)
solve n k ps cs 
  | k==1 = Vec.zip3 ps cs cs
  | (k `mod` 2)==0 = sou n mae mae
  | otherwise = sou n (sou n mae mae) (Vec.zip3 ps cs cs)
  where
    mae = solve n (k `div` 2) ps cs

sou n ta tb = Vec.generate n (go ta tb)


  --一回のダブリング畳み込み  
go:: Vec.Vector  (Int,Int,Int) -> Vec.Vector  (Int,Int,Int) -> Int -> (Int,Int,Int)
go ta tb i =
  (fir (tb Vec.! p),(sec (ta Vec.!i))+(sec (tb Vec.!p)),max (trd (ta Vec.!i)) ((sec (ta Vec.!i))+(trd (tb Vec.!p))))
  where
    p= (fir (ta  Vec.! i))


--va :: (Vec.Unbox a, Num a) => Vec.Vector a

Measured memory_bytes: 15284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1302>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int m,n;
map<string,int> mp;
int rec(vector<string>& obj){
    if(obj.size() <= 1) return 0;
    int ret = m;
    string s; for(auto v:obj) s += v;
    if(mp.count(s)) return mp[s];
    vector<string> l,r;
    for(int i = 0; i < m;i++){
        l.clear(); r.clear();
        for(int j = 0; j < obj.size(); j++){
            if(obj[j][i] == '0') l.push_back(obj[j]);
            else r.push_back(obj[j]);
        }
        if(l.empty() || r.empty()) continue;
        ret = min(ret,1 + max(rec(l),rec(r)));
    }
    mp[s] = ret;
    return ret;
}

int solve(){
    mp.clear();
    int res = 0;
    vector<string> obj(n);
    for(auto& in:obj) cin >> in;
    res = rec(obj);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> m >> n,m|n){
        cout << solve() << endl;
    }
    return 0;
}



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

int main(){
	int n,m;
	multiset<int> s;
	cin>>n;
	for(int x; n--;){
		cin>>x;
		s.insert(x);
	}
	scanf("%d",&m);
	for(int x; m--;){
		scanf("%d", &x);
		auto t=s.find(x);
		if(t==s.end()){
			puts("NO");
			return 0;
		}
		s.erase(t);
	}
	puts("YES");
}


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

int main() {
  int n; cin >>n;
  string s; cin >>s;
  int cnt=0, cmax=0;
  
  for (int i=0; i<n; i++){
    if (s.at(i) == 'I'){
      cnt++;
      if (cnt>cmax){
        cmax=cnt;
      }
    }else{
      cnt--;
    }
  }
  
  cout <<cmax <<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 1100000

int V;
vector<int> G[MAX_V]; // グラフの隣接リスト表現
vector<int> rG[MAX_V];// 辺の向きを逆にしたグラフ
vector<int> vs;       // 帰りがけ順の並び
bool used[MAX_V];     // すでに調べたか
int cmp[MAX_V];       // 属する強連結成分のトポロジカル順序

// from から to への辺を張る関数
void add_edge(int from, int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;
	for(int i = 0; i < rG[v].size(); i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i], k);
		}
	}
}

// 強連結成分分解を行う関数、返り値は強連結成分の個数
int scc(){
	memset(used, 0, sizeof(used));
	vs.clear();
	for(int v = 0; v < V; v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for(int i = vs.size() - 1; i >= 0; i--){
		if(!used[vs[i]]){
			rdfs(vs[i], k++);
		}
	}
	return k;
}

int memo[MAX_V] = {};

int func(int pos){
    if(memo[pos] != 0){
        return memo[pos];
    }
    int ret = 0;
    for(int to : G[pos]){
        ret = max(ret, func(to) + 1);
    }
    memo[pos] = ret;
    return ret;
}

int main(){
    int N;
    cin >> N;
    V = N * N;
    for(int i = 0; i < N; i++){
        int pre;
        cin >> pre;
        pre -= 1;
        for(int j = 0; j < N - 2; j++){
            int A;
            cin >> A;
            A -= 1;
            int p1 = i, p2 = pre;
            if(p1 > p2){
                swap(p1, p2);
            }
            int from = p1 * N + p2;
            p1 = i;
            p2 = A;
            if(p1 > p2){
                swap(p1, p2);
            }
            int to = p1 * N + p2;
    		add_edge(from, to);
            pre = A;
        }
    }

    int ret = scc();
    if(ret != N * N){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 0; i < N * N; i++){
        ans = max(ans, func(i));
    }
    cout << ans + 1 << endl;
}

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

using namespace std;

int main() {
	int n, i, x, length = 0;

	cin >> n;

	int a[n+2];

	a[0] = 0;
	a[n + 1] = 0;

	for (i = 1; i < n + 1; i++) {
		cin >> x;
		a[i] = x;
	}
	for (i = 0; i <= n; i++) {
		length += abs(a[i] - a[i + 1]);
	}

	for (i = 1; i < n + 1; i++) {
		cout << length + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;
	}
	
	return 0;

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    LL a, b, c;
    cin >> a >> b >> c;

    if( 4*a*b < (c-a-b)*(c-a-b) && 0 < c-a-b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
//Rectangle
#include<iostream>
using namespace std;

int menseki(int, int);
int nagasa(int, int);

int main()
{
	int tate, yoko;
	cin >> tate;
	cin >> yoko;
	cout << menseki(tate,yoko) << " " << nagasa(tate, yoko) << endl;
	return 0;
}

int menseki(int a, int b)
{
	return a*b;
}

int nagasa(int a, int b)
{
	return 2*(a+b);
}


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

int main() {
    int n,m,x;
    cin >> n >> m >> x;
    int cnt = 0;
    for (int i = 1; i <= m; i++) {
        int a;
        cin >> a;
        if (a < x) {
            cnt++;
        }
    }
    cout << min(cnt, m - cnt) << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll h[1000000];
ll v[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll DP[50][500][500];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	ll Ma,Mb;
	cin>>N>>Ma>>Mb;
	rep(i,0,N){
		cin>>a[i]>>b[i]>>c[i];
	}
	rep(i,0,50){
		rep(j,0,500){
			rep(k,0,500){
				DP[i][j][k]=INF;
			}
		}
	}
	DP[0][0][0]=0;
	rep(i,0,N){
		rep(j,0,401){
			rep(k,0,401){
				if(DP[i][j][k]==INF)continue;
				DP[i+1][j][k]=min(DP[i][j][k],DP[i+1][j][k]);
				DP[i+1][j+a[i]][k+b[i]]=min(DP[i+1][j+a[i]][k+b[i]],DP[i][j][k]+c[i]);
			}
		}
	}
	ans=INF;
	ll tmp1=Ma;
	ll tmp2=Mb;
	rep(i,1,1000){
		if(tmp1>400 || tmp2>400)break;
		ans = min(ans,DP[N][tmp1][tmp2]);
		tmp1+=Ma;
		tmp2+=Mb;
	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 102656
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

constexpr long long MOD=1e9+7;
int s[2010],t[2010];
long long dp[2010][2010];

int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)cin>>s[i];
    for(int j=1;j<=m;++j)cin>>t[j];
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            dp[i][j]%=MOD;
            if(s[i]==t[j]){
                dp[i][j]+=dp[i-1][j-1]+1;
                dp[i][j]%=MOD;
            }
        }
    }
    if(dp[n][m]<0)dp[n][m]+=MOD;
    cout<<(dp[n][m]+1)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 31616
// AOJ 1395 What Goes Up Must Come Down
// bitツリーによる転倒数の計算
// 2019.3.25 bal4u

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

//// 数値入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

//// Fenwick Tree
#define MAX 100005
int bit[MAX], maxn;
void add(int i, int v)
{
	while (i <= maxn) bit[i] += v, i += i & -i;
}

int _sum(int i)
{
	int s = 0;
	while (i > 0) s += bit[i], i -= i & -i;
	return s;
}

int sum(int left, int right) {
	return _sum(right) - _sum(left);
}

int n;
int a[MAX];
int re[MAX];

int main()
{
	int i, t;
	long long ans;

	n = in();
	maxn = 0;  for (i = 0; i < n; i++) {
		a[i] = in();
		if (maxn < a[i]) maxn = a[i];
	}
	maxn++;
	ans = 0;
	for (i = 0; i < n; i++) {
		re[i] = sum(a[i], maxn);
		add(a[i], 1);
	}

	memset(bit, 0, sizeof(bit));
	for (i = n - 1; i >= 0; i--) {
		t = sum(a[i], maxn);
		if (t < re[i]) ans += t; else ans += re[i];
		add(a[i], 1);
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		count += b - a + 1;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int A, B, C, K;

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

    if (K <= A) {
        cout << K << endl;
    } else {
        K = K - A;
        if (K <= B) {
            cout << A << endl;
        } else {
            K = K - B;
            if (K <= C) {
                cout << A - K << endl; 
            } else {
                cout << A - C << endl;
            } 
        }
    }

    return 0;
}

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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
int cnt[4];
int main(){
  char str[512];
  int n;
  scanf("%s", str);
  rep(i, strlen(str)){
    switch(str[i]){
    case 'K': cnt[0]++; break;
    case 'U': cnt[1]++; break;
    case 'P': cnt[2]++; break;
    case 'C': cnt[3]++; break;
    }
  }
  printf("%d\n", min(cnt[0], min(cnt[1], min(cnt[2], cnt[3]))));
  return 0;
}

Measured memory_bytes: 1136
#include<stdio.h>

int main(void){
    int h, w;
    while(1){
        scanf("%d%d", &h, &w);
        if (!h && !w) break;
        for(int i=0; i<h; i++){
            for(int l=0; l<w; l++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2024
"use strict";

function main(arg) {
    const W = arg.split("\n")[0].split(" ").map(n=>parseInt(n));
    const L = W[0] + W[1];
    const R = W[2] + W[3];
    
    if(L > R) {
        console.log("Left");
    } else if ( L < R) {
        console.log("Right");
    } else {
        console.log("Balanced");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<queue>

int h, w;
int ch, cw;
int dh, dw;
std::vector<std::string> maze;
std::vector<std::vector<int>> mazeLabel;
int labelCount=0;

void dfs(int label, int x, int y){
	if(x<0 || x>=w || y<0 || y>=h)
		return;

	if(maze[y][x] =='#')
		return;

	if(mazeLabel[y][x]!= -1)
		return;


	mazeLabel[y][x]= label;

	dfs(label, x-1, y);
	dfs(label, x+1, y);
	dfs(label, x, y-1);
	dfs(label, x, y+1);
}



int main(){
	std::cin>>h>>w;
	std::cin>>ch>>cw;
	std::cin>>dh>>dw;
	maze.resize(h);
	mazeLabel.resize(h);

	for(int i=0; i<h; i++)
		std::cin>>maze[i];

	for(int i=0; i< h; i++)
		mazeLabel[i].resize(w, -1);

	for(int y=0; y<h; y++){
		for(int x=0; x<w; x++){
			if(mazeLabel[y][x]!=-1)
				continue;

			if(maze[y][x]=='#')
				continue;

			dfs(labelCount, x, y);
			labelCount++;
		}
	}

	std::vector<std::set<int>> graph(labelCount);

	for(int y=0; y<h; y++){
		for(int x=0; x<w; x++){
			for(int i= -2; i<=2; i++){
				for(int j= -2; j<=2; j++){
					if(i==0 && j==0)
						continue;

					if(y+i < 0 || y+i >=h || x+j <0 || x+j >=w)
						continue;

					if(maze[y][x] =='#')
						continue;

					if(maze[y+i][x+j] =='#')
						continue;

					if(mazeLabel[y][x] != mazeLabel[y+i][x+j]){
						graph[mazeLabel[y][x]].insert(mazeLabel[y+i][x+j]);
						graph[mazeLabel[y+i][x+j]].insert(mazeLabel[y][x]);
					}
				}
			}
		}
	}

	int startLabel= mazeLabel[ch-1][cw-1];
	int goalLabel= mazeLabel[dh-1][dw-1];

	std::vector<int> dist(labelCount, -1);
	std::queue<int> que;
	que.push(startLabel);
	dist[startLabel]= 0;
	int ans= -1;	

	while(!que.empty()){
		int cur= que.front();
		if(cur== goalLabel){
			ans= dist[cur];
			break;
		}

		for (auto itr = graph[cur].begin(); itr != graph[cur].end(); ++itr) {
        	if(dist[*itr] < 0){
        		que.push(*itr);
        		dist[*itr]= dist[cur]+1;
        	}
    	}

		que.pop();
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 33696
N = int(input())
D = list(map(int, input().split()))
D_dict = {}
for i in range(N):
    if not D[i] in D_dict:
        D_dict[D[i]] = 0
    D_dict[D[i]] += 1

M = int(input())
T = list(map(int, input().split()))
ans = True
for i in range(M):
    if not T[i] in D_dict:
        ans = False
        break
    if D_dict[T[i]] == 0:
        ans = False
        break
    D_dict[T[i]] -= 1

print("YES" if ans else "NO")

Measured memory_bytes: 47700
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()] 
A = [[int(i) for i in input().split()] for i in range(N)]

res = []
for values in A:
  sum_res = 0
  for i in range(len(values)):
	  sum_res += values[i] * B[i]
  sum_res += C
  
  if sum_res > 0:
    res.append(1)
  else:
    res.append(0)
print(sum(res))
    

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

using namespace std;

bool BinarySearch(const vector<int>& vec, int key, int begin, int end) {
    while (begin <= end) {
        int index = (end - begin) / 2 + begin;
        if (vec[index] == key) return true;
        else if (vec[index] > key) end = index - 1;
        else begin = index + 1;
    }
    return false;
}

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

    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int q;
    cin >> q;

    vector<int> t(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i];
    }

    int sameNumCount = 0;
    for (auto numT : t) {
        if (BinarySearch(s, numT, 0, s.size() - 1)) sameNumCount++;
    }

    cout << sameNumCount << endl;

    return 0;
}

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

long long dp[110][100010],v[110],w[110];
int main()
{
    long long n , W;
    cin >> n >> W;
    for(int i = 0 ; i < n ; i++)    cin >> w[i] >> v[i];

    for(int i = 1 ; i <= 1e5 ; i++)  dp[n][i] = 1e15;
    for(int i = n-1 ; i >= 0 ; i--)
        for(int curVal = 0 ; curVal <= 1e5 ; curVal++)
            dp[i][curVal] = min(dp[i+1][curVal],(curVal - v[i] >= 0 ? dp[i+1][curVal - v[i]] + w[i] : (long long)1e15));

    for(int i = 1e5 ; i >=0 ; i--)
        if(dp[0][i] <= W)return cout << i << endl , 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

// s = "aabbbc" -> [[a,2],[b,3],[c,1]]
vector<pair<string,int>> rle (vs s) {
  vector<pair<string,int>> res;
  int n = (int)s.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && s[j] == s[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(s[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vs s(n);
  rep(i,n) cin >> s[i];
  int m;
  cin >> m;
  vs t(m);
  rep(i,m) cin >> t[i];
  
  sort(rng(s));
  sort(rng(t));

  int ans = 0;
  auto srle = rle(s);
  for (auto p : srle) {
    int ns = p.se;
    int nt = count(rng(t),p.fi);
    ans = max(ans, ns-nt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, ans = 0;
vector< int > arr( 30 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	for( int i = 2; i <= n - 1; ++i )
	{
		if( arr[ i ] > arr[ i - 1 ] && arr[ i ] < arr[ i + 1 ] )
		{
			++ans;
		}
		else if( arr[ i ] < arr[ i - 1 ] && arr[ i ] > arr[ i + 1 ] )
		{
			++ans;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
while True:
    height, width = [int(x) for x in input().split(" ")]
    if height == width == 0:
        break
    print("#" * width)
    column = "#" + "." * (width - 2) + "#"
    for i in range(height - 2):
        print(column)
    print("#" * width + "\n")


Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


string table[10]={
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int mod[10]={1,5,3,3,3,3,3,4,3,4};


int main(){
    
    int N;
    cin>>N;
    
    REP(i,N){
        string S;
        cin>>S;
        
        int cnt=0;
        string ans;
        
        REP(i,S.size()){
            if(S[i]!='0')cnt++;
            else{
                if(cnt!=0){
                    ans=ans+table[S[i-1]-'0'][(cnt-1)%mod[S[i-1]-'0']];
                    cnt=0;
                }
            }
        }
        
        cout<<ans<<endl;
        
    }
    
    return 0;
}

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

using namespace std;

bool modified_euclidean_distance(vector<int>& a,vector<int>& b){

	double dist = 0.0;

	for(int i = 0;i<a.size();i++){
		dist += pow((a[i] - b[i]),2);
	}

	dist = sqrt(dist);
	
	// cout<<dist<<"\n";
	// cout<<ceil(dist - int(dist))<<"\n";

	if(ceil(dist - int(dist)))
		return false;
	return true;
}

int main(){

	int n,d,count = 0;
	cin>>n>>d;

	vector<vector<int>> points(n,vector<int>(d,0));

	for(int i = 0;i<n;i++){
		for(int j = 0;j<d;j++){
			cin>>points[i][j];
		}
	}

	for(int i = 0;i<n;i++){
		for(int j = i+1;j<n;j++){
			if(modified_euclidean_distance(points[i],points[j]))
				count++;
		}	
	}

	cout<<count<<"\n";

	return 0;
}


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


using namespace std;
int main(void){
    // Your code here!
  string s;
  cin>>s;
  long long sum=0;
  for(long long i=0;i<s.size();i++){
      sum+=s.at(i)-'0';
     
      
  }
if(sum%9==0) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
}


Measured memory_bytes: 3692
import itertools
N,M = map(int,input().split())
L=[]
for i in range(M):
    a,b=map(int,input().split())
    L.append([a,b])

number=[]
for i in range(1,N+1):
    number.append(i)
    
ans=0

for v in itertools.permutations(number,N):
    a=0
    v=list(v)
    for j in range(N-1):
        if ([v[j],v[j+1]] not in L ) and ([v[j+1],v[j]] not in L):
            a=1
    if a==0 and v[0]==1:
        ans+=1

print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	int n,k;
	rd2(n,k);
	double ans=.0;
	fr(i,1,n+1)
	{
		//double temp=0;
		int x=i;
		double ct=1.0;
		//if(i<k)
		{
			while(x<k)
			{
				ct/=2;
				x*=2;
			}
		
		//ans+=(double)pow((double)0.5,ct);
			ans+=ct;
		//cout<<(double)pow(0.5,ct)<<endl;
		}
	}
	//cout<<ans<<endl;
	printf("%.10f\n", (double)ans/n);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> a;
    int maxa = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a[x]++;
        maxa = max(maxa, x);
    }
    vector<bool> dp(maxa + 1, true);
    int ans = 0;
    for(auto& [key, value] : a){
        if(!dp[key]) continue;
        if(value == 1) ans++;
        for(int i = 1; i * key <= maxa; i++){
            dp[i*key] = false;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a, b; cin >> a >> b;
  string s; cin >> s;
  string ans="Yes";
  for(int i=0; i<a; i++) if(!isdigit(s[i])) ans="No";
  if(s[a]!='-') ans="No";
  for(int i=0; i<b; i++) if(!isdigit(s[a+i+1])) ans="No";
  cout << ans << endl;
  return 0;
}


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

int main() {
	// your code goes here
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = i - 1; j >= i - k and j >= 0; --j) {
            if (j == 0) {
                dp[i] = min(dp[i], abs(a[0] - a[i]));
            }
            else {
                dp[i] = min(dp[j] + abs(a[i] - a[j]), dp[i]);
            }
            // cout << i << ' ' << j << ' ' << dp[i] << '\n';
        }
	}
	cout << dp[n - 1];
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		sum += m[i];
	}
	cout << (N + (X - sum) / *min_element(m.begin(), m.end())) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        private static Dictionary<char, char[]> rooting = new Dictionary<char, char[]>
        {
            {'R', "URDL".ToCharArray()},
            {'D', "RDLU".ToCharArray()},
            {'L', "DLUR".ToCharArray()},
            {'U', "LURD".ToCharArray()},
        };

        struct Pair
        {
            public int from;
            public int to;

            public Pair(int @from, int to) : this()
            {
                this.@from = @from;
                this.to = to;
            }
        }

        private static HashSet<Pair> walls = new HashSet<Pair>();

        static void Main(string[] args)
        {
            string line;
            bool horizontal = true;
            int l = 0;
            while((line = Console.ReadLine()) != null)
            {
                int i = 0;
                foreach(var c in line)
                {
                    if (c == '1')
                    {
                        walls.Add(new Pair(l / 2 * 5 + i, l / 2 * 5 + (horizontal ? 1 : 5) + i));
                    }
                    i++;
                }
                l++;
                horizontal = !horizontal;
            }
            char dir = 'R';
            int point = 1;
            Console.Write(dir);
            while(true)
            {
                MoveNext(ref point, ref dir);
                Console.Write(dir);
                if (point == 0) break;
            }
            Console.WriteLine();
        }

        private static void MoveNext(ref int point, ref char dir)
        {
            foreach(var root in rooting[dir])
            {
                int next_point = GetNext(point, root);
                if (next_point == -1) continue;
                if (!IsWall(point, next_point)) continue;
                point = next_point;
                dir = root;
                return;
            }
        }

        private static int GetNext(int point, char root)
        {
            switch(root)
            {
            case 'R':
                if (point % 5 == 4) return -1;
                return point + 1;
            case 'D':
                if (point >= 20) return -1;
                return point + 5;
            case 'L':
                if (point % 5 == 0) return -1;
                return point - 1;
            default:
                if (point < 5) return -1;
                return point - 5;
            }
        }

        private static bool IsWall(int point, int nextPoint)
        {
            return
                walls.Contains(new Pair(point, nextPoint)) ||
                walls.Contains(new Pair(nextPoint, point));
        }
    }
}

Measured memory_bytes: 6056
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):
    res = 0
    i = 0
    while i < N:
        j = i + 1
        if p[i] == j:
            res += 1
            if i+1 < N and p[i+1] == j + 1:
                i += 1
        i += 1
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 53412
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int, int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;
int xs, ys, xt, yt, n;
int x[1010], y[1010], r[1010];

double dist[1010][1010];

priority_queue<PDI, VD, greater<PDI> > q;
double fast[1010];
bool visited[1010];

double dijk()
{
  q.push(MP((double)0, 0));

  while(!q.empty()){
    PDI now = q.top();
    q.pop();
    
    if(!visited[now.S]){
      fast[now.S] = now.F;
      visited[now.S] = true;
      for(int i = 0; i <= n + 1; i++){
	q.push(MP(now.F + dist[now.S][i], i));
      }
    }
  }

  return fast[n + 1];
}

signed main()
{
  cin >> xs >> ys >> xt >> yt >> n;
  for(int i = 1; i <= n; i++){
    cin >> x[i] >> y[i] >> r[i];
  }

  x[0] = xs, y[0] = ys, x[n + 1] = xt, y[n + 1] = yt;
  
  for(int i = 0; i <= n + 1; i++){
    for(int j = 0; j <= n + 1; j++){
      double idist = sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));

      idist -= r[i] + r[j];
      if(idist < 0){
	idist = 0;
      }

      dist[i][j] = idist;
    }
  }

  printf("%.12f\n", dijk());
  
  return 0;
}


Measured memory_bytes: 24808
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from itertools import permutations

N, M, r = map(int, input().split())
R = list(map(int, input().split()))

INF = 10 ** 9

G = [[INF] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
    G[i][i] = 0

for _ in range(M):
    A, B, C = map(int, input().split())
    G[A][B] = C
    G[B][A] = C

for k in range(N + 1):
    for i in range(N + 1):
        for j in range(N + 1):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

ans = INF
for tmp in permutations(R):
    score = 0
    for i in range(r - 1):
        score += G[tmp[i]][tmp[i + 1]]
    ans = min(ans, score)

print (ans)


Measured memory_bytes: 42460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	
}
	

Measured memory_bytes: 256
import itertools
import math
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
lis=[LI() for i in range(N)]
nums = list(range(N))

su = 0.0
for perm in itertools.permutations(nums, N):
    for i in range(len(perm)-1):
        su += math.sqrt((lis[perm[i]][0]-lis[perm[i+1]][0])**2 + (lis[perm[i]][1]-lis[perm[i+1]][1])**2)

print(su / math.factorial(N))


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

vector<string> t{"dream","dreamer","erase","eraser"};

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

    while(point >= 0){
        bool ok = false;
        for(string& ss : t){
            int bp = point - ss.size() + 1;
            if(bp >= 0 and s.substr(bp,ss.size()) == ss){
                point = bp - 1;
                ok = true;
                break;
            }
        }
        if(!ok){
            cout << "NO"<< endl;
            return 0;
        }
    }
    cout << "YES"<< endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
  int A,B,T;
  std::cin >> A>>B>>T;
  int cookie=0;
  int time;
  for ( time = A; time <= T;) {
    cookie=cookie+B;
    time=time+A;
  }
  std::cout << cookie << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                for(int i=1;i<10001;i++){
                        String val=scan.nextLine();
                        if(val.equals("0 0")){
                                System.exit(0);
                        }
                        String [] num=val.split(" ",0);
                        int x=Integer.parseInt(num[0]);
                        int y=Integer.parseInt(num[1]);
                        if(x<y){
                                System.out.println(x+" "+y);
                        }else{
                                System.out.println(y+" "+x);
                        }
                }
        }
}

Measured memory_bytes: 35268
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), D = sc.nextInt(), X = sc.nextInt(), t = 0, no = N;
		while (no-->0) {
			int a = sc.nextInt();
			t+=a==1 ? D : (D%a==0) ? D/a : (D/a)+1;
		}
		System.out.println(t+X);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 36000
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

ll combin(int n, int r){
    if(r == 0){
        return 1;
    }else{
        return n*combin(n-1, r-1)/r;
    }
}

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

    vector<ll> v(n);
    for(auto& i : v){
        cin >> i;
    }

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

    double ave = 0.0;
    REP(i, a){
        ave += v[i];
    }
    ave /= (double)a;

    ll comb = 0;
    if(v[0] != v[a-1]){
        int x = 0, y = 0;
        REP(i, n){
            if(v[i] == v[a-1]){
                x++;
                if(i < a){
                    y++;
                }
            }
        }
        comb = combin(x, y);
    }else{
        int x = 0;
        REP(i, n){
            if(v[i] == v[0]){
                x++;
            }
        }
        for(int i=a; i<=b; i++){
            comb += combin(x, i);
        }
    }

    cout << fixed << setprecision(6) << ave << endl << comb << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b)
    {
        if(a==0 &&b==0)break;
        /*c=a;
        a=b;
        b=c;
        printf("%d %d\n",a,b);*/
        else if(a>=b)printf("%d %d\n",b,a);
        else printf("%d %d\n",a,b);

    }


    return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 200100


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

	int n;
	cin >> n;
	vi a(n + 1), dp(n + 1);


	for (int i = 1; i <= n; i++)
		cin >> a[i];

	a[0] = a[1];

	for (int i = 2; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));

	cout << dp[n];


}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 1792
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    if A[0] >= 2:
        print(-1)
        return
    l, r = [None] * (N + 1), [None] * (N + 1)
    l[0], r[0] = 1, 1
    l[-1], r[-1] = A[-1], A[-1]
    for i in range(N - 1, 0, -1):
        l[i] = (l[i + 1] + 1) // 2 + A[i]
        r[i] = r[i + 1] + A[i]
    
    ans = 1
    x = 1
    for i in range(1, N + 1):
        x -= A[i - 1]
        if x < 0:
            print(-1)
            return
        s = max(x, l[i])
        t = min(2 * x, r[i])
        if s > t:
            print(-1)
            return
        x = t
        ans += t
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22444
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	int n = s.length(), i, j, k, best = 0;
	for (i = 0; i < n; i++) {
		if ((s[i] == 'A') || (s[i] == 'T') || (s[i] == 'G') || (s[i] == 'C')) {
			for (j = i; (j < n) && ((s[j] == 'A') || (s[j] == 'T') || (s[j] == 'G') || (s[j] == 'C')); j++);
			best = max(best, j - i);
		}
	}

	cout << best << "\n";

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp" 
//#include "ext/pb_ds/tree_policy.hpp" 
using namespace std;
//using namespace __gnu_pbds;
#define ff first
#define ss second
#define ld long double
#define ll long long int
#define ull unsigned ll
#define ins insert
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int> 
#define pll pair<ll , ll>
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define per1(i,n) for(i=n;i>=1;i--)
#define mod 1000000007
#define pi 3.141592653589793238460
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
//#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t, i, j;
    t=1;
    while(t--){
        ld n, x, T;
        ll c = 1;
        cin>>n>>x>>T;
        ll X=x;
        while(n > X){
            X+=x;
            c++;
        }
        cout<<(ll)(T*c)<<'\n';
        
    }
    return 0;
}







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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<pair<int, int>> C(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
    C[i] = {A[i] + B[i], i};
  }
  sort(C.begin(), C.end(), greater<pair<int, int>>());

  int64_t answer = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      answer += (int64_t)A[C[i].second];
    } else {
      answer -= (int64_t)B[C[i].second];
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using LL = int64_t;
const LL INF=1e18;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    LL x,y;cin>>x>>y;
    cout<<x+y/2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<long long> A(X), B(Y), C(Z);
	for (long long &a : A) cin >> a;
	for (long long &b : B) cin >> b;
	for (long long &c : C) cin >> c;

	vector<long long> sumAB, sumABC;

	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			sumAB.push_back(A[i] + B[j]);
		}
	}

	sort(sumAB.begin(), sumAB.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());

	for (int i = 0; i < K && i < X*Y; i++) {
		for (int j = 0; j < Z && j < K; j++) {
			sumABC.push_back(sumAB[i] + C[j]);
		}
	}

	sort(sumABC.begin(), sumABC.end(), greater<long long>());

	for (int i = 0; i < K; i++)
		cout << sumABC[i] << endl;

	return 0;
}

Measured memory_bytes: 43240