akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	int n;
	cin>>n;
	int weight;
	cin>>weight;
	vector<int> w(n),v(n);
	rep(i,n){
		cin>>v[i]>>w[i];
	}
	
	vector<vector<int>> a(n);
	rep(i,n){
		a[i].resize(weight+1);
		rep(j,weight+1){
			if(i==0){
				if(j>=w[0])a[0][j]=v[0];
				else a[0][j]=0;
			}else{
				if(j<w[i]) a[i][j]=a[i-1][j];
				else a[i][j]=max(a[i-1][j],a[i-1][j-w[i]]+v[i]);
			}
		}
	}
	cout<<a[n-1][weight]<<endl;
}


Measured memory_bytes: 6732
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

#define MAX 257

int main(void)
{
	int n;
	cin >> n;
	vector<string> us = vector<string>(n);
	rep(i, n) cin >> us[i];

	int m;
	cin >> m;
	vector<string> ts = vector<string>(m);
	rep(i, m) cin >> ts[i];

	bool closed = true;
	rep(i, ts.size()) {
		bool f = true;
		rep(j, us.size())
			if (ts[i] == us[j]) {
				printf("%s by %s\n", (closed?"Opened":"Closed"), us[j].c_str());
				closed = !closed;
				f = false;
				break;
			}
		if (f)
			printf("Unknown %s\n", ts[i].c_str());
	}
	return 0;
}

Measured memory_bytes: 1244
S = str(input())
T = str(input())

s = len(S)
t = len(T)
if s < t:
  flag = False
else:
  for i in range(s-t+1):
    num = s-t-i
    tmp = S[num:num+t]
    flag = True
    for j in range(t):
      if (tmp[j]!='?') and (T[j]!=tmp[j]):
        flag = False
        break
    if flag:
      if 0 < num < s-t:
        ans = S[:num] + T + S[num+t:]
      elif num == 0:
        ans = T + S[num+t:]
      else:
        ans = S[:num] + T
      break
    
if flag:
  ans = ans.replace('?', 'a')
  print(ans)
else:
  print('UNRESTORABLE')

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1L);

int main() {
    int n;
    cin >> n;
    vi operation;
    operation.push_back(1);
    for (int i = 6; i <= n; i *= 6) {
        operation.push_back(i);
    }
    for (int i = 9; i <= n; i *= 9) {
        operation.push_back(i);
    }
    vi dp(n + 1, INF);
    dp[0] = 0;

    rep(i, n + 1) {
        for (auto op : operation) {
            if (i + op <= n) {
                // debug(op);
                dp[i + op] = min(dp[i + op], dp[i] + 1);
            }
        }
        // debug(dp[i]);
    }

    out(dp[n]);
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void dfs(int node, VEC(VEC(int))& edges, VEC(bool)& visited)
{
    if (visited[node])
        return;
    visited[node] = true;
    
    for (int next : edges[node])
        dfs(next, edges, visited);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(VEC(int)) edges(N);
    FOR(i, 0, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    int ret = 0;
    VEC(bool) visited(N, false);
    FOR(i, 0, N) {
        if (!visited[i]) {
            ret++;
            dfs(i, edges, visited);
        }
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 10496
class BinarySearchTree:
    class Node:
        def __init__(self, k, p, left, right):
            self.key = k
            self.p = p
            self.left = left
            self.right = right
    def __init__(self):
        self.root = None
    def insert(self, k):
        p = None
        x = self.root
        while x != None:
            p = x
            if k < x.key : x = x.left
            else         : x = x.right
        z = self.Node(k, p, None, None)
        if p == None      : self.root = z
        elif z.key < p.key: p.left  = z
        else              : p.right = z
    def getInorderList(self, root):
        l = root.left
        r = root.right
        if l: yield from self.getInorderList(l)
        yield root.key
        if r: yield from self.getInorderList(r)
    def getPreorderList(self, root):
        l = root.left
        r = root.right
        yield root.key
        if l: yield from self.getPreorderList(l)
        if r: yield from self.getPreorderList(r)


if __name__=='__main__':
    m = int(input())

    T = BinarySearchTree()
    for _ in range(m):        
        op = input().split()
        if   op[0] == 'insert': T.insert(int(op[1]))
        else:
            print("",*T.getInorderList(T.root))
            print("",*T.getPreorderList(T.root))

Measured memory_bytes: 161820
#include <bits/stdc++.h>
#define fi first
#define se second
#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(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

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

    vi h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    int tmp = 0;

    rep(i, n-1){
        if(h[i] >= h[i+1]){
            tmp++;
            if(tmp>ans) ans = tmp;
        }
        else{
            tmp=0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
gr = [dict() for _ in range(n)]
l = [10*6]*n
l[0]= 0
for _ in range(n-1):
  x,y,w = map(int, input().split())
  w %= 2
  gr[x-1][y-1] = w
  gr[y-1][x-1] = w
  
seen = set()
q = [0]
while q:
  cur = q.pop()
  seen.add(cur)
  for x in set(gr[cur].keys())-seen:
    l[x] = l[cur] + gr[cur][x]
    q.append(x)
for i in range(n):
  print(l[i]%2)

Measured memory_bytes: 47252
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	int ans = 0;
	for(int i = 1,x;i <= n; ++i)
	{
		scanf("%d",&x);
		ans += (i & 1) & (x & 1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3732
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
cntr = Counter(A)
ans = 0
for kv in cntr.items():
  #print(kv[0], kv[1])
  if kv[0] <= kv[1]:
    ans += kv[1] - kv[0]
  else:
    ans += kv[1]
print(ans)

Measured memory_bytes: 18164
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  int N;
  cin>>N;
  char S[N];
  int p=0,w=0,g=0,y=0;
  for(int i=0; i<N; ++i){cin>>S[i];}
  for(int i=0; i<N; ++i){
    if (S[i] == 'P') {p++;}
    if (S[i] == 'W') {w++;}
    if (S[i] == 'G') {g++;}
    if (S[i] == 'Y') {y++;}
}
  if(p>0&&w>0&&g>0&&y>0)
  cout<<"Four"<<endl;
  else
  cout<<"Three"<<endl;


}

  


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
    
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
    
int main(){
    int n;
    cin>>n;
    printf("%.20lf\n", n * 2 * M_PI); //Macではバックスラッシュは Opt + ¥ で入力できる。

    //cout<< n * 2 * M_PI <<endl;
    
} // end of main
    
//実行は、Opt + Ctl + N


Measured memory_bytes: 3720
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

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

// デバッグ

#ifdef DEBUG
#include <cassert>
#define my_assert(x) assert(x)
#else
#define my_assert(x)
#define assert(x)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<vector<i64>>> m(r, vector<vector<i64>>(c, vector<i64>(4, 0LL)));
    vector<vector<int>> items(r, vector<int>(c, 0LL));
    rep(i, k)
    {
        int ri, ci, vi;
        cin >> ri >> ci >> vi;
        --ri;
        --ci;
        items[ri][ci] = vi;
    }
    rep(cur_row, r)
    {
        rep(cur_column, c)
        {
            rep(cnt, 4)
            {
                if (cur_row > 0)
                {
                    m[cur_row][cur_column][cnt] = m[cur_row - 1][cur_column][0];
                }
                if (cur_column > 0)
                {
                    m[cur_row][cur_column][cnt] = max(m[cur_row][cur_column][cnt], m[cur_row][cur_column - 1][cnt]);
                }
            }
            rep(cnt, 3)
            {
                m[cur_row][cur_column][cnt] = max(m[cur_row][cur_column][cnt], m[cur_row][cur_column][cnt + 1] + items[cur_row][cur_column]);
            }
        }
    }
    cout << m[r - 1][c - 1][0] << endl;

    return 0;
}


Measured memory_bytes: 671372
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  A.pb(0);

  int ans = 1000;
  int stock = 0;
  rep(i, N) {
    ans += stock * A[i];
    stock = 0;

    if (A[i] < A[i + 1]) {
      int buy = ans / A[i];
      ans -= A[i] * buy;
      stock += buy;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
using namespace std;
typedef long long ll;

void Main()
{
    string s;
    cin >> s;
    string t;
    cin >> t;

    if (s == t.substr(0, t.size() - 1))
    {
        Yes;
    }
    else
    {
        No;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 3596
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from itertools import accumulate
import sys
def main(N, M, K, A, B):
    *AA, = accumulate(A, initial=0)
    *BB, = accumulate(B, initial=0)

    def f(c):
        res = 10 ** 18
        for a in range(max(0, c - M), min(c, N) + 1):
            res = min(res, AA[a] + BB[c - a])
        return res

    l = 0
    r = N + M + 1
    while r - l > 1:
        m = (l + r) // 2
        if f(m) > K:
            r = m
        else:
            l = m
    print(l)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    main(N, M, K, A, B)


Measured memory_bytes: 47304
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace atcoder;
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, q;
  cin >> n >> q;
  dsu d(n);
  rep(i,q) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
      d.merge(b, c);
    } 
    else {
      if (d.same(b, c)) {
        cout << 1 << '\n';
      } 
      else {
        cout << 0 << '\n';
      }
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}


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

int main()
{
    //freopen("test.in","r",stdin);
   // freopen("test.ok","w",stdout);
    int h;
    int a;
    int n=0;
    cin >> h;
    cin >> a;
    do 
    {
    h=h-a;
    n++;
    }
    while (h>0);
    cout << n;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    queue<int> q;
    int j=0;
    int k=1;
    int x= sqrt(m);

    for(int i=1;i<x+1;i++){
        if(m%i==0){
            q.push(i);
            q.push(m/i);
            j+=2;
        }
    }

    for(int i=0;i<j;i++){
        if(n<=m/q.front()&&q.front()>k){
            k=q.front();
        }
        q.pop();
    }
    cout<<k<<endl;


    return 0;
}

Measured memory_bytes: 3588
<?php
    $input = fgets(STDIN);
    $a = explode(" ", $input);
    $x3 = $a[1] - $a[3] + $a[2];
    $y3 = $a[2] - $a[0] + $a[3];
    $x4 = $a[1] - $a[3] + $a[0];
    $y4 = $a[2] - $a[0] + $a[1];
    echo "$x3 $y3 $x4 $y4\n";
?>


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int t[m],c[m];
	for(int i=0;i<m;i++){
		cin>>t[i]>>c[i];
	}
	int ret=-1;
	for(int i=0;i<1000;i++){
		string s=to_string(i);
		if(s.length()!=n)continue;
		bool val=true;
		for(int j=0;j<m;j++){
			val&=s[t[j]-1]-'0'==c[j];
		}
			if(val){
				ret=i;
				break;
			}
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
N=parse(Int,readline())
S=chomp(readline())
ans=0
for i=1:N-1
	ret=0
	for c='a':'z'
		if c in S[1:i]&&c in S[i+1:N]
			ret+=1
		end
	end
	ans=max(ans,ret)
end
println(ans)


Measured memory_bytes: 110340
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Println(logic(n))
}

func logic(n int) float64 {
	numerator := math.Ceil(float64(n) / 2)

	return numerator / float64(n)
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        test();
        System.out.println(solve(sc.next().trim()));
    }

    private static int solve(String str) {
        int s = 0;
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == 'S') {
                s++;
            } else if (str.charAt(i) == 'T' && s == 0) {
                count++;
            } else {
                s--;
            }
        }

        return count * 2;
    }

    private static void test() {
        assert solve("TSTTSS") == 4: "TSTTSS";
        assert solve("SSTTST") == 0: "SSTTST";
        assert solve("TSSTTTSS") == 4: "TSSTTTSS";
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>N;
	
	/*
	vector<vector<int>> S;
	vector<vector<int>> C;
	C.resize(1);
	FOR(i,N) {
		vector<vector<int>> C2;
		FORR(c,C) {
			for(j=1;j<=K;j++) {
				c.push_back(j);
				C2.push_back(c);
				S.push_back(c);
				c.pop_back();
			}
		}
		C=C2;
	}
	sort(ALL(S));
	FORR(c,S) {
		FORR(a,c) cout<<a<<" ";
		cout<<endl;
	}
	cout<<S.size()<<endl;
	FORR(c,S[(S.size()+1)/2-1]) cout<<c;
	cout<<endl;
	return;
	*/
	if(K%2==0) {
		FOR(i,N) {
			_P("%d%c",(i==0)?(K/2):K,(i==N-1)?'\n':' ');
		}
		return;
	}
	if(N==1) {
		_P("%d\n",K/2+1);
		return;
	}
	if(K==1) {
		FOR(i,(N+1)/2) _P("%d%c",1,(i==(N+1)/2-1)?'\n':' ');
		return;
	}
	vector<int> V;
	FOR(i,N) V.push_back(K/2+1);
	FOR(i,N/2) {
		if(V.back()==1) V.pop_back();
		else {
			V.back()--;
			while(V.size()<N) V.push_back(K);
		}
	}
	
	FORR(c,V) cout<<c<<" ";
	cout<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3568
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int T = sc.nextInt();
      int[] c = new int[n];
      int[] t = new int[n];
      int min = 100000;
      for(int i = 0;i < n;i++){
      	c[i] = sc.nextInt();
        t[i] = sc.nextInt();
        if(t[i] > T) c[i] = 10000;
        min = Math.min(min,c[i]);
      }
      if(min >= 10000)System.out.println("TLE");
      else if(min <= 1000)System.out.println(min);
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;

    } else if  (k > a && k <= a+b){
        cout << a << endl;

    } else {
        cout << a - (k-(a+b)) <<endl;
    }

}

Measured memory_bytes: 3192
#include<stdio.h>

void swap(int *a, int *b ){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp; 
}

int main(void){
    int a, b;
    
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0){
            break;
        }
        else if(a > b){
            swap(&a, &b);
        }
        
        printf("%d %d\n", a, b);
        
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N;
 int start=0;
  int finish=0;
  int customarNo =0;
  int total=0;
  
  
  int j = 0;
  while (j < N) {
    cin >> start;
    cin >> finish;
   customarNo = finish - start +1;
    total += customarNo;
    j++;
  }
 
 cout << total << endl;
 
 }

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

ans = 0
res = A[0]
for i in range(N):
  if (B[i] < res):
    #まるまる残る
    ans += B[i]
    res = A[i+1]
  else:
    ans += res
    b = B[i] - res
    res = A[i+1]
    if (b <= res):
      #一部倒せた
      ans += b
      res -= b
    else:
      #余った
      ans += res
      res = 0
print(ans)


Measured memory_bytes: 18624
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N, X, Y = map(int,input().split())
    X, Y = X - 1, Y - 1

    # iからjまでの距離
    # 到達の仕方は以下の３パターンなので、このうち最小が最短の距離になる
    # 直線のパターン
    # |j - i|
    # まずiからXまでいって、その後XからYまでジャンプ、Yからjまでのパターン
    # |X - i| + 1 + |j - Y|
    # まずiからYまでいって、その後YからXまでジャンプ、Xからjまでのパターン
    # |Y - i| + 1 + |j - X|

    ans = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            ij = abs(j - i)
            ixyj = abs(X - i) + 1 + abs(j - Y)
            iyxj = abs(Y - i) + 1 + abs(j - X)

            dist = min(ij, ixyj, iyxj)

            ans[dist] += 1

    for a in ans[1:]:
        print(a)


if __name__ == "__main__":
    main()


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int hm1 = h1*60 + m1;
  int hm2 = h2*60 + m2;

  cout << hm2 - hm1 - k;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2]){cout << "Yes" << endl;}
    else if(n[1] == n[2] && n[2] == n[3]){cout << "Yes" << endl;}
    else cout << "No" << endl;
 
 
    return 0;
}

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

int main() {
  int a,b,c,d,s,e;
  cin >> a >> b >> c >> d;
  s= max(a,c);
  e=min(b,d);
  cout << (e-s>0 ? e-s : 0) << endl;
}

Measured memory_bytes: 3516
from math import factorial


def comb(n, k, mod):
  if n < 0 or k < 0 or n < k:
      return 0
  if n == 0 or k == 0:
      return 1
  
  a=factorial(n) % mod
  b=factorial(k) % mod
  c=factorial(n-k) % mod
  return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod


N, M, K = map(int, input().split())
mod = 10**9 + 7


x = N*N*(M*M*(M+1)//2 - M*(M+1)*(2*M+1)//6)
y = M*M*(N*N*(N+1)//2 - N*(N+1)*(2*N+1)//6)
ans = comb(N*M-2, K-2, mod) * (x + y) % mod
print(ans)

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

using namespace std;

int main()
{
  int n;
  long long ans=0,tmp;
  cin>>n;
  for(int i=1;i<=n;++i)
  {
    tmp=n/i;
    ans+=(i+tmp*i)*tmp/2;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
s_a=list(input())
s_b=list(input())
s_c=list(input())

tmp =''
tmp=s_a.pop(0)
while 1:
    if tmp=='a':
        if s_a:
            tmp=s_a.pop(0)
        else:
            print('A')
            break
    elif tmp=='b':
        if s_b:
            tmp=s_b.pop(0)
        else:
            print('B')
            break
    elif tmp=='c':
        if s_c:
            tmp=s_c.pop(0)
        else:
            print('C')
            break


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
n,x = map(int, input().split())

d = [0 for _ in range(51)]
d[0] = 1
for i in range(50):
    d[i+1] = 3 + 2*d[i]

p = [0 for _ in range(51)]
p[0] = 1
for i in range(50):
    p[i+1] = 1 + 2*p[i]

def f(l,x):
    if l==1:
        if x>3:
            return 3
        elif x<2:
            return 0
        else:
            return x-1
    if x==0:
        return 0
    if d[l]==x:
        return p[l]

    if 2+d[l-1]<=x:
        return f(l-1,d[l-1]) + 1 + f(l-1, x-1-d[l-1]-1)
    else:
        return f(l-1, x-1)

print(f(n,x))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
}
  
  


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
class Card {
public:
	char c;
	int n;
};
bool operator<(const Card&a, const Card&b) {
	return a.n < b.n;
}
bool operator<=(const Card&a, const Card&b) {
	return a.n <= b.n;
}
bool operator==(const Card&a, const Card&b) {
	return a.n == b.n&&a.c == b.c;
}
int partition(Card *line, int p, int r) {
	int i = p - 1;
	Card x = line[r];
	for (int j = p; j < r; ++j) {
		if (line[j] <= x) {
			swap(line[j], line[++i]);
		}
	}
	swap(line[r], line[++i]);
	return i;
}
void quicksort(Card *line, int p, int r) {
	if (p < r) {
		int q = partition(line, p, r);
		quicksort(line,p, q - 1);
		quicksort(line, q + 1, r);
	}
}
int main() {
	int N;
	cin >> N;
	Card *line = new Card[N];
	Card *line2 = new Card[N];
	for (int i = 0; i < N; ++i) {
		cin >> line[i].c >> line[i].n;
		line2[i] = line[i];
	}
	quicksort(line, 0, N - 1);
	stable_sort(line2, line2 + N);
	bool flag = false;
	for (int i = 0; i < N; ++i) {
		if (!(line[i] == line2[i])) {
			flag = true;
			break;
		}
	}
	cout << (flag ? "Not stable" : "Stable") << endl;
	for (int i = 0; i < N; ++i) {
		cout << line[i].c << " " << line[i].n << endl;
	}
	return 0;
}


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

typedef long long LL;

const int N=5000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}

int n,a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int pw[N+9];

void Get_pw(){
  pw[0]=1;
  for (int i=1;i<=n;++i) pw[i]=mul(pw[i-1],n-1);
}

int uni[N+9],siz[N+9];

int Query_uni(int k){return k==uni[k]?k:uni[k]=Query_uni(uni[k]);}

int ans;

void Get_a(){
  int cnt=0;
  for (int i=1;i<=n;++i) cnt+=a[i]==-1,uni[i]=i,siz[i]=1;
  ans=mul(n,pw[cnt]);
  for (int i=1;i<=n;++i){
	if (a[i]==-1) continue;
	int fx=Query_uni(i),fy=Query_uni(a[i]);
	if (fx==fy){
	  siz[fx]=0;
	  ssub(ans,pw[cnt]);
	}else{
	  uni[fx]=fy;
	  siz[fy]=siz[fx]&&siz[fy]?siz[fx]+siz[fy]:0;
	}
  }
  int ca=0;
  for (int i=1;i<=n;++i)
	if (siz[i]&&Query_uni(i)==i){
	  a[++ca]=siz[i];
	  if (siz[i]>1) ssub(ans,mul(siz[i]-1,pw[max(cnt-1,0)]));
    }
  n=ca;
}

int dp[N+9][N+9];

void Get_dp(){
  for (int i=1;i<=n;++i){
	dp[i][1]=add(dp[i-1][1],a[i]);
	for (int j=2;j<=i;++j) dp[i][j]=add(dp[i-1][j],mul(dp[i-1][j-1],a[i]));
  }
  int fac=1;
  for (int i=2;i<=n;++i) ssub(ans,mul(dp[n][i],mul(pw[n-i],fac))),smul(fac,i);
}

void work(){
  Get_pw();
  Get_a();
  Get_dp();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

ll sum(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  for (int i = K; i <= N + 1; i++) {
    ll l = sum(0, i - 1), r = sum(N - i + 1, N);
    ans += r - l + 1;
    ans = ans % 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    int n, a[100];
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
                    cout << "DENIED";
                    return 0;
            }
    }
    cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define ull unsigned long long

#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))

#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll d[300010];
ll n,cnt;
void f(ll a,ll b,ll l,ll r,ll s){
	//[l,r)をincがa,decがb以下になるようs+1からの数で埋める
	if(a==0||b==0){
		puts("-1");
		exit(0);
	}
	if(cnt+a<=n){
		rep(j,0,a)d[r-1-j]=s+a-j;
		cnt+=a;
		if(cnt+b-1<=n){
			rep(i,0,b-1)d[l+i]=s+a+b-1-i;
			cnt+=b-1;
		}else{
			for(ll i=r-a-1;i>=l;i--)d[i]=s+r-i;
			cnt=n;
		}
	}else{
		rep(j,0,n-cnt)d[l+j]=s+1+j;
		cnt=n;
	}
//	printf("%lld %lld %lld %lld %lld\n",a,b,l,r,s);
//	rep(i,0,16)printf("%lld ",d[i]);puts("");
	if(n!=cnt)f(a-1,b-1,l+b-1,r-a,s+a+b-1);
}

int main(){
	ll a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a+b>n+1){
		puts("-1");
		return 0;
	}
	f(a,b,0,n,0);
	rep(i,0,n)printf("%lld ",d[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=145000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


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

using namespace std;

const int inf = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> w(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i];
    }
    vector <int> dp(n, inf);
    dp[0] = 0;
    dp[1] = abs(w[1] - w[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(
            dp[i - 1] + abs(w[i] - w[i - 1]),
            dp[i - 2] + abs(w[i] - w[i - 2])
        );
    }
    cout << dp[n - 1] << '\n';
    return 0;
}


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

int N;
int func(int a[],int b){
	int cost=0;
	for (int i = 0; i < N; ++i)
	{
		cost+=(a[i]-b)*(a[i]-b);
	}
	return cost;
}
int main(){
	int a[200];
	int sum=0;
	int ave;

	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		sum+=a[i];
	}
	ave = sum/N;
	int cost = func(a,ave) ;
	while(cost>func(a,ave+1)){cost=func(a,ave+1);ave+=1;}
	while(cost>func(a,ave-1)){cost=func(a,ave-1);ave-=1;}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1 << 30
#define LINF (ll)1 << 62
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

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


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

#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()

string s;
int r=0,g=0,b=0;

signed main(){
    int n;
    cin >> n;
    cin >> s;
    
    int ans=0,exclude=0;

    rep(i,n){
        if(s.at(i)=='R') r++;
        else if(s.at(i)=='G') g++;
        else b++;
    }

    ans=r*g*b;
    //cout << ans << endl;

    //二つ目の条件の除外を考える(k=2*j-i)
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            int k=2*j-i;
            if(j<k && k<n){
                if(s[i]!=s[j] && s[i]!=s[k] && s[k]!=s[j]){
                    exclude++;
                }
            }
        }
    }
    cout << ans-exclude << endl;

    
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }.toMutableList()
    var cnt = 0
    for (i in 0 until n) {
        for (j in n - 1 downTo i + 1) {
            if (xs[j] < xs[j - 1]) {
                val t = xs[j]
                xs[j] = xs[j - 1]
                xs[j- 1] = t
                cnt++
            }
        }
    }
    println(xs.joinToString(" "))
    println(cnt)
}


Measured memory_bytes: 34452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int a[200010],b[200010];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",a+i),b[i]=a[i];
	sort(a+1,a+1+n);
	
	for(int i=1;i<=n;i++){
		if(b[i]==a[n])printf("%d\n",a[n-1]);else printf("%d\n",a[n]);
	}
}

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

int main()
{
	int H, W, HW[52][52] = { 0 };
	string S;

	cin >> H >> W;

	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			cin >> S[0];

			if (S[0] == '.')HW[h][w] = 0;
			else HW[h][w] = -1;
		}
	}


	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			if (HW[h][w] == -1) {
				for (int y = h - 1; y < h + 2; y++) {
					for (int x = w - 1; x < w + 2; x++) {
						if (HW[y][x] != -1) {
							HW[y][x]++;
						}
					}
				}
			}
		}
	}

	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			if (HW[h][w] == -1)cout << "#";
			else cout << HW[h][w];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	double sum=0.0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		sum += 1.0/x;
	}
	cout<<setprecision(12)<<1.0/sum<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 1
if N % 2 == 0:
    if len(A) != 2*len(set(A)):
        ans = 0
else:
    if A.count(0) == 1:
        A.remove(0)
        if len(A) != 2*len(set(A)):
            ans = 0
    else:
        ans = 0
if ans == 0:
    print(0)
else:
    print((2**(N//2))%(10**9+7))

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
//typedef pair< int , int > P;

/*vector<vector<long long>> comb(ll n, ll r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}*/

int main(){
    ll n;
    ll sum = 0;
    cin>>n;
    map<ll,ll> b;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        b[a[i]]+=1;
        //cout<<b[a[i]];
   }
    for(auto c :b){
      if (c.second==1) continue;
      sum += c.second*(c.second-1)/2;
    }
    rep(k,n){
      ll d = sum;
      ll e = b[a[k]];
      if(b[a[k]]<=1) cout<<d<<endl;
      else{
        d-= b[a[k]]*(b[a[k]]-1)/2;
        d+= (b[a[k]]-1)*(b[a[k]]-2)/2;
        cout<<d<<endl;
      }
    }
}


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

int main(){
    ll x;
    ll money = 100;
    cin >> x;
    int year = 0;
    while(money < x){
        year++;
        money = money*1.01;
    }
    cout << year << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<double> a(N,0);
  double ave = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    ave += a[i];
  }
  ave /= N;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (abs(a[i]-ave) < abs(a[ans]-ave)) {
      ans = i;
    }
  }
  cout << ans;
}

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

int main(){
  ll n;
  cin >> n;
  ll a,ans = INF;
  for(ll i=1;i<n;++i){
    a = n-i;
    string sa = to_string(a);
    string sb = to_string(i);
    ll sum = 0;
    for(char c:sa) sum += c-'0';
    for(char c:sb) sum += c-'0';
    ans = min(ans,sum);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
a=(tx-sx)*"R"+(ty-sy)*"U"
a=a+a.replace("R","L").replace("U","D")
b="D"+(tx-sx+1)*"R"+(ty-sy+1)*"U"+"L"
b=b+b.translate(str.maketrans({"D":"U","U":"D","R":"L","L":"R"}))
print(a+b)

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

const int D = 365;
vector<int> C(26), ans(D, 1);
vector<vector<int>> s(D, vector<int>(26));

void input()
{
    int tmp;
    cin >> tmp;
    rep(i,26) cin >> C[i];
    rep(i,D)rep(j,26) cin >> s[i][j];
}

void output()
{
    for(auto x : ans)
        cout << x << "\n";
}

int main()
{
    input();
    output();
    
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int k=0;
	vector<int> s(32);
	s={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<s[k-1];
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll mn=9999999999999999;
    ll x;
    for(int i=1;i<=5;i++)
    {
        cin>>x;
        if(x<mn)mn=x;
    }
    ll sum=5;
    n-=mn;
    sum+=(n/mn);
    if(n%mn!=0&&n>0)sum++;
    cout<<sum<<'\n';
}


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







const double EPS = 1e-9;
const double INF = 1e12;

struct P {
	double x, y, z;
	P() {}
	P(double x, double y, double z) :
		x(x), y(y), z(z) {}
};
P operator + (P a, P b) {
	return P(a.x + b.x, a.y + b.y, a.z + b.z);
}
P operator - (P a, P b) {
	return P(a.x - b.x, a.y - b.y, a.z - b.z);
}
P operator * (double a, P b) {
	return P(a * b.x, a * b.y, a * b.z);
}

double dot(P a, P b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

double abs(P a) {
	return sqrt(dot(a, a));
}

double norm(P a) {
	return dot(a, a);
}

struct L : public vector<P> {
	L() {}
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;

struct C {
	P p; double r;
	C() {}
	C(const P &p, double r) : p(p), r(r) { }
};

P projection(const L &l, const P &p) {
	double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
	return l[0] + t*(l[0] - l[1]);
}

bool intersectSP(const L &s, const P &p) {
	return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS; // triangle inequality
}

double distanceSP(const L &s, const P &p) {
	const P r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}

bool intersectCS(C c, L s) {
	P a = s[0], b = s[0] + s[1];
	bool ain = abs(a - c.p)<c.r - EPS, bin = abs(b - c.p)<c.r - EPS;
	if (ain && bin) return false;
	if (ain + bin == 1) return true;
	return distanceSP(s, c.p)<c.r + EPS;
}

bool intersect(const C &s, const L &l) {
	P a = l[0] - s.p, b = l[1] - s.p, c = projection(l, s.p) - s.p;
	if (abs(a) < s.r - EPS and abs(b) < s.r - EPS and abs(c) < s.r - EPS) return 0; // contain
	if (abs(c) > s.r + EPS) return 0; // far
	if (abs(a) < s.r - EPS or abs(b) < s.r - EPS) return 1; // intersect
	if (abs(a - c) + abs(b - c)<abs(a - b) + EPS) return 1; // intersect
	return 0;
}




int N, M, R;
C S[2010];
P T[15];
int TB[15];
P E;

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

	while (cin >> N >> M >> R)
	{
		if (N == 0) return 0;

		rep(i, 0, N)
		{
			double x, y, z, r; cin >> x >> y >> z >> r;
			S[i] = C(P(x, y, z), r);
		}

		rep(i, 0, M)
		{
			double x, y, z; cin >> x >> y >> z >> TB[i];
			T[i] = P(x, y, z);
		}

		{
			double x, y, z; cin >> x >> y >> z;
			E = P(x, y, z);
		}

		vector<int> crossed[15];
		rep(i, 0, M)
		{
			rep(j, 0, N)
			{
				if (intersect(S[j], L(E, T[i]))) crossed[i].push_back(j);
			}
		}

		/*rep(i, 0, M)
		{
			printf("%d -> %d : ", i, cnt[i].size());
			for (auto p : cnt[i]) printf("%d ", p);
			printf("\n");
		}*/

		double ans = 0;
		rep(i, 0, 1 << M)
		{
			bool done[2020];
			rep(j, 0, N) done[j] = false;

			double score = 0;
			int cnt = 0;
			rep(j, 0, M) if (i & (1 << j))
			{
				for (int p : crossed[j]) if(!done[p])
				{
					done[p] = true;
					cnt++;
				}
				double down = abs(E - T[j]) * abs(E - T[j]);
				score += (double)TB[j] / down;
			}
			if (cnt <= R) ans = max(ans, score);
		}
		printf("%.10f\n", ans);
	}
}

Measured memory_bytes: 3384
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[1] - h[0])]
for i in range(n - 2):
    a = dp[i] + abs(h[i + 2] - h[i])
    b = dp[i + 1] + abs(h[i + 2] - h[i + 1])
    dp.append(min(a, b))
print(dp[-1])

Measured memory_bytes: 20520
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N,K;
    cin >> N >> K;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        ans += min(x,K-x) * 2;
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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,d;
  	cin >> a >> b >> c >> d;
  	cout << max(a*b,c*d) << endl;
    return 0;
}

Measured memory_bytes: 256