akhauriyash/Code-Regression huggingface dataset:
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)

typedef long long ll;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};


int main() {
  while (true) {    
    int N = Scanner::nextInt();
    if (N == 0) break;
    int field[110][110];
    memset(field, 0, sizeof(field));    
    int W = Scanner::nextInt();
    int H = Scanner::nextInt();
    REP(i, N) {
     int x = Scanner::nextInt();
     int y = Scanner::nextInt();
     field[x - 1][y - 1] = 1;
    }
  
    int S = Scanner::nextInt();
    int T = Scanner::nextInt();
    
    int M = -1;
    REP(x, W) {
      REP(y, H) {
        int t = 0;
        REP(i, S) {
          if (x + i > W) break;
          REP(j, T) {
            if (y + j > H) break;
            t += field[x + i][y + j];
            if (t > M) {
              M = t;            
            }
          }
        }
      }
    }
    PRINT(M);
  } 
  
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,m;
	int k,t;
	int cnt[30],ans = 0;
	for (int i = 0; i < 30; ++i)	cnt[i] = 0;
	scanf("%d %d",&n,&m);
	for (int i = 1; i <= n; ++i){
		scanf(" %d",&k);
		for (int j = 1; j <= k; ++j){
			scanf(" %d",&t);
			++cnt[t - 1];
		}
	}
	for (int i = 0; i < m; ++i)
	{
		if(cnt[i] == n)	++ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
# https://onlinejudge.u-aizu.ac.jp/problems/GRL_2_A
# 最小全域木

# https://qiita.com/Kerzival/items/6923c2eb3b91be86f19f
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

# 入力値の取得・構造化
V, E = map(int, input().split())
edges = []

for i in range(E):
    s, t, w = map(int, input().split())
    edges.append({"s": s, "t": t, "w": w})

# kruskal
edges = sorted(edges, key=lambda x:x['w'])
union_find = UnionFind(V)
res = 0
for i in range(E):
    edge = edges[i]
    if not union_find.isSameGroup(edge["s"], edge["t"]):
        union_find.Unite(edge["s"], edge["t"])
        res = res + edge["w"]
print(f"{res}")


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 094 A / Link: http://abc094.contest.atcoder.jp/tasks/abc094_a  ----- */


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

	LL A, B, X; cin >> A >> B >> X;


	LL ans = A <= X && A + B >= X;


	cout << (ans?"YES":"NO") << "\n";

	return 0;
}


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

import fileinput

if __name__ == '__main__':
    for line in fileinput.input():
        tokens = line.strip().split()
        a, b = int(tokens[0]), int(tokens[1])
        if a == b == 0:
            pass
        elif a <= b:
            print '%d %d' % (a, b)
        elif b < a:
            print '%d %d' % (b, a)

Measured memory_bytes: 6292
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    C_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+2].split(' ')))[::-1]  # type:list(int)
        C_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    C_B_arr.sort(reverse=True)
    A_arr.sort(reverse=True)
    min_iter = len(A_arr)-1
    _min = A_arr[-1]

    cnt = 0
    for i in range(M):
        for j in range(C_B_arr[i][1]):
            if A_arr[min_iter] < C_B_arr[i][0]:
                A_arr[min_iter] = C_B_arr[i][0]
                min_iter -= 1
            else:
                break
    cnt = sum(A_arr)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 101212
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

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

const int mod = 1e9 + 7;
ll qp(ll base, ll b)
{
    ll res = 1;
    while (b) {
        if (b & 1)
            res = res * base % mod;
        base = base * base % mod;
        b >>= 1;
    }
    return res;
}
ll C(int m, int n)
{
    ll res = 1;
    for (int i = n - m + 1; i <= n; i++)
        res = res * i % mod;
    for (int i = 1; i <= m; i++)
        res = res * qp(i, mod - 2) % mod;
    return res;
}
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = (qp(2, n) - 1 - C(a, n) - C(b, n) + 2 * mod) % mod;
    cout<<ans;
}


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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  ll x, n; cin >> x >> n;

  if (n == 0) {
    cout << x << endl;
    return;
  }
  vector<ll> v(n, 0);
  rep(n, i) cin >> v[i];

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

  vector<ll> vb;
  vector<ll> vc;
  for (ll i = 0; i <= 101; ++i) {
    bool flag = false;
    for (ll j = 0; j < n; ++j) {
      if (i == v[j]){
        flag = true;
        break;
      } 
    }
    if (flag == false) {
      ll temp = abs(x - i);
      vb.emplace_back(i);
      vc.emplace_back(temp);
    }
  }

  ll res = vb[(ll)vb.size() - 1];
  for (ll i = (ll)vb.size()-1; i-1 >= 0; --i) {
    if (vc[i-1] <= vc[i]) res = vb[i-1];
  }
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 3632
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;
int n,m,q;
vi a,b,c,d;
int ans = 0;
void solve(vi v){
	if(v.size()== n){
			int sum = 0;
		for(int i = 0; i < q; i++){
			if(v[b[i]] - v[a[i]] == c[i]){
				sum += d[i];
			}
		}
			ans = max(sum,ans);
	}
	else{
		int st = 1;
		if(v.size()) st = v.back();
		for(int i = st; i <= m; i++){
			v.push_back(i);
			solve(v);
			v.pop_back();
		}
	
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	a.resize(q);	
	b.resize(q);	
	c.resize(q);	
	d.resize(q);	
	for(int i = 0; i < q; i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];	
		a[i]--;
		b[i]--;
	}
	vector<int> v;
	solve(v);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

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

int H, W, K;
int sx, sy;
char data[801][801];
int mn = INF;

bool ok( int n ) {
  if( mn - (n-1) * K <= 0 ) return true;
  else return false;
}

void bfs()
{
  queue<Pip> q;
  bool used[801][801] = {{0}};
  q.push( Pip(K, Pii(sy, sx)) );


  while( !q.empty() ) {
    Pip p = q.front(); q.pop();
    int k = p.fr, y = p.sc.fr, x = p.sc.sc;
    //cout << y << " " << x << endl;
    mn = min( mn, min(y - 0, H-1 - y ) );
    mn = min( mn, min(x - 0, W-1 - x ) );

    if( k == 0 ) continue;
    if( used[y][x] ) continue;
    used[y][x] = true;

    for(int i=0; i<4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if( nx < 0 || ny < 0 || nx >= W || ny >= H || data[ny][nx] == '#' ) continue;
      q.push( Pip(k-1, Pii(ny, nx)) );
    }
  }
}

main()
{
  cin >> H >> W >> K;

  Rep(i, H) Rep(j, W) {
    cin >> data[i][j];
    if( data[i][j] == 'S' ) {
      sy = i; sx = j;
      data[i][j] =  '.';
    }
  }

  bfs();
  //cout << mn << endl;
  for(int i=1; i<1000; i++) {
    if( ok( i ) ) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 1536
def solve(S):
    ret = 0
    tmp_ret = 0
    for s in S:
        if s in ["A", "T", "C", "G"]:
           tmp_ret += 1
        else:
            ret = max(ret, tmp_ret)
            tmp_ret = 0
    ret = max(ret, tmp_ret)
    return ret

if __name__ == '__main__':
    S = input()
    print(solve(S))


Measured memory_bytes: 38292
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
pi a[N];
int main()
{
    ft
    int t,i,j,n,m,l=0,r,z=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>l;
        a[i]={l,i};
    }
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
    {
        cout<<a[i].S<<" ";
    }
    return 0;
}



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

int x[100100];

int main()
{
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        x[a]++;
    }
    int ans = x[0] + x[1];
    repl(i, 1, 100100) {
        int t;
        t = x[i] + x[i + 1] + x[i - 1];
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem (I) in C++
// MAIN IDEA   : max sum of S(X) + S(S(X)) => 100 so brute force
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
vi vv;
vector<vi> v, vec;
set<int> st;
int ans[N] = { }, comp[N] = { };
bool vis[N] = { };
void dfs(int node) {
	vis[node] = true;
	for (auto u : v[node])
		if (!vis[u])
			dfs(u);
	vv.pb(node);
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k, l;
	cin >> n >> k >> l;
	v.resize(n + 1);
	lp(i,1,k)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int cnt = 0;
	lp(i,1,n)
	{
		if (vis[i])
			continue;
		vv.clear();
		dfs(i);
		cnt++;
		for (auto u : vv)
			comp[u] = cnt;
	}
	clr(vis, 0);
	v.clear();
	v.resize(n + 1);
	vec.resize(n + 1);
	lp(i,1,l)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	lp(i,1,n)
	{
		if (vis[i])
			continue;
		vv.clear();
		dfs(i);
		st.clear();
		for (auto u : vv) {
			vec[comp[u]].pb(u);
			st.insert(comp[u]);
		}
		for (auto u : st) {
			for (auto k : vec[u])
				ans[k] = vec[u].size();
			vec[u].clear();
		}
	}
	lp(i,1,n)
		cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 19580
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
typedef long long int LL;
using namespace std;
int n;
LL a[115];
LL gcd(LL x,LL y){
    if(y==0) return x;
    return gcd(y,x%y);
}
void solve()
{
    LL lcm = 1;
    for(int i=1;i<=n;i++)
    {
        lcm = lcm/gcd(lcm,a[i])*a[i];
    }
    cout<<lcm<<endl;
    //printf("%I64d\n",lcm);
}
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++) cin>>a[i];//scanf("%I64d",&a[i]);
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef vector<ull> vec;
typedef vector<vec> mat;
typedef pair<int,ull> P;
#define N 4
ull po[N*N+10];
ull m2i(mat m){
  int res=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      res+=m[i][j]*po[i*N+j];
  return res;
}
mat i2m(ull x){
  mat res(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(i==N-1&&j==N-1) res[i][j]=x/po[i*N+j];
      else res[i][j]=(x%po[i*N+j+1])/po[i*N+j];
  return res;
}
int dist(mat m){
  int res=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(!m[i][j]) continue;
      int k=m[i][j]-1;
      int y=k/N,x=k%N;
      res+=abs(i-y)+abs(j-x);
    }    
  }
  return res;
}
signed main(){
  po[0]=1;
  for(int i=0;i<N*N;i++) po[i+1]=po[i]*(N*N);
  mat p(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>p[i][j];
  mat e(p);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      e[i][j]=i*N+j+1;
  e[N-1][N-1]=0;
  ull ans=m2i(e);
  //cout<<ans<<endl;
  priority_queue<P,vector<P>,greater<P> > q;
  map<ull,int> m;
  q.push(P(dist(p),m2i(p)));
  m[m2i(p)]=0;
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  while(!q.empty()){
    P y=q.top();q.pop();
    ull x=y.second;
    if(x==ans) break;
    p=i2m(x);
    int zy,zx;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	if(p[i][j]==0) zy=i,zx=j;
    //cout<<zy<<" "<<zx<<endl;
    for(int k=0;k<4;k++){
      int ny=zy+ay[k],nx=zx+ax[k];
      if(ny<0||N<=ny||nx<0||N<=nx) continue;
      swap(p[zy][zx],p[ny][nx]);
      ull t=m2i(p);
      //cout<<t<<endl;
      if(!m.count(t)||m[x]+1<m[t]){
	m[t]=m[x]+1;
	//if(t==ans) break;
	q.push(P(m[t]+dist(p),t));
      }
      swap(p[zy][zx],p[ny][nx]);
    }
  }
  cout<<m[ans]<<endl;
  return 0;
}

Measured memory_bytes: 177600
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
n = I()
ans = 1000 * (n // 1000 + 1) - n
if n % 1000 == 0:
    ans = 0
print(ans)


Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
template<typename T> 
T dig_sum(T n){
   if(n < 10)  return n;
   return dig_sum(n/10) + n%10;
}
int main(){
    int X;
    cin >> X;
    if(X % dig_sum(X)) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a, b) for (auto &&a:b)
#define FIND(s, e) (s.find(e) != s.end())
#define EB emplace_back

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF+7;
const LL LLINF = 1e18;

int main(void) {
    int N, K;
    cin >> N >> K;
    cout << K * (int)pow(K - 1, N - 1) << endl;
}


Measured memory_bytes: 384
# https://www.kumilog.net/entry/python-speed-comp#input-%E3%81%A8-sysstdinreadline
# https://teratail.com/questions/88396

from heapq import heapify, heappush, heappop
import sys

input = sys.stdin.readline


class Data:
    def __init__(self, value, indices):
        self.value = value
        self.indices = indices

    def __lt__(self, other):
        return self.value < other.value


X, Y, Z, K = map(int, input().split())
a = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())

a = list(sorted(a, reverse=True))
b = list(sorted(b, reverse=True))
c = list(sorted(c, reverse=True))

hq = []
heapify(hq)

t = a[0] + b[0] + c[0]
t *= -1

d = Data(t, (0, 0, 0))

heappush(hq, d)

dtpls = ((1, 0, 0), (0, 1, 0), (0, 0, 1))

st = set()

cnt = 0
for _ in range(K):
    d = heappop(hq)
    print(-d.value)
    for dtpl in dtpls:
        na = d.indices[0] + dtpl[0]
        if na >= X: continue
        nb = d.indices[1] + dtpl[1]
        if nb >= Y: continue
        nc = d.indices[2] + dtpl[2]
        if nc >= Z: continue

        nt = a[na] + b[nb] + c[nc]
        nt *= - 1

        ntpl = (na, nb, nc)
        if ntpl in st: continue
        heappush(hq, Data(nt, ntpl))
        st.add(ntpl)


Measured memory_bytes: 5352
# import sys
# sys.setrecursionlimit(10 ** 6)
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(H):
    ans = 0
    monster = 1
    while True:
        ans += monster
        if H == 1:
            break
        H = H // 2
        monster *= 2
    print(ans)


if __name__ == '__main__':
    H = int(input())
    solve(H)


Measured memory_bytes: 2940
n,k = map(int,input().split())
sn = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        sn[a[j]-1]+=1
cnt =0
for i in sn:
    if i==0:
        cnt+=1
print(cnt)




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

int main() {
  string S, T;
  cin >> S >> T;
  int C=0, m=1000000;
  for (int i=0; i<=S.size()-T.size(); i++) {
    C=0;
    for (int j=0; j<T.size(); j++) {
      if (S[i+j]!=T[j]) {
        C++;
      }
    }
    m=min(m, C);
  }
  cout << m << endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
using namespace std;

int dp[103];

const int INF = 0x3f3f3f3f;
const int MAXN = 1000010;
struct qnode{
    int v;
    int c;
    qnode(int _v=0,int _c=0):v(_v),c(_c){}
    bool operator < (const qnode &r) const
        {
            return c > r.c;
        }
};
struct Edge
{
    int v,cost;
    Edge(int _v=0,int _cost=0):v(_v),cost(_cost){}
};
vector<Edge>E[MAXN];
bool vis[MAXN];
int dist[MAXN];
void Dijkstra(int n,int start)//点的编号从1开始
{
    memset(vis,false,sizeof(vis));
    for(int i = 1; i <= n; i++) dist[i] = INF;
    priority_queue <qnode> que;
    while(!que.empty()) que.pop();
    dist[start] = 0;
    que.push(qnode(start,0));
    qnode tmp;
    while(!que.empty())
    {
        tmp = que.top();
        que.pop();
        int u = tmp.v;
        if(vis[u]) continue;
        vis[u] = true;
        for(int i = 0; i < E[u].size(); i++)
        {
            int v = E[tmp.v][i].v;
            int cost = E[u][i].cost;
            if(!vis[v]&&dist[v]>dist[u] + cost)
            {
                dist[v] = dist[u] + cost;
                que.push(qnode(v,dist[v]));
            }
        }
    }
}
void addedge(int u,int v,int w)
{
    E[u].push_back(Edge(v,w));
}


int main()
{
//    freopen("/Users/ecooodt/Desktop/c++ and acm/_集训/atcode/1/1.txt","r",stdin);
    int cnt = 0;
    int a,b;
    int n,m;
    scanf("%d%d",&n,&m);
//    for(int i = 0 ; i < )
//    while(~scanf("%d%d",&a,&b))
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d",&a,&b);
        addedge(a,b,1);
//        cnt ++;
//        n = max(b,n);
//        n = max(a,n);
    }
    Dijkstra(n,1);
//    printf("%d\n",n);
    int t = dist[n];
    if(t > 2)
    {
        printf("IMPOSSIBLE\n");
//        printf("%d",t);
    }

    else
    {
        printf("POSSIBLE\n");
//        printf("%d",t);
    }
}

Measured memory_bytes: 32756
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	
	int scount;
	int tcount;
	foreach(c; s){
		if(c == 'S') scount += 1;
		else{
			if(scount > 0) scount -= 1;
			else tcount += 1;
			}
		}
	
	int ans = tcount * 2;
	ans.writeln;
	
	}


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

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (auto &x : p){
		cin >> x;
	}
	int cnt = 0;
	for (int i = 1; i < N-1; i++){
		int max_p = max({ p[i - 1], p[i], p[i + 1] });
		int min_p = min({ p[i - 1], p[i], p[i + 1] });
		if (p[i] != max_p && p[i] != min_p){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust\n";
	else
		cout<<"win\n";
	return 0;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ1158().doit();
	}

	class AOJ1158{
		int w,h;
		int[][] controll;
		int[] cost;
		Point2D go(int x,int y,int muki){
			Point2D result = new Point2D.Double();
			if(muki==0)result = new Point2D.Double(x,y-1);
			else if(muki==1)result = new Point2D.Double(x+1, y);
			else if(muki==2)result = new Point2D.Double(x, y+1);
			else if(muki==3)result = new Point2D.Double(x-1, y);
			return result;
		}

		int solve(){
			int result = 0;
			int[][][] map = new int[31][31][4];
			for(int i=0;i<31;i++)for(int s=0;s<31;s++)Arrays.fill(map[i][s],Integer.MAX_VALUE/2);
			PriorityQueue<State> q = new PriorityQueue<State>();
			q.add(new State(0, 0, 1, 0));
			map[0][0][1] = 0;
			while(q.size()>0){
				State now = q.remove();
				int x = now.x;
				int y = now.y;
				int muki = now.muki;
//				System.out.println("*******************");
//				System.out.println(x+" "+y+" "+muki+" "+now.step);
				if(x==w-1&&y==h-1){
					result = now.step;
					break;
				}
				for(int i=0;i<4;i++){//0=直進,1=右折,2=反転,3=左折
					int nmuki = (muki+i)%4;
					Point2D nxy = go(x, y, nmuki);
					int nx = (int)nxy.getX();
					int ny = (int)nxy.getY();
					int nstep = now.step;
					if(nx<0||nx>=w||ny<0||ny>=h)continue;
					if(controll[y][x]!=i)nstep += cost[i];
//					if(nx==7&&ny==0){
//						System.out.println("------");
//						System.out.println(nx+" "+ny+" "+nmuki+" "+nstep+" "+i+" "+controll[ny][nx]);
//					}
					if(map[ny][nx][nmuki]<=nstep)continue;
					map[ny][nx][nmuki] = nstep;
					q.add(new State(nx, ny, nmuki, nstep));
				}
			}
//			System.out.println();
//			for(int i=0;i<h;i++){
//				for(int s=0;s<w;s++)System.out.print(map[i][s][0]+" ");
//				System.out.println();
//			}
//			System.out.println();
//			for(int i=0;i<h;i++){
//				for(int s=0;s<w;s++)System.out.print(map[i][s][1]+" ");
//				System.out.println();
//			}
//			System.out.println();
//			for(int i=0;i<h;i++){
//				for(int s=0;s<w;s++)System.out.print(map[i][s][2]+" ");
//				System.out.println();
//			}
//			System.out.println();
//			for(int i=0;i<h;i++){
//				for(int s=0;s<w;s++)System.out.print(map[i][s][3]+" ");
//				System.out.println();
//			}
			return result;
		}
		class State implements Comparable<State>{
			int x,y,muki,step;
			public State(int x,int y,int muki,int step) {
				this.x = x;
				this.y = y;
				this.muki = muki;
				this.step = step;
			}
			public int compareTo(State arg0) {
				return this.step - arg0.step;
			}
		}

		void doit(){
			while(true){
				w = in.nextInt();
				h = in.nextInt();
				if(w+h==0)break;
				controll = new int[h][w];
				cost = new int[4];//直進、右折、反転、左折
				for(int i=0;i<h;i++)for(int s=0;s<w;s++)controll[i][s] = in.nextInt();
				for(int i=0;i<4;i++)cost[i] = in.nextInt();
				int ans = solve();
//				System.out.print("Answer= " );
				System.out.println(ans);
				//break;
			}
		}
	}

}

Measured memory_bytes: 61968
from collections import deque
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]
if s[0][0] == '#' or s[H-1][W-1] == '#':
    print(-1)
    exit()
m = s[:]
goal = [H-1,W-1]
move = ((-1,0),(1,0),(0,-1),(0,1))
queue = deque()
queue.append((0,0))
m[0][0] = 0
while queue:
    now = queue.popleft()
    count = m[now[0]][now[1]] + 1
    for h,w in move:
        y,x = now[0]+h,now[1]+w
        if y < 0 or y >= H or x < 0 or x >= W:
            continue
        if m[y][x] == '.':
            m[y][x] = count
            queue.append((y,x))
    if m[H-1][W-1] != '.':
        break
if m[H-1][W-1] == '.':
    print(-1)
    exit()
ans = H*W - m[H-1][W-1] - 1 - sum([i.count('#') for i in s])
print(ans)


Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int N=200005;
int n,ans,a[N],b[N],tot[N];
set<int> st;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1,j=0;j<=30;i*=2,j++){
		st.insert(i);
	}
	sort(a+1,a+n+1);
	memcpy(b,a,4*(n+1));
	b[0]=unique(b+1,b+n+1)-b-1;
	for(int i=1;i<=b[0];i++){
		tot[i]=upper_bound(a+1,a+n+1,b[i])-lower_bound(a+1,a+n+1,b[i]);
	}
	for(int i=b[0];i>=1;i--){
		if(st.count(b[i])){
			ans+=tot[i]/2;
		}else{
			int res=*st.upper_bound(b[i])-b[i];
			if(upper_bound(a+1,a+n+1,res)-lower_bound(a+1,a+n+1,res)){
				res=lower_bound(b+1,b+b[0]+1,res)-b;
				int tmp=min(tot[res],tot[i]);
				ans+=tmp;
				tot[i]-=tmp;
				tot[res]-=tmp;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

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

    int x = int((s[0]-'0')*10) + int(s[1]-'0');
    int y = int((s[2]-'0')*10) + int(s[3]-'0');
    //cout << x << y << endl;

    if ((1 <= x && x <= 12) && (1 <= y && y <= 12)) {
        cout << "AMBIGUOUS" << endl;
    } else if (1 <= x && x <= 12) {
        cout << "MMYY" << endl;
    } else if (1 <= y && y <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;

int c[N][N];

int main(){
	int n, m, a, b;
	scanf("%d%d%d%d", &n, &m, &a, &b);
	for (int i = 1; i <= b; i++){
		for (int j = 1; j <= a; j++){
			c[i][j] = 1;
		}
	}
	for (int i = b + 1; i <= n; i++){
		for (int j = a + 1; j <= m; j++){
			c[i][j] = 1;
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			printf("%d", c[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5120
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val (r, s, p) = readLine()!!.split(" ").map { it.toInt() }
    val tt = readLine()!!.toMutableList()

    var score = 0L

    tt.forEachIndexed { idx, it ->
        val addedScore = when (it) {
            'r' -> p
            's' -> r
            'p' -> s
            else -> 0
        }
        score += addedScore

        if (idx < k) return@forEachIndexed
        if (tt[idx-k] != it) return@forEachIndexed

        score -= addedScore
        tt[idx] = '-'
    }

    println(score)
}


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

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool flg = false;
    // cout << s[a] << endl;
    if (s[a] == '-')
    {
        int cnt = 0;
        for (int i = 0; i < a + b + 1; i++)
        {
            int num = (int)(s[i] - '0');
            // cout << num << endl;
            if (0 <= num && num <= 9)
            {
                cnt++;
            }
        }
        if (cnt == a + b)
        {
            flg = true;
        }
    }

    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cout << b - a + 1 - (b / c - (a - 1) / c + b / d - (a - 1) / d) + b / ((c * d) / gcd(c, d)) -
	        (a - 1) / ((c * d) / gcd(c, d)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <functional>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
vector<int> ans;

bool isPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0)return false;
  }
  return true;
}

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

  vector<int> P;

  cin >> N;

  for (int i=6; i<=55555; i+=5){
    if (isPrime(i)) ans.push_back(i);
  }

  rep(i, N) cout << ans[i]<< ' ';
  return 0;
}

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

using namespace std;

string s;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    int N = s.size();
    string lst = " ";
    int ans = 0;
    for(int i = 0; i<N; i++){
        if(lst.size() == 1 && s[i] == lst[0]){
            lst.clear();
            lst.push_back(s[i]);
            i++;
            if(i != N){
                lst.push_back(s[i]);
                ans++;
            }
        }
        else{
            ans++;
            lst.clear();
            lst.push_back(s[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
#Equals
n,m=map(int,input().split())
p=list(map(int,input().split()))
p=[0]+p
data=[[] for _ in range(n+1)]
flag=[0]*(n+1)
for i in range(m):
    x,y=map(int,input().split())
    data[x].append(y)
    data[y].append(x)
tree=[0]*(n+1)
for i in range(1,n+1):
    if flag[i]==0:
        que=[i]
    while que:
        h=que.pop()
        flag[h]=1
        tree[h]=i
        for u in data[h]:
            if flag[u]==0:
                que.append(u)
count=0
for i in range(1,n+1):
    if tree[i]==tree[p[i]]:
        count+=1
print(count)

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

using namespace std;

const int MAXN = 50;
long long a[MAXN];

long long check(long long steps, long long ub, int n)
{
    long long moves = 0;
    for (int i = 0; i < n; i++)
    {
        moves += max(0LL, (a[i] + steps - ub + n) / (n + 1));
    }
    return moves;
}

bool isBad(int n)
{
    for (int i = 0; i < n; i++)
        if (a[i] >= n)
            return true;
    return false;
}

int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    long long steps = max(0LL, sum - n * (n - 1));
    long long ub = 0;
    for (long long jump = 1E17; jump > 0; jump /= 2)
    {
        while (check(steps, ub + jump, n) > steps)
            ub += jump;
    }
    ub++;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        long long add = (a[i] + steps - ub + n) / (n + 1);
        ans += max(0LL, add);
        a[i] = a[i] + steps - max(0LL, add) * (n + 1);
    }
    long long extra = steps - ans;
    while (isBad(n))
    {
        ans++;
        long long big = -1E18;
        int pos = 0;
        for (int i = 0; i < n; i++)
        {
            if (extra <= 0)
                a[i]++;
            if (a[i] > big)
            {
                big = a[i];
                pos = i;
            }
        }
        extra--;
        a[pos] -= n + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,counter;
  counter=1;
  cin >> n;
  vector<int>vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);  
}  
  sort(vec.begin(),vec.end());
  int ma=vec.at(0);
  for(i=0;i<n;i++){
    if(vec.at(i)>ma){
      counter++;
      ma=vec.at(i);
    }
    else
      continue;
  }
  cout << counter << endl;
} 


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

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

    if (input == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (input == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 138
// Practice
// C - Alchemist
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
const ll mxsize = 1e5 + 15;
const ll linf = 1e9;
const long double inf = 10000000000.0;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
const ll mod = 1e9 + 7;
/******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
 
ll pow(ll x, ll n) {
  if (n == 0)
    return 1ll;
  ll temp;
  temp = pow(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
 
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
 
int sum_digit(int val) {
  if (val < 0)
    return -1;
  if (val == 0)
    return 0;
  int ans = 0;
  while (val > 0) {
    ans = ans + val % 10;
    val = val / 10;
  }
  return ans;
}
 
ll count_div(ll l, ll r, ll val) {
  if (l % val == 0)
    return (((r / val) - (l / val)) + 1);
  else
    return ((r / val) - (l / val));
}
 
int powmod(int x, int y, int m) {
  int res = 1;
  // x = x % mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % m;
    cout << res << endl;
    y = y / 2;
    cout << x << endl;
    x = (x * x) % m;
  }
  // cout << res << endl;
  return res;
}
/******************************************** CODE STARTS FROM HERE *************************************************/ 
 
int main()
{
  fastIO;
  int n;
  cin >> n;
  int v[n];
  for(int i = 0 ; i < n ; i++) cin >> v[i];
  sort(v , v + n);
  double ans = 0.0;
  ans = v[0];
  for(int i = 1 ; i < n ; i++)
  {
    ans = (ans + v[i]) / 2.0; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

 /*
  * Всегда прогоняй макс-тест перед 
  * нажатием «Отослать». Всегда.
  */ 

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> s(n);
    vector<pair<int, int>> c(m);
    int u, v;
    fr(i,n) {
        cin >> u >> v;
        s[i] = {u, v};
    }
    fr(i,m) {
        cin >> u >> v;
        c[i] = {u, v};
    }

    fr(i,n) {
        auto p = min_element(c.begin(), c.end(), [&i, &s](const pair<int,int> &l, const pair<int, int> &r) {
            return abs(s[i].x - l.x) + abs(s[i].y - l.y) < abs(s[i].x - r.x) + abs(s[i].y - r.y);
        });
        cout << p - c.begin() + 1 << '\n';
    }

    return 0;
}


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

namespace ABC136_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(0, abc[2] - (abc[0] - abc[1])));
        }
    }
}


Measured memory_bytes: 13396
from collections import deque

k = int(input())
q = deque(list(range(1,10)))

for i in range(k):
    x = q.popleft()
    if x%10:
        q.append(10*x+(x%10)-1)
    q.append(10*x+(x % 10))
    if x%10 != 9:
        q.append(10*x+(x%10)+1)
print(x)

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

const int N = 10010;

typedef long long LL;

int flag[N], prime[N], pcnt;

inline void sieve() {
	for (int i = 2; i <= N - 10; i++) {
		if (!flag[i]) prime[++pcnt] = i;
		for (int j = 1; j <= pcnt && i * prime[j] <= N - 10; j++) {
			flag[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
}

LL G[510][510];

LL gcd(LL a, LL b) {
	return b ? gcd(b, a % b) : a;
}

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

template<typename... T>
inline LL lcm(LL a, T... b) {
	LL t = lcm(b...);
	return a / gcd(a, t) * t;
}

int main() {
	int n; scanf("%d", &n), sieve();
	if (n == 2) return puts("4 7\n23 10"), 0;
	for (int i = 0; i <= n + 1; i++)
		for (int j = 0; j <= n + 1; j++) G[i][j] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) if ((i + j) & 1) {
			int a = i + j, b = i - j; a = (a - 1) / 2, b = (b + n + 1) / 2;
			G[i][j] = (LL)prime[a] * prime[b + n - 1];
		}
	for (int i = 1; i <= n; i++, puts(""))
		for (int j = 1; j <= n; j++) {
			if (!((i + j) & 1)) G[i][j] = (LL)lcm(G[i - 1][j], G[i][j - 1], G[i + 1][j], G[i][j + 1]) + 1;
			printf("%lld ", G[i][j]);
		}
}//

Measured memory_bytes: 5248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define CC(x) cout << (x) << endl
#define rep(i,n) for(int i=0;i<n;i++)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
const long long inf=1e12;
const int range=1e6;
const long long inff=1e-12;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { -1, 0, 0, 1 };
typedef unsigned long long ull;
using namespace std;
int main()
{
    ll x,y,z,t,cas=1,a,b,d;
    cin >>x;
    int v[x+1]={0};
    for(int i=1;i<x;i++)
    {
        cin >>y;
        v[y]++;
    }
    for(int i=1;i<=x;i++)
        cout <<v[i]<<endl;
}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) (a).size()
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(ll &a, ll b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(ll &a, ll b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

const int nax = 3005;

int dp[nax][nax];

void solve()
{
  int n;
  cin>>n;
  vector<int > a(n);
  rep(i, 0, n-1)
    cin>>a[i];
  nrep(L, n-1, 0)
  {
    rep(R, L, n-1)
    {
      if(L == R)
        dp[L][R] = a[L];
      else
        dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
    }
  }
  cout<<dp[0][n-1]<<endl; 
}
signed main()
{
  

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int t = 1;
  //cin>>t;
  while(t--) solve();
  return 0;
}















Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
typedef pair<double,int> P;
const double EPS=1e-10;
const int MOD=1e9+7;
#define EQ(a,b) fabs(a-b)<EPS

ll N,K;

vector<ll> dp;
vector<ll> divisor;

ll mod_pow(ll n,ll m){
	ll ret=1;
	while(m){
		if (m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}

ll mod_inverse(ll n){
	return mod_pow(n,MOD-2);
}

void div(){
	for(ll d=1;d*d<=N;d++){
		if (N%d==0){
			divisor.push_back(d);
			if (N/d!=d){
				divisor.push_back(N/d);
			}
		}
	}
	sort(divisor.begin(),divisor.end());
}

int main(){
	scanf("%lld %lld",&N,&K);
	div();
	dp.resize(divisor.size());
	REP(i,(int)divisor.size()){
		ll d=divisor[i];
		dp[i]=mod_pow(K,(d+1)/2);
		REP(j,i){
			if (d%divisor[j]==0){
				dp[i]=(dp[i]-dp[j]+MOD)%MOD;
			}
		}
	}
	ll ans=0;
	REP(i,(int)divisor.size()){
		ll d=divisor[i];
		if (d%2==1){
			ans+=dp[i]*d%MOD;
		}else{
			ans+=dp[i]*d%MOD*mod_inverse(2)%MOD;
		}
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384