akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n - 2; i++) {
			if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long
using namespace std;
int main(){
	char ch;
	while(cin>>ch){
		if(ch=='a' || ch=='o' || ch=='e' || ch=='i' || ch=='u')
			cout<<"vowel"<<endl;
		else
			cout<<"consonant"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
//いちいちreverseすると時間がかかりまくるので、どっちの向きで読めばよいかを記録する
//また普通の構造だと先頭追加はO(s.length)で末尾追加はO(1)
//先頭に追加--->H stack|M stack<=======末尾に追加
//reverseの時はstackを入れ替えるだけ
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        var M = new Stack<string>();//main
        var H = new Stack<string>();//head
        var C = new Stack<string>();//Copy用
        for (int i = 0; i < s.Length; i++)
        {
            M.Push(s[i].ToString());
        }
        int q = int.Parse(Console.ReadLine());
        string[] In;
        for (int i = 0; i < q; i++)
        {
            In = Console.ReadLine().Split(' ');
            if (In[0] == "1")
            {
                C = M;
                M = H;
                H = C;
            }
            if (In[0] == "2")
            {
                if (In[1] == "1")
                {
                    H.Push(In[2]);
                }
                else if (In[1] == "2")
                {
                    M.Push(In[2]);
                }
            }
        }
        var HA = H.ToArray();
        var MA = M.ToArray().Reverse();
        foreach (var ha in HA) Console.Write(ha);
        foreach (var ma in MA) Console.Write(ma);
    }
}
//計算は合っているがこれだと終わらない
//O(Q^2)
//class Program
//{
//    static void Main()
//    {
//        string s = Console.ReadLine();
//        var L = new List<string>();
//        for (int i = 0; i < s.Length; i++)
//        {
//            L.Add(s[i].ToString());
//        }
//        int q = int.Parse(Console.ReadLine());
//        string[] In;
//        for (int i=0; i < q; i++)
//        {
//            In = Console.ReadLine().Split(' ');
//            if (In[0] == "1")
//            {
//                L.Reverse();
//            }
//            if (In[0] == "2")
//            {
//                if(In[1] == "1")
//                {
//                    L.Insert(0, In[2]);
//                }else if (In[1] == "2")
//                {
//                    L.Add(In[2]);
//                }
//            }
//        }
//        L.ForEach(Console.Write);
//    }
//}

Measured memory_bytes: 33460
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double t = double(e)/100.0;
    a *= 100; b *= 100;
    bool wat[3145]={},sug[3145]={};
    wat[0] = sug[0] = true;
    REP(i,3145){
        if(i>=a) if(wat[i-a]) wat[i] = true;
        if(i>=b) if(wat[i-b]) wat[i] = true;
    }
    REP(i,3145){
        if(i>=c) if(sug[i-c]) sug[i] = true;
        if(i>=d) if(sug[i-d]) sug[i] = true;
    }
    double Marx = 0.0;
    int an=a,s=0;
    REP(i,3145){
        for(int j=0;i+j<=f;j++){
            if(wat[i]&&sug[j]){
                if(double(j)/double(i)<=t&&double(j)/double(i)>Marx){
                    Marx = double(j)/double(i);
                    an = i+j;
                    s = j;
                }
            }
        }
    }
    printf("%d %d\n",an,s);
}

Measured memory_bytes: 256
m = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(int(input())):
    k = input()
    m[k] = m[k] + 1

for k in ["AC", "WA", "TLE", 'RE']:
    print(f"{k} x {m[k]}")

Measured memory_bytes: 9184
n,m = map(int,input().split())
ans = [-1] * n
edge = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
    
import collections
que = collections.deque()
que.append(0)
    
while que:
    x = que.popleft()
    
    for to in edge[x]:
        if ans[to] == -1:
            ans[to] = x + 1
            que.append(to)
            
if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    print(*ans[1:],sep="\n")

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

long long int h;
long long int w;
int n;

vector<pair<int, int> > s;
bool valid(int i, int j){
	return i >= 0 && j >= 0 && i < h&&j < w;
}
vector<pair<int, int> > S;

long long int cnt[10];
long long int SUM = 0;

int main(){
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		s.emplace_back(make_pair(a, b));
		for (int i = -2; i <= 2; i++){
			for (int j = -2; j <= 2; j++){
				int aa = a + i;
				int bb = b + j;
				if (valid(aa, bb)){
					S.emplace_back(make_pair(aa, bb));
				}
			}
		}
	}
	sort(s.begin(), s.end());
	sort(S.begin(), S.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	S.erase(unique(S.begin(), S.end()), S.end());
	SUM = (h-2LL)*(w-2LL);
	SUM -= S.size();
	cnt[0] += SUM;
	for (auto it = S.begin(); it != S.end(); it++){
		int a = (*it).first;
		int b = (*it).second;
		bool ng = false;
		int c = 0;
		for (int k = 0; k < 3; k++){
			for (int kk = 0; kk < 3; kk++){
				if (valid(a + k, b + kk)){
					if (binary_search(s.begin(),s.end(),make_pair(a + k, b + kk))){
						c++;
					}
				}
				else{
					ng = true;
				}
			}
		}
		if (ng){
			cnt[0]++;
		}
		else{
			cnt[c]++;
		}
	}
	for (int i = 0; i < 10; i++){
		printf("%lld\n", cnt[i]);
	}
	return 0;
}

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

for i in range(m):
    b.append(int(input()))

for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 8072
#include<stdio.h>
long long d[60][60][2510]={1};
int main(){
  long long n,m,a,i,j,k;
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    for(j=0;j<=i;j++){
      for(k=0;k<2510;k++){//printf("%d ",d[i][j][k]);
	if(d[i][j][k]==0)continue;
	d[i+1][j][k]+=d[i][j][k];
	d[i+1][j+1][k+a]+=d[i][j][k];
      }//printf("\n");
    }//printf("\n\n");
  }
  for(i=j=1;i<=n;i++)j+=d[n][i][i*m];
  printf("%lld\n",j-1);
  return 0;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  string str,rstr;
  cin >> str;
  rstr = str;
  ll cnt = 0;
  for(int i=0; i<str.length(); i++){
    if(str[i]!=rstr[str.length()-1-i]){
      cnt++;
    }
  }
  
  cout << cnt/2;
 

  return 0;
}

Measured memory_bytes: 256
import numpy as np
s = [int(i) for i in input()]

n = len(s)

list01 = [int(i%2) for i in range(n)]
list10 = [int((i+1)%2) for i in range(n)]

        
list_a = np.array(s) - np.array(list01)
list_b = np.array(s) - np.array(list10)

count0 = np.sum(list_a == 0)
count1 = np.sum(list_b == 0)
countmin = min((n-count0),(n-count1))
print(countmin)

Measured memory_bytes: 17868
lis=[]

for i in range(10):
    h=int(input())
    lis.append(h)

for i in range(10):
    for j in range(i+1,10):
        if lis[i]<lis[j]:
            a=lis[i]
            lis[i]=lis[j]
            lis[j]=a

for i in range(3):
    print(lis[i])

Measured memory_bytes: 6720
#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
n %= 10;
if(n == 3)
  cout<<"bon";
else if(n == 0 || n == 1 || n == 6 || n == 8)
  cout<<"pon";
else
  cout<<"hon";
return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
struct{
	vector<int> e;
	int iro=0;
} p[114514];
signed main(){
	int i,j;
	cin>>a;
	for(i=0;i<a-1;i++){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		p[u].e.push_back(v);
		p[v].e.push_back(u);
	}
	int u=0,v=0;
	queue<pair<int,int> > qu;
	qu.push({0,1});
	qu.push({a-1,-1});
	while(!qu.empty()){
		auto x=qu.front();
		qu.pop();
		if(p[x.first].iro==0){
			if(x.second==1)
				u++;
			else
				v++;
			p[x.first].iro=x.second;
			for(auto y:p[x.first].e)
				qu.push({y,x.second});
		}
	}
	if(u>v)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
}

Measured memory_bytes: 8320
#include<iostream>
#include<string>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
    else cout<<"No";
}

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;
using P = pair<int,int>;

int main() {
  ll n,m,ans=0,w;
  cin >>n>>m;
  rep(i,m){
    cin >>w;
    ans+=w;
  }
  if(n<ans){
    cout << -1<<endl;
  }else{
    cout << n-ans<<endl;
  }
  
}


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

S = input()

flg = False
cnt = 0
ans = 0

for i in range(len(S)):
	if flg == False and S[i] == "B":
		flg = True
		start = i

	if flg and S[i] == "W":
		ans += i - start - cnt
		cnt += 1

print(ans)



Measured memory_bytes: 10752
#include <iostream>

using namespace std;

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

    int house[4][3][10];
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 10; k++) house[i][j][k] = 0;

    int b, f, r, v;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        house[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) cout << ' ' << house[i][j][k];
            cout << endl;
        }
        if (i < 3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>

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

  std::vector<int> in(n);
  for(int i = 0;i<n;++i){
    std::cin >> in[i];
  }

  std::vector<int> dp(n);


  //O(n*k)
  for(int i = 1; i < n; i++){
    std::vector<int> currCosts;
    for(int j = 1; j <= k; j++){
      if(i - j < 0){
        break;
      }
      currCosts.push_back(dp[i - j] + std::abs(in[i] - in[i - j]));
    }
    dp[i] = *std::min_element(currCosts.begin(), currCosts.end());
  }

  
  std::cout << dp[n-1] << std::endl;
  return 0;
}

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

using namespace std;

int main() {
    int bingo[3][3];
    int N;
    
    cin >> bingo[0][0]; cin >> bingo[0][1]; cin >> bingo[0][2];
    cin >> bingo[1][0]; cin >> bingo[1][1]; cin >> bingo[1][2];
    cin >> bingo[2][0]; cin >> bingo[2][1]; cin >> bingo[2][2];
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        for (int a = 0; a < 3; a++) {
            for (int b = 0; b < 3; b++) {
                if (bingo[a][b] == num)
                    bingo[a][b] = 0;
            }
        }
    }
    
    for (int i = 0; i < 3; i++) {
        if (bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0)
            goto YES;
        if (bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0)
            goto YES;
        if (bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0)
            goto YES;
        if (bingo[2][0] == 0 && bingo[1][1] == 0 && bingo[0][2] == 0)
            goto YES;
    }
    
    cout << "No" << endl;
    return 0;

YES:
    cout << "Yes" << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n), al(n, 0);
    rep(i, n){
        cin >> a[i];
        if(i > k-1){
            if(a[i-k] < a[i]) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        
    }
    return 0;
}

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

int main() {
  int N, A, B, C, D;
  cin >> N ;
  
  A = N % 10;
  B = (N - A) % 100 / 10;
  C = (N - A - B) % 1000 / 100;
  D = (N - A - B - C) % 10000 / 1000;
  
  if (A == B && B == C) {
    cout << "Yes" << endl;
  }
  else if (B == C && C == D) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int n, m, k;

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if (i * j + (n - i) * (m - j) == k) {
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
	return 0;
}

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

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

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1
#define debug(x) cout<< #x <<" :: "<< x <<end1;
#define debug2(x, y) cout<< #x <<" :: "<< x << "\t" << #y <<" :: "<< y <<end1;



int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif

////////
int n; cin >> n;

double ans = 2*PI*n;

cout << fixed << setprecision(5) << ans << end1;

return 0;
}


Measured memory_bytes: 3800
N,M=map(int,input().split())
A=[int(b) for b in input().split()]
cnt=0
ans=sum(A)/(4*M)
#print(ans)

for i in range(N):
  if A[i] >=ans:
    cnt+=1
#print(cnt)

if cnt >= M:
  print('Yes')
else: print('No')


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int H = GetInt();
		int W = GetInt();
		char[,] c = new char[H, W];
		for(int i = 0; i < H; i++)
		{
			string s = GetString();
			for(int j = 0; j < W; j++)
			{
				c[i, j] = s[j];
			}
		}

		int[,] numR = new int[H, W];
		for(int i = 0; i < H; i++)
		{
			int num = 0;
			for(int j = 0; j < W; j++)
			{
				if(c[i, j] == '#')
				{
					num = 0;
				}
				else
				{
					num++;
					numR[i, j] = num;
				}
			}

			for(int j = W - 2; j >= 0; j--)
			{
				if(c[i, j+1] != '#')
					numR[i, j] = numR[i, j+1];
			}
		}

		int[,] numC = new int[H, W];
		for(int i = 0; i < W; i++)
		{
			int num = 0;
			for(int j = 0; j < H; j++)
			{
				if(c[j, i] == '#')
				{
					num = 0;
				}
				else
				{
					num++;
					numC[j, i] = num;
				}
			}

			for(int j = H - 2; j >= 0; j--)
			{
				if(c[j+1, i] != '#')
					numC[j, i] = numC[j+1, i];
			}
		}

		int ans = 0;
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++)
				ans = Math.Max(ans, numR[i, j] + numC[i, j] - 1);
	
		Console.WriteLine(ans);		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





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

using namespace std;

int main(){
	int n, x=0, max=0;
	string s;
	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		else x--;
		if (x > max)max = x;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
ll a,b,t,s=1;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a>>b;
	t=__gcd(a,b);
	if (!(t&1)){
		s++;
		for (;!(t&1);t>>=1);
	}
	for (ll i=3;i*i<=t;i+=2){
		if (t%i==0){
			s++;
			for (;t%i==0;t/=i);
		}
	}
	if (t>1)
		s++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vector<vii> f(n, vii(5, vi(2)));
    rep (i, n) {
        rep (j, 5) {
            rep (k, 2) {
                cin >> f[i][j][k];
            }
        }
    }

    vii p(n, vi(11));
    rep (i, n) {
        rep (j, 11) {
            cin >> p[i][j];
        }
    }

    ll ans = -INF;
    rep (i, 1 << 10) {
        if (i == 0) continue;
        vi cnt(n);
        rep (j, 10) {
            int jj = j / 2;
            int kk = j % 2;
            rep (aa, n) {
                if (f[aa][jj][kk] && ((i & (1 << j)) != 0)) {
                    cnt[aa]++;
                }
            }
        }

        ll mm = 0;
        rep (aa, n) {
            mm += p[aa][cnt[aa]];
        }
        chmax(ans, mm);
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

void LIS_append(std::vector<i8t>& vec,i8t add,bool semi_increase = false){
  auto it = semi_increase ? std::upper_bound(vec.begin(), vec.end(), add) :
    std::lower_bound(vec.begin(), vec.end(), add);
  if (it == vec.end())
    vec.push_back(add);
  else
    *it = add;
}

struct node_t {
  i8t value;
  i8t mark = 0;
  i8t weight = 0;//蟄仙ｭｫ縺ｮ謨ｰ(閾ｪ蛻・ｂ蜈･繧後ｋ)
  std::vector<i8t> adj;

  std::vector<i8t> lis_save;
  i8t ans;
};

void tree_make_directed_by_root(std::vector<node_t>& vtx, i8t root){
  std::vector<i8t> stk;
  std::vector<i8t> ind;
  i8t p,i;
  vtx[p=root].mark=1;
  i=0;
  while(1){
    node_t& node=vtx[p];
    if (i<node.adj.size()) {
      i8t& p2=node.adj[i];
      if(vtx[p2].mark){
        p2=-1;
        i++;
      }else{
        stk.push_back(p);
        ind.push_back(i+1);
        vtx[p=p2].mark=1;
        i=0;
      }
    }else{
      // remove parents
      node.adj.erase(
        std::remove(node.adj.begin(),node.adj.end(),-1),
        node.adj.end());

      // update weight
      node.weight = 1;
      for (i8t p2:node.adj)
        node.weight+=vtx[p2].weight;

      if (stk.size()){
        p=stk.back();
        i=ind.back();
        stk.pop_back();
        ind.pop_back();
      }else{
        break;
      }
    }
  }
}

int main() {
  R(N);
  std::vector<node_t> vtx;
  F(I,N){
    R(a);
    node_t v {a};
    vtx.push_back(v);
  }
  F(I,N-1){
    R(u1)R(v1);
    u1--;
    v1--;
    vtx[u1].adj.push_back(v1);
    vtx[v1].adj.push_back(u1);
  }

  tree_make_directed_by_root(vtx, 0);
  for(node_t& node:vtx){
    std::sort(node.adj.begin(),node.adj.end(),[&](i8t a, i8t b){
      return vtx[a].weight < vtx[b].weight;
    });
  }

  std::vector<i8t> lis;
  std::vector<i8t> stk;
  std::vector<i8t> ind;
  i8t p=0,i=0;
  LIS_append(lis,vtx[p].value);
  vtx[p].ans=lis.size();

  while (1){
    if (i<vtx[p].adj.size()){
      if(i<vtx[p].adj.size()-1)
        vtx[p].lis_save = lis;
      else
        vtx[p].lis_save = std::vector<i8t>();

      stk.push_back(p);
      ind.push_back(i+1);
      p=vtx[p].adj[i];
      i=0;
      LIS_append(lis,vtx[p].value);
      vtx[p].ans=lis.size();
    }else{
      if(stk.size()){
        p=stk.back();
        i=ind.back();
        stk.pop_back();
        ind.pop_back();
        lis = std::move(vtx[p].lis_save);
      }else
        break;
    }
  }

  for(auto const& node:vtx){
    P(node.ans);
  }
  return 0;
}


Measured memory_bytes: 32340
#include <stdio.h>

int main(void)
{
	int a[1000],b[1000],c[1000],i,n;
	char op[1000];
	i=1;
	scanf("%d %c %d" ,&a[i],&op[i],&b[i]);
	while(op[i]!='?'){
		i++;
		scanf("%d %c %d" ,&a[i],&op[i],&b[i]);
	};
	n=i;
	for(i=1; i<=n-1; i++){
		if(op[i]=='+'){
			c[i]=a[i]+b[i];
		} else if(op[i]=='-'){
			c[i]=a[i]-b[i];
		} else if(op[i]=='*'){
			c[i]=a[i]*b[i];
		} else if(op[i]=='/'){
			c[i]=a[i]/b[i];
		};
		printf("%d\n" ,c[i]);
	};
	return 0;
}

Measured memory_bytes: 612
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[10][10];
int n,m,cnt1,cnt2;
void dfs(int x,int y)
{
	int f=0;
	cnt2++;
	if(x==n&&y==m)
		return ;
	int dx=x,dy=y+1;
	if(dx>=0&&dx<n&&dy>=0&&dy<m)
		if(a[dx][dy]=='#')
		{
			dfs(dx,dy);
			f=1;
		}
	if(!f)
	{
		dx=x+1,dy=y;
		if(dx>=0&&dx<n&&dy>=0&&dy<m)
			if(a[dx][dy]=='#')
				dfs(dx,dy);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("\n");
		scanf("%s",a[i]);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(a[i][j]=='#')
				cnt1++;
	dfs(0,0);
	if(cnt1-cnt2!=0)
		printf("Impossible\n");
	else
		printf("Possible\n");
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    string s,t;
    cin >> s >> t;
    puts(s == t.substr(0, s.size()) ? "Yes" : "No");
}

Measured memory_bytes: 3596
// #pragma GCC optimize "trapv"

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define MAP map<ll ,ll>
#define UMAP unordered_map<ll , ll>
#define endl "\n"
#define SET set<ll> 
#define SETC set<char>
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
#define time cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define ll long long int
const ll INF = 1e13+7;
const ll mod = 1e9+7;


vvll dp;
ll doSome(vvll &arr , int index , int set){

    int n = arr.size();
    if(index == n ){
        if(set == 0){
            // cerr <<" YES " ;
            return 1;
        }
        return  0;
    }

    if(dp[index][set] != -1){
        return dp[index][set];
    }
    ll ans = 0;
    for(int i = 0 ; i < n ; ++i){

        bool val = (((1 << i) & (set)) == 0 ? 0 : 1) ;

        if(arr[index][i] == 1 and val ){
            ans += doSome(arr , index+1 , ((1<< i)^set));
            ans %= mod;
        }
    }

    return dp[index][set] = ans;
}

void solv(){
    ll n ;
    cin >> n ;

    vvll arr(n , vll(n));

    FOR(i , 0 , n-1){
        FOR(j , 0 , n-1){
            cin >> arr[i][j];
        }
    }
    int set = (1 << n) - 1 ;

    dp.assign(n+1 , vll(set+1 , -1));
    cout << doSome(arr , 0 , set ) << endl;
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
    time;
}




Measured memory_bytes: 380168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int N; cin >> N;
    vector <pair<int, int> > a(N);
    rep(i, N){
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a.begin(), a.end());
    // cout << endl;
    // rep(i, N) cout << a[i].first << " " << a[i].second << endl;
    // cout << endl;

    // sort(a.rbegin(), a.rend());
    // cout << endl;
    // rep(i, N) cout << a[i].first << " " << a[i].second << endl;
    // cout << endl;
    
    rep(i, N){
        if(a[N-1].second == i) cout << a[N-2].first << endl;
        else cout << a[N-1].first << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
 
struct item
{
	int w, v;
};
 
ll knapsack(vector <item> &v, int n, int w)
{
	int MAXV = 100005, INF = 2000000000;
	vector <ll> dp(MAXV+1,INF), aux(MAXV+1,INF);
	vector <bool> visto(MAXV,false);
	visto[0]=true; dp[0]=0;
	forn(i,n)
	{
		forn(j,MAXV)
		{
			aux[j]=dp[j];
			if(j-v[i].v < 0) continue;
			if(visto[j-v[i].v] == true)
			{
				aux[j]=min(aux[j],dp[j-v[i].v]+v[i].w);
				visto[j]=true;
			}
		}
		forn(j,MAXV) dp[j]=aux[j];
	}
	ll ans = 0;
	forn(i,MAXV+1) if(dp[i] <= w && visto[i]==true) ans=i;
	return ans;
}
 
int main()
{ 
	FIN;
	
	#ifdef input
		freopen("test3.txt", "r", stdin);
	#endif
	
	int n, w;
	cin >> n >> w;
	vector <item> v(n);
	forn(i,n) cin >> v[i].w >> v[i].v;
	cout << knapsack(v,n,w) << endl;
	return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())
h=[]
for i in range(N):
    h.append(int(input()))
h.sort()
_min=1145141919
for i in range(N-K+1):
    _min = h[K+i-1]-h[i] if h[K+i-1]-h[i]<_min else _min
print(_min)

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

using namespace std;

int n, m, a[1000005], b[1000005], c[10000005], sum;
pair <int, int> p;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum+=a[i];
    }
    cin >> m;
    for(int i = 1; i <= m; i++) {
        cin >> b[i] >> c[i];
        sum-=a[b[i]];
        sum+=c[i];
        cout << sum << "\n";
        sum+=a[b[i]];
        sum-=c[i];
    }
    return 0;
}

Measured memory_bytes: 4352
n=int(input())
l=list(map(int,input().split()))

if n==2:
  print(sum(l)*2)
else:
  ans=[]
  ans.append(l[0])
  ans.append(l[len(l)-1])

  for i in range(len(l)-1): 
    num=min(l[i],l[i+1])
    ans.append(num)
  
  print(sum(ans))

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    string s;
    int flag=1;
    map<char,int> mp;
    cin >> s;
    rep(i,s.length()){
        if(mp.count(s[i]))flag=0;
        mp[s[i]]=1;
    }
    if(flag)cout << "yes" << endl;
    else cout << "no" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define MOD 1e9+7
#define EPS 1e-8
#define INF 1e9+10
typedef long long ll;
using namespace std;
int main()
{
   int N,W;
   cin >> N >> W;
   vector<vector<ll>>w(4,vector<ll>());
   ll mw;
   rep(i,0,N){
       ll a,b;
       cin >> a >> b;
       if(i==0){mw=a;}
       w[a-mw].push_back(b);
   } 
   rep(i,0,4){
       sort(w[i].begin(),w[i].end(),greater<ll>());
   }
   vector<vector<ll>>imos(4,vector<ll>());
   
   rep(i,0,4){
       imos[i].push_back(0);
       rep(j,0,w[i].size()){
           imos[i].push_back(imos[i][j]+w[i][j]);
       }
   }
   ll ans=0;
   
   rep(i,0,imos[0].size()){
       rep(j,0,imos[1].size()){
           rep(k,0,imos[2].size()){
               rep(l,0,imos[3].size()){
                   ll sum=i*mw+j*(mw+1)+k*(mw+2)+l*(mw+3);
                   
                   if(sum<=W){
                       ans=max(ans,imos[0][i]+imos[1][j]+imos[2][k]+imos[3][l]);
                   }
               }
           }
       }
   }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b;
  cin >> a >> b;
  if (a > 9 or b > 9) {
    cout << -1 << "\n";
  } else {
    cout << a*b << "\n";
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int W,H,x,y,r,j;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if( 0<=(x-r) && (x+r)<=W && 0<=(y-r) && (y+r)<=H){
        j=1;
    }

    else{
        j=0;
    }

    if (j==1){
        printf("Yes\n");
    }
    else if (j==0){
        printf("No\n");
    }
    return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		if(s[0] != 'A' || s[s.Length - 1] == 'C' || s[1] == 'C')
		{
			Console.WriteLine("WA");
			return;
		}
		bool cflag = false;
		var a = s;
		for(int i = 1; i < s.Length; i++)
		{
			if(a[i] == 'C' && cflag)
			{
				Console.WriteLine("WA");
				return;
			}
			else if(a[i] == 'C' && !cflag)
			{
				cflag = true;
			}
			else if('A' <= a[i] && a[i] <= 'Z')
			{
				Console.WriteLine("WA");
				return;
			}
		}
		if(cflag)
			Console.WriteLine("AC");
		else
			Console.WriteLine("WA");
		
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
#include <iostream>
#include <complex>
using namespace std;
 
typedef complex<double> P;
 
#define EPS 1e-10
#define EQ(a, b) (abs((a)-(b)) < EPS)
 
double cross(P a, P b){
  return (a.real()*b.imag() - a.imag()*b.real());
}
 
int is_parallel(P a1, P a2, P b1, P b2){
  return EQ(cross(a1-a2, b1-b2), 0.0);
}
 
int main(void){
  int n;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
    if(is_parallel(a, b, c, d)){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1224
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int,N)
	lated := make([]int,8)
	min := 0
	max := 0
	for i:= 0; i<N; i++ {
		fmt.Scan(&a[i])
	}
	for i:=1; i<= 8; i++ {
		lated[i-1] = i*400
	}
	// lateIndex := 0
	colos := make([]bool, 8)
	// beyonds := 0
	for i:= 0; i<N; i++ {
		target := a[i]
		for i:=0; i<8; i++ {
			if target < lated[i] {
				if !colos[i] {
					colos[i] = true
					// fmt.Println(target, lated[i])
					min += 1
					max += 1
					break
				} else {
					break
				}
			}
		}
		if target >= 3200 {
			// beyonds += 1
			max += 1
		}
 	}
 	//for i:= 0; i<beyonds; i++ {
 	//	for j:= 0; j<=7; j++ {
 	//		if !colos[j] {
 	//			colos[j] = true
 	//
	//		}
	//	}
	//}
	if min <= 0 {
		fmt.Print(1)
	} else {
		fmt.Print(min)
	}
	fmt.Print(" ")
	if max >= 8 {
		fmt.Print(max)
	} else {
		fmt.Print(max)
	}
	// fmt.Println(colos,lated)
}

//func lateExamine(lated []int,lateIndex int, value int, count int,minCount int,check int) (int,int,int){
//	// fmt.Println(lated,lateIndex,value,count,minCount)
//	if value >= lated[lateIndex] {
//		if lateIndex == 7 {
//			return lateIndex,count+1,count
//		} else {
//			return lateExamine(lated,lateIndex+1,value,count,minCount,1)
//		}
//	}
//	return lateIndex,count+check,count+check
//}


Measured memory_bytes: 512
//author: zekigurbuz (Zeki Gurbuz) 2019

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef queue<int> qi;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mvi;
typedef map<int, vpii> mvpii;
typedef priority_queue<int> pqi;
typedef set<int> si;

#define int ll
#define double ld
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define forn(a,b) for(int a=0;a<b;++a)
#define rep(a,b,c) for(int a=b;a<c;++a)
#define all(x) begin(x), end(x)

const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; //998244353
const ll INF = 1e18;
const int N = 200005;

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;}

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
void eval(bool b){cout<<(b?"Yes":"No");}


signed main() {ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	forn(i, n) {
		int x; cin >> x;
		pq.push(x);
	}
	while (m--) {
		int x = pq.top();
		pq.pop();
		pq.push(x / 2);
	}
	int s = 0;
	while (!pq.empty()) {
		s += pq.top();
		pq.pop();
	}
	cout << s << endl;
	
return 0;}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> const int inf<int> = 1e9;
template <> const ll inf<ll> = 1e18;
 
int N, K;
 
using graph = vector<vector<int>>;
 
int res = 0;
 
int dfs(graph const& g, int v, int p, vector<int>& sz) {
    sz[v] = 1;
    vector<pii> cnt;
    int cntK = 0;
    for(auto to : g[v]) {
        if(to == p) {
            continue;
        }
        cnt.push_back(make_pair(dfs(g, to, v, sz), to));
        sz[v] += sz[to];
        cntK += sz[to] >= K;
    }
    sort(cnt.rbegin(), cnt.rend());
 
    int par_size = N - sz[v];
    int t = 0;
    for(int i = 0; i < cnt.size(); ++i) {
        int ch = cnt[i].second;
        t = max(t, cnt[i].first + cntK - (sz[ch] >= K));
        res = max(res, t + (par_size >= K));
    }
 
    if(cnt.size() >= 2) {
        int t2 = cnt[0].first + cnt[1].first;
        t2 += cntK - (sz[cnt[0].second] >= K) - (sz[cnt[1].second] >= K) + (par_size >= K);
        res = max(res, t2);
    }
 
    t = max(t, cntK);
    return t;
}
 
int main() {
    cin >> N >> K;
    vector<vector<int>> g(N);
    for(int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }
 
    vector<int> sz(N);
    dfs(g, 0, -1, sz);
    cout << res << endl;
}



Measured memory_bytes: 18900
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
   vector<ll>a(3);
   bool che = false;
   for(int i=0;i<3;i++){
      cin >> a.at(i);
      if(a.at(i)%2==0)che=true;
   }
   if(che){cout<<0<<endl; return 0;}
   sort(a.begin(),a.end());
   ll ans = a.at(0)*a.at(1);
   cout<<ans<<endl;

}
    



Measured memory_bytes: 256
k = int(input())
remainder = [0] * k
remainder[0] = 7 % k
if remainder[0] == 0:
    print(1)
    exit()
for i in range(1, k):
    remainder[i] = (10 * remainder[i - 1] + 7) % k
    if remainder[i] == 0:
        print(i + 1)
        exit()
print('-1')

Measured memory_bytes: 71232
h, w = map(int, input().split())
able = True
tonari = [(-1, 0), (0, -1), (1, 0), (0, 1)]
s = []
for _ in range(h):
    s.append(input())
for i in range(h):
    for j in range(w):
        if s[i][j] == '#' and able:
            count = 0
            for tx, ty in tonari:
                y = i + ty
                x = j + tx
                if 0 <= y < h and 0 <= x < w:
                    if s[y][x] == '#':
                        count += 1
            if count == 0:
                able = False
                break

print('Yes' if able else 'No')


Measured memory_bytes: 3064
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    D, T, S = read_values()
    print("Yes" if D <= T * S else "No")


if __name__ == "__main__":
    main()



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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double n;
  cin >> n;
  double x;
  x = n/1.08;
  double xx = ceil(x);
  double k = 1/1.08;
  if (xx >= x + k) cout << " :(" ;
  else cout << xx;
}



Measured memory_bytes: 3796
from itertools import product
from sys import exit

def maxindexes(L,Lmax):
    ret = []
    for i in range(len(L)):
        if L[i] == Lmax:
            ret.append(i)
    
    return ret


H,W,M = map(int,input().split())
row = [0]*H
col = [0]*W
bomb = set([])

for _ in range(M):
    a,b = (int(x)-1 for x in input().split())
    row[a] += 1
    col[b] += 1
    bomb.add((a,b))

rmax = max(row)
cmax = max(col)

rmaxind= maxindexes(row,rmax)
cmaxind = maxindexes(col,cmax)
prod = product(rmaxind,cmaxind)

for p in prod:
    if p not in bomb:
        print(rmax+cmax)
        exit(0)

print(rmax+cmax-1)

Measured memory_bytes: 186852
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A, B, C;
string S[101010];
//---------------------------------------------------------------------------------------------------
vector<char> ans;
bool dfs(int cu, int a, int b, int c) {
	if (cu == N) return true;

	if (S[cu] == "AB") {
		if (a == 0 && b == 0) return false;
		if (0 < a && dfs(cu + 1, a - 1, b + 1, c)) {
			ans.push_back('B');
			return true;
		}
		if (0 < b && dfs(cu + 1, a + 1, b - 1, c)) {
			ans.push_back('A');
			return true;
		}
		return false;
	}

	if (S[cu] == "AC") {
		if (a == 0 && c == 0) return false;
		if (0 < a && dfs(cu + 1, a - 1, b, c + 1)) {
			ans.push_back('C');
			return true;
		}
		if (0 < c && dfs(cu + 1, a + 1, b, c - 1)) {
			ans.push_back('A');
			return true;
		}
		return false;
	}

	if (S[cu] == "BC") {
		if (b == 0 && c == 0) return false;
		if (0 < b && dfs(cu + 1, a, b - 1, c + 1)) {
			ans.push_back('C');
			return true;
		}
		if (0 < c && dfs(cu + 1, a, b + 1, c - 1)) {
			ans.push_back('B');
			return true;
		}
		return false;
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> A >> B >> C;
	rep(i, 0, N) cin >> S[i];

	dfs(0, A, B, C);

	if (ans.size() == 0) cout << "No" << endl;
	else {
		printf("Yes\n");
		reverse(all(ans));
		fore(c, ans) printf("%c\n", c);
	}
}







Measured memory_bytes: 14892