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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, W;
  IN(N, W);
  vll w(N), v(N);
  ll v_sum = 0;
  ll w_sum = 0;
  REP(i,N){
    IN(w[i], v[i]);
    v_sum += v[i];
    w_sum += w[i];
  }

  vll dp(v_sum+1, w_sum+1);
  dp[0] = 0;
  vll dp_copy;
  REP(i,N){
    dp_copy = dp;
    REP(j,v[i]+1){
      chmin(dp[j], w[i]);
    }
    REP(j,v_sum+1){
      if(j+v[i]>=v_sum+1) break;
      chmin(dp[j+v[i]], dp_copy[j]+w[i]);
    }

    //vec_print(dp);
  }

  //vec_print(dp);

  ll ans = 0;
  REP(i,v_sum+1) if(dp[i]<=W) chmax(ans, i);
  OUT(ans);

  return 0;
}

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

int main()
{
  string a,b;
  char s;
 
  cin >>a ;
  cin>>b;
  for(int i=0;i<a.size()+b.size();i++){
    //cout << i ;
    if(i%2==0){
      s=a.at((i/2));
    }else{
      s=b.at((i/2));
    }
  
  cout <<s ;
  }
  //cout <<a.at(0);
}



Measured memory_bytes: 256
n = int(input())
n_s = {}
for i in range(n):
  s = input()
  if s in n_s:
    n_s[s] += 1
  else:
    n_s[s] = 1

m = int(input())

for i in range(m):
  s = input()
  if s in n_s:
    n_s[s] -= 1
  else:
    n_s[s] = -1

if max(n_s.values()) < 0 :
  print(0)
else:
  print(max(n_s.values()))

Measured memory_bytes: 9176
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

import collections

dms = collections.deque()
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, D, A = LI()
xh = []
for i in range(N):
    xh.append(LI())
xh.sort()

# sum_dm = [] # start + 2 * D
ans = 0
sum_dm = 0
for i in range(N):
    X, H = xh[i]
    while len(dms) > 0:
        if dms[0][0] + 2 * D < X:
            x, dm = dms.popleft()
            sum_dm -= dm
        else:
            break
    H -= sum_dm
    if H > 0:
        ans += math.ceil(H / A)
        dms.append([X, math.ceil(H/A) * A])
        sum_dm += math.ceil(H/A) * A
print(ans)


Measured memory_bytes: 117976
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;

#define N 500000
int key[N];
int rt[N];
int lt[N];
int parent[N];
int np = 0;
int root = -1;

void insert(int k){
	int y = -1;
	int x = root;
	while(x!=-1){
		y = x;
		if(k < key[x]){
			x = lt[x];
		}else{
			x = rt[x];
		}
	}
	if(y==-1){
		root = np;
	}else{
		if(k<key[y]){
			lt[y] = np;
		}else{
			rt[y] = np;
		}
	}
	key[np] = k;
	parent[np] = y;
	np++;
}

void saiki1(int x){
	if(lt[x]!=-1) saiki1(lt[x]);
	cout << " " << key[x];
	if(rt[x]!=-1) saiki1(rt[x]);
}

void saiki2(int x){
	cout << " " << key[x];
	if(lt[x]!=-1) saiki2(lt[x]);
	if(rt[x]!=-1) saiki2(rt[x]);
}
void print(){
	saiki1(root);
	cout << endl;
	saiki2(root);
	cout << endl;
}


int main(){

	for(int i=0; i<N; i++){
		key[i] = -1;
		parent[i] = -1;
		lt[i] = -1;
		rt[i] = -1;
	}

	int n;
	cin >> n;
	for(int i=0; i<n; i++){
//		cout << i << endl;
		string s;
		cin >> s;
		if(s=="print"){
			print();
		}else if(s=="insert"){
			int k;
			cin >> k;
			insert(k);
		}
	}


	return 0;
}

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N;
  vector<string>s(N);
  for(int i=0;i<N;i++)
    cin>>s.at(i);
  cin>>M;
  vector<string>t(M);
  for(int j=0;j<M;j++)
    cin>>t.at(j);
  map<string,int>U;
  for(int i=0;i<N;i++){
  if(U.count(s.at(i))){
  U.at(s.at(i))++;
  }else
    U[s.at(i)]=1;
  
  }
  for(int i=0;i<M;i++){
  if(U.count(t.at(i))){
  U.at(t.at(i))--;
  }
  }
  int ans=0;
  for(auto p:U){
  auto k=p.first;
    auto v=p.second;
    if(ans<=v)
      ans=v;
    }
  cout<<ans<<endl;
  
  
  
  return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
//const int inf = pow(2, 31) - 10;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */




signed main(){

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


    int n;
    cin >> n;

    vi arr; rep(i,0,n * 3) arr.push_back(input());

    int a = 0;
    priority_queue<int, vi, greater<int>> a_que;
    rep(i,0,n){
        a_que.push(arr[i]);
        a += arr[i];
    }
    vi suma;
    suma.push_back(a);

    rep(i,0,n){
        a_que.push(arr[n + i]);
        a += arr[n + i];
        a -= a_que.top();
        a_que.pop();
        suma.push_back(a);
    }

    int b = 0;
    vi sumb;
    priority_queue<int> b_que;
    revrep(i,3 * n - 1, 2 * n - 1){
        b_que.push(arr[i]);
        b += arr[i];
    }

    sumb.push_back(b);

    revrep(i,2 * n - 1, n - 1){
        b_que.push(arr[i]);
        b += arr[i];
        b -= b_que.top();
        b_que.pop();
        sumb.push_back(b);
    }
    
    reverse(all(sumb));


    int ans = -1 * inf;
    rep(i,0,n + 1){
        chmax(ans,suma[i] - sumb[i]);
    }
    print(ans);





    




    

    





    

   




    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 8556
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
 int A,B,C,K,s;
 cin>>A>>B>>C>>K;
s = max({A,B,C});
if(s == A){
  for(int i = 0;i < K;i++){
     s = s*2;
  }
  cout<<s+B+C;
}
if(s == B){
  for(int i = 0;i < K;i++){
     s = s*2;
  }
  cout<<s+A+C;
}
if(s == C){
  for(int i = 0;i < K;i++){
     s = s*2;
  }
  cout<<s+B+A;
}

   return 0;
}

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    if ( s[i] == '+' ) cnt++;
    else cnt--;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#coding:utf-8
#1_5_B
def merge(array, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = array[left:mid]  + [sentinel]
    R = array[mid:right] + [sentinel]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1
    cnt += right - left

def merge_sort(array, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(array, left, mid)
        merge_sort(array, mid, right)
        merge(array, left, mid, right)


n = int(input())
S = list(map(int, input().split()))
cnt = 0
sentinel = 10 ** 9 + 1
merge_sort(S, 0, len(S))
print(*S)
print(cnt)

Measured memory_bytes: 63780
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

minN = sys.maxsize
for i in range(len(S)-2) :
  minN = min(minN, abs(int(S[i:i+3]) - 753))

print (minN)

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>=10||a>10||b>10) cout<<"error"<<endl;//如果a+b大于等于10，输出error
    else cout<<a+b<<endl;//否则输出a+b
    return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush 


if __name__ == '__main__':
	n = int(input())
	graph = [[-1]*n for i in range(n)]
	for i in range(n):
		node_data = list(map(int, input().split()))
		index = node_data[0]
		edge_num = node_data[1]
		node_list = node_data[2:]
		for i in range(edge_num):
			graph[index][node_list[i * 2]] = node_list[i * 2 + 1]

	cost_map = [-1 for i in range(n)]

	heap_q = []
	heap_q.append((0, 0))

	while len(heap_q) != 0:
		node = heappop(heap_q)
		cost = node[0]
		u = node[1]

		if cost_map[u] != -1:
			continue
		cost_map[u] = cost

		for v in range(n):
			if graph[u][v] != -1:
				heappush(heap_q, (graph[u][v] + cost, v))

	for i in range(n):
		print(i, cost_map[i])



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

int main(){
  int h[50],p,n,i,all;
 loop:
  scanf("%d %d",&n,&p);
  for(i=0;i<n;i++){
    h[i]=0;
  }
  
  if(n==0 && p==0){
    exit(0);
  }
  all=p;

  while(1){
    for(i=0;  i<n; i++ ){
      
      p--;
      if(p<0){
	p=0;
	p=h[i];
	h[i]=0;
      }
      else{
	h[i]++;
      }
      
      if(h[i]==all){
	printf("%d\n",i);
	goto loop;
      }
    }
  }
}
      

  

  

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin>>h>>w>>n;
    ll num=max(h,w);
    cout << (n+num-1)/num<<endl;
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N+1, vector<int>());
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<vector<int>> dp(N+1, vector<int>(11, 0));
    int Q;
    cin >> Q;
    vector<int> c(Q+1, 0);
    for (int i = 1; i <= Q; i++) {
        int v, d;
        cin >> v >> d >> c[i];
        dp[v][d] = i;
    }
    for (int i = 9; i >= 0; i--) {
        for (int v = 1; v <= N; v++) {
            dp[v][i] = max(dp[v][i], dp[v][i+1]);
            for (int u : edge[v]) {
                dp[v][i] = max(dp[v][i], dp[u][i+1]);
            }
        }
    }
    for (int v = 1; v <= N; v++) cout << c[dp[v][0]] << endl;
    return 0;
}


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


void solve(long long A, long long B, long long T){
  cout << T / A * B << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long T;
    scanf("%lld",&T);
    solve(A, B, T);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1e18
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
vector <long long> v[8];
int main() {
    long long n,m,x,y,z;
    cin>>n>>m;
    for (int i=1;i<=n;i++){
        cin>>x>>y>>z;
        for (int j=0;j<8;j++){
            long long t=0;
            j&1 ? t+=x : t-=x;
            j&2 ? t+=y : t-=y;
            j&4 ? t+=z : t-=z;
            v[j].pb(t);
        }
    }
    long long ans=-1*inf;
    for (int i=0;i<8;i++){
        sort(v[i].begin(),v[i].end(),greater<long long>());
        long long sum=0;
        for (int j=0;j<m;j++)
            sum+=v[i][j];
        ans=max(ans,sum);
    }
    cout<<(long long)ans<<"\n";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int count=0;
  count += N%10;
  if(count==3){
    cout << "bon" << endl;
  }else if(count==0||count==1||count==6||count==8){
    cout << "pon" << endl;
  }else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

const int N=10005,M=200005;
struct edge {
	int x,y;
	double c;
} a[M];
int n,m,u[N],x[N],y[N];

int ufind(int x)
{
	if(u[x]<0) return x;
	else return u[x]=ufind(u[x]);
}

void uunion(int x,int y)
{
	x=ufind(x); y=ufind(y);
	if(x!=y) u[x]=y;
}

bool cmp(edge a,edge b) { return a.c>b.c; }

int main()
{
	int i,cnt;
	double ans=0;
	scanf("%d%d",&n,&m);
	memset(u,-1,sizeof(u));
	for(i=1;i<=n;i++) scanf("%d%d",x+i,y+i);
	for(i=0;i<m;i++) {
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].c=hypot(x[a[i].x]-x[a[i].y],y[a[i].x]-y[a[i].y]);
		ans+=a[i].c;
	}
	std::sort(a,a+m,cmp);
	cnt=1;
	for(i=0;i<m&&cnt<n;i++) {
		if(ufind(a[i].x)==ufind(a[i].y)) continue;
		cnt++;
		ans-=a[i].c;
		uunion(a[i].x,a[i].y);
	}
	printf("%.3f",ans);
	return 0;
}	


Measured memory_bytes: 3376
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double x = sc.nextDouble();

    double S = x/a;

    if((a*b)/2>=S){
      double a1 =(2*S)/b;
      double result = Math.atan(b/a1);
      System.out.println(Math.toDegrees(result));

    }else{

      double n = a*b-S;

      double h = 2*n/a;
      n = a*h/2;

      System.out.println(Math.toDegrees(Math.atan(h/a)));

    }

  }

}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll xr = 0LL;
  vector<ll> v(n);
  for(int i=0; i<n; i++) {
    cin >> v[i];
    xr^=v[i];
  }
  for(auto& x : v)
    cout << (x^xr) << ' ';
  return 0;
}


Measured memory_bytes: 4668
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
ll getnum(ll A , ll B) {
    int len1 , len2;
    if(A == B) return 1;
    for(len1 = 0 ; ((ll)1 << len1) <= A ; len1++);
    for(len2 = 0 ; ((ll)1 << len2) <= B ; len2++);
    if(len2 < len1) {
        ll t;
        for(t = len1 - 2 ; t >= 0 ; t--)
            if(((ll)1 << t) & A) break;
        if(t == -1) t = 0;
        else t = ((ll)1 << (t + 1)) - 1;
        if(B <= t + 1) return ((ll)1 << len1) - B;
        return (((ll)1 << (len1 - 1) | t) - B + 1) + (((ll)1 << len1) - 1 - (((ll)1 << (len1 - 1)) + B) + 1);
    }
    return getnum(A ^ ((ll)1 << (len1 - 1)) , B ^ ((ll)1 << (len2 - 1)));
}
int main() {
    ll A , B;
    cin >> B >> A;
    cout << getnum(A , B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, a[101], b[101];
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++) cin >> a[i] >> b[i];
    for(int i = 1;i <= n - 2;i++)
    {
        if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2])
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    if(b>c){
        d = b;
        b = c;
        c = d;
    }
    if(a>b){
        d = a;
        a = b;
        b = d;
    }

    cout << a << " " << b << " " << c <<"\n";

    return 0;
}


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

int main() {
  int N, K, res = 0;
  cin >> N >> K;
  rep(i, N){
  	int x;
    cin >> x;
    res += min(x * 2, (K - x) * 2);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++){
      cin>> vec.at(i);
  }
  int a=0;
  int b=0;
  for(int h=0; h<n; h++){
      int j=0;
      for(int i=1; i<n;i++){
        if(vec.at(i)>vec.at(j)) j=i;
      }
      if(h%2==0) a+=vec.at(j);
      else b+=vec.at(j);
      vec.at(j)=0;
  }
  cout << a-b <<endl;
}

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

int main() {
  int x;
  scanf("%d", &x);
  switch (x) {
    case 22:
      printf("Christmas Eve Eve Eve");
      return 0;
    case 23:
      printf("Christmas Eve Eve");
      return 0;
    case 24:
      printf("Christmas Eve");
      return 0;
    case 25:
      printf("Christmas");
      return 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int h,w; cin>>h>>w;
  vector<string> s(h);
  rep(i,h) cin>>s[i];

  vector<int> dx={-1,0,1,0};
  vector<int> dy={0,1,0,-1};
  // rep(i,4)
  // cout<<dx[i]<<endl;
  vector<vector<bool>> memo(h,vector<bool>(w));

  rep(i,h){
    rep(j,w){
      if(memo[i][j]||s[i][j]=='.') continue;
      queue<P> st;
      // cout<<"iku"<<endl;
      st.push({i,j});
      while(!(st.empty())){
        int x=st.front().fs;
        int y=st.front().sc;
        rep(k,4){
          int zx=x+dx[k];
          int zy=y+dy[k];

          // if(x==0&&y==6)
          // cout<<zx<<" "<<zy<<endl;
          if(zx<0||h<=zx||zy<0||w<=zy) continue;
          if(s[zx][zy]=='#'&&!(memo[zx][zy])){
            memo[zx][zy]=1;
            // memo[zx-dx[k]][zy-dy[k]]=1;
            st.push({zx,zy});
          }
        }
        st.pop();
      }
    }
  }

  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'&&!(memo[i][j])){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }

  cout<<"Yes"<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<n;i++)
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
            i+=2;
        }   
    cout<<ans<<endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define krep(n) for(ll k=0;k<(n);k++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 2000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

ll h,w; 
ll comb(ll x, ll y){
    return 2000*x+y;
}
vector<ll> lnb(ll a){
    ll x=a/2000; ll y = a%2000;
    vector<ll> ret;
    if(x+1<=h) ret.append(comb(x+1,y));
    if(y+1<=w) ret.append(comb(x,y+1));
    if(x-1>0) ret.append(comb(x-1,y));
    if(y-1>0) ret.append(comb(x,y-1));
    return ret;
}

vector<ll> llnb(ll a){
    ll x=a/2000; ll y = a%2000;
    vector<ll> ret;
    for(ll i=-2;i<=2;i++) for(ll j=-2;j<=2;j++) if(i!=0 || j!=0){
        if(x+i<=h && x+i >0 && y+j<=w && y+j>0) ret.append(comb(x+i,y+j));
    }
    return ret;
}

ll dist[4000005];
void solve(ll ts){
    cin>>h>>w;
    rep(4000005) dist[i]=1000000000;
    ll ch,cw; cin>>ch>>cw; ll dh,dw; cin>>dh>>dw;
    vector<string> mat(h); rep(h) cin>>mat[i];
    priority_queue<pair<ll,ll>, vector <pair<ll,ll>> , greater<pair<ll,ll>>> pq;
    dist[comb(ch,cw)]=0;
    pq.push(make_pair((ll)0,comb(ch,cw)));
    while(!pq.empty()){
        ll a = pq.top().second; pq.pop();
//        cout<<a<<endl;
        for(auto i:lnb(a)){
            if(mat[i/2000-1][i%2000-1]=='.'){
                ll w=0;
                if(dist[i] > dist[a] + w){
                    dist[i]=dist[a]+w;
                    pq.push(make_pair(dist[i],i));
                }
            }
        }
        for(auto i:llnb(a)){
            if(mat[i/2000-1][i%2000-1]=='.'){
                ll w=1;
                if(dist[i] > dist[a] + w){
                    dist[i]=dist[a]+w;
                    pq.push(make_pair(dist[i],i));
                }
            }
        }
    }
//    rep(h){ jrep(w) cout<<dist[comb(i+1,j+1)]<<" "; cout<<endl; }
    if(dist[comb(dh,dw)]<1000000000){
        cout<<dist[comb(dh,dw)]<<endl;
    } else cout<<-1<<endl;
}
 
int main(){
    ffast
    ll t=1;
//    cin>>t;
    rep(t) solve(i+1);
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


Measured memory_bytes: 36000
#include<bits/stdc++.h>
using namespace std;
# define int long long
signed main(){
int N;
cin >> N;
int a = 2,b = 1,c;
for(int i = 0; i < N + 1; i++){
    if(N == 1)
    {
        cout << b << endl;
      return 0;
    }

else
{
    if(i >= 2){
        c = a + b;
        const int d = a;
        a = b;
        b = c;
    }
}

}
cout << c << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()

w_num = [0] * (n+1)
e_num = [0] * (n+1)
e = s.count('E')

for i in range(n):
    if s[i] == 'W':
        w_num[i+1] = w_num[i] + 1
    else:
        w_num[i+1] = w_num[i]
        
    if s[i] == 'E':
        e_num[i+1] = e_num[i] + 1
    else:
        e_num[i+1] = e_num[i]


ans = n

for i in range(n):
    cnt = w_num[i] + (e - e_num[i+1])
    if cnt < ans:
        ans = cnt

print(ans)

Measured memory_bytes: 17604
import java.util.Scanner;
import java.util.ArrayList;


public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        int num2 = scan.nextInt();
        int num3 = scan.nextInt();
        int max = num1+num2;
        if(max > num1 + num3)   max = num1 + num3;
        if(max > num2 + num1)   max = num2 + num1;
        if(max > num2 + num3)   max = num2 + num3;
        if(max > num3 + num1)   max = num3 + num1;
        if(max > num3 + num2)   max = num3 + num2;

         
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            if(a > b) {
                Console.WriteLine("a > b");
            }else if(a == b)
            {
                Console.WriteLine("a == b");
            }
            else
            {
                Console.WriteLine("a < b");
            }
        }
    }
}

Measured memory_bytes: 9328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> c(10, vector<int>(10, 0));
    rep1(i, N + 1)
    {
        string s = to_string(i);
        c[s[0] - 48][s[s.length() - 1] - 48]++;
    }
    ll ans = 0;
    rep1(i, 10)
    {
        rep1(j, 10)
        {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans;
    return 0;
}

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll to5(ll i) { return i * i * i * i * i; }
vector<char> ans;

bool bt(vector<int>& s, int n, int a, int b, int c, int idx) {
    if (idx == n)
        return true;

    if (s[idx] == 0) {
        if (a > 0) {
            a--;
            b++;
            ans.push_back('B');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            a++;
            b--;
        }
        if (b > 0) {
            a++;
            b--;
            ans.push_back('A');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            a--;
            b++;
        }
    } else if (s[idx] == 1) {
        if (a > 0) {
            a--;
            c++;
            ans.push_back('C');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            a++;
            c--;
        }
        if (c > 0) {
            a++;
            c--;
            ans.push_back('A');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            a--;
            c++;
        }
    } else {
        if (b > 0) {
            b--;
            c++;
            ans.push_back('C');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            b++;
            c--;
        }
        if (c > 0) {
            b++;
            c--;
            ans.push_back('B');
            bool ret = bt(s, n, a, b, c, idx + 1);
            if (ret)
                return true;
            ans.pop_back();
            b--;
            c++;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> s(n);

    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        if (t == "AB")
            s[i] = 0;
        else if (t == "AC")
            s[i] = 1;
        else
            s[i] = 2;
    }

    bool r = bt(s, n, a, b, c, 0);
    if (r == true) {
        cout << "Yes" << endl;
        for (char c : ans) {
            cout << c << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

string s;

int main () {
    cin >> s;
    if (s == "SUN") {
        cout << 7;
    }if (s == "MON") {
        cout << 6;
    }if (s == "TUE") {
        cout << 5;
    }if (s == "WED") {
        cout << 4;
    }if (s == "THU") {
        cout << 3;
    }if (s == "FRI") {
        cout << 2;
    }if (s == "SAT") {
        cout << 1;
    }
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 105;
char c[maxN][maxN];
int dp[maxN][maxN];
int n, m;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }
    dp[1][1] = (c[1][1] == '#');
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) continue;
            dp[i][j] = 1e9;
            if (i > 1) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1][j] == '.' && c[i][j] == '#'));
            }
            if (j > 1) {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (c[i][j - 1] == '.' && c[i][j] == '#'));
            }
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int occur[200];

int main(){
    AC
    int x, n;
    cin>>x>>n;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        occur[x] = 1;
    }

    if(!occur[x]){
        cout<<x<<nl;
        return 0;
    }

    int ans = 500;
    int idx = 500;
    for(int i=0; i<=101; i++){
        if(!occur[i] && abs(i-x)<ans){
           ans = abs(i-x);
           idx = i; 
        }
    }
    cout<<idx<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//#define int long long
const int MAX_N = 55;

int n, p;

int check(){
  int v[MAX_N], pp = p;
  memset(v, 0, sizeof(v));
  for(int i = 0; ; ++i){
    int now = i % n;
    if(p != 0){
      v[now] += 1;
      --p;
      if(v[now] == pp) return now;
    } else{
      p = v[now];
      v[now] = 0;
    }
  }
}

int main() {
  while(cin >>n >>p && n) cout <<check() <<endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			String S = sc.next();
			String T = sc.next();

			char[] Schar = new char[S.length()];
			char[] Tchar = new char[T.length()];

			for(int i =0; i < Schar.length; i++) {
				Schar[i] = S.charAt(i);
				Tchar[i] = T.charAt(i);
			}
			int count = 0;

			for(int i = 0; i < Schar.length; i++) {
				if(Schar[i]!=Tchar[i] ){
					Tchar[i] = Schar[i];
					count++;
				}
			}

			System.out.print(count);

		}

//	    public static int[] shuffle(int[] nums, int n) {
//
//
//	    	int[] xAray = new int[nums.length];
//	    	int[] yAray = new int[nums.length];
//	    	int[] xyAray = new int[nums.length];
//
//	    	for(int i = 0;i<n;i++) {
//
//	    		xAray[i] = nums[i];
//
//	    	}
//
//	    	for(int i = n;i<nums.length;i++) {
//	    		yAray[i] = nums[i];
//	    	}
//
//	    	for(int i = 0; i<n;i++) {
//	    		if(i == 0) {
//	    			xyAray[i]=xAray[i];
//	    		}if(i %2 == 0 ) {
//	    			xyAray[i] = xAray[i];
//	    		}else if(i % 2 != 0){
//	    			xyAray[i] = yAray[i+n];
//	    		}
//	    	}
//
//	    	return xyAray;
//
//
//	    }
}



Measured memory_bytes: 41808
/*input
9
1 2 3 4 5 6 7 8 9
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 205
#define bit(x,y) ((x>>y)&1LL)
#define show(x) cout << (#x) << ": " << x << endl;
#define ii pair<int,int>
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

class max_matching {
private:
	const int INF = 1e18;
	int match[N];
	int dis[N];
	vector<vector<int> > a;
	int n;
	bool bfs() {
		fill(dis, dis + N, INF);
		queue<int> q;
		for (int i = 1; i <= n; i++) {
			if (!match[i]) {
				dis[i] = 0;
				q.push(i);
			}
		}
		while (!q.empty()) {
			int u = q.front(); q.pop();
			if (u == 0) break;
			for (int i = 0; i < a[u].size(); i++) {
				int v = a[u][i]; v = match[v];
				if (dis[v] > dis[u] + 1) {
					dis[v] = dis[u] + 1;
					q.push(v);
				}
			}
		}
		return dis[0] != INF;
	}
	bool dfs(int u) {
		if (u == 0) return true;
		for (int i = 0; i < a[u].size(); i++) {
			int v = a[u][i];
			if (dis[match[v]] == dis[u] + 1 && dfs(match[v])) {
				match[u] = v;
				match[v] = u;
				return true;
			}
		}
		return false;
	}
public:
	int whmatch(int x) {
		return match[x];
	}
	max_matching(int _n) {
		n = _n;
		a.assign(n + 5, vector<int>());
		memset(match, 0, sizeof(match));
		memset(dis, 0, sizeof(dis));
	}
	void add_egde(int u, int v) {
		a[u].push_back(v); a[v].push_back(u);
	}
	int solve() {
		int ret = 0;
		while (bfs()) {
			for (int i = 1; i <= n; i++)
				if (match[i] == 0 && dfs(i)) ret++;
		}
		return ret;
	}
};

#define M 10000005
int primes[M];
void eratosthene() {
	for (int i = 2; i <= M - 5; i++) if (primes[i] == 0) for (int j = i; j <= M - 5; j += i) primes[j] = i;
}

int n;
bool mark[10000005];
vector<int> a;

signed main() {
	eratosthene();
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int t; cin >> t;
		mark[t] = true;
	}
	for (int i = 0; i <= 10000000; i++) {
		if (mark[i] != mark[i + 1]) a.push_back(i);
	}
	int ME = 0, MO = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] & 1) MO++;
		else ME++;
	}
	max_matching D(a.size());
	for (int i = 1; i < a.size(); i++) {
		for (int j = 0; j < i; j++) {
			if (primes[a[i] - a[j]] == a[i] - a[j] && a[i] - a[j] > 2) {
				D.add_egde(j + 1, i + 1);
			}
		}
	}
	int rec = D.solve();
	cout << rec * 1 + ((ME - rec) / 2 + (MO - rec) / 2) * 2 + (ME - rec) % 2 * 3 << endl;
}

Measured memory_bytes: 86272
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,x = inpl()
h = [1] * (n+1)
b = [0] * (n+1)
p = [1] * (n+1)
for i in range(1,n+1):
    h[i] = 3 + h[i-1] * 2
    b[i] = 2 + b[i-1] * 2
    p[i] = h[i] - b[i]
# print(h,p)
def sol(n,x):
    if n == 0 :
        return 0 if x <= 0 else 1
    elif x == 1:
        return 0
    elif x <= 1 + h[n-1]:
        return sol(n-1, x-1)
    elif x == 2 + h[n-1]:
        return p[n-1] + 1
    elif x < h[n]:
        return p[n-1] + 1 + sol(n-1, x-(h[n-1]+2))
    else:
        return p[n-1] * 2 + 1
print(sol(n,x))



Measured memory_bytes: 39916
//simple dfs not enough coz constraints of order 10^5 are high for normal recursion
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX
  vector<int> g[110005];
  vector<int> dp;
  void pairsort(int a[], int b[], int n)
  {
      pair<int, int> pairt[n];
      for (int i = 0; i < n; i++) 
      {
          pairt[i].first = a[i];
          pairt[i].second = b[i];
      }
      sort(pairt, pairt + n);
      for (int i = 0; i < n; i++) 
      {
          a[i] = pairt[i].first;
          b[i] = pairt[i].second;
      }
  }
   int binomialCoeff(int n, int k) 
  { 
       int res = 1; 
    
      // Since C(n, k) = C(n, n-k) 
      if ( k > n - k ) 
          k = n - k; 
    
      // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] 
      for (int i = 0; i < k; ++i) 
      { 
          res *= (n - i); 
          res /= (i + 1); 
      } 
    
      return res; 
  } 
  void printVector(vector<ll> v) {
    for(int i=0;i<v.size();i++)
      {
        cout << v[i];
      }
 
    }
  int divisor(int num)
  { int div=0;
    for (int i = 1; i <= num; i++)
    {
      /* code */
      if(num%i==0)
        div++;
    }
      return div;
    
  }
  int sub(int a, int b)
  {
    if(a>=b)
      return a-b;
    else
      return b-a;
 
  }
  //this is like a modified DFS
  //dp array stores overlapping substructures results & hence also does work of visited

 int solve(int a)
 {
     if(dp[a]!=-1) return dp[a];
     int res=0;
     for(int i=0;i<g[a].size();i++)
      res=max(res,solve(g[a][i])+1);
     return dp[a]=res;
 }
  
  int32_t main()
  { 
      int n,m,x,y;
      cin>>n>>m;
      //dp[i]: stores max length in the graph starting from ith node
      dp.resize(n+2,-1);
      for(int i=0;i<m;i++)
      {
          cin>>x>>y;
          g[x].pb(y);
      }
      
      int ans=0;
      for(int i=1;i<=n;i++)
       ans=max(ans,solve(i));
      cout<<ans;
      return 0;
  }




Measured memory_bytes: 8832
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n').map((x) => x * 1)
min = 10
sum = 0
lines.forEach((x) => {
    a = x % 10
    min = min > a && a > 0 ? a : min
})
lines.forEach((x) => {
    a = x % 10
    if (min == a) {
        sum += x
        min = 10    
    } else {
        sum += ~~((x + 10 - 1) / 10 ) * 10
    }
})
console.log(sum)

Measured memory_bytes: 7880
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust"<<endl;
	} else{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())

l1 = [list(map(int, input().split())) for i in range(n)]
l2 = [list(map(int, input().split())) for i in range(m)]
result = []

for i in range(n):
    tmp = l1[i]
    _ = []
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += (tmp[k] * l2[k][j])
        _ += [ans]
    result += [_]

for i in result:
    print(" ".join([str(x) for x in i]))
    


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


int main()
{
	int n;cin>>n;
	unordered_set<string> s;
//	vector<string> st;
	for(int i=0;i<n;i++){
		string letters;
		cin>>letters;
		s.insert(letters);
	}
	cout<<s.size();
	


	
}

Measured memory_bytes: 17784
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int n,m,a[1005],sum,cnt;
double x;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
	sum+=a[i];
	}
	x=sum*1.0/(4*m);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=x) cnt++;
	}
	if(cnt>=m) cout<<"Yes";
	else cout<<"No";
return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007

int main(){
    FAST
    int x;
    cin>>x;
    int y;
    int flag=0;
    for(int i=1;i<=9;i++){
        if(x%i==0){
            y=x/i;
            if(y/10==0){
                flag=1;
                break;
            }
        }
    }
    if(flag==0)cout<<"No";
    else cout<<"Yes";
    return 0;
}

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

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

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	if (a1 + a2 + a3 >= 22)cout << "bust" << endl;
	else cout << "win" << endl;

	return 0;
}


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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	int zeroCnt = 0, oneCnt = 0;
	for (auto c : s) {
		if (c == '0') {
			zeroCnt++;
		} else if (c == '1') {
			oneCnt++;
		}
	}

	int ans = 2 * min(zeroCnt, oneCnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;


void solve(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double l; cin >> l;
    l /= 3;

    double ans = pow(l, 3);

    cout << setprecision(14) << ans << endl;
}


int main() {
    solve();
}


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

const int N = 305;

int n, m;

int mx[N][N], f[N];

int main() {
#ifdef HOME
	freopen("agc018b.in", "r", stdin);
	freopen("agc018b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int answer, best;

	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j)
		cin >> mx[i][j];

	answer = 1e9;
	for (int it = 1; it <= m; ++it) {
		memset(f, 0x00, sizeof f);

		for (int j, i = 1; i <= n; ++i) {
			for (j = 1; !mx[i][j]; ++j);
			++f[mx[i][j]]; }

		best = 0;
		for (int j = 1; j <= m; ++j)
			if (f[j] >= f[best])
				best = j;
	
		answer = min(answer, f[best]);
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j) if (mx[i][j] == best)
				mx[i][j] = 0; }

	cout << answer << endl;

	return 0; }



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);


class comb{
	vector<ll> f,fr;
	ll MOD_;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		if(n<0||r<0||n<r)return 0;
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}
};


int main(){
	ll r1,r2,c1,c2,ans=0;
	cin >> r1 >> c1 >> r2 >> c2;
	comb co;
	co.init(2000088,MOD);
	FOR(i,c1,c2+1){
		ans += co.nCr(i+r2+1,r2);
		ans %= MOD;
		ans += MOD - co.nCr(i+r1,r1-1);
		ans %= MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 31488
use std::io::{BufRead, Write};

fn main () {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let (k, q): (usize, usize) = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let d: Vec<i64> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    for _ in 0..q {
        let (n, x, m): (usize, i64, i64) = {
            let mut buf = String::new();
            reader.read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };
        let x = x % m;
    
        let mut res = 0;
        let (mut quo, mut rem) = (0, x);
        for i in 0..k {
            if (n - 1) < (i + 1) { continue; }
            let c = (1 + ((n - 1) - (i + 1)) / k) as i64;
            let d = d[i] % m;
            if d == 0 {
                res += c;
            } else {
                quo += (rem + d * c) / m;
                rem = (rem + d * c) % m;
            }
        }

        let ans = (n - 1) - (res + quo - x / m) as usize;
        writeln!(writer, "{}", ans).unwrap();
    }
}

Measured memory_bytes: 2192