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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll M,D[202020],C[202020],Cn;
ll ans = 0;
pll mk[15][15];
ll i, j, k;


ll calc(ll d,ll c,ll& rest){
    ll i = 0, a = d,r=0,ret=0;
    while(c>=(1ll<<i)){
        if(c&(1ll<<i)){
            rest += a;
            ret += r;
            while(rest>=10){
                rest = rest/10 + rest%10;
                ret++;
            }
        }
        a *= 2;
        r += r;
        while(a>=10){
            a = a % 10 + a / 10;
            r++;
        }
        i++;
    }
    return ret;
}

int main(){
    scanf("%lld", &M);
    fornum(i,0,M){
        scanf("%lld%lld", &D[i], &C[i]);
        Cn += C[i];
    }
    ans += Cn-1;
    ll a = 0;
    fornum(i,0,M){
        ans += calc(D[i], C[i], a);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ll long long

#define MOD 1000000007
typedef pair<int, int> pii;
// typedef vector<int> vi;
// typedef vector<pii> vpi;
// typedef vector<vi> vvi;
// typedef long long i64;
// typedef vector<i64> vi64;
// typedef vector<vi64> vvi64;
// typedef pair<i64, i64> pi64;
// typedef double ld;
typedef  long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
// ui64 mx=1000*1000*1000+3;
// ui64 dp[mx];
bool dp[100009];
ui64 arr[300];

int main()
{
ui64 n,k;
cin>>n>>k;
for1(i,n)
cin>>arr[i];
// memset(dp,false,sizeof(dp));
for1(i,k)
{
	for1(j,n)
	{
		if(i>=arr[j]&&!dp[i-arr[j]])
		dp[i]=true;


	}
}
if(dp[k])
cout<<"First";
else
cout<<"Second";
return 0;
}


Measured memory_bytes: 384
for i in range(int(input())):
  input()
  t=[]
  for i,j in zip(map(int,input().split()[::-1]),input()[::-1]):
    for k in t:i^=k*(i^k<i)
    if i and j=="0":t.append(i)
    if i and j=="1":print(1);break
  else:print(0)

Measured memory_bytes: 68416
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    DP = [0]*(len(S)+1)

    for i in range(len(S)):
        # print("-")
        DP[i+1] = DP[0] + int(S[:i+1])
        # print(DP[0] + int(S[i]))
        for j in range(i):
            DP[i+1] += DP[j+1]+int(S[j+1:i+1])*(2**j)
            # print(DP[j+1]+int(S[j+1:i+1])*(2**j))
    print(DP[-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 13 17:35:46 2016

"""
D = {"K":0, "U":0, "P":0, "C":0}
S = input()
for s in S:
    if s in D:
        D[s] += 1
        
print(min(D["K"], D["U"], D["P"], D["C"]))

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

class union_find {
 public:
  using tp = std::vector<size_t>::size_type;
  // 取り扱う型.

  explicit union_find(const tp n) : parent(n), rank(n, 0), cache(),
    distance(n, 0), dis_cache() {
    for (tp i = 0; i < n; i++) {
      parent[i] = i;
    }
    cache.reserve(n);
    dis_cache.reserve(n);
  }

  tp root(tp n) {
    // 番号nの親を求める. ついでに経路圧縮を行う.

    while (parent[n] != n) {
      // 根になるまで親を探索. ついでにキャッシュ変数に追加.
      cache.push_back(n);
      dis_cache.push_back(distance[n]);
      n = parent[n];
    }
    for (int64_t i = cache.size() - 1; 0 <= i; i--) {
      parent[cache[i]] = n;
      distance[cache[i]] = dis_cache[i];
      if (0 < i) {
        dis_cache[i - 1] += dis_cache[i];
      }
    }
    cache.clear();
    dis_cache.clear();
    return n;
  }

  bool same(tp x, tp y) {
    // xとyが同じグループに属しているか計算.
    return root(x) == root(y);
  }

  int64_t get_dis(const tp x, const tp y) {
    return distance[x] - distance[y];
  }

  void unite(const tp x, const tp y, const int64_t d) {
    // xとyを同じグループにする.
    const auto x_root = root(x);
    const auto y_root = root(y);

    if (x_root == y_root) {
      // 根が同じなら元から同じグループ.
      return;
    }

    if (rank[x_root] < rank[y_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[x_root] = y_root;
      distance[x_root] = distance[y] + d - distance[x];
    } else if (rank[y_root] < rank[x_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[y_root] = x_root;
      distance[y_root] = distance[x] - d - distance[y];
    } else {
      // rankが同じなら, どっちかを根にして根になったほうのランクを上げる.
      parent[x_root] = y_root;
      distance[x_root] = distance[y] + d - distance[x];
      rank[x_root]++;
    }
  }

 private:
  std::vector<tp> parent;
  // 親の番号を格納. 自分が根なら parent[i] == i になる.
  std::vector<tp> rank;
  // 自分の下に何段分の子があるかを格納.
  std::vector<tp> cache;
  // root計算のときに経路圧縮を行うためのキャッシュ変数.
  std::vector<int64_t> distance;
  std::vector<int64_t> dis_cache;
};

int main() {
  int64_t n, m;
  std::cin >> n >> m;

  union_find uf(n);

  for (int64_t i = 0; i < m; i++) {
    int64_t l, r, d;
    std::cin >> l >> r >> d;
    l--;
    r--;
    if (uf.same(l, r)) {
      if (d != uf.get_dis(l, r)) {
        std::cout << "No" << std::endl;
        return 0;
      }
    } else {
      uf.unite(l, r, d);
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 2560
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	int res = 0;
	for (int i = 1; i <= n; ++i)
	{
		int a; cin >> a;
		if ((i*a) % 2 == 1)++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,num=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%2==1) num++;
    }
    double ans=(double)num/(double)n;
    printf("%.10f",ans);
}  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int L;
    cin >> L;
    int mx = 0;
    for(int i=0; i<22; i++){
        if(L & (1<<i)) mx = i;
    }
    int n = mx + 2;
    vector<vector<pair<int, int>>> G(n);

    for(int i=0; i<=mx-1; i++){
        G[i].push_back(make_pair(i+1, 0));
        G[i].push_back(make_pair(i+1, 1<<i));
    }

    int cur = 0;
    for(int i=0; i<=mx; i++){
        if(L & (1<<i)){
            G[i].push_back(make_pair(mx+1, cur));
            cur += (1<<i);
        }
    }

//    if(n == 21){
        int tmp = G[n-2][0].second;
        for(auto &x : G[n-3]){
            if(x.first==n-2)
                x.second += tmp;
        }
        for(int i=0; i<n-2; i++){
            int tmp = -1;
            for(auto x : G[i]){
                if(x.first == n-1){
                    tmp = x.second;
                    break;
                }
            }
            if(tmp != -1){
                G[i].push_back(make_pair(n-2, tmp));
            }
        }
        n--;
 //   }


    int m = 0;
    for(int i=0; i<n; i++)
        m += G[i].size();

    int cnt = 0;
    for(int i=0; i<n; i++){
        for(auto x : G[i]){
            if(x.first+1==n+1) continue;
            cnt++;
        }
    }

    cout << n << " " << cnt << endl;

    for(int i=0; i<n; i++){
        for(auto x : G[i]){
            if(x.first+1==n+1) continue;
            cout << i+1 << " " << x.first+1 << " " << x.second << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
#define pi 3.1415926535897
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, s.length()){
		if(s[i] != t[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3896
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

string S;

int main() {
	cin >> S;
	string f;
	string g;
	int K = 0;
	for (int i = 0; i < S.size(); ++i) {
		g.push_back(S[i]);
		if (g == f) {
			continue;
		}
		else {
			++K;
			f = g;
			g = "";
		}
	}
	//if (g != "")--K;
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 640
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    x = int(input())
    if x >= 30:
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 67512
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define dump(x) cerr << " [L" << __LINE__ << "] " << #x << " = " << (x) << endl;

template<typename T>string join(vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream& operator<<(ostream& o, vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, vector<vector<T> >&vv)
{int l=vv.size();if(l){rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vvi g;
vi a;

int dfs(int v, int par){
    each(u, g[v]){
        if(*u != par) if(a[v] > a[*u] && !dfs(*u, v)) return 1;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int N;
    cin >> N;
    g = vvi(N); a = vi(N);
    rep(i, N) cin >> a[i];
    rep(i, N-1){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    rep(i, N) if(dfs(i, -1)) cout << i+1 << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys 
import math
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = list(map(int,readline().split()))

#2分法
#K回の切断ですべてN以下にできるか
def solve(N):
    cnt = 0
    for a in A:
        if a % N ==0:
            cnt += (a//N-1)
        else:
            cnt += a//N
    if cnt <= K:
        return True
    else:
        return False

left = 0
right = 10**9+5
while right-left > 1:
    N = (right+left)//2
    flag = solve(N)
    if flag:
        right = N
    else:
        left = N
print(right)

Measured memory_bytes: 92648
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const int N = 2e7 + 7;
const int mod=1e9+7;
const int INF=1e18+7;
const int dx[] = {-1, 1, 0,  0}; // UDLR
const int dy[] = { 0, 0, -1, 1}; // UDLR
inline int maximum (int a,int b) {int c=a>b?a:b; return c;}
inline int minimum (int a,int b) {int c=a>b?b:a; return c;}

int32_t main (){
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);cout.tie(NULL);

       int n,w; cin>>n>>w; vector<int> wt(n+1),val(n+1); vector<vector<int>> dp(n+1,vector<int>(w+1,0));
       for(int i=1;i<=n;i++){
         cin>>wt[i]>>val[i];
       }
       for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
          dp[i][j]=dp[i-1][j];
          if(j-wt[i]>=0){
            dp[i][j]=maximum(dp[i][j],dp[i-1][j-wt[i]]+val[i]);
          }
        }
       }
          cout<<dp[n][w];
 return 0;
 }


Measured memory_bytes: 83000
import java.util.Scanner;

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

        // 入力(a)
        int a = sc.nextInt();
        // 入力(b)
        int b = sc.nextInt();
        // 入力(h)
        int h = sc.nextInt();

        System.out.println((a + b) * h / 2);
        sc.close();
    }
}

Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	var ans, a, b int
	a = nextInt()
	ans = a
	for i := 1; i < N; i++ {
		b = nextInt()
		ans += max(b-a, 0)
		a = b
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
ll a[maxn];
void run_case()
{
    int n;
    cin >> n;
    bool ok = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
            ok = 0;
    }
    if (!ok)
    {
        cout << 0 << "\n";
        return;
    }
    ll now = 1;
    ll num = 1e18;
    for (int i = 1; i <= n; i++)
    {
        //C;
        //DBG(now);
        if (now > num / a[i])
        {
            //ok = 0;
            cout << -1 << "\n";
            return;
        }
        now *= a[i];
    }
    cout << now << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4432
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define itr(i, n) for(int i = 0; i < n; ++i)
#define itr1(i, a, n) for(int i = a; i < n; ++i)
#define INF 1e9 + 5
#define pb push_back 
#define ppi pair<int, int>
#define min_heap(type) priority_queue<type, vector<type>, greater<type>>
#define max_heap(type) priority_queue<type>
#define endl "\n"
#define nl cout << "\n"
// For Debugging
#define deb(x) cout << #x << " " << x << endl;

int solution() {
    int x; cin >> x;
    int ans = 0;
    while(x >= 500) {
        ans += 1000;
        x -= 500;
    }
    while(x >= 5) {
        ans += 5;
        x -= 5;
    }
    return ans;
}
int32_t main() {
      IOS;
      cout << solution() << endl;
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,a) for (int i = 0; i < (a); i++)
using namespace std;
int const INF = 1 << 28;
int n, m, s, g1, g2, b1, b2, c;
int G[101][101];

int main(void){
    while (cin >> n >> m >> s >> g1 >> g2, n) {
        s--, g1--, g2--;
        rep(i, 101) rep(j, 101) G[i][j] = (i == j ? 0:INF);
        rep(i, m) {
            cin >> b1 >> b2 >> c;
            G[b1-1][b2-1] = c;
        }
        rep(k, n) rep(i, n) rep(j, n) G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
        int ans = INF;
        rep(i, n) {
            ans = min(ans, G[s][i]+G[i][g1]+G[i][g2]);
            ans = min(ans, G[s][i]+G[i][g1]+G[g1][g2]);
            ans = min(ans, G[s][i]+G[i][g2]+G[g2][g1]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = int(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, m, a[MAX_N],d[MAX_N], ans = 0;
    cin >> n >> m;
    REP(i,m) cin >> a[i];
    sort(a,a+m);
    REP(i,m-1) d[i] = a[i+1]-a[i];
    sort(d,d+m-1);
    REP(i,max(0,m-n)) ans += d[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
T=["."+input()+"." for i in range(h)]
S="."*(w+2)
T.insert(0,S)
T.append(S)
Ans=["" for i in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    count=0
    if T[i][j]=="#":
      A="#"
    elif T[i][j]==".":
      for m in range(3):
        for n in range(3):
          if T[i-1+m][j-1+n]=="#":
            count+=1
          A=str(count)
    Ans[i-1]+=A
print(*Ans,sep="\n")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>s;
  int pre=0;
  for(int i=0;i<n;i++){
    if(s[i]=='o'){
      pre=0;
    }else{
      if(pre==1){
        cout<<i<<"\n";
        return 0;
      }else{
        pre=1;
      }
    }
  }
  cout<<n<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3280
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int a, b;
    cin >> a >> b;
    int c = b;
    int cnt = 0;
    while (c) {
        cnt++;
        c /= 10;
    }
    rep(i, cnt) a *= 10;
    int d = b + a;
    ///cout << a*pow(10,cnt) << endl;
    //cout << b << endl;
    //cout << d << endl;
    rep(i, 317) {
        if (i * i == d) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = [int(item) for item in input().split()]
ab = [[int(item) for item in input().split()] for _ in range(n)]
cd = [[int(item) for item in input().split()] for _ in range(m)]

for j, (a,b) in enumerate(ab):
    ans = 10**10 
    prev = 10**10
    for i in range(m):
        c, d = cd[i] 
        ans = min(ans, abs(a-c) + abs(b-d))
        if ans != prev:
            id = i+1
        prev = ans
    print(id)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_C
{
    class _008
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            long[] array = ReadLongs();
            long res1 = 0;
            res1 += (array[0] / 2) * 2;
            res1 += (array[3] / 2) * 2;
            res1 += (array[4] / 2) * 2;
            long res2 = 0;
            if (array[0] > 0 && array[3] > 0 && array[4] > 0)
            {
                res2 += 3;
            }
            res2+=((array[0]-1)/2)*2;
            res2 += ((array[3] - 1) / 2) * 2;
            res2 += ((array[4] - 1) / 2) * 2;
            WriteLine(Max(res1, res2) + array[1]);
        }

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


Measured memory_bytes: 13140
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	vector<int>v(M);
	for (int i = 0; i < M; i++) {
		cin >> v[i];
		v[i]--;
	}
	vector<vector<int>>edge(N, vector<int>(K));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			cin >> edge[i][j];
			edge[i][j]--;
		}
	}
	vector<int>dp(1 << M, MOD);
	dp[(1 << M) - 1] = 0;
	set<pair<int, int>>s;
	s.insert({ 0,(1 << M) - 1 });
	while(!s.empty()){
		vector<int>p(M);
		auto c = *s.begin();
		int cn = c.second;
		int cc = c.first;
		//cout << cn << " " << cc << endl;
		s.erase(*s.begin());
		if (dp[cn] < cc)continue;
		for (int j = 0; j < M; j++) {
			if (cn >> j & 1) {
				p[j] = v[j];
			}
			else {
				p[j] = -1;
			}
		}
		for (int j = 0; j < K; j++) {
			auto box = p;
			for (int k = 0; k < M; k++) {
				if (box[k] == -1)continue;
				box[k] = edge[box[k]][j];
			}
			int nx = 0;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (box[k] == v[l]) {
						nx |= 1 << l;
					}
				}
			}
			if (dp[cn] + 1 < dp[nx]) {
				dp[nx] = dp[cn] + 1;
				s.insert({ dp[nx],nx });
			}
		}
	}
	cout << dp[0] << endl;
	return 0;
}


Measured memory_bytes: 4876
/*  ex2_3
      fmuacshai */
 
#include <stdio.h>
 
int main(void){
  //numberは一辺のマスの個数、Aは白のマス目の数、Blackは黒のマスの個数
  int number,white,black;
  //numberを入力
  scanf("%d",&number);
  //Aを入力
  scanf("%d",&white);
  //黒のマス目の個数の計算
  black=number*number-white;
  //黒のマス目の個数を出力
  printf("%d\n",black);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, x, y;
int cnt[2020];

signed main() {
	cin >> n >> x >> y;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int t = min(j - i, abs(x - i) + abs(j - y) + 1);
			cnt[t]++;
		}
	}
	for (int i = 1; i < n; i++)cout << cnt[i] << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] L = new Integer [2 * N];
		for(int i =0; i < 2 * N; i++) {
			L[i] = sc.nextInt();
		}
		Arrays.sort(L, Collections.reverseOrder());
		int ans = 0;
		for(int i = 0; i < 2 * N; i++) {
			if(i % 2 != 0) ans += L[i];
		}
		sc.close();
		System.out.println(ans);
	}

}


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

int main(){
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);

    int total = x-z;
    int pes = y+z;

    printf("%d\n", total/pes);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	ll x;
	cin >> x;
	for (ll i = -1000;i <= 1000;++i) {
		for (ll j = -1000;j <= 1000;++j) {
			ll a = i * i * i * i * i;
			ll b = j * j * j * j * j;
			if (a - b == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  int n,y;
  cin >> n >> y;
  bool t = false;
  rep(i,n+1){
    int a = 0;
    rep(j,n-i+1){
      a = (i*10000) + (j*5000) + (n-i-j)*1000;
//      cout << a << ":" << ","<< i << "," << j<< "," <<n-i-j << endl;
      if (y == a) {
        t = true;
        cout << i << " " << j << " " << n-i-j << endl;
        j = n + 1;
        i = n + 1;
      }
    }
  }
  if (!t) cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int N, Y; std::cin >> N >> Y;
  Y /= 1000;
  rep(x, 2001) rep(y, 2001) {
    int z = Y - (x * 10 + y * 5);
    if (z >= 0 && x + y + z == N) {
      std::cout << x << " " << y << " " << z << "\n";
      return 0;
    }
  }
  std::cout << -1 << " " << -1 << " " << -1 << "\n";
}


Measured memory_bytes: 256
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    int n = Integer.parseInt(br.readLine());
    int[] arr = new int[n];
    String[] s=  br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      arr[i] = Integer.parseInt(s[i]);
    }
    Arrays.sort(arr);
    System.out.println(arr[n-1]-arr[0]);
  }
}


Measured memory_bytes: 21204
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var sum = 0.0
    for (i in 1..n) {
        val xu = readLine()!!.split(' ')
        if (xu[1].equals("JPY")) sum += xu[0].toDouble()
        else sum += (xu[0].toDouble() * 380000.0)
    }
    println(sum)
}

Measured memory_bytes: 38140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
P p[200005];
ll t;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i].second>>p[i].first;
		t=t+p[i].second;
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		if(t>p[n-i-1].first){
			cout<<"No"<<endl;
			return 0;
		}
		t-=p[n-i-1].second;
	}
	cout<<"Yes"<<endl;
	
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  ll n_o = 0, n_2 = 0, n_4 = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a%4 == 0) n_4++;
    else if (a%2 == 0) n_2++;
    else n_o++;
  }
  if (n_o <= n_4) cout << "Yes" << endl;
  else if (n_o==n_4+1 && !n_2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
//orz kczno1    POD only
template<typename T>
struct vec{T *a;int n;void clear(){n=0;}
void pb(const T &x){if((n&-n)==n)a=(T*)realloc(a,(n*2)*sizeof(T));a[n++]=x;}
inline T* begin(){return a;}inline T* end() {return a+n;}};
char str[SZ]; int n;
int app[SZ];
int main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;++i)
		++app[str[i]];
	ll tot=n*(ll)(n-1)/2;
	for(int i='a';i<='z';++i)
		tot-=(app[i]-1)*ll(app[i])/2;
	cout<<tot+1<<"\n";
}

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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N;
	ll A[200005] = {0};

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);

	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 1792
from collections import Counter
n,m=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(n)]
ls.sort(key=lambda x:x[0])
ans=0
tmp=0
# print(ls)
for i in range(len(ls)):
  if tmp+ls[i][1]<=m:
    tmp+=ls[i][1]
    ans+=ls[i][0]*ls[i][1]
  else:
    ans+=ls[i][0]*(m-tmp)
    print(ans)
    exit()
print(ans)


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

int main() {
    int n;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++) cin >> w[i];

    int min = 100;
    for (int t = 0; t < n; t++) {
        int s1 = 0, s2 = 0;
        for (int i = 0; i < t; i++) s1 += w[i];
        for (int i = t; i < n; i++) s2 += w[i];

        if (abs(s1 - s2) < min) min = abs(s1 - s2);
    }
    cout << min << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll dist[100000];
int A[333][333];

int main() {
   int H, W, D;
   cin >> H >> W >> D;
   vec<pair<int, int>> P(H*W+10);
   rep (i, H) {
      rep (j, W) {
         cin >> A[i][j];
         P[A[i][j]] = {i, j};
      }
   }

   repp (i, D, H*W+1) {
      dist[i] = dist[i-D] + abs(P[i].first - P[i-D].first) + abs(P[i].second - P[i-D].second);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << dist[r] - dist[l] << endl;
   }

   return 0;
}

Measured memory_bytes: 2944
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

n = INT()
a = LIST()
a_front = []
a_back = []
 
flg = 1
for i in range(n):
	if flg == 1:
		a_back.append(a[i])
	else:
		a_front.append(a[i])
	flg *= -1

ans = a_front[::-1] + a_back
if flg == 1:
	print(*ans)
else:
	print(*ans[::-1])




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

const int maxn=205;
int T,n;
long long a[maxn];
char s[maxn];

namespace Basis{
	const int mlog=63;
	long long b[mlog];
	void clear(){
		memset(b,0,sizeof(b));
	}
	void add(long long x){
		for(int i=mlog-1;i>=0;i--){
			if(!((x>>i)&1))continue;
			if(b[i])x^=b[i];
			else{
				b[i]=x;
				break;
			}
		}
	}
	bool ask(long long x){
		for(int i=mlog-1;i>=0;i--){
			if(!((x>>i)&1))continue;
			if(b[i])x^=b[i];
		}
		return x==0;
	}
}

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
		scanf("%s",s+1);
		bool ok=true; 
		Basis::clear(); 
		for(int i=n;i>=1;i--){
			if(s[i]=='0')Basis::add(a[i]);
			else ok&=Basis::ask(a[i]);
		}
		puts(ok?"0":"1");
	}
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include <utility>
#include<unordered_set>
using namespace std;


int main(){
	int N;
	cin>>N;
	vector<int> d(N,0);
	for(int i = 0; i < N; i++)
		cin>> d[i];
	
	
	
	unordered_set<int> S;
	
	for(int i = 0; i < N; i++)
		S.insert(d[i]);
	
	
	
	cout<< S.size();
return 0;
}

Measured memory_bytes: 256
n = int(input())
c = [int(input()) for _ in range(n)]
mod = 10 ** 9 + 7
MAX = 2 * 10 ** 5

cc = []
prev = 0
for e in c:
    if e != prev:
        cc.append(e)
        prev = e

ln = len(cc)

dp_prev = 1
acc = [0] * (MAX + 1)

for i, e in enumerate(cc, 1):
    dp_now = dp_prev + acc[e]
    dp_now %= mod

    acc[e] += dp_prev
    acc[e] %= mod

    dp_prev = dp_now

print(dp_now)


Measured memory_bytes: 18084
#include "bits/stdc++.h"

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int N;
   cin >> N;
   int A;
   double ans=0;
   REP(i,0,N-1)
   {
      cin >> A;
      ans += 1.0/A;
   }
   cout << 1.0/ans << endl;
   return;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    
    char a[H][W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    char b[H+2][W+2];
    for(int j = 0; j < W+2; j++) {
        b[0][j] = '#';
        b[H+1][j] = '#';
    }
    for(int i = 1; i <= H; i++) {
        b[i][0] = '#';
        b[i][W+1] = '#';
    }
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            b[i][j] = a[i-1][j-1];
        }
    }

    for(int i = 0; i < H+2; i++) {
        for(int j = 0; j < W+2; j++) {
            cout << b[i][j];
        }
        cout << "\n";
    }

    cout << endl;
    
    return 0;
}

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

int main() {
  string S, T;
  cin >> S;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(i) == '0') {
      T += '0';
    }
    else if(S.at(i) == '1') {
      T += '1';
    }
    else {
      if(T != "") {
        T.erase(T.size()-1);
      }
    }
  }
  cout << T << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S,T; cin>>S>>T;
    ll A,B; cin>>A>>B;
    string U; cin>>U;
    if(S==U) --A;
    else --B;
    cout<< A<< " " <<B <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
int n,w,z;
vector<int> v;
int main(){
	while(cin>>n>>w&&n){
	v.clear();
	int highest=0;
	for(int i=0;i<n;i++){
		cin>>z;
		while(true){
			if(v.size()>z/w)break;
			v.push_back(0);
		}
		v[z/w]++;
		highest=max(v[z/w],highest);
	}
	double ans=0.01;
	for(int i=0;i<v.size();i++){
		ans+=v[i]/(highest+0.0)*(1-i/(v.size()-1.0));
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
max = l[N-1]
tc = N
st = [j+1 for j in range(N-1)]
for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1
print(ans)

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int main() {
    char b;
    cin >> b;
    char ans;
    if(b == 'A') {
        ans = 'T';
    }
    if(b == 'T') {
        ans = 'A';
    }
    if(b == 'G') {
        ans = 'C';
    }
    if(b == 'C') {
        ans = 'G';
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    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

const ll N = 100003;
ll i,n,k,mi = MAX;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    rep(i,0,n) cin>>a[i];
    sort(a,a + n);
    for(i = 0;i + k - 1 < n;i += 1)
        mi = min(mi,a[i + k - 1] - a[i]);
    cout<<mi;
    return 0;
}

Measured memory_bytes: 1024