akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    long n;
    vector<long> cap(5);
    cin >> n;
    for(int i=0; i<5; i++) cin >> cap[i];
    long min_cap = *min_element(cap.begin(), cap.end());
    //cout << min_cap << endl;
    long turn_num = n / min_cap;
    if(n%min_cap) turn_num++; // ここまででみんな都市1にいる
    cout << turn_num + 4 << endl;

    
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int dx[8]={1,1,1,0,0,-1,-1,-1};
int dy[8]={1,0,-1,1,-1,1,0,-1};
int main(){
  int h,w;
  cin >> h >>w;
  string s[h]; string t[h];
  for(int i=0;i<h;i++){
    cin >> s[i]; t[i]=s[i];
  }
  int c=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.'){
        for(int k=0;k<8;k++){
          int x=j+dx[k];int y=i+dy[k];
          if(x<0||y<0||x>=w||y>=h) continue;
          if(t[y][x]=='#') c++;
        }
        s[i][j]=c+'0';
        c=0;
      }
    }
  }
  for(int i=0;i<h;i++){
      cout <<s[i]<<endl;
    }
  }


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

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

    if(s!="AAA" && s!="BBB"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;
int gcd(int a, int b)
{
    if(b) return gcd(b,a%b);
    return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7;


int n;
vector<int>vec[1 << 17];
int a,b,dp[1 << 17][2];

void dfs(int nod,int par)
{
	dp[nod][0] = dp[nod][1] = 1;
	for(auto it : vec[nod])
	{
		if(it != par)
		{
			dfs(it,nod);
			dp[nod][0] *= dp[it][0] + dp[it][1];
			dp[nod][0] %= mod;
			dp[nod][1] *= dp[it][0];
			dp[nod][1] %= mod;
		}
	}
}

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n;
	if(n == 1) rc(2);
	for(int i = 1;i < n;i++)
	{
		cin >> a >> b;
		vec[a].pb(b);
		vec[b].pb(a);
	}
	dfs(1,0);
	rc((dp[1][0] + dp[1][1]) % mod);
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int amax = 0;
    rep(i,n) amax = max(amax,a[i]);
    int gcda = 0;
    rep(i,n) gcda = __gcd(gcda,a[i]);
    if(amax >= k && k%gcda == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	string s; cin >> s;
	if (s.back() == 's') s += "es";
	else s += 's';
	cout << s << endl;
}
// Remember to clear the global containers



// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 3652
//文字である数字を整数に変換するときは'0'を引けばいい
#include<iostream>
#include<string>
using namespace std;

int main(){
    string str;
    int sum;
    while(cin >> str && str !="0"){
        sum = 0;
        for(int i=0,l=str.size(); i<l; i++){
            sum += str[i]-'0';
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3152
#!/usr/bin/env python3

s = input()

def dfs(i, t):
    if i == len(s) - 1:
        return sum(list(map(int, t.split('+'))))
    return dfs(i+1, t + s[i+1]) + dfs(i+1, t + '+' + s[i+1])

print(dfs(0, s[0]))

Measured memory_bytes: 3060
from sys import stdin
readline = stdin.buffer.readline
read = stdin.buffer.read
def i_input(): return int(input().rstrip())
def i_map(): return map(int, input().rstrip().split())
def i_list(): return list(i_map())

# import numpy as np
# from numba import jit
# stdin = open('sample.txt')

def main():
    A, B = i_map()
    if (A * B) % 2 == 0:
        print('Even')
    else:
        print('Odd')

if __name__ == "__main__":
    main()


Measured memory_bytes: 61896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    string S;
    cin >> S;
    N = S.size();
    rep(i,N-1){
        if(S[i] == S[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    rep(i,N-2){
        if(S[i] == S[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}

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

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

// code starts
int main()
{
  int h1,m1,h2,m2;cin>>h1>>m1>>h2>>m2;
  int t1,t2;
  t1=h1*60+m1;
  t2=h2*60+m2;
  int k;cin>>k;
  cout<<t2-t1-k<<endl;
}


Measured memory_bytes: 3632
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
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


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 100005;
vector<ll> adj[maxn];
ll dp[maxn];
bool vis[maxn];

void dfs(ll s){
    if(vis[s]) return;
    vis[s] = true;
    ll pVal = -1;
    for(auto parent: adj[s]){
        dfs(parent);
        pVal = max(pVal, dp[parent]);
    }
    dp[s] = pVal + 1;
}

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        // string s, st;
        ll n,m,x,y;
        cin>>n>>m;
        rep(i,m){
            cin>>x>>y;
            x--;y--;
            adj[x].pb(y);
        }
        rep(i,n)
            dfs(i);
        ll ans = 0;
        rep(i,n){
            ans = max(ans, dp[i]);
        }
        cout<<ans;
    }
}

Measured memory_bytes: 8704
# -*- coding: utf-8 -*-
K, N = map(int, input().split())
A_list = list(map(int, input().split()))
q = K - (A_list[N-1] - A_list[0])
for i in range(N-1):
    p = A_list[i+1] - A_list[i]
    if p > q:
        q = p
print(K - q)

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

int main(void) {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int l = N / 2 - 1, r = N / 2;
  cout << d[r] - d[l] << endl;
  return 0;
}

Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<pair<ll,ll>> task;
    rep(i,n){
        ll a,b; cin >> a >> b;
        task.push_back(make_pair(b,a));
    }
    
    sort(task.begin(),task.end());
    
    ll time = 0;
    bool isCanTask = true;
    rep(i,n){
        time += task[i].second;
        if(!(time <= task[i].first)) isCanTask = false;
    }
    
    if(isCanTask) cout << "Yes" << endl;
    else cout << "No" << endl;
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 6512
A,B = map(int, input().split())
num = 0
while num < 1011:
  num += 1
  X = num * 0.08
  if int(X) == A:
    Y = num * 0.1
    if int(Y) == B:
      print(num)
      break
    else:
      pass
  elif num == 1010:
    print(-1)
    break
  else:
    pass


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
using namespace std;
bool ok(int a, int b, int c) {
    return a * a == b *b + c *c;
}

int main() {
    int n, a, b, c;
    cin >> n;
    while (n--) {
        cin  >> a >> b >> c;
        if (ok(a, b, c) || ok(b, a, c) || ok(c, b, a)) puts("YES");
        else puts("NO");
    }
}


Measured memory_bytes: 3080
import queue
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

dxs = [0, 0, 1, -1]
dys = [1, -1, 0, 0]
cand = []
for j in range(H):
    for i in range(W):
        if S[j][i] == '#':
            continue
        q = queue.Queue()
        q.put((i, j, 0))
        field = [[-1] * W for _ in range(H)]
        field[j][i] = 0
        while not q.empty():
            p = q.get()
            for dx, dy in zip(dxs, dys):
                x, y = p[0] + dx, p[1] + dy
                if not (0 <= x < W) or not (0 <= y < H) or S[y][x] == '#' or field[y][x] != -1:
                    continue
                field[y][x] = p[2] + 1
                q.put((x, y, p[2] + 1))
        cand.append(max(max(row) for row in field))
print(max(cand))

Measured memory_bytes: 3944
#include <iostream>

using namespace std;

int cal(int v, int per) {
	return v * (100 + per) / 100;
}
int main() {
	int x, y, s;
	while ( cin >> x >> y >> s, x || y || s ) {
		int ans = 0;
		for (int i = 1; i <= s; ++i) {
			for (int j = i; j <= s-i; ++j) {
				if ( cal(i, x) + cal(j, x) == s ) {
					ans = max(ans, cal(i, y) + cal(j, y));
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
    char S[201],P[101],R[101];
    scanf("%s",S);
    strcpy(R,S);
    strcat(S,R);
    scanf("%s",P);
    if(strstr(S,P) == NULL) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
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; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ
vector<int> deg; // 各頂点の入次数

int dp[100100];
int main() {
    // 入力受け取り, 入次数も管理する
    cin >> N >> M;
    G.assign(N, vector<int>());
    deg.assign(N, 0);
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
        deg[y]++;
    }
    
    // source をキューに突っ込む
    queue<int> que;
    for (int v = 0; v < N; ++v) if (deg[v] == 0) que.push(v);
    
    // BFS
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            deg[nv]--; // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                que.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                chmax(dp[nv], dp[v] + 1); // さらにソースから nv までの再長距離が確定する
            }
        }
    }
    
    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, dp[v]);
    cout << res << endl;
}


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

int main(){
  long long n,k;
  cin >> n >> k;
  long long a = n % k;
  long long ans = min(a,k-a);
  cout << ans << endl;
}
//n=16,k=7とかで考えてみたらわかると思う

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int ans = 0;
	
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int f, l;
		
		cin >> f >> l;
		
		ans += l - f + 1;
	}
	
	cout << ans << endl;
	
	return (0);
}

Measured memory_bytes: 256
#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    N, M = map(int, raw_input().split())
    if N == 0: break

    INF = [0]*20010
    INF[1] = 1
    p = []
    for i in range(M):
        p.append(map(int, raw_input().split()))
    p.sort()
    for t, s, d in p:
        if INF[s] == 1:
            INF[d] = 1
    print INF.count(1)

    
    

Measured memory_bytes: 8948
#include <bits/stdc++.h>
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(S.at(i) == '-') ans = "No"; 
  }
  if(S.at(A) != '-') ans = "No"; 
  for (int i = A+1; i <= A+B; i++) {
    if(S.at(i) == '-') ans = "No"; 
  }
  cout << ans << endl;
}

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

int main() {
  string 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";
  int k;
  cin >> k;
  if(k < 16){
    cout << s[3 * (k - 1)];
  }else if(k == 16){
    cout << 14;
  }else if(k < 24){
    cout << s[3 * (k - 1) + 1];
  }else if(k == 24){
    cout << 15;
  }else if(k < 32){
    cout << s[3 * (k - 1) + 2];
  }else{
    cout << 51;
  }
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    x = a[0]
    y = sum(a) - x
    x_y = abs(x - y)
    for i in range(1, n - 1):
        x += a[i]
        y -= a[i]
        x_y = min(x_y, abs(x - y))
    print(x_y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24812
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    queue<ll> q;
    rep1(i, 9) q.push(i);
    rep(i, k-1) {
        ll x = q.front(); q.pop();
        if (x % 10 != 0) q.push(10 * x + (x % 10) - 1);
        q.push(10 * x + (x % 10));
        if (x % 10 != 9) q.push(10 * x + (x % 10) + 1);
    }
    cout << q.front() << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
inputs = [int(i) for i in input().split()]

count = 0
for i in range(1, n-1):
    if (inputs[i-1] < inputs[i] < inputs[i+1]) or (inputs[i+1] < inputs[i] < inputs[i-1]):
        count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    int l = 0, r = n-1;
    while (l < r) {
        if (s[l] == s[r]) l++, r--;
        else if (s[l] == 'x' && s[r] != 'x') cnt++, l++;
        else if (s[l] != 'x' && s[r] == 'x') cnt++, r--;
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int n;
Graph G;

void bfs(int s, vector<int> &dist) {
    queue<int> que;
    que.push(s);
    dist[s] = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}

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

    cin >> n;

    G.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist1(n, -1);
    vector<int> dist2(n, -1);

    bfs(0, dist1);
    bfs(n - 1, dist2);

    int fennec = 0;
    int snuke = 0;
    rep(i, n) {
        if (dist1[i] <= dist2[i]) fennec++;
        else snuke++;
    }

    if (fennec > snuke) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int b=0;
    rep(i,n){
        if(a[i]>=((sum+4*m-1)/(4*m)))b++;
    }

    string ans=(b>=m)?"Yes":"No";
    cout<<ans<<endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°?????????????????????????????????????????????  
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_4_B 
 
auto topological_sort(const G& graph){
    const int n=graph.size();
    vector<int> used(n,0),order;

    auto dfs=[&](int v){
        auto func=[&](int v,auto func)->void{
            used[v]=true;
            for(auto &e:graph[v]) if(!used[e.to]) func(e.to,func);
            order.push_back(v);
        };
        return func(v,func);
    };
    
    rep(v,n)if(!used[v]) dfs(v);
    reverse(_all(order));
    return order;
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
	}

	auto res=topological_sort(graph);
    for(auto &it:res) cout <<  it << endl;
	return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=n/(a+b)*a;
    n%=(a+b);
    ans+=min(n,a);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())
    if A == 1:
        A = 14
    if B == 1:
        B = 14

    if A > B:
        print('Alice')
    elif A < B:
        print('Bob')
    else:
        print('Draw')

    return


if __name__ == '__main__':
    main()


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

int main()
{
    bool flag=false;
    ll N;
    cin >> N;
    ll max=1;

    for(ll i = 1;i <= sqrt(N);i++)
    {
        if(N%i==0)
        {   
            max = i;
        }
    }

    ll ans = N/max + max - 2;
    
    cout << ans << endl;
    

    return 0;
}



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

struct edge {
    int to, cost;
};

class dijkstra {
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<P>> que;

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    int find(int e) {
        return d[e];
    }
};

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

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

bool prime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y)) return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}
signed main() {
    int n;
    P ball[50];
    cin>>n;
    map<P,int> mp;
    rep(i,n)cin>>ball[i].first>>ball[i].second;
    sort(ball,ball+n);
    rep(i,n){
        rep(j,i){
            int x=ball[i].first-ball[j].first;
            int y=ball[i].second-ball[j].second;
            if(x<0){
                x*=-1;
                y*=-1;
            }
            mp[{x,y}]++;
        }
    }
    int mx=0;
    for(auto it:mp)mx=max(mx,it.second);
    cout<<n-mx<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main (String[] args) {
        final Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] numbers = new int[length];

        for (int i = 0; i < length; i++) {
            numbers[i] = sc.nextInt();
        }

        int max = numbers[1] - numbers[0];
        int min = numbers[0];
        for (int i = 1; i < length; i++) {
            if (numbers[i] < min) {
                min = numbers[i];
                continue;
            }

            if (numbers[i] - min > max) {
                max = numbers[i] - min;
            }
        }

        System.out.println(max);
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n,T;
  cin >> n >> T;
  vector<int> t(n);
  REP(i,n)cin >> t[i];
  ll res = 0;
  REP(i,n-1){
    res += min(t[i+1]-t[i],T);
  }
  res += T;
  cout << res << endl;




  

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
P = [int(x) for x in input().split()]
mins = [0]*N
mins[0] = P[0]
for n in range(1,N):
    mins[n] = min(P[n],mins[n-1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)


Measured memory_bytes: 25768
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr))
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
int32_t main(){
    
    ios_base::sync_with_stdio(cin.tie(NULL));
    cout.tie(NULL);
    
    int tc = 1;
    // cin>>tc;
    while(tc -- ){
        
        
        int a,b,m;
        
        cin>>a>>b>>m;
        int vala[a+1];
        int valb[b+1];
        int min1 = 1e9;
        int min2 = 1e9;
        
        for(int i =0 ; i < a; i++)cin>>vala[i] , min1 = min(min1,vala[i]);
        for(int i =0 ; i < b; i++)cin>>valb[i] , min2 = min(min2 , valb[i]);
        
        
        int ans = 1e9;
        
        for(int i = 0; i < m ; i++){
            
            
            int x1,x2,pr;
            cin>>x1>>x2>>pr;
            
            
            int sum = vala[x1-1]+valb[x2-1] - pr;
            
            
            sum = max(0ll,sum);
            
            ans = min(ans,sum);
        }
        ans  = min(ans , min1+min2);
        cout<<ans<<endl;
        
    }
    
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, M;
	int s[10], c[10];
	int a[105] = {0};

	cin >> N >> M;

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

	for (int i = 0; i < M; i++) {
		if (s[i] == 1 && c[i] == 0) {
			if (N == 2 || N == 3) {
				cout << -1 << endl;
				return 0;
			}
		}
		if (s[i] > N) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (M == 0) {
		if (N == 1) {
			cout << 0 << endl;
		} else if (N == 2) {
			cout << 10 << endl;
		} else {
			cout << 100 << endl;
		}
		return 0;
	}
	int tmp[3] = {-1, -1, -1};
	for (int i = 0; i < M; i++) {
		if (tmp[s[i] - 1] == -1 || tmp[s[i] - 1] == c[i]) {
			tmp[s[i] - 1] = c[i];
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	if ((N == 2 || N == 3) && tmp[0] == -1) {
		tmp[0] = 1;
	}
	for (int i = 0; i < N; i++) {
		if (tmp[i] == -1) {
			printf("0");
		} else {
			printf("%d", tmp[i]);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var a int
        var b int
        var c int
        fmt.Scan(&a)
        fmt.Scan(&b)
        fmt.Scan(&c)

        if a == b && a == c && b == c {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}

Measured memory_bytes: 512
#pragma warning(disable:4996)
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
     
    #include<bits/stdc++.h>
     
    #define pb push_back
    #define X first
    #define Y second
    #define all(x) (x).begin(),(x).end()
    #define rall(x) (x).rbegin(),(x).rend()
    #define f(i, a ,b) for(int i = (int)a; i <=(int)(b);i++)
    #define endl "\n"
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define int long long
    using namespace std;
     
    const int N = 1e5+5,MOD = 1000000007;
    const long long INF = 0xFFFFFFFFFFFFFFFL;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
     
    void IOS()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr);
       	cout.precision(10);
       	cout << fixed;
    }
    	
    int32_t main()
    {
    	IOS();
    	int n,s;
    	cin >> n >> s;
    	vector<int> w(n+1),v(n+1);
    	f(i,0,n-1)cin >> w[i] >> v[i];
    	vector<int> dp(n*1000+1,INF);
    	dp[0] = 0;
    	for(int i = 0; i < n; i++)
    	{
    		for(int j = n*1000; j >= v[i]; j--)
    		{
    			dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
    		}
    	}
    	int ans = 0;
    	for(int i = 0;i < 1000*n+1; i++)if(dp[i] <= s)ans = i;
    	cout << ans;		
    	return 0;
    }

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

int main(){
    long long N,K;
    cin >> N >> K;

    long long cnt=0;
    for(int b=K+1;b<=N;b++){
        cnt+=((N+1)/b)*(b-K);
        cnt+=(((N+1)%b)-K>0?((N+1)%b)-K:0);
        if(K==0) cnt--;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;

public class Main {
	public static void main(String[] args) throws IOException {

		NumberFormat format = NumberFormat.getInstance();
		format.setMaximumFractionDigits(3);
		format.setMinimumFractionDigits(3);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		while (n-- > 0) {
			String[] s = br.readLine().split(" ");
			double[] x = new double[3];
			double[] y = new double[3];
			for (int i = 0; i < 3; i++) {
				x[i] = Double.parseDouble(s[2 * i]);
				y[i] = Double.parseDouble(s[2 * i + 1]);
			}
			double p = ((y[0] - y[2]) * (y[0] * y[0] - y[1] * y[1] + x[0] * x[0] - x[1] * x[1]) - (y[0] - y[1]) * (y[0] * y[0] - y[2] * y[2] + x[0] * x[0] - x[2] * x[2]))
					/ (2 * (y[0] - y[2]) * (x[0] - x[1]) - 2 * (y[0] - y[1]) * (x[0] - x[2]));
			double q = ((x[0] - x[2]) * (x[0] * x[0] - x[1] * x[1] + y[0] * y[0] - y[1] * y[1]) - (x[0] - x[1]) * (x[0] * x[0] - x[2] * x[2] + y[0] * y[0] - y[2] * y[2]))
					/ (2 * (x[0] - x[2]) * (y[0] - y[1]) - 2 * (x[0] - x[1]) * (y[0] - y[2]));
			double r = Math.sqrt((p - x[0]) * (p - x[0]) + (q - y[0]) * (q - y[0]));
			System.out.println(BigDecimal.valueOf(p).setScale(3, RoundingMode.HALF_UP) + " " + BigDecimal.valueOf(q).setScale(3, RoundingMode.HALF_UP) + " "
					+ BigDecimal.valueOf(r).setScale(3, RoundingMode.HALF_UP));
		}
	}
}

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

int main() {
	int a, b;

	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (a <= 5) {
		cout << 0 << endl;
	}
	else {
		cout << b / 2 << endl;
	}
}

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

const int max_n = 2e5;

int main()
{
    int n;
    cin >> n;
    pair<int, int> a[max_n];
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        a[i] = make_pair(x, i);
    }

    sort(a, a + n, greater<pair<int, int>>());
    for (int i = 0; i < n; ++i)
    {
        if(a[0].second == i)
        {
            cout << a[1].first << endl;
        } else
        {
            cout << a[0].first << endl;
        }
    }
}

Measured memory_bytes: 3200
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
//int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
//int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}


int main()
{
	fast();
	int n;
	cin >> n;
	vector<ll> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

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

	double ans = v[0];

	for (int i = 1; i < n; i++)
		ans += v[i], ans /= 2.0;

	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = S()

if N == N[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

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

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int k; ll X; cin >> k >> X;
  cout << (500*k >= X ? "Yes" : "No") << endl;
}

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

using namespace std;

#define mp make_pair
#define fr first
#define sc second

long long n,m=0,ttl=0,cr,wg[10069],z=0,inf=1e18;
vector<pair<long long,long long>> al[169];
bitset<169> vtd;
bool r0=1;

void ae(long long x,long long y,long long w)
{
	m+=2;
	al[x].push_back({y,m-(x<y)});
	al[y].push_back({x,m-(y<x)});
	wg[m-(x<y)]=w;
}

void dfs(long long x,long long mn)
{
	long long i,sz=al[x].size(),l,p;
	
	vtd[x]=1;
	if(x==n+1)
	{
		r0=1;
		cr=mn;
		z+=cr;
		return;
	}
	for(i=0;i<sz;i++)
	{
		l=al[x][i].fr;
		p=al[x][i].sc;
		if(wg[p])
		{
			if(!vtd[l])
			{
				dfs(l,min(mn,wg[p]));
				if(r0)
				{
					wg[p]-=cr;
					wg[(p-1)/2*2+1+p%2]+=cr;
					return;
				}
			}
		}
	}
}

int main()
{
	long long i,j,k;
	
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&k);
		ttl+=max(k,0ll);
		if(k>=0)
		{
			ae(i,n+1,k);
		}
		else
		{
			ae(0,i,-k);
		}
		for(j=i*2;j<=n;j+=i)
		{
			ae(i,j,inf);
		}
	}
	for(;r0;)
	{
		vtd.reset();
		r0=0;
		dfs(0,inf);
	}
	printf("%lld\n",ttl-z);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    ll ans=0;
    rep(i,s.size()/2)if(s[i]!=s[s.size()-1-i])ans++;
    puta(ans);
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int m,n;
    while(cin>>m>>n,m){
        int b[200];
        int max_b = 0;
        for(int i = 0;i < n;i++){
            cin>>b[i];
            max_b = max(max_b,b[i]);
        }

        int D = 100;
        int l = 1,r = 1500001;
        int ans = 1600000;
        while(D--){
            int mid = (l+r)/2;
            if(mid < max_b){
                l = mid;
                goto next;
            }
            {
                int idx = 0,br = 0;
                for(int i = 0;i < n;i++){
                    if(br + b[i] <= mid)br = br + b[i];
                    else{
                        idx++;
                        br = b[i];
                        if(idx == m){
                            l = mid;
                            goto next;
                        }
                    }
                }
            }
            r = mid;
            next:;
        }
        cout<<r<<endl;
    }



    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<int> a(n);
	REP(i,n){
		cin>>a[i];
	}
	sort(ALL(a));
	
	int ans=INF;
	for(int i=a[0];i<=a[n-1];++i){
		int cost=0;
		REP(j,n){
			cost+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,cost);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256