akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = []

for _ in range(N):
    a = int(input().split()[0])
    a_list.append(a)

c = 0

for i in range(N):
    before = a_list[i - 1] if i != 0 else 0

    c += (before + a_list[i]) // 2
    a_list[i] = (before + a_list[i]) % 2 if a_list[i] != 0 else 0

ans = c
print(ans)


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

int main() {
  int n; cin >> n;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i]; p[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    if (p[i] == i) {
      swap(p[i], p[i+1]);
      ans++;
    }
  }
  cout <<(p[n-1] == n-1 ? ans+1 : ans) << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
	int d, n; cin >> d >> n;

	int m = 1;
	rep(i, d) m *= 100;

	if (n == 100) printf("%d\n", m * 101);
	else printf("%d\n", m * n);
	return 0;
}

Measured memory_bytes: 256
fh=STDIN
regB=Regexp.new(/^>\^(Q=)+~~$/)
n=fh.gets.chomp.to_i
0.upto(n-1){|i|
  s=fh.gets.chomp
  if s=~ /^>'(=+)#/ and s=~ Regexp.new(/^>'#{$1}##{$1}~/) then
    puts "A"
  elsif s=~ regB then
    puts "B"
  else
    puts "NA"
  end
}

Measured memory_bytes: 9572
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, 10010)
	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				v := x*x + y*y + z*z + x*y + y*z + z*x
				if v <= 10000 {
					a[v]++
				}
			}
		}
	}
	for i := 1; i <= N; i++ {
		fmt.Println(a[i])
	}
}


Measured memory_bytes: 1980
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int n, w, h, t, s, x,y, ans, map[101][101], sum[100][100], i, j, per;
	while(1){
		cin >> n;
		if(!n) break;
		cin >> w >> h;
		for(i=0; i<=w; i++){
			for(j=0; j<=h; j++){
				map[i][j] = 0;
				sum[i][j] = 0;
			}
		}
		for(i=0; i<n; i++){
			cin >> x >> y;
			map[x][y]++;
		}
		/*for(j=0; j<=h; j++){
			for(i=0; i<=w; i++){
				cout << map[i][j] << " ";
			}
			cout << endl;
		}*/
		for(i=0; i<=w; i++){
			for(j=0; j<=h; j++){
				sum[i][j] = map[i][j];
				if(i>0)sum[i][j]+=sum[i-1][j];
				if(j>0)sum[i][j]+=sum[i][j-1];
				if(i>0 && j>0)sum[i][j]-=sum[i-1][j-1];
			}
		}
		/*for(j=0; j<=h; j++){
			for(i=0; i<=w; i++){
				cout << sum[i][j] << " ";
			}
			cout << endl;
		}*/
		cin >> s >> t;
		ans = -1;
		for(j=1; j+t-1<=h; j++){
			for(i=1; i+s-1<=w; i++){
				per=sum[i+s-1][j+t-1]-sum[i-1][j+t-1]-sum[i+s-1][j-1]+sum[i-1][j-1];
				//cout << i << " " << j << " " << sum[i+s-1][j+t-1] << "-" << sum[i+s-1][j-1] << "-" << sum[i-1][j+t-1] << "+" << sum[i-1][j-1] << "=" << per << endl;
				if(per > ans)ans = per;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		//		new Main().solveB2();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();

			if (numN % numK == 0) {
				System.out.println(0);
			} else {
				System.out.println(1);
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int isPurchase(int numN, int num) {

		if (numN <= 0) {
			return numN;
		}
		if (bWkMap.get(numN) != null) {
			return bWkMap.get(numN);
		}

		int val1 = isPurchase(numN - 7, 4);
		int val2 = isPurchase(numN - 7, 7);
		int val3 = isPurchase(numN - 4, 4);
		int val4 = isPurchase(numN - 4, 7);

		val1 = val1 < 0 ? 999999999 : val1;
		val2 = val2 < 0 ? 999999999 : val2;
		val3 = val3 < 0 ? 999999999 : val3;
		val4 = val4 < 0 ? 999999999 : val4;

		int wk = Math.min(Math.min(val1, val2), Math.min(val3, val4));

		bWkMap.put(numN, wk);
		return wk;
	}

	private Map<Integer, Integer> bWkMap = new HashMap<Integer, Integer>();

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int val = isPurchase(numN, 0);

			System.out.println(val == 0 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB2() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    int ACnum=0;
    int WAnum=0;
    int TLEnum=0;
    int REnum=0;

    for(int i=0;i<N;++i){
        string str;
        cin >> str;


        if(str == "AC"){
            ACnum++;
        }
        else if(str == "WA"){
            WAnum++;
        }
        else if(str== "TLE"){
            TLEnum++;
        }
        else if(str == "RE"){
            REnum++;
        }
    }

    cout<<"AC x " << ACnum<<endl;
    cout<<"WA x " << WAnum<<endl;
    cout<<"TLE x " << TLEnum<<endl;
    cout<<"RE x " << REnum<<endl;
}



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

using namespace std;

using LL = long long;
const int NDigit = 19;

int mod, pw10[NDigit];
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int mul(int a, int b) { return (int)( (LL)a * b % mod); }

LL nTerm, a, b;

struct Matrix {
    int nR, nC;
    vector<vector<int> > a;
    Matrix(int _nR, int _nC) : nR(_nR), nC(_nC) {
        a.assign(nR, vector<int>(nC, 0) );
    }
    Matrix operator*(const Matrix &_) const {
        Matrix ret(nR, _.nC);
        for (int i = 0; i < ret.nR; ++i) {
            for (int j = 0; j < ret.nC; ++j) {
                for (int k = 0; k < nC; ++k) ret.a[i][j] = add(ret.a[i][j], mul(a[i][k], _.a[k][j]) );
            }
        }
        return ret;
    }
    Matrix binpw(LL exp) const {
        Matrix M = *this;
        assert(nR == nC);
        Matrix ret(nR, nC);
        for (int i = 0; i < nR; ++i) ret.a[i][i] = 1;
        for (; exp; exp >>= 1, M = M * M) if (exp & 1) ret = ret * M;
        return ret;
    }
    void debug() {
        for (int i = 0; i < nR; ++i) {
            for (int j = 0; j < nC; ++j) cerr << a[i][j] << ' '; cerr << '\n';
        }
        cerr << "====\n";
    }
};

int nDigit(LL num) {
    int ret = 0;
    while (num) { ++ret; num /= 10; }
    return ret;
}

int main() {
    scanf(" %lld %lld %lld %d", &nTerm, &a, &b, &mod);

    pw10[0] = 1;
    for (int i = 1; i < NDigit; ++i) pw10[i] = mul(pw10[i - 1], 10);

    Matrix cur(1, 3);
    cur.a[0][0] = (int)(b % mod); cur.a[0][1] = (int)(a % mod); cur.a[0][2] = (int)(a % mod);

    for (LL prv = 0; prv + 1 < nTerm; ) {
        LL lNxt = prv + 1, rNxt = nTerm - 1;
        while (lNxt < rNxt) {
            LL mNxt = (lNxt + rNxt + 1) >> 1;
            if (nDigit(a + b * mNxt) == nDigit(a + (prv + 1) * b) ) lNxt = mNxt;
            else rNxt = mNxt - 1;
        }
        LL nxt = lNxt;

        Matrix tranMatrix(3, 3);
        tranMatrix.a[0][0] = tranMatrix.a[0][1] = tranMatrix.a[0][2] = tranMatrix.a[1][1] = tranMatrix.a[1][2] = 1;
        tranMatrix.a[2][2] = pw10[nDigit(a + nxt * b)];
        tranMatrix = tranMatrix.binpw(nxt - prv);
        cur = cur * tranMatrix;
        prv = nxt;
    }

    printf("%d\n", cur.a[0][2]);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL) x=x->right;
  return x;
}

Node treeSearch(Node u, int k) {
  if(u == NIL || k== u->key) return u;
  if(k < u->key ) return treeSearch(u->left,k);
  else return treeSearch((u->right), k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right); //case 1

  y=x->parent;
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y; //case2
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left != NIL) x=y->left;
  else x=y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL) {
    y=x;
    if(z->key < x->key) x=x->left;
    else x= x->right;
    z->parent = y;
  }
    
    if(y==NIL) root = z;
    else if(z->key<y->key) y->left = z;
    else y->right = z;
  
}

void inorder(Node u,int n){
  //static int count=0;
  if(u != NIL) {
    inorder(u->left,n);
    //if(count < n) {
      printf(" %d",u->key);
      //count++;
      //} else printf("%d",u->key);
    inorder(u->right,n);
  }
}

void preorder(Node u,int n) {
  //static int count=0;
  if(u==NIL) {
    return ;
  }
  //if(count < n) {
    printf(" %d",u->key);
    //count++;
    //} else printf("%d",u->key);
  preorder(u->left,n);
  preorder(u->right,n);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
      
    } else if ( com[0] == 'p' ){
      inorder(root,n);
      printf("\n");
      preorder(root,n);
      printf("\n");
      
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main(void) {
	string S, T;
	cin >> S >> T;
	int ans = S.length();
	for (int i = 0; i < S.length() - T.length() + 1; i++) {
		int cnt = 0;
		for (int j = 0; j < T.length(); j++) {
			if (S[i + j] != T[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	printf("%d\n", ans);

	return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    vector<int>b(n-1);
    rep(i,n-1){
        cin>>b[i];
    }

    vector<int>a(n);
    a[0]=b[0];
    a[n-1]=b[n-2];
    rep2(i,1,n-1){
        a[i]=min(b[i-1],b[i]);
    }

    int ans=0;
    rep(i,n){
        ans+=a[i];
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
sc = input().split()
n = int(sc[0])
m = int(sc[1])
l = int(sc[2])

a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]

for i in range(n):
    sc = input().split()
    for j in range(m):
        a[i][j] = int(sc[j])
    
for i in range(m):
    sc = input().split()
    for j in range(l):
        b[i][j] = int(sc[j])

for i in range(n):
    for j in range(l):
        x = 0
        for k in range(m):
            x += a[i][k] * b[k][j]
        if j == 0:
            print(x, end = '')
        else:
            print(' {}'.format(x), end = '')
    print('')


Measured memory_bytes: 6576
using System;

namespace AtCoderABC132A
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ans = false;
            char[] c = Console.ReadLine().ToCharArray();

            if(c[0] == c[1])
            {
                if(c[2] == c[3])
                {
                    if (c[0] == c[2])
                        ans = false;
                    else
                        ans = true;
                }
                else
                    ans = false;
            }
            else
            {
                if(c[0] == c[2])
                {
                    if (c[1] == c[3])
                        ans = true;
                    else
                        ans = false;

                }
                else
                {
                    if (c[0] == c[3])
                    {
                        if (c[1] == c[2])
                            ans = true;
                        else
                            ans = false;
                    }
                    else
                        ans = false;
                }
            }
            if(ans)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int H, A;
    cin >> H >> A;
    cout << ((H + A - 1) / A) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <ll, ll> P; typedef vector <int> vecint; typedef pair<ll, P> P1; typedef pair<P1, int> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int a, b, c; cin >> a >> b >> c;
	int res = 0;
	if (a < b) swap(a, b);
	if (b < c) swap(b, c);
	if (a < b) swap(a, b);
	if (a == b)
	{
		if ((a - c) % 2)
			res += (a - c) / 2 + 2;
		else res += (a - c) / 2;
	}
	else
	{
		res += (a - b);
		if ((b - c) % 2)
			res += (b - c) / 2 + 2;
		else res += (b - c) / 2;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;

int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll sum=0;
    rep(i,n) {
        cin >> a[i];
        sum+=a[i];
    }
    ll x[n];
    x[0]=sum;
    for(ll i=1;i<=n-2;i+=2){
        x[0]-=2*a[i];
    }
    for(ll i=1;i<n;i++){
        x[i]=2*a[i-1]-x[i-1];
    }
    rep(i,n-1) cout << x[i]  << " ";
    kaku(x[n-1]);
}



Measured memory_bytes: 2816
#include <iostream>
#define MOD 1000000007

typedef long long ll;

using namespace std;

ll mulMod(ll a, ll b) { return a * b % MOD; }

ll powMod(ll n, ll r) {
    if (r == 0) return 1;
    if (r % 2) return mulMod(n, powMod(n, r - 1));
    ll temp = powMod(n, r / 2);
    return mulMod(temp, temp);
}

ll combMod(ll n, ll r) {
    if (r > n - r) return combMod(n, n - r);
    ll deno = 1, nume = 1;
    for (ll i = 0; i < r; ++i) {
        nume = mulMod(nume, n - i);
        deno = mulMod(deno, i + 1);
    }
    return mulMod(nume, powMod(deno, MOD - 2));
}

int main() {
    ll n, m;
    cin >> n >> m;

    ll remaining = m;
    ll ans = 1;
    for (ll i = 2; i * i <= remaining; ++i) {
        if (remaining % i) continue;
        ll cnt = 0;
        while (remaining % i == 0) {
            ++cnt;
            remaining /= i;
        }
        ans = mulMod(ans, combMod(n + cnt - 1, n - 1));
    }
    if (remaining > 1) ans = mulMod(ans, n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//long a = Long.parseLong(sc.next());
		String t = sc.next();
//		String buff="";
		//long b = Long.parseLong(sc.next());
		//int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		String s = sc.next();
		//String t = sc.next();
		//String b = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		if(t.equals(s)) {//a、e、i、o、u
			System.out.println("H");
		}else {
			System.out.println("D");
		}
		/*for(int i=0;i<t.length();i++) {
			if(t.substring(i,i+1).equals(",")) {
				buff+=" ";
			}else {
				buff+=t.substring(i, i+1);
			}
		}*/
		//System.out.println(a*800-(a/15)*200);
	}
}




Measured memory_bytes: 23760
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        int N;
        string S;
        cin >> N >> S;

        int count = 0;
        for(int i = 0; i < (N-2); i++){
            if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')
                count++;
        }

        cout << count << endl;

    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s,t,d;
    cin>>s>>t>>d;
    cout<<s[0]<<t[0]<<d[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int cnt=0,m=0,G[100];
void insertionsort(int a[],int n,int g){
    int i,j,v;
    for(i=g;i<n;i++){
        v=a[i];
        j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void makeg(int n){
    int i;
    G[0]=1;
    for(i=0;G[i]<=n;i++){
        G[i+1]=G[i]*3+1;
        m++;
    }
}
void shellsort(int a[],int n){
  int i;
  makeg(n);
  for(i=m-1;i>=0;i--)insertionsort(a,n,G[i]);
}
int main(){
    int n,i,a[1000000];
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    shellsort(a,n);
    printf("%d\n",m);
    for(i=m-1;i>0;i--)printf("%d ",G[i]);
    printf("%d\n%d\n",G[0],cnt);
    for(i=0;i<n;i++)printf("%d\n",a[i]);
    return 0;
}


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

int main (){
    string s;
    cin>>s;
    ll ans[s.size()]={0},l[s.size()]={0},r[s.size()]={0};
    for(ll i=0;i<s.size();i++){
        if(s[i]=='R')   r[i]=i;
        else            r[i]=r[i-1];
    }
    for(ll i=s.size()-1;i>=0;i--){
        if(s[i]=='L')   l[i]=i;
        else            l[i]=l[i+1];
    }
    ll dist=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='R'){
            if((i-l[i]+1)%2==0)   ans[l[i]-1]++;
            else            ans[l[i]]++;
        }
        else{
            if((i-r[i]-1)%2==0)   ans[r[i]+1]++;
            else            ans[r[i]]++;
        }
    }
    for(ll i=0;i<s.size();i++) cout<<ans[i]<<" ";
    return 0;
}





Measured memory_bytes: 3072
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        list.sort(Comparator.reverseOrder());

        int longSide = 0;
        int shortSide = 0;
        //降順にならべてあるリストから長辺と短辺をとっていく。長辺と短辺の長さが同じになることもある。
        for (int i = 0; i < n - 1; i++) {
            if (list.get(i).equals(list.get(i + 1)) && longSide == 0) {
                longSide = list.get(i);
                i++;
            } else if (list.get(i).equals(list.get(i + 1))) {
                shortSide = list.get(i);
                break;
            }
        }
        System.out.println((long) longSide * shortSide);

    }

}


Measured memory_bytes: 60144
#include<iostream>
#include<algorithm>
#include<set>
#include<climits>
#define inf INT_MAX
using namespace std;

int main()
{
	int n;
	while(cin>>n,n)
	{
		unsigned long long d[10][10],sum[10]={};
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
				d[i][j]=i==j?0:inf;
			}
		}
		set<int> ss;
		for(int i=0;i<n;i++)
		{
			int s,t,c;
			cin>>s>>t>>c;
			ss.insert(s);
			ss.insert(t);
			d[s][t]=d[t][s]=c;
		}
		int v=ss.size();		
		for(int k=0;k<v;k++)
		{
			for(int i=0;i<v;i++)
			{
				for(int j=0;j<v;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}

		int ans;
		for(int i=0;i<v;i++)
		{
			for(int j=0;j<v;j++)
			{
				sum[i]+=d[i][j];
			}
		}
		ans=min_element(sum,sum+v)-sum;
		cout<<ans<<" "<<sum[ans]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if( z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  } else {
    if (z->key < y->key){
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}



int main() {
    ios::sync_with_stdio(false);

    int n, x;
    string com;
    cin >> n;
    for(int i=0; i<n; i++){
      cin >> com;
      if(com == "insert"){
        cin >> x;
        insert(x);
      } else {
        inorder(root);
        cout << "\n";
        preorder(root);
        cout << "\n";
      }
    }
    return 0;
}

Measured memory_bytes: 24660
@S=map$|++,@p=@i=0..1e5;$\-=<>;sub f{$p[$_]=$_-(local$_=$p[$_])?&f:$_}/ />${*a=-$'}||($S[$p[$v=f$_=$a]=f]+=$v-&f&&$S[$v]),$a=$`for<>;$\+=$S[f$_=${-$_}]for@i;print

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

int solve(string s, bool *ans, int N);

int main(void){
    int N; string s;
    cin >> N >> s;
    //SS, SW, WS, WWの順にシミュレート
    bool ans[N+1];
    int res;
    ans[0] = true; ans[1] = true;
    res = solve(s, ans, N);
    if(res == 1) return 0;
    ans[0] = true; ans[1] = false;
    res = solve(s, ans, N);
    if(res == 1) return 0;
    ans[0] = false; ans[1] = true;
    res = solve(s, ans, N);
    if(res == 1) return 0;
    ans[0] = false; ans[1] = false;
    res = solve(s, ans, N);
    if(res == -1) cout << -1 << endl;
    return 0;
}

int solve(string s, bool *ans, int N){
    //1-Nまで時計回りに並んでいるとして、自分の右側の動物と自分の答えが分かっていれば自分の左側がどちらか確定する
    for(int i = 1; i <= N-1; i++){
        if(s[i] == 'o' && ans[i]){
            ans[i+1] = ans[i-1];
        }
        else if(s[i] == 'o'){
            ans[i+1] = !ans[i-1];
        }
        else if(s[i] == 'x' && ans[i]){
            ans[i+1] = !ans[i-1];
        }
        else{
            ans[i+1] = ans[i-1];
        }
    }
    //ans[0]とans[N]が等しければ辻褄が合っている -> どうやらそうではないらしい s[N-1]の検査をしているだけ
    //検査してないのはs[0].そこの正当性を確認する
    //正当なのはans[0]がS && s[0]がo && (ans[1] == ans[N-1]), ans[0]がS && s[0]がx && (ans[1] != ans[N-1]),...
    if((ans[0] == ans[N])){
        if(ans[0] && s[0] == 'o' && (ans[1] == ans[N-1]) ||
           ans[0] && s[0] == 'x' && (ans[1] != ans[N-1]) ||
           !ans[0] && s[0] == 'o' && (ans[1] != ans[N-1]) ||
           !ans[0] && s[0] == 'x' && (ans[1] == ans[N-1]))
        {
            rep(i, N){
                if(ans[i]) cout << 'S';
                else cout << 'W';
            }
            cout << endl;
            return 1;
        }
        else return -1;
    }
    else return -1;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDR.ARR;
	a.sort!"a > b"();
	long alice, bob;
	foreach (i; 0..N)
	{
		if (i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];
	}

	writeln(alice - bob);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Colorful Leaderboard
	var N int
	fmt.Scanf("%d", &N)

	color := make(map[int]int, 9)
	var a int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a)
		if 1 <= a && a <= 399 {
			color[0]++
		} else if 400 <= a && a <= 799 {
			color[1]++
		} else if 800 <= a && a <= 1199 {
			color[2]++
		} else if 1200 <= a && a <= 1599 {
			color[3]++
		} else if 1600 <= a && a <= 1999 {
			color[4]++
		} else if 2000 <= a && a <= 2399 {
			color[5]++
		} else if 2400 <= a && a <= 2799 {
			color[6]++
		} else if 2800 <= a && a <= 3199 {
			color[7]++
		} else {
			color[8]++
		}
	}

	var count int
	for i := 0; i < 8; i++ {
		if color[i] > 0 {
			count++
		}
	}

	var min, max int
	min = int(math.Max(float64(count), 1))
	max = count + color[8]

	fmt.Println(min, max)
}


Measured memory_bytes: 1844
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }


ll solve(ll a,ll b) { // 1<=x<a b<y such that x*y<a*b
	// y<a*b/x
	ll xlim=min(a-1,(a*b-1)/(b+1));

	// a*b/x-a*b/(x+1)<1 -> a*b/(x*(x+1))<1 -> x*(x+1)>a*b -> z
	ll z=(ll)floor(sqrt(1.0*a*b));
	while((z-1)*z>a*b) --z; while(z*(z+1)<=a*b) ++z;
	z=min(z,xlim);
	//printf("%lld %lld -> z=%lld\n",a,b,z);
	
	// values of 1..z for x give different values for a*b/x 
	ll ret=z;
	if(a==1) return ret;
	if(z==0) { z=1; if((a*b-1)/z<=b) return ret; else ++ret; }
	ll w=(a*b-1)/z;
	ret+=max(0LL,min(xlim-z,w-b-1));
	//printf("%lld %lld -> z=%lld w=%lld [%lld -> %lld %lld] -> %lld\n",a,b,z,w,xlim-z,w-b-1,ret);
	return ret;
}


void run() {
	ll a,b; scanf("%lld%lld",&a,&b);
	ll ret=solve(a,b)+solve(b,a);
	printf("%lld\n",ret);
}

int main() {
	int n; scanf("%d",&n); FORE(i,1,n) run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;

	ll ans = 0;
	for (ll i = 2; i <= sqrt(N-1); i++) {
		if ((N - 1) % i == 0) {
			ans += 2;
			if ((N - 1) / i == i)
				ans--;
		}
	}
	if(N!=2) ans++;

	for (int i = 2; i <= sqrt(N); i++) {
		if (N % i == 0) {
			ll q = N / i;
			if (q % i == 1) {
				ans++;
			}
			else {
				while (q % i == 0) {
					q /= i;
					if (q % i == 1) {
						ans++;
						break;
					}
				}
			}
		}
	}
	ans++;
	cout << ans << endl;
}

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

#define int long long int
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define float long double
#define M 1000000007
int32_t main()
{
	int n;
	cin >> n;
	int a[n];
	f(i,0,n) cin >> a[i];
	
	f(i,0,n)
	{
		if(a[i]%2==0)
		{
			
			
			if(a[i]%3!=0 && a[i]%5!=0 ) 
			{
				return cout<<"DENIED",0;
			}
		}
	}
	cout<<"APPROVED";
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N = int(input())
q = list(map(int, input().split()))
heapify(q)
while len(q) > 1:
    a, b = heappop(q), heappop(q)
    heappush(q, (a+b)*0.5)
print(q[0])


Measured memory_bytes: 3316
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: Chars
    };

    let mut res = 0;
    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - 1 - i] {
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

const int max_n = 2005;

ll dp[max_n];
void solve() {
    memset(dp, 0, sizeof(dp));
    int S;
    cin >> S;
    if (S < 3) {
        cout << 0;
        return;
    }
    dp[3] = 1;
    REP(i, 4, S) {
        dp[i] = 1;
        REP(j, 3, i) {
            dp[i] = (dp[i] + dp[i-j]) % MOD;
        }
    }
    cout << dp[S];
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>

int main() {

	int d, n;
	scanf("%d %d", &d, &n);
	int ans = 1;
	if(d == 0) ans = 1;
	else if(d == 1) ans = 100;
	else ans = 10000;
	ans *= n;
	if(d == 0 && ans == 100) ans += 1;
	else if(d == 1 && ans == 10000) ans += 100;
	else if(d == 2 && ans == 1000000) ans += 10000;
	printf("%d\n", ans);


	return 0;
}


Measured memory_bytes: 128
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n: number = +input[0];
const s: string[] = input[1].split('');

let ans: string = '';
const len = s.length;

for(let i = 0; i < len; i++){
    const id: number = s[i].charCodeAt(0) + n;
    let id2: number;
    if (id >= 91){
        id2 = id%91 + 65;
    }else{
        id2 = id;
    }
    const tmp = String.fromCharCode(id2);
    ans += tmp;
}
console.log(ans);


Measured memory_bytes: 7500
import java.util.*;
import java.io.*;

class Main {
	public static void main(String... args) {
		long N = IN.nextLong();
		long K = IN.nextLong();

		long num = N / K;
		if (K % 2 == 1) {
			puts(num * num * num);
		} else {
			long tmp = (N + K / 2) / K;
			puts(num * num * num + tmp * tmp * tmp);
		}
		flush();
	}

	static final Scanner IN = new Scanner(System.in);
	static final PrintWriter OUT = new PrintWriter(System.out);
	static <T> void puts(T arg) { OUT.println(arg); }
	static void flush() { OUT.flush(); }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll 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
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll cnt = 0;
    rep(i, n) {
        if(s[i] == '.') {
            cnt++;
        }
    }

    ll ans = cnt;
    rep(i, n) {
        if(s[i] == '#') {
            cnt++;
        }
        else {
            cnt--;
        }
        chmin(ans, cnt);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 1e5+99;

in issolved[maxn],pe[maxn];

int main()
{
    IOS;
    in n,m,so=0,p=0;
    cin >> n >> m;
    rep(i,0,m)
    {
        in x;
        string s;
        cin >> x >> s;
        if(s == "AC")
        {
            if(issolved[x] == 0)
            {
                p+=pe[x];
                issolved[x]++;
                so++;
            }
        }
        else
        {
            if(issolved[x] == 0)
            {
                pe[x]++;
            }
        }
    }  
    cout << so << " " << p << "\n";
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect,copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

h,w=map(int,input().split())
A=[tuple(map(int,input().split())) for i in range(h)]
B=[tuple(map(int,input().split())) for i in range(h)]
# a=[set() for j in range(w)]
K=160*80
dp = [[0]*w for i in range(h)]
dp[0][0]=1<<K
for i in range(h):
    for j in range(w):
        d=abs(A[i][j]-B[i][j])
        if i-1>=0:
            dp[i][j] |= dp[i-1][j]
        if j-1>=0:
            dp[i][j] |= dp[i][j-1]
        dp[i][j] = (dp[i][j]<<d) | (dp[i][j]>>d)


ans = K
for i in range(2*K):
    if dp[h-1][w-1]  & (1 << i)>0:
        ans = min(ans,abs(K-i))
print(ans)
# for di in dp:
#     print(di)



Measured memory_bytes: 59356
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,ans=0;
  cin >>n;
  
  int d[n];
  
  for(int i=0;i<n;i++) cin >>d[i];
  
  for(int j=0;j<n-1;j++){
    for(int k=j+1;k<n;k++){
      ans += d[j]*d[k];
    }
  }

  cout << ans << endl;  
  return 0;
}

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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shwv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shwv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shwv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline void getv(T& v) { for (auto& t : v) cin >> t; }
template<typename T> inline int siz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    string s;
    cin >> s;
    int n = s[siz(s) - 1] - '0';
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        prt("hon");
        break;
    
    case 0:
    case 1:
    case 6:
    case 8:
        prt("pon");
        break;
    
    case 3:
        prt("bon");
        break;
    
    default:
        break;
    }

    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    priority_queue<double> q;
    rep(_, 0, n) {
        double a;
        cin >> a;
        q.push(-a);
    }

    while (q.size() > 1) {
        double a = -q.top();
        q.pop();
        double b = -q.top();
        q.pop();
        q.push(-(a + b) / 2);
    }

    cout << -q.top() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
 
 
using namespace std;
 
const ll N = 4e5;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
 
ll n;
ll a[N], b[N], dp[N], ans;
int main() {
	speed;
	cin >> n;
	for(int i = 2; i <= n + 1; i++)
		cin >> a[i];
	for(int i = 2; i <= n + 1; i++) {
		ans += a[i] / 2;
		a[i] %= 2;
		if(a[i + 1] && a[i])
			ans++, a[i + 1]--;
	}
	cout << ans << '\n';
}
 
/*
4
1 2 3 4
*/

Measured memory_bytes: 4420
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    ll a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    ll ans = 0ll;
    ll d = min(a, k);
    ans += d;
    k -= d;
    d = min(k, b);
    k -= d;
    d = min(k, c);
    ans -= d;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string T;
    cin >> T;
    REP(i, T.size()) {
        if (T[i] == '?' || T[i] == 'D') cout << "D";
        else cout << "P";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void x_y(const string x, const string y, unordered_set<ll> &x_y) {
  ll xsize = x.size();
  ll ysize = y.size();
  for (ll i = -ysize; i <= xsize; i++) {
    ll xpos = 0;
    ll ypos = 0;
    if (i < 0) ypos -= i;
    else xpos += i;
    bool flag = true;
    while (xpos < xsize and ypos < ysize) {
      if (x[xpos] == '?' or y[ypos] == '?' or x[xpos] == y[ypos]) {
        xpos++;
        ypos++;
        continue;
      } else {
        flag = false;
        break;
      }
    }
    if (!flag) x_y.insert(i);
  }
}

void solve() {
  string a, b, c;
  cin >> a >> b >> c;

  unordered_set<ll> a_b;
  unordered_set<ll> b_c;
  unordered_set<ll> c_a;

  x_y(a, b, a_b);
  x_y(b, c, b_c);
  x_y(c, a, c_a);

  vector<bool> abvec(4020);
  vector<bool> bcvec(4020);
  vector<bool> cavec(4020);

  for (auto it: a_b) abvec[it + 2010] = true;
  for (auto it: b_c) bcvec[it + 2010] = true;
  for (auto it: c_a) cavec[it + 2010] = true;

  // for (auto it: a_b) cerr << "a_b: " << it << endl;
  // for (auto it: b_c) cerr << "b_c: " << it << endl;
  // for (auto it: c_a) cerr << "c_a: " << it << endl;

  ll ans = a.size() + b.size() + c.size();

  for (ll aabb = -4020; aabb < 4020; aabb++) for (ll bbcc = -4020; bbcc < 4020; bbcc++) {
    ll ccaa = -(aabb + bbcc);
    if (0 <= aabb + 2010 and aabb + 2010 < 4020 and abvec[aabb + 2010]) continue;
    if (0 <= bbcc + 2010 and bbcc + 2010 < 4020 and bcvec[bbcc + 2010]) continue;
    if (0 <= ccaa + 2010 and ccaa + 2010 < 4020 and cavec[ccaa + 2010]) continue;

    ll abegin = 0;
    ll aend = a.size();
    ll bbegin = 0;
    ll bend = b.size();
    ll cbegin = 0;
    ll cend = c.size();

    bbegin += aabb;
    bend += aabb;
    cbegin -= ccaa;
    cend -= ccaa;

    ll begin = min(min(abegin, bbegin), cbegin);
    ll end = max(max(aend, bend), cend);
    ll size = end - begin;
    ans = min(ans, size);
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 896