akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define MINF 0xc0c0c0c0
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
static const double EPS = 1e-8;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int compute_optimal_swing(int level2_satisfaction,
                          int level1_satisfaction,
                          int none_satisfaction,
                          int level2_remaining,
                          int level1_remaining
){
  int res = none_satisfaction;
  for(int use_level2 = 0; use_level2 <= level2_remaining; use_level2++){
    for(int use_level1 = 0; use_level1 <= level1_remaining; use_level1++){
      if(use_level2 + use_level1 > 8) continue;
      if(use_level2 ==0 &&  use_level1 == 0) continue;
      res = max(level2_satisfaction * use_level2
                + level1_satisfaction * use_level1,res);
    }
  }
  return res;
}

int main(){
  int total_songs;
  int cyalume;
  while(~scanf("%d %d",
               &total_songs,
               &cyalume)){

    int dp[51][51]; //next accumulate
    memset(dp,0xc0,sizeof(dp));
    dp[0][0] = 0;

    int res = MINF;
    for(int song_idx=0;song_idx < total_songs;song_idx++){
      int level2_satisfaction,level1_satisfaction,none_satisfaction;
      scanf("%d %d %d",
            &level2_satisfaction,
            &level1_satisfaction,
            &none_satisfaction);

      int next_dp[51][51];
      memset(next_dp,0xc0,sizeof(next_dp));
      
      for(int accumulate=cyalume;accumulate>=0;accumulate--){
        for(int prev=0;prev<=cyalume;prev++){
          if(prev > accumulate) continue;

          for(int next=0;next<=cyalume;next++){
            if(dp[prev][accumulate - next] == MINF) continue;
            if(accumulate - next < 0) continue;

            next_dp[next][accumulate] 
              = max(dp[prev][accumulate - next]
                    + compute_optimal_swing(level2_satisfaction,
                                            level1_satisfaction,
                                            none_satisfaction,
                                            next,prev),
                    next_dp[next][accumulate]);

            if(song_idx == total_songs - 1){
              res = max(res,next_dp[next][accumulate]);
            }
          }
        }
      }
      
      memcpy(dp,next_dp,sizeof(int)*51*51);
    }

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

Measured memory_bytes: 1228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 1000000001


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

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

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}
#define MAX_VALUE 1000
int main(void) {
	
	ll N,W;
	inp(N);
	inp(W);
	vector<ll> weight(N);
	vector<ll> value(N);
	rep(i,N){
		inp(weight[i]);
		inp(value[i]);
	}
	ll V = MAX_VALUE*N;
	vector<vector<ll>> dp_w(N+1, vector<ll>(V+1));
	rep(i,N)rep(v,V+1) dp_w[i][v] = INF;
	dp_w[0][0] = 0;
	ll ans = 0;
	rep2(i,1,N+1)rep(v,V+1){// i:品物番号 v:ナップサックの中の価値
		if( value[i-1] <= v && dp_w[i-1][v-value[i-1]] < INF
		&& dp_w[i-1][v-value[i-1]]+weight[i-1]<=W ){//入れてその価値になりうるなら
			dp_w[i][v] = min(dp_w[i-1][v-value[i-1]]+weight[i-1],//入れたら重さを増やす
							dp_w[i-1][v]//入れない場合は上のやつ
							);
		}else{//価値がオーバーする
			dp_w[i][v] = dp_w[i-1][v];
		}
		if(dp_w[i][v]<INF && ans<v) ans = v;
	}
/*	
	rep(i,N+1){
		for(int v=0; v<30; v+=10){
			cout << dp_w[i][v] << " , ";
		}
		cout << endl;
	}
*/
	out(ans);
	
		
}


Measured memory_bytes: 80256
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            long temp = 0;
            long count = 0;
            
            Map<Long, Long> map = new HashMap<Long, Long>();
            
            map.put((long)0, (long)1);
            
            for(int i=0; i<n; i++){
            	temp += Integer.parseInt(sc.next());
            	
            	if(map.get(temp) == null){
            		map.put(temp, (long)1);
            	}else{
            		map.put(temp, map.get(temp) + 1);
            	}
            }
            
    		for (Long val : map.values()) {
    			count += (val * (val-1)) / 2;
    		}
            
            //出力
            System.out.println(count);
            sc.close();
        }
    }
	

Measured memory_bytes: 67320
//
// ABC055B
// URL : https://atcoder.jp/contests/abc055/tasks/abc055_b
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC055B
    {
        public static readonly long CONSTANT = (int)Math.Pow(10.0f, 9) + 7;
        static void Main(string[] args)
        {
            preprocess();
            long n = long.Parse(Console.ReadLine());

            long ans = 1;
            for(int i = 2; i <= n; ++i)
            {
                ans *= i;
                ans = ans % CONSTANT;
            }


            Console.WriteLine(ans.ToString());
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

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

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}



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

int main()
{
	long long int n,m,k,sum=0,index=-1,subsum = 0;
	cin>>n>>m>>k;
	
	vector<long long int >a(n),b(m);
	
	for(long long int i=0;i<n;i++)
	{
		cin>>a[i];
		
		if(i!=0)
		a[i] += a[i-1];
		
		if(a[i]<=k)
		{
			subsum = (i+1);
		}
	}
	//cout<<"hi";
	for(long long int i=0;i<m;i++)
	{
		cin>>b[i];
		
		if(i!=0)
		{
			b[i] += b[i-1];
		}
		//cout<<"gi";
		if(b[i]<=k)
		{
			index = i;
		}
	}
	
	//cout<<"hi";
	for(long long int i=0;i<=index;i++)
	{
		if(b[i]>k)
		{
			break;
		}
		long long int subk = k-b[i];
		
		sum = max(sum , (i+1 + (upper_bound(a.begin(),a.end(),subk) - a.begin())));
	}

	cout<<max(sum,subsum);
	
	return 0;
}

Measured memory_bytes: 6428
N, K = map(int, input().split())
As = list(map(int, input().split()))
for i in range(K):
  if min(As) == N:
    break
  dBs = [0]*(N+1)
  for i in range(N):
    A = As[i]
    dBs[max(0, i-A)] += 1
    dBs[min(N, i+A+1)] -= 1
  #print(dBs)
  Bs = [dBs[0]]
  for i in range(1, N):
    B = Bs[i-1]+dBs[i]
    Bs.append(B)
  As = Bs
print(" ".join(map(str, As)))


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  
        for (int b = 0; b + a <= N; ++b) {  
            int c = N - a - b;  
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

   
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Dice dice = new Dice(br.readLine().split(" "));
        int q = Integer.parseInt(br.readLine());
        String[] input;
        int top;
        int front;
        for (int i = 0; i < q; i++) {
            input = br.readLine().split(" ");
            top = Integer.parseInt(input[0]);
            front = Integer.parseInt(input[1]);

            dice.setTopFace(top);
            dice.setFrontFace(front);

            System.out.println(dice.getFace(3));
        }
    }
}

class Dice {
    private int[] dice = new int[6];

    Dice (String[] num) {
        for (int i = 0; i < 6; i++) {
            dice[i] = Integer.parseInt(num[i]);
        }
    }

    public void roll (char direction) {
        int temp;
        switch (direction) {
            case 'N':
            temp = dice[0];
            dice[0] = dice[1];
            dice[1] = dice[5];
            dice[5] = dice[4];
            dice[4] = temp;
            break;

            case 'S':
            temp = dice[0];
            dice[0] = dice[4];
            dice[4] = dice[5];
            dice[5] = dice[1];
            dice[1] = temp;
            break;

            case 'E':
            temp = dice[0];
            dice[0] = dice[3];
            dice[3] = dice[5];
            dice[5] = dice[2];
            dice[2] = temp;
            break;

            case 'W':
            temp = dice[0];
            dice[0] = dice[2];
            dice[2] = dice[5];
            dice[5] = dice[3];
            dice[3] = temp;
            break;
        }
    }

    public int getFace (int num) {
        return dice[num - 1];
    }

    public void setTopFace (int top) {
        if (top == dice[1]) {
            this.roll('N');
        } else if (top == dice[2]) {
            this.roll('W');
        } else if (top == dice[3]) {
            this.roll('E');
        } else if (top == dice[4]) {
            this.roll('S');
        } else if (top == dice[5]) {
            this.roll('N');
            this.roll('N');
        }
    }

    public void setFrontFace (int front) {
        int temp;
        if (front == dice[2]) {
            temp = dice[1];
            dice[1] = dice[2];
            dice[2] = dice[4];
            dice[4] = dice[3];
            dice[3] = temp;
        } else if (front == dice[3]) {
            temp = dice[1];
            dice[1] = dice[3];
            dice[3] = dice[4];
            dice[4] = dice[2];
            dice[2] = temp;
        } else if (front == dice[4]) {
            temp = dice[1];
            dice[1] = dice[4];
            dice[4] = temp;
            temp = dice[2];
            dice[2] = dice[3];
            dice[3] = temp;
        }
    }
}

Measured memory_bytes: 24312
N = int(input())
h = list(map(int,input().split()))
count = 0
def island(h):
    global count
    while 0 not in h:
        for i in range(len(h)):
            h[i] -= 1
        count += 1

def devide(h):
    h2 = []
    h3 = []
    for i in h:
        if i == 0:
            h2.append(h3)
            h3 = []
        if i != 0:
            h3.append(i)
    h2.append(h3)


    for i in h2:
        if i == []:
            continue
        else:
            island(i)
            devide(i)
            
island(h)
devide(h)
print(count)

Measured memory_bytes: 3064
inf = float('inf')


def rec(cur, partially_solved, solve_num, score):
    if cur == d:
        return solve_num if score >= g else inf

    res = rec(cur + 1, partially_solved, solve_num, score)
    res = min(res,
              rec(cur + 1, partially_solved, solve_num + p[cur], score + p[cur] * (cur + 1) * 100 + c[cur]))
    if not partially_solved:
        for i in range(1, p[cur]):
            res = min(res,
                      rec(cur + 1, True, solve_num + i, score + i * (cur + 1) * 100))
    return res


d, g = map(int, input().split())

p, c = [], []
for _ in range(d):
    tp, tc = map(int, input().split())
    p.append(tp)
    c.append(tc)
print(rec(0, False, 0, 0))


Measured memory_bytes: 3064
import numpy as np
N = input()

N = int(N)
strs = []
for ii in range(N):
  stri = input()
  strs.append(stri)
strs = np.sort(strs)

ustr, idx = np.unique(strs,return_index=True)
cnts = []
for ii in range(len(idx)-1):
  c = idx[ii+1] - idx[ii]
  cnts.append(c)

cnts.append(N - idx[len(idx)-1]) #最後の文字のカウント
maxcnt = np.max(cnts)

ans = []

for ii in range(len(idx)):
  if cnts[ii] == maxcnt:
    ans.append(ustr[ii])

for ii in range(len(ans)):
  print(ans[ii])

Measured memory_bytes: 69388
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

#include <math.h> 

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) if (num % i == 0) return false;
    return true;
}

int main(){
  long long  N;
  cin >> N;
  if(N==1) {
    cout << 0 << endl;
    return 0;
  }
  if(IsPrime(N)) {
    cout << 1 << endl;
    return 0;
  }

  int ans = 0;
  double root = sqrt(N);
  for(int i=2; i<=root; i++) {
    int cnt = 0;
    while(N%i==0) {
      N /= i;
      cnt++;
      long long z = i*i;
      while(N%z==0) {
        N /= z;
        z *= i;
        cnt++;
      }
      for (int j=0; j<cnt;j++){
        z/=i;
        if (N%z==0) N/=z;
      }
    }
    ans += cnt;
  }
  if (N!=1) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define ff first
#define ss second
#define mp make_pair

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define MOD 1000000007LL
#define N 100005

vector<int> adj[N];
ll val[N];

void dfs(int v, int p){
   if(p && adj[v].size() == 1) return;

   long long s = 0, big = 0;
   for(int x : adj[v]){
      if(x == p) continue;
      dfs(x, v);
      s += val[x];
      big = max(big, val[x]);
   }
   ll a, b, mx;
   mx = min(s / 2, s - big);
   a = s - val[v];
   b = val[v] - a;
   if(a < 0 || b < 0 || a > mx){
      cout<<"NO";
      exit(0);
   }

   val[v] = b;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
   int n;
   cin>>n;

   for(int i = 1; i <= n; i++){
      cin>>val[i];
   }
   for(int i = 1; i < n; i++){
      int v, u;
      cin>>v>>u;
      adj[v].pb(u);
      adj[u].pb(v);
   }
   if(n == 2){
      cout<< (val[1] == val[2] ? "YES" : "NO");
      return 0;
   }

   int t = 1;
   while(adj[t].size() == 1) t++;

   dfs(t, 0);
   if(!val[t])cout<<"YES";
   else cout<<"NO";
}


Measured memory_bytes: 13184
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = (int)1e+3;
const int MAX_M = (int)1e+2;
int a, b, c, d;
void input()
{
	cin >> a >> b >> c >> d;
}
int main() {
	input();
	int ans1 = a*b;
	int ans2 = c*d;
	if (ans1 > ans2) {
		cout << ans1 << endl;
	}
	else {
		cout << ans2 << endl;
	}
	return 0;
}

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

typedef long long ll;

ll mod=998244353;

ll modinv(ll a){
  ll b=mod,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod;
  if(u<0) u+=mod;
  return u;
}

ll fac[300010];

void modfac(){
  fac[0]=1;
  for(ll i=1;i<300010;i++){
    fac[i]=(fac[i-1]*i)%mod;
  }
}

ll modcomb(ll n,ll k){
  return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

int main(){
  ll n,a,b,k;
  cin >> n >> a >> b >> k;
  modfac();
  ll ans=0;
  for(ll i=0;i<=n;i++){
    ll x=k-a*i;
    if(x>=0&&x%b==0&&x/b<=n){
      ll count=(modcomb(n,i)*modcomb(n,x/b))%mod;
      ans=(ans+count)%mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0;i<n;i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0,n=(int)s.size();
    rep(i,n)for(int j=i;j<n;j++){
        bool bl=true;
        for(int k=i;k<=j;k++){
            if(s.at(k) != 'A' & s.at(k) != 'G' & s.at(k) != 'C' & s.at(k) != 'T') bl=false;
        }
        if(bl)ans=max(ans,j-i+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

class union_find {
    vector<int> par, sz;

public:
    union_find(int n) {
        par.resize(n);
        sz.resize(n, 0);
        for (int i = 0; i < n; i++)
            par[i] = i;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else 
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);

        if (sz[y] > sz[x])
            par[x] = y;
        else
        {
            par[y] = x;
            if (sz[x] == sz[y])
                sz[x]++;
        }
    }

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

int main() {
    int n, m;   cin >> n >> m;
    union_find uf(n);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }


    vector<long long> cnt(n, 1);
    vector<long long> tmp(m+1); //i回目の崩壊後に連結な島の組の数
    tmp[m] = 0;
    for (int i = m-1; i >= 0; i--) {
        a[i] = uf.find(a[i]);
        b[i] = uf.find(b[i]);
        if (uf.same(a[i], b[i])) {
            tmp[i] = tmp[i+1];
            continue;
        }
        uf.unite(a[i], b[i]);
        tmp[i] = tmp[i+1] + cnt[a[i]] * cnt[b[i]];
        if (uf.find(b[i]) == a[i])
            swap(a[i], b[i]);
        
        cnt[b[i]] += cnt[a[i]];
        cnt[a[i]] = 0;
    }
    
    for (int i = 0; i < m; i++) 
        cout << tmp[0] - tmp[i+1] << endl;
    return 0;
}


Measured memory_bytes: 6372
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        bool flag = Calq(n);

        if (flag) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }

    static bool Calq(int n)
    {
        bool flag = false;

        if (n < 4) return flag;
        else
        {
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 26; j++)
                {
                    if (7 * i + 4 * j > 100) break;
                    else if (7 * i + 4 * j == n)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag == true) break;
            }
        }

        return flag;
    }
}

Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly int WHITE = 0;
        static readonly int GRAY = 1;
        static readonly int BLACK = 2;


        static long prim(long n, long[][] M)
        {
            long u, minv;
            var d = new long[n];
            var p = new long[n];
            var color = new long[n];

            for (var i = 0; i < n; ++i)
            {
                d[i] = long.MaxValue;
                p[i] = -1;
                color[i] = WHITE;
            }
            d[0] = 0;
            while (true)
            {
                minv = long.MaxValue;
                u = -1;
                for (var i = 0; i < n; ++i)
                {
                    if (d[i] < minv && color[i] != BLACK)
                    {
                        u = i;
                        minv = d[i];
                    }
                }
                if (u == -1) break;
                color[u] = BLACK;
                for (var v = 0; v < n; ++v)
                {
                    if (color[v] != BLACK && M[u][v] != long.MaxValue)
                    {
                        if (M[u][v] < d[v])
                        {
                            d[v] = M[u][v];
                            p[v] = u;
                            color[v] = GRAY;
                        }
                    }
                }
            }
            long sum = 0;
            for (var i = 0; i < n; ++i)
            {
                if (p[i] != -1) sum += M[i][p[i]];
            }
            return sum;
        }

        static void Main(string[] args)
        {
            var N = Sarray()[0];

            var M = new long[N][];
            for (var i = 0; i < N; ++i)
            {
                M[i] = Sarray().Select(e => e == -1 ? long.MaxValue : e).ToArray();
            }
            WriteLine(prim(N, M));
        }
    }
}


Measured memory_bytes: 18432
#include<bits/stdc++.h>
using namespace std;
char a[55][55];
int dis[8][2]={1,0,1,-1,0,-1,-1,-1,-1,0,-1,1,0,1,1,1};
int main()
{
    int m,n,i,j,k;
    while(cin>>m>>n)
    {
        for(i=0;i<m;i++)
        {
            cin>>a[i];
        }
        for(i=0;i<m;i++)
        {
            for(j=0;j<n;j++)
            {
                if(a[i][j]=='.')
                {
                    int count=0;
                    for(int k=0;k<8;k++)
                    {

                        int disx=i+dis[k][0];
                        int disy=j+dis[k][1];
                        //cout<<disx<<' '<<disy<<endl;
                        if(disx>=0&&disx<m&&disy>=0&&disy<n&&a[disx][disy]=='#')
                        {
                            count++;
                        }
                    }
                    //cout<<"ha"<<endl;
                    a[i][j]='0'+count;
                }
            }
        }
        for(i=0;i<m;i++)
        {
            for(j=0;j<n;j++)
                cout<<a[i][j];
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int count=0;
    string s,t;
    cin>>s;
    cin>>t;
    rep(i,3)
    {
        if(s[i]==t[i])count++;
    }
    cout<<count;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    cout << min(N - N/K * K, abs(N - N/K * K - K)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int ans;
	int b[5];
	int max = 100;
	for (int i = 0; i < 5; i++) {
		b[i] = (a[i] - 1) % 10;
		if (b[i] < max) {
			max = b[i];
			ans = i;
		}
	}
	int ans2 = 0;
	for (int i = 0; i < 5; i++) {
		if (i == ans) ans2 += a[i];
		else if (a[i] % 10 == 0) ans2 += a[i];
		else ans2 += (a[i] / 10 + 1) * 10;
	}
	cout << ans2;
	return 0;
}

Measured memory_bytes: 256
// B - Minesweeper
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int dy[]{-1, 1, 0, 0, -1, 1, -1, 1};
	int dx[]{ 0, 0,-1, 1, -1, 1,  1,-1};
	int H,W; cin>>H>>W;
	string S[H]; rep(i, H) cin>>S[i];
	rep(h, H)
		rep(w, W){
			if(S[h][w] == '#') continue;
			int c = 0;
			rep(k, 8){
				int y = h + dy[k], x = w + dx[k];
				if(y<0 || H<=y || x<0 || W<=x) continue;
				if(S[y][x] == '#') c++;
			}
			S[h][w] = c + '0';
		}
	rep(h, H) cout<<S[h]<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V))                                                           \
  cout << v << " "
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
}
template < class T > bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  string S = to_string(N);
  int sum = 0;
  REPR(i, S.size() - 1) { sum += S[i] - '0'; }
  if (N % sum == 0) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int H,W;
string s[20];
int dir[5]={0,1,0,-1,0};
vector<vector<int> >calc(int sx,int sy)
{
	vector<vector<int> >d(H,vector<int>(W,1e9));
	d[sx][sy]=0;
	queue<pair<int,int> >P;
	P.push(make_pair(sx,sy));
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;
		P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=x+dir[r],ty=y+dir[r+1];
			if(tx<0||ty<0||tx>=H||ty>=W||s[tx][ty]=='#'||d[tx][ty]<=d[x][y]+1)continue;
			d[tx][ty]=d[x][y]+1;
			P.push(make_pair(tx,ty));
		}
	}
	return d;
}
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	int ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(s[i][j]=='#')continue;
		vector<vector<int> >d=calc(i,j);
		for(int I=0;I<H;I++)for(int J=0;J<W;J++)
		{
			if(s[I][J]!='#')ans=max(ans,d[I][J]);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	int flag = 1;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x % 2 == 0){
			if((x % 3) && (x % 5))
				flag = 0;
		}
	}
	if(flag == 0)
		cout << "DENIED\n";
	else
		cout << "APPROVED\n";

	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,K;
    cin >> N >> K;
    double P[N];
    rep(i,N) cin >> P[i];
    rep(i,N) P[i]=(1+P[i])/2;
    double ans=0;
    double now=0;
    lint sum[N+1]={};
    rep(i,K) now+=P[i];
    ans=now;
    for(int i=K;i<N;i++){
        now-=P[i-K];
        now+=P[i];
        ans=max(ans,now);
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

void solve() {
    string s, t;
    cin >> s >> t;

    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
    vector<vector<pair<int, int>>> piv(s.size() + 1, vector<pair<int, int>>(t.size() + 1, {0, 0}));
    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                piv[i][j] = {i, j};
            }
            if (dp[i][j - 1] > dp[i][j]) {
                dp[i][j] = dp[i][j - 1];
                piv[i][j] = piv[i][j - 1];
            }
            if (dp[i - 1][j] > dp[i][j]) {
                dp[i][j] = dp[i - 1][j];
                piv[i][j] = piv[i - 1][j];
            }
        }
    }

    string ans;
    pair<int, int> now = piv[s.size()][t.size()];
    while (now != pair<int, int>{0, 0}) {
        ans.push_back(s[now.first - 1]);
        now = piv[now.first - 1][now.second - 1];
    }

    reverse(ans.begin(), ans.end());
    cout << ans;
}

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

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

    return 0;
}


Measured memory_bytes: 105984
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int a,b;
    while(cin>>a>>b){
        bool got=0;
       for(int i=1;i<=10000;i++){
            int ta=(i)*0.08;
            int tb=(i)*0.1;
            if(a==ta && b==tb){
                cout << i << endl;
                got=1;
                break;
            }
       }
       if(!got)cout << -1 << endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
  int A,B,K;
  int i=1,j=1;
  int C[100];
  scanf("%d %d %d",&A,&B,&K);
  
  for(i=1;i<=A && i<=B;i++){
      if((A%i==0) &&(B%i==0)){
      C[j]=i;
      j++;
      }
  }
  printf("%d",C[j-K]);
  
  return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353 //1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int st[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,x,m;
   cin>>n>>x>>m;
   int ans=0;
   map<int,int>mp;
   int i=1;
   int last=(x);
   while(mp.find(last)==mp.end() && i<=n)
   {   st[i]=last;
       mp[last]=i++;
       ans+=(last);
       last=(last*last)%m;
   }
   if(i>n)
   {
       cout<<ans<<endl;
       return 0;
   }
   else
   {
       int len=(i-mp[last]);
       n-=(i-1);
       int idx=mp[last];
       int s=0;
       for(int j=idx;j<i;j++)
        s+=st[j];
       int rem=(n%len);
       ans+=((n/len) * s);
       for(int j=idx;j<(idx+rem);j++)
        ans+=st[j];
       cout<<ans<<endl;
   }

}


Measured memory_bytes: 7092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, a[128];
	ll dp[128][21];
	scanf("%d", &n);
	rep(i, n)
		scanf("%d", a + i);

	memset(dp, 0, sizeof(dp));
	dp[0][a[0]] = 1;
	for (int i = 1; i < n - 1; ++i)
	{
		for (int j = 0; j <= 20; ++j)
		{
			int pl = j + a[i];
			int mi = j - a[i];
			if (0 <= pl && pl <= 20)
				dp[i][pl] += dp[i - 1][j];
			if (0 <= mi && mi <= 20)
				dp[i][mi] += dp[i - 1][j];
		}
	}
	printf("%lld\n", dp[n - 2][a[n - 1]]);
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int n,x;
  cin>>n>>x;
  Vi V(n);
  int sum = 0;
  int min_g = 1000;
  rep(i,n){
    cin >> V[i];
    sum += V[i];
    min_g = min(min_g, V[i]);
  }
  
  cout << n + (x-sum)/min_g << endl;
}      
       



Measured memory_bytes: 3604
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf("%d", &N);
    char S[N+1];
    scanf("%s", S);
    int K;
    scanf("%d", &K);
    
    char target = S[K-1];
    int i;
    for(i = 0; i < N; i++){
        if(target != S[i]){
            putchar('*');
        }else{
            putchar(S[i]);
        }
    }
    putchar('\n');
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int x, y;
	cin >> x >> y;

	cout << x + y / 2 << "\n";


}

Measured memory_bytes: 256
import itertools
def f(s):
 for a,b,c,d in itertools.permutations(s):
  for x,y,z in itertools.product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"{a} {x} ({b} {y} ({c} {z} {d}))",f"({a} {x} ({b} {y} {c})) {z} {d}",f"{a} {x} (({b} {y} {c}) {z} {d})"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5672
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxl = 33;

char S[maxl];
int vis[26];
char ans[maxl];

int len = 0;

int main() {
    scanf("%s", S+1);
    len = (int) strlen(S+1);
    memcpy(ans, S, sizeof(S));
    for (int i = len; i >= 0; i--) {
        memset(vis, 0, sizeof(vis));
        for (int j = 1; j <= i; j++) {
            vis[S[j]-'a'] = 1;
        }
        for (int j = 0; j < 26; j++) {
            if (!vis[j] && (i == len || j > (S[i+1]-'a'))) {
                int cur = i;
                ans[++cur] = j+'a';
                ans[cur+1] = 0;
                puts(ans+1);
                return 0;
            }
        }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())

q = deque([i for i in range(1,10)])
for i in range(k):
  a = q.popleft()
  
  if a%10 != 0:
    q.append(a*10 + a%10 - 1)
    
  q.append(a*10 + a%10)
  
  if a%10 != 9:
    q.append(a*10 + a%10 + 1)
print(a)

Measured memory_bytes: 18684
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	string x;
	cin >> x;
	x[3]='8';
	cout << x << endl;
	system("pause");
	return 0;
}


Measured memory_bytes: 504
//Tuvshee
 
#include<iomanip>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define V void
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define anD &&
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
V pRec(I m,I n)
{
	reps(0,m,i){
		reps(0,n,j)cout<<'#';
		cout<<eL;
	}
}

int main()
{
	I m,n;
	for(int i=0;;i++){
		cin>>m>>n;
		if(m==0 anD n==0)rtn 0;
		pRec(m,n);
		cout<<eL;
	}
}

Measured memory_bytes: 1152
n = int(input())
a = [input() for _ in range(n)]
al = [[0]*26 for _ in range(n)]
alph = 'abcdefghijklmnopqrstuvwxyz'
for i,s in enumerate(a):
    for k in s:
        al[i][alph.index(k)] += 1
        
ans = ''
for i in range(26):
    cnt = float('inf')
    for j in range(n):
        cnt = min(cnt, al[j][i])
    ans += alph[i]*cnt
ans = sorted(list(ans))
print(''.join(ans))

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int n, k;
	sii(n, k);
	char cad[n+6];
	ss(cad);
	int tip = 1, sum = 0, cnt = 0;
	for(int i = 1; i < n; i++)
	{
		if(cad[i-1] == cad[i])
			cnt++;
		else
		{
			tip++;
			sum += cnt;
			cnt = 0;
		}
	}
	sum += cnt;
	if(tip/2 <= k)
		sum = n-1;
	else
		sum += k*2;
	printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int c=0;
	while(-1){
		c++;
		int a;cin>>a;
		if(a==0){RE;}
		cout<<"Case "<<c<<": "<<a<<endl;
	}
	RE;
}


Measured memory_bytes: 2988
s = input()

start_0 = 0
start_1 = 0

for i, l in enumerate(s):
  if i % 2 == 0:
    start_0 += int(l) # 偶数番目が１のとき、０１０１０はエラー
    start_1 += 1-int(l)
  else:
    start_0 += 1-int(l)
    start_1 += int(l) # 奇数番目が１のとき、１０１０１は

print(min([start_0, start_1]))

Measured memory_bytes: 3188
A = []
b = []

n, m = map(int, input().split())
for i in range(n):
    A.append([int(i) for i in input().split()])
for i in range(m):
    b.append(int(input()))

# with open('input_itp1_6_d_1.txt', mode='r', encoding='utf8') as f:
#     n, m = map(int, next(f).split())
#     try:
#         for i in range(n):
#                 A.append([int(i) for i in next(f).split()])
#         for i in range(m):
#             b.append(int(next(f)))
#     except StopIteration:
#         raise ValueError('入力データがおかしい')

c = []
for i in range(len(A)):
    tmp = 0
    for j in range(len(A[i])):
        tmp += A[i][j] * b[j]
    c.append(tmp)
for i in range(len(c)):
    print(c[i])


Measured memory_bytes: 6012