akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

struct LOC{

	int row,col;
};

struct Info{
	Info(int arg_row,int arg_col,char arg_ch){
		loc.row = arg_row;
		loc.col = arg_col;
		ch = arg_ch;
	}

	LOC loc;
	char ch;
};

int H,W;
int info_index[128],min_dist[128][128];
char table[55][55],buf[SIZE];
vector<Info> V;


void func(){

	V.clear();

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);
		for(int col = 0; col < W; col++){

			if(table[row][col] == '_')continue;

			info_index[table[row][col]] = V.size(); //文字からインデックスを調べる表
			V.push_back(Info(row,col,table[row][col]));
		}
	}

	scanf("%s",buf);

	for(int i = 0; i < V.size()-1; i++){
		for(int k = i; k < V.size(); k++){

			min_dist[V[i].ch][V[k].ch] = abs(V[i].loc.row-V[k].loc.row)+abs(V[i].loc.col-V[k].loc.col);
			min_dist[V[k].ch][V[i].ch] = min_dist[V[i].ch][V[k].ch];
		}
	}

	int ans = V[info_index[buf[0]]].loc.row+V[info_index[buf[0]]].loc.col+1;

	char pre = buf[0];

	for(int i = 1; buf[i] != '\0'; i++){

		ans += min_dist[pre][buf[i]]+1;
		pre = buf[i];
	}

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

int main(){

	while(true){

		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;

		func();
	}

	return 0;
}



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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		pr.println((a + b) % 24);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int INF = 1001001001;


void dfs(int v, const Graph &G, vector<bool> &seen, vector<int> &order) {
    seen[v] = true;

    for (auto u: G[v]) {
        if (seen[u]) continue;
        dfs(u, G, seen, order);
    }
    order.push_back(v);
}


int main(){
    int n, m;
    cin >> n >> m;
    Graph G(n, vector<int>());
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
    }

    vector<int> dp(n, 0);
    vector<bool> seen(n, false);
    vector<int> order;

    rep(v, n) {
        if (seen[v]) continue;
        dfs(v, G, seen, order);
    }

    int ans = 0;

    for(auto v: order) {
        for (auto u: G[v]) {
            dp[v] = max(dp[v], dp[u] + 1);
        }
        ans = max(ans, dp[v]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 10236
#!/usr/bin python3
# -*- coding: utf-8 -*-

########################################
# ナップサック
# 重さ：max_wi,Wー10**9くらい
# 価値：N*max_viー10**5くらい
# dp[v]:v以上の価値となる最小の重さ
########################################

import numpy as np

def main():
    N, W = map(int, input().split())
    max_vi = 10**3
    max_V = N*max_vi
    dp = [W+1] * (max_V+1)
    dp[0] = 0
    dp = np.array(dp)
    for _ in range(N):
        w_, v_ = map(int, input().split())
        dp[v_:] = np.minimum(dp[v_:], dp[:-v_] + w_)
#    print(dp)
    print(np.max(np.where(dp <= W)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 14812
#include <iostream>

using namespace std;

template<typename T>
class Dice {

private:
   void Init() {
      upId = 0;
      frontId = 1;
      rightId = 2;
   }

public:
   Dice() :
      number{1, 2, 3, 4, 5, 6}
   {
      Init();
   }
   Dice(T (&n)[6]) :
      number{n[0], n[1], n[2], n[3], n[4], n[5]}
   {
      Init();
   }
   virtual ~Dice() {;}

   enum Direction {
      north,
      south,
      east,
      west
   };

   void Roll(Direction direction) {
      switch (direction) {
      case north: {
         int tmp = upId;
         upId = frontId;
         frontId = 5 - tmp;
         break;
      }
      case south: {
         int tmp = frontId;
         frontId = upId;
         upId = 5 - tmp;
         break;
      }
      case east: {
         int tmp = rightId;
         rightId = upId;
         upId = 5 - tmp;
         break;
      }
      case west: {
         int tmp = upId;
         upId = rightId;
         rightId = 5 - tmp;
         break;
      }
      }
   }

   T Print() {
      return number[upId];
   }   

   T Search(T up, T front) {
      int downId = 5 - upId;
      int backId = 5 - frontId;
      int leftId = 5 - rightId;
      
      if (number[frontId] == up) {
         Roll(north);
      } else if (number[rightId] == up) {
         Roll(west);
      } else if (number[downId] == up) {
         Roll(north);
         Roll(north);
      } else if (number[backId] == up) {
         Roll(south);
      } else if (number[leftId] == up) {
         Roll(east);
      }

      downId = 5 - upId;
      backId = 5 - frontId;
      leftId = 5 - rightId;

      if (number[frontId] == front) {
         return number[rightId];
      } else if (number[rightId] == front) {
         return number[backId];
      } else if (number[backId] == front) {
         return number[leftId];
      } else if (number[leftId] == front) {
         return number[frontId];
      }
      return 0;
   }

private:
   T number[6];
   int upId;
   int frontId;
   int rightId;

};

int main() {

   int number[6]{};
   for (int i = 0; i < 6; ++i) {
      cin >> number[i];
   }

   int n{};
   cin >> n;
   while (n--) {
      int up{}, front{};
      cin >> up >> front;
      
      Dice<int> dice(number);
      cout << dice.Search(up, front) << endl;;
   }

   return 0;

}

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

//long int


int main() {

	long int n,i,c,flag;
	char str[1000001];
	cin >> n;
	cin >> str;
	flag = 0;
	c = 0;
	for (i = 0; i < n; i++) {
		if (str[i] == '2') {
			flag = 1;
		}
	}
	if (flag == 1) {
		for (i = 0; i < n; i++) {
			if ((str[i] == '1') || (str[i] == '3')) {
				if (((n - 1) ^ i) == (n - 1 - i)) {
					if (c == 0) { c = 1; }
					else { c = 0; }
				}
			}
		}
	}
	else {
		for (i = 0; i < n; i++) {
			if (str[i] == '3') {
				if (((n - 1) ^ i) == (n - 1 - i)) {
					if (c == 0) { c = 2; }
					else { c = 0; }
				}
			}
		}
	}
	/*
	if (flag == 1) {
		for (i = 0; i < n ; i++) {
			if ((str[i]  == '1' ) || (str[i] == '3')){
				if (i % 4 == 0) {
					if (c == 0) { c = 1; }
					else { c = 0; }
				}
				else if (i % 4 == 1) {
					if (n % 2 == 0) {
						if (c == 0) { c = 1; }
						else { c = 0; }
					}
				}
				else if (i % 4 == 2) {
					if ((n % 4 == 0) || (n % 4 == 3)) {
						if (c == 0) { c = 1; }
						else { c = 0; }
					}
				}
				else {
					if (n % 4 == 0) {
						if (c == 0) { c = 1; }
						else { c = 0; }
					}
				}
			}
		}
	}
	else {
		for (i = 0; i < n; i++) {
			if  (str[i] == '3') {
				if (i % 4 == 0) {
					if (c == 0) { c = 2; }
					else { c = 0; }
				}
				else if (i % 4 == 1) {
					if (n % 2 == 0) {
						if (c == 0) { c = 2; }
						else { c = 0; }
					}
				}
				else if (i % 4 == 2) {
					if ((n % 4 == 0) || (n % 4 == 3)) {
						if (c == 0) { c = 2; }
						else { c = 0; }
					}
				}
				else {
					if (n % 4 == 0) {
						if (c == 0) { c = 2; }
						else { c = 0; }
					}
				}
			}
		}
	}*/
	
	cout << c;

}

Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
    int N, K, X, Y;
    int ans;

    scanf("%d%d%d%d", &N, &K, &X, &Y);
    
    if (N <= K) {
        ans = N * X;
    } else {
        ans = K * X + (N-K) * Y; 
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x2000 = sc.nextInt();
        int p;

        for(int i=1;i<11;i++){
            p =r*x2000-D;
            System.out.println(p);
            x2000=p;
        }

    }
}

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

#define MAX 131072

int N, M;
int rinsetuNum[MAX];
int* rinsetu[MAX];

int ken[MAX], kenken[MAX], pa[MAX];

int newKenNum, newKenKenNum, newPaNum;
int newKenBuffer[2][MAX], newKenKenBuffer[2][MAX], newPaBuffer[2][MAX];

int main(void) {
	int i;
	int S, T;
	int phase;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int u, v;
		if (scanf("%d%d", &u, &v) != 2) return 1;
		u--;
		v--;
		rinsetu[u] = realloc(rinsetu[u], sizeof(int) * (++rinsetuNum[u]));
		rinsetu[u][rinsetuNum[u] - 1] = v;
	}
	if (scanf("%d%d", &S, &T) != 2) return 1;
	S--;
	T--;
	pa[S] = 1;
	newKenNum = 0;
	newKenKenNum = 0;
	newPaNum = 1;
	newPaBuffer[0][0] = S;
	phase = 0;
	while (newKenNum > 0 || newKenKenNum > 0 || newPaNum > 0) {
		int nextKenNum, nextKenKenNum, nextPaNum;
		int *newKen = newKenBuffer[phase], *nextKen = newKenBuffer[1 - phase];
		int *newKenKen = newKenKenBuffer[phase], *nextKenKen = newKenKenBuffer[1 - phase];
		int *newPa = newPaBuffer[phase], *nextPa = newPaBuffer[1 - phase];
		nextKenNum = 0;
		nextKenKenNum = 0;
		nextPaNum = 0;
		for (i = 0; i < newKenNum; i++) {
			int node = newKen[i];
			int j;
			for (j = 0; j < rinsetuNum[node]; j++) {
				int nnode = rinsetu[node][j];
				if (kenken[nnode] == 0 || kenken[nnode] > ken[node]) {
					kenken[nnode] = ken[node];
					nextKenKen[nextKenKenNum++] = nnode;
				}
			}
		}
		for (i = 0; i < newKenKenNum; i++) {
			int node = newKenKen[i];
			int j;
			for (j = 0; j < rinsetuNum[node]; j++) {
				int nnode = rinsetu[node][j];
				if (pa[nnode] == 0 || pa[nnode] > kenken[node]) {
					pa[nnode] = kenken[node];
					nextPa[nextPaNum++] = nnode;
				}
			}
		}
		for (i = 0; i < newPaNum; i++) {
			int node = newPa[i];
			int j;
			for (j = 0; j < rinsetuNum[node]; j++) {
				int nnode = rinsetu[node][j];
				if (ken[nnode] == 0 || ken[nnode] > pa[node] + 1) {
					ken[nnode] = pa[node] + 1;
					nextKen[nextKenNum++] = nnode;
				}
			}
		}
		phase = 1 - phase;
		newKenNum = nextKenNum;
		newKenKenNum = nextKenKenNum;
		newPaNum = nextPaNum;
	}
	printf("%d\n", pa[T] - 1);
	return 0;
}


Measured memory_bytes: 8192
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

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


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 5e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

int pref[N];
int suff[N];

int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);

  string s;
  cin >> s;
  int n = s.length();

  for(int i = n - 1; i >= 0; i--) {
    if(s[i] == '>') {
      pref[i] = 1 + pref[i+1];
    }
    else {
      pref[i] = 0;
    }
  }

  if(s[0] == '<')suff[0] = 1;
  for(int i = 1; i < n; i++) {
    if(s[i] == '<') {
      suff[i] = 1 + suff[i-1];
    }
    else
      suff[i] = 0;
  }
  // for(int i = 0 ; i < n; i++)cout << pref[i] << " ";cout << "\n";
  // for(int i = 0 ; i < n; i++)cout << suff[i] << " ";cout << "\n";    
  ll ans = 0;
  for(int i = 0; i <= n; i++) {
    int val = 0;
    if(i - 1 >= 0)val = max(val, suff[i-1]);
    if(i < n)val = max(val, pref[i]);
    // debug(i,val);
    ans = ans + val;
  }
  cout << ans << "\n";

  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 4764
n, m, k = map(int, input().split())
MOD = 998244353

def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
dp = [0]*(k+1)
dp[0] = m* modpow(m-1, n-1, MOD) % MOD
bunsi = 1
bunbo = 1
for j in range(1, k+1):
  bunsi = bunsi * (n-j) % MOD
  bunbo = bunbo * j % MOD

  comb = bunsi * modpow(bunbo, MOD-2, MOD) % MOD
  dp[j] = (m * modpow(m-1, n-1-j, MOD)*comb % MOD + dp[j-1]) % MOD
print(dp[k])

Measured memory_bytes: 95884
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	sum := make([]int, n+1) // 0~n-1までEを向いている人数の累積和
	for i := 0; i < n; i++ {
		if s[i] == 'E' {
			sum[i+1] = sum[i] + 1
		} else {
			sum[i+1] = sum[i]
		}
	}
	ans := n
	// fmt.Println("n", n, "s", s, "sum", sum)
	for i := 0; i < n; i++ {
		var c1, c2 int
		// i番目の人をリーダーに指名したとする。
		// 0 ~ i-1番目の人でWを向いている人はEを向く必要がある。
		c1 = i - (sum[max(0, i)] - sum[0])
		// i+1 ~ n-1番目の人でEを向いている人はWを向く必要がある。
		c2 = sum[n] - sum[i+1]
		ans = min((c1 + c2), ans)
		// fmt.Printf("i %d, c1 %d, c2 %d, ans %d\n", i, c1, c2, ans)
	}
	fmt.Println(ans)
}

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


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, L;
    cin >> N >> L;
    REP(i, N) {
        cin >> A[i];
    }
    ll index = -1;
    REP(i, N - 1) {
        if (A[i] + A[i + 1] >= L)
            index = i + 1;
    }

    if (index < 0) {
        cout << "Impossible" << endl;
    }
    else {
        cout << "Possible" << endl;
        for (ll i = 1; i < index; ++i)
            cout << i << endl;
        for (ll i = N - 1; i > index; --i)
            cout << i << endl;
        cout << index << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<std::string> a(n), b(m);
    for (int i = 0; i < n; ++i)
    {
        std::string tmp;
        std::cin >> tmp;
        a[i] = std::move(tmp);
    }
    for (int i = 0; i < m; ++i)
    {
        std::string tmp;
        std::cin >> tmp;
        b[i] = std::move(tmp);
    }

    bool exists = false;
    for (int y = 0; y <= n - m; ++y)
    {
        for (int x = 0; x <= n - m; ++x)
        {
            if (a[y][x] != b[0][0])
            {
                continue;
            }

            bool match = true;
            for (int i = 0; i < m; ++i)
            {
                for (int j = 0; j < m; ++j)
                {
                    if (a[y + i][x + j] != b[i][j])
                    {
                        match = false;
                        break;
                    }
                }
                if (!match)
                {
                    break;
                }
            }
            if (match)
            {
                exists = true;
                break;
            }
        }
        if (exists)
        {
            break;
        }
    }

    if (exists)
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int a;
      cin >> a;
      //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
      //else cout << (a+b)/2 << endl;
      cout << 48-a << endl; 
      return 0;
    }

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

typedef long long LL;

const int N=200000;

int n,a[N+9],b[N+9],p[2][N+9],ans[N+9];

int main(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
  for (int i=n;i>=1;--i)
	if (!p[0][a[i]]) p[0][a[i]]=i;
  for (int i=1;i<=n;++i){
	scanf("%d",&b[i]);
	if (!p[1][b[i]]) p[1][b[i]]=i;
  }
  int mx=0;
  for (int i=1;i<=n;++i)
	if (p[0][i]&&p[1][i]) mx=max(mx,p[0][i]-p[1][i]+1);
  for (int i=1;i<=n;++i) ans[(i+mx-1)%n+1]=b[i];
  for (int i=1;i<=n;++i)
	if (a[i]==ans[i]) {puts("No");return 0;}
  puts("Yes");
  for (int i=1;i<=n;++i)
	printf("%d ",ans[i]);
  puts("");
  return 0;
}

Measured memory_bytes: 7728
def rankmod2(A):
    n,m=len(A),len(A[0])
    rank=0
    i,j=0,0
    while i<n and j<m:
        if A[i][j]:
            rank+=1
        else:
            for ii in range(i+1,n):
                if A[ii][j]:
                    A[i],A[ii]=A[ii],A[i]
                    rank+=1
                    break
            else:
                j+=1
                continue
        for ii in range(i+1,n):
            if A[ii][j]:
                for jj in range(j,m):
                    A[ii][jj]=(A[ii][jj]+A[i][jj])% 2
        i+=1
        j+=1
    return rank

n,m=map(int,input().split())
mod=998244353
A=[list(map(int,input().split())) for _ in range(n)]
r=rankmod2(A)
ans=(pow(2,n+m-1,mod)-pow(2,n+m-r-1,mod))%mod
print(ans)

Measured memory_bytes: 3828
#include <iostream>

int main(int argc, const char * argv[]) {
    int a,b,c,k;
    std::cin>>a>>b>>c>>k;
    if(k-a<=0){
        std::cout<<k<<std::endl;
    }else if(k-a-b<=0){
        std::cout<<a<<std::endl;
    }else {
        std::cout<<a-k+a+b<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i;
  vi num(31,0);
  rep(i,28){
    int n;
    cin>>n;
    num[n]++;
  }
  loop(i,1,31)
    if(num[i]==0)
      cout<<i<<endl;

}

Measured memory_bytes: 3116
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


h, w, k = LI()
A = SRL(h)
q = deque()
for a in range(h):
    if 'S' in A[a]:
        sy = a; sx = A[a].index('S')
        q += [(sy, sx)]

A[sy][sx] = 0
min_dist = INF
while q:
    y, x = q.popleft()
    min_dist = min(min_dist, x, y, h - 1 - y, w - 1 - x)
    for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nx, ny = x + i, y + j
        if 0 <= nx < w and 0 <= ny < h and A[ny][nx] == '.':
            A[ny][nx] = A[y][x] + 1
            if A[ny][nx] > k:
                continue
            q += [(ny, nx)]

print(1-(-min_dist // k))









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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int d;cin>>d;
  string ans;
  if(d==22)ans="Christmas Eve Eve Eve";
  else if(d==23)ans="Christmas Eve Eve";
  else if(d==24)ans="Christmas Eve";
  else ans="Christmas";
  cout << ans << endl;
}


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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> v(N);
    ll tmp_max = -1;
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
        tmp_max = max(v[i], tmp_max);
    }

    ll sum[tmp_max];
    sum[0] = 0;
    for (int i = 1; i <= tmp_max; ++i) {
        sum[i] = sum[i - 1] + i;
    }

    double exp[N + 1];
    exp[0] = 0;
    for (int i = 1; i <= N; ++i) {
        exp[i] = exp[i - 1] + (double)sum[v.at(i - 1)] / v.at(i - 1);
    }

    double ans_max = -1.0;
    for (int i = K; i <= N; ++i) {
        ans_max = max(ans_max, exp[i] - exp[i - K]);
    }
    cout << fixed << setprecision(12) << ans_max << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int sum = 0;
  for (int i = 1; i < n; i++) {
    sum += l[i];
  }
  cout << (l[0] < sum ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;


int main(){
	int k,n;
	ci2(k,n);
	vi h(n);
	int i;
	fo(i,n){
		ci(h[i]);
	}
	int ans=1e6;
	fo(i,n){
		int x=h[(i+1)%n]-h[i];
		if(x<0){
			x+=k;
		}
		ans=min(ans,k-x);
	}
	co(ans);
}


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

int main() {
  short int N;
  cin >> N;
  vector<short int> a(N);
  for(short int i=0; i<N; ++i)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  short int score=0;
  for(short int i=0; i<N; ++i)
    score += a.at(i) * (1-(i%2==1)*2);
  cout << score << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for(int i = 0; i < H; ++i) cin >> A[i];
  queue<pair<int,int>> Q;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(A[i][j] == '.') continue;
      Q.emplace(i,j);
    }
  }
  int ans = 0;
  queue<pair<int,int>> Q_;
  int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
  while(not Q.empty()){
    int x = Q.front().first, y = Q.front().second;
    Q.pop();
    for(int i = 0; i < 4; ++i){
      int x_ = x + dx[i], y_ = y + dy[i];
      if((not in_range(x_,H)) or (not in_range(y_,W))) continue;
      if(A[x_][y_] == '#') continue;
      A[x_][y_] = '#';
      Q_.emplace(x_,y_);
    }
    if(Q.empty()) swap(Q,Q_), ++ans;
  }
  cout << max(0,ans-1) << endl;
}


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

int main() {
  string s;
  int N;
  cin >> N;
  getline(cin, s);

  unordered_map<string, int> index;
  map<string, int> var;
  vector<vector<string>> stmt(N, vector<string>(5));
  for(auto i = 0; i < N; ++i) {
    getline(cin, s);
    stringstream ss(s);
    ss >> stmt[i][0] >> stmt[i][1] >> stmt[i][2] >> stmt[i][3] >> stmt[i][4];
    index[stmt[i][0]] = i;
    int j = 0;
    if(stmt[i][1] == "ADD" || stmt[i][1] == "SUB") j = 5;
    if(stmt[i][1] == "SET") j = 4;
    if(stmt[i][1] == "IF") j = 3;
    while(2 <= --j) var[stmt[i][j]] = 0;
  }
  stmt.push_back({"", "HALT", "", ""});

  for(s = "0";  s[0] <= '9'; ++s[0]) var[s] = s[0] - '0';
  for(s = "10"; s[1] <= '5'; ++s[1]) var[s] = s[1] - '0' + 10;

  auto valid = [](int n) {return 0 <= n && n < 16;};

  int i = 0;
  for(auto step = 0; ; ++step) {
    if(52428800 < step) {
      cout << "inf" << endl;
      return 0;
    }
    auto& s = stmt[i++];
    if(s[1] == "HALT") {
      break;
    } else if(s[1] == "IF") {
      if(!var[s[2]]) continue;
      if(!index.count(s[3])) break;
      i = index[s[3]];
    } else if(s[1] == "SET") {
      var[s[2]] = var[s[3]];
    } else if(s[1] == "ADD") {
      if(!valid(var[s[3]] + var[s[4]])) break;
      var[s[2]] = var[s[3]] + var[s[4]];
    } else if(s[1] == "SUB") {
      if(!valid(var[s[3]] - var[s[4]])) break;
      var[s[2]] = var[s[3]] - var[s[4]];
    }
  }

  for(s = "0";  s[0] <= '9'; ++s[0]) var.erase(s);
  for(s = "10"; s[1] <= '5'; ++s[1]) var.erase(s);

  for(auto i: var) cout << i.first << "=" << i.second << endl;
}

Measured memory_bytes: 3212
s = input()
n = len(s) - 1

ans = 0

for bit in range(2 ** n):
    f = s[0]
    for i in range(n):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
        
    ans += eval(f)
    #ans = ans + sum(map(int, f.split("+")))
    #print(ans)

print(ans)

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

using namespace std;

int main(){
	int n,resp=0;
	scanf("%d",&n);

	for(int i = 1;i < n;i++){
		for(int j = 1;j < n;j++){
			if(i*j >= n)
				break;
			resp++;
		}
	}
	printf("%d\n",resp);
}

Measured memory_bytes: 3768
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int height(int i, vector<vector<int>>chi, vector<int> &hei) {
	int res = 0;
	REP(j, 2) {
		if (chi[i][j] != -1) res = max( res, height(chi[i][j], chi, hei) + 1 );
	}
	hei[i] = res;
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<vector<int>> chi(n, vector<int>(2)); // 子
	vector<int> par(n, -1); // 親
	vector<int> dep(n, 0); // 深さ
	vector<string> type = { "root", "internal node", "leaf" };
	vector<int> type_index(n, 0);
	vector<int> sib(n, -1); // 兄弟
	vector<int> deg(n, 0); // 子の数
	vector<int> hei(n, 0); // 高さ

	REP(i, n) {
		int node;
		cin >> node;
		REP(k, 2) {
			cin >> chi[node][k];
			if (chi[node][k] != -1) deg[node]++;
		}
		if (chi[node][0] != -1) {
			par[chi[node][0]] = node;
			sib[chi[node][0]] = chi[node][1];
		}
		if (chi[node][1] != -1) {
			par[chi[node][1]] = node;
			sib[chi[node][1]] = chi[node][0];
		}
	}
	REP(i, n) {
		int x = i;
		while (par[x] != -1) {
			dep[i]++;
			x = par[x];
		}
		if (par[i] == -1) type_index[i] = 0;
		else if (chi[i] == vector<int>{-1, -1}) type_index[i] = 2;
		else type_index[i] = 1;
	}
	int x = 0;
	while (par[x] != -1) {
		x = par[x];
	}
	height(x, chi, hei);
	REP(node, n) {
		cout << "node" << " " << node << ": ";
		cout << "parent = " << par[node] << ", ";
		cout << "sibling = " << sib[node] << ", ";
		cout << "degree = " << deg[node] << ", ";
		cout << "depth = " << dep[node] << ", ";
		cout << "height = " << hei[node] << ", ";
		cout << type[type_index[node]];
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 3192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		int[] cnt = new int[N];
		for (int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			cnt[a[i] - 1]++;
			cnt[b[i] - 1]++;
		}
		for (int i = 0; i < N; i++) {
			System.out.println(String.valueOf(cnt[i]));
		}
	}
}



Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,x=0;
  cin>>x>>a>>b;
  if(-a+b<=0)
  {
    cout<<"delicious"<<endl;
  }
  else if(-a+b<=x)
 {
   cout<<"safe"<<endl;
 }
 else
 {
   cout<<"dangerous"<<endl;
 }
  
  

}
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, n, m=0;
	int list[100]={0};
	// Get Input Information
	for(i=0;i<12;i++) {
		scanf("%d",&n);
		list[n-1]++;
		if (m<list[n-1]) m = list[n-1];
	}
	for(i=0;i<100;i++) {
		if (m==list[i]) printf("%d\n",i+1);
	}
	return 0;
}

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

int N,M;
vector<int> u,v;
vector<vector<int>> edge(100010);
int a,b;
int visited[100010] = {0};

void dfs1(int n){
	visited[n] = 1;
	u.push_back(n);
	for(int i=0;i<edge[n].size();i++){
		if(visited[edge[n][i]]==0){
			dfs1(edge[n][i]);
			break;
		}
	}
}

void dfs2(int n){
	visited[n] = 1;
	v.push_back(n);
	for(int i=0;i<edge[n].size();i++){
		if(visited[edge[n][i]]==0){
			dfs2(edge[n][i]);
			break;
		}
	}
}


int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	if(edge[1].size()==1){
		dfs1(1);
		cout << u.size() << endl;
		for(int i=0;i<u.size();i++){
			if(i!=u.size()-1) cout << u[i] << " ";
			else cout << u[i] << endl;
		}
	}else{
		dfs1(1);
		for(int i=0;i<edge[1].size();i++){
			if(visited[edge[1][i]]==0){
				dfs2(edge[1][i]);
				break;
			}
		}
		cout << u.size() + v.size() << endl;
		for(int i=0;i<u.size();i++){
			cout << u[u.size()-1-i] << " ";
		}
		for(int i=0;i<v.size();i++){
			if(i!=v.size()-1) cout << v[i] << " ";
			else cout << v[i] << endl;
		}
	}
}

Measured memory_bytes: 9976
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
ll n,s=1,ans;
int main(){
	in(n);
    while(n){
        n/=2;
        ans+=s;
        s*=2;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    if (ans <= 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3600
def devide(number, count):
  if number%2==0:
    count += 1
    return devide(number/2, count)
  else:
    return count

length = int(input())
str_arr = input().split(' ')
numbers = [int(s) for s in str_arr]

counts = [0 for s in str_arr]
for i in range(len(numbers)):
  counts[i] = devide(numbers[i], 0)

print(min(counts))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main(){
    int n,m;
    std::cin>>n>>m;
    std::vector<std::pair<int,int>> ed;
    for (int i = 0; i < n; ++i) {
        int a,b;
        std::cin>>a>>b;
        ed.emplace_back(a,b);
    }
    std::sort(ed.begin(),ed.end());
    long long int ans=0;
    for(auto p:ed){
        if(m<=0)break;
        else ans+= static_cast<long long>(p.first)* static_cast<long long>(std::min(m,p.second));
        m-=p.second;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
long long q[1000];
long long n;
string s;
char aaa='a';
void running(){
	while(n){
        int ans=n%26;
        if(ans==0){
            ans=26;
            n--;
        }
        s+=q[ans];
        n=n/26;
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=26;i++,aaa++) q[i]=aaa;
    running();
    for (int i=s.size()-1; i>=0; i--) cout<<s[i];
    return 0;
}

Measured memory_bytes: 3676
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
int a[2011];
bitset<4000011> dp;
int main()
{
	geti(n);
	dp[0] = 1;
	int S = 0;
	for (int i=1; i<=n; i++)
	{
		int x;
		geti(x);
		S += x;
		dp = dp<<x|dp;
	}
	for (int i=(S+1)/2; i<=S; i++)
	{
		if (dp[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	assert(false);
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

const int M = 1e6 + 5;


int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> cnt(M,0);
  rep(i,n){
    if (cnt[a[i]] != 0) cnt[a[i]] = 2; //すでにチェックしたことがあればスルー
    else {
      for(int j=a[i]; j<M; j+=a[i]) cnt[j]++;
    }
  }
  ll ans = 0;
  rep(i,n){
    if (cnt[a[i]] == 1) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12756
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 1<<30
#define MAX_V 200

struct edge{int to,cap,rev;};

vector<edge> G[10000];
bool used[10000];
void add_edge(int from,int to,int cap){
    G[from].pb((edge){to,cap,(int)G[to].size()});
    G[to].pb((edge){from,0,(int)(G[from].size())-1});
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap)); if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
// s??????t???????????§???????±???????
int max_flow(int s, int t) {
    int flow = 0; for (;;) {
        memset(used, 0, sizeof(used)); int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main(){
    int v,e;
    cin>>v>>e;
    rep(i,e){
        int uu,vv,cc;
        cin>>uu>>vv>>cc;
        add_edge(uu,vv,cc);
    }
    cout<<max_flow(0,v-1)<<endl;
}

Measured memory_bytes: 1512
import math

n, h= map(int, input().split())
a = []
b = []

for i in range(n):
   a_tmp, b_tmp = map(int, input().split())
   a.append(a_tmp)
   b.append(b_tmp)

maxa = max(a)
b.sort()
b.reverse()

cnt = 0

for i in b:
   if i >= maxa:
      h -= i
      cnt += 1
      if h <= 0:
         break

if h > 0:
   cnt += math.ceil(h/maxa)

print(cnt)


Measured memory_bytes: 11312
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int a,b,ar = 0,br = 0;
		while(n--){
			cin >> a >> b;
			ar += a>b?a+b:a==b?a:0;
			br += b>a?a+b:a==b?b:0;
		}
		cout << ar << " " << br << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


int ans = 0;
int n,m;
int cnt=0;

//最長増加部分列の長さの計算
int LIS(vector<int> V) {
	int DP[200001] = { 0 };
	fill(DP, DP + V.size(), INF);
	rep(i, V.size()) {
		*lower_bound(DP, DP + V.size(), V[i]) = V[i];
	}
	return lower_bound(DP, DP + V.size(), INF) - DP;
}

vector<int> p;
int main() 
{
 char out[10]={0};
 int len=0;
 string s;
 cin>>s;
 rep(i,s.length()){
   if(s[i]=='0'){
     out[len++]='0';
   }else if(s[i]=='1'){
     out[len++]='1';
   }else{
     len--;
     if(len<0) len=0;
   }
 }

 rep(i,len){
   cout<<out[i];
 }
 cout<<endl;
}



Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;



long long a[4];

int main(int argc, const char * argv[]) {
  //  freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 2);
    cout << ((((a[0] == a[1]) && (a[1] == a[2])) &&  a[0] + a[1] >= a[2]) ? "Yes\n" : "No\n");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                  long long int
#define ff                   first
#define ss                   second
#define pb                   push_back
#define mp                   make_pair
#define pii                  pair<int,int>
#define vi                   vector<int>
#define mi                   map<int,int>
#define pqb                  priority_queue<int>
#define pqs                  priority_queue<int,vi,greater<int>>
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define inf                  1e18
#define precise(x,y)         fixed<<setprecision(y)<<x
#define w(x)                 int x;cin>>x;while(x--)
#define endl                 "\n"
#define no_of_digit(n)       floor(log10(n))+1
#define copyarr(a,b,n)       copy_n(a,n,b)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

//*******************to check if all number in array are positive*******************
//all_of(arr,arr+n,[](int x){return x>0;})?cout<<"positive":cout<<"some negative";


//*******************to check if any element in array is negative*******************
//any_of(arr,arr+n,[](int x){return x<0;})?cout<<"Any negative":cout<<"All positive";


int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //*****************Enter the code here*******************//
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
    	while(arr[i]%2==0)
    		{
    			arr[i]/=2;
    			sum++;
    		}
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace __gnu_pbds; 
using namespace std;

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(4e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int M = 1e9+7;
const int N = 1e6+1;

int f[N], inv[N];

int Pow(int x, int p) {
	int ans = 1;
	while(p) {
		if(p&1) ans = (ans*x)%M;
		x = (x*x)%M;
		p >>= 1;
	}
	return ans;
}

int ncr(int n, int r) {
	return f[n]*inv[r]%M*inv[n-r]%M;
}

void pre() {
	f[0] = inv[0] = 1;
	for(int i = 1; i < N; i++) {
		f[i] = f[i-1]*i%M;
		inv[i] = Pow(f[i], M-2);
	}
}

void solve() {
	pre();
	int n; cin >> n;
	int ans = 0;
	for(int i = 2; i <= n; i++) {
		int add = ncr(n, i);
		add *= (Pow(2, i)-2+M)%M;
		add %= M;
		ans += add*Pow(8, n-i)%M;
		ans %= M;
	}
	cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    int test = 1;
    // cin >> test;
    
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


Measured memory_bytes: 19436