akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    int num = 1;
    int ans = 0;
    for(int i=0; n>i; i++){
        if(arr[i] == num){
            num++;
        }else{
            ans++;
        }
    }
    if(ans == n){
        ans = -1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    ans=0
    cnt=[[] for i in 0:9]
    for i in 1:n
        push!(cnt[s[i]-'0'+1],i)
    end
    for i in 0:999
        t=lpad(i,3,"0")
        index=1
        flg=true
        for j in 1:3
            index=searchsortedfirst(cnt[t[j]-'0'+1],index)
            if index>length(cnt[t[j]-'0'+1])
                flg=false
                break
            end
            index=cnt[t[j]-'0'+1][index]+1
        end
        if flg
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 166884
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
 
#define reg register
#define LL long long
#define cmin(a,b) ((a)<(b)?(a):(b))
#define cmax(a,b) ((a)>(b)?(a):(b))
 
const int MaxN = 100010;
 
struct Data{
	int Next, To;
}Tree[MaxN*2];
 
int Last[MaxN], T, N, Cnt, Dis_S[MaxN], Dis_T[MaxN];
bool Vis[MaxN];
 
inline int Read()
{
	reg int aa;reg char ch;while(ch=getchar(),ch<'0'||ch>'9'); aa=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9') aa=(aa<<1)+(aa<<3)+ch-'0'; return aa;
}
 
inline void Insert(reg int u, reg int v)
{
	Tree[++Cnt].To = v;
	Tree[Cnt].Next = Last[u];
	Last[u] = Cnt;
}
 
inline void Dfs(reg int Node,reg int dep, reg int* Dis)
{
	//printf("%d\n", Node);
	Vis[Node] = 1;
	for(reg int x = Last[Node]; x; x = Tree[x].Next)
	{
		reg int y = Tree[x].To;
	//	printf("To : %d Vis : %d\n", y, Vis[y]);
		if(!Vis[y])
		{ 	
			Dis[y] = dep;
			Dfs(y, dep+1, Dis);
		}
	}
}
 
int main()
{ 
	Cnt = 0;
	N = Read();
	for(reg int i = 1; i < N; ++i)
	{
		reg int a, b;
		a = Read(), b = Read();
		Insert(a, b);
		Insert(b, a);
	}
	Dis_S[0] = Dis_T[N] = 0;
	Dfs(1, 1, Dis_S);
	memset(Vis, 0, sizeof(Vis));
	Dfs(N, 1, Dis_T);
	Cnt = 0;
	//	for(reg int i = 1; i <= N; ++i)
		//	printf("DisS[%d] = %d, DisT[%d] = %d\n", i, Dis_S[i], i, Dis_T[i]);
	for(reg int i = 1; i <= N; ++i)
		Dis_S[i] <= Dis_T[i] ? ++Cnt : --Cnt;
	Cnt > 0 ? puts("Fennec") : puts("Snuke");
	return 0;
 } 

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

int main() {
  int n; cin>>n;
  vector<vector<pair<int,int>>> eviArr(n);
  for(int i=0; i<n; i++) {
    int eviNum; cin>>eviNum;
    for(int j=0; j<eviNum; j++) {
      int person,isHonest; cin>>person>>isHonest;
      eviArr[i].push_back({person-1,isHonest});
    }
  }
  int ans=0;
  // bit全探索
  for(int i=0; i<pow(2,n); i++) {
    bitset<15> bs(i);
    bool isFinished = true;
    for(int j=0; j<n; j++) {
      if(bs[j]) {
        for(int k=0; k<(int)eviArr[j].size(); k++) {
          if(bs[eviArr[j][k].first]!=eviArr[j][k].second) isFinished=false;
          if(!isFinished) break;
        }
        if(!isFinished) break;
      }
    }
    if(!isFinished) continue;
    ans = max(ans,(int)bs.count());
  }
  cout << ans << endl;
}


Measured memory_bytes: 4076
#include <stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
printf("Yes\n");
return 0;
}
printf("No\n");
return 0;
}


Measured memory_bytes: 2100
import math, cmath
 
def koch(p1, p2, n):
    if n == 0:
        return [p1, p2]
     
    rad60 = math.pi/3
    v1 = (p2 - p1)/3
    v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
    q1 = p1 + v1
    q2 = q1 + v2
    q3 = q1 + v1
    if n == 1:
        return [p1,q1,q2,q3,p2]
    else:
        x1 = koch(p1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,p2,n-1)
        x = x1 + x2 + x3 + x4
    return x
 
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
 
for e in koch(p1,p2,n):
    print e.real,e.imag

Measured memory_bytes: 6904
#include <iostream>
#include <vector>

template<typename T>
void print_ary(std::vector<T> ary, char delim = '\n') {
    for(int i = 0; i < ary.size()-1; i++) {
        std::cout << ary[i] << delim;
    }
    std::cout << ary[ary.size()-1];
}


template<typename T>
void insertion_sort(std::vector<T>&& ary) {
    for (int i = 1; i < ary.size(); i++) {
        int target = ary[i];
        int j = i - 1;
        while(j >= 0 &&  ary[j] > target) {
            ary[j+1] = ary[j];
            j--;
        }
        ary[j+1] = target;
        print_ary(ary, ' ');
        std::cout << std::endl;
    }
}

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> ary(n);
    for (auto &i: ary) {
        std::cin >> i;
    }
    print_ary(ary, ' ');
    std::cout << std::endl;
    insertion_sort(std::move(ary));
    return 0;
}

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

using namespace std;

int x[100001];

int main(void)
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);

	x[0] = 1;
	for(int i = 1; i <= n; i++)
		scanf("%d", x+i);
	sort(x+1, x+n+1);

	long long ret = 0;

	for(int i = 2; i <= n; i++)
	{
		long long dis = x[i] - x[i-1];
		long long plusa, plusb;
		plusa = dis * a;
		plusb = b;

		ret += min(plusa, plusb);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool solve(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];

  long x = 0;
  rep(i,n){
    if(a[i] < b[i]){
      long y = b[i] - a[i];
      x += y/2;
    } else if(a[i] > b[i]){
      x -= a[i] - b[i];
    }
  }
  return x >= 0;
}

int main(){
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 384
w = str(input())
count_list = []
result = ""
for i in range(97, 123) :
  count_list.append(w.count(chr(i)))
for i in count_list :
  if i % 2 == 0 :
    result = "Yes"
  else:
    result = "No"
    break
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string A,B;
  cin>>A>>B;

  if(A.length()<B.length()){
    cout<< "LESS" <<"\n";
    return;
  }
  if(A.length()>B.length()){
    cout<< "GREATER"<<"\n";
    return;
  }

  rep(i,A.length()){
    if(A[i]<B[i]){
      cout<< "LESS" <<"\n";
      return;
    }
    if(A[i]>B[i]){
      cout<< "GREATER" <<"\n";
      return;
    }
  }

  cout<< "EQUAL" <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int D = scan.nextInt();
        int[][] A = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                A[i][j] = scan.nextInt();
            }
        }
        long[][] original = new long[H*W+1][2];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                original[A[i][j]][0] = i;
                original[A[i][j]][1] = j;
            }
        }
        long[] s = new long[H*W+1];
        for (int i = 1; i <= H * W-D; i++) {
            s[i+D] += s[i];
            s[i+D] += Math.abs(original[i+D][0]-original[i][0]);
            s[i+D] += Math.abs(original[i+D][1]-original[i][1]);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.nextInt();
            int R = scan.nextInt();
            System.out.println(s[R]-s[L]);
        }
    }
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



int main()
{
  int S, W;

  cin >> S >> W;

  if( S <= W )
  {
    cout << "unsafe" << endl;
  }
  else
  {
    cout << "safe" << endl;
  }
  
  return 0;
  
    
}

Measured memory_bytes: 3632
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import bellman_ford, NegativeCycleError


def main():
    N, M, P = map(int, input().split())
    A, B, C = [0] * M, [0] * M, [0] * M
    v = [set() for _ in range(N)]
    u = [set() for _ in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        A[i], B[i], C[i] = a - 1, b - 1, P - c
        u[a - 1].add(b - 1)
        v[b - 1].add(a - 1)
    vv = set()
    cur = set([N - 1])
    while cur:
        vv |= cur
        cur = set().union(*(v[c] for c in cur)) - vv
    uu = set()
    cur = set([0])
    while cur:
        uu |= cur
        cur = set().union(*(u[c] for c in cur)) - uu
    reachable = vv & uu
    l = {}
    for a, b, c in zip(A, B, C):
        if a in reachable and b in reachable:
            l[(a, b)] = min(c, l.get((a, b), 10 **9))
    AA, BB, CC = [], [], []
    for (a, b), c in l.items():
        AA.append(a)
        BB.append(b)
        CC.append(c)
    mx = csr_matrix((CC, (AA, BB)), shape=(N, N))
    try:
        dm = bellman_ford(mx, indices=[0])
    except NegativeCycleError:
        return -1
    return max(0, -int(dm[0][N - 1]))


print(main())


Measured memory_bytes: 26644
#include <stdio.h>

int main()
{
    int a, b, d, c[36]= {0}, i,base;
    int count = 0;
    i=0;
    scanf("%d %d",&a,&base);
    d=a;
    while (a!=0)
    {
        b=a%base;
        a=a/base;
        c[i]=b;
        i++;
    }
    for(i=i-1; i>=0; i--)
    {
        count = count + 1;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    string s,t;
    cin>>s>>t;
    int64 ans=0;

    for (int64 i = 0; i < s.length(); i++)
    {
        ans+=(s[i]!=t[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
local h,w,k=io.read("n","n","n","l")
local c={}
for i=0,h-1 do
    local input=io.read()
    c[i]={}
    for j=0,w-1 do
        c[i][j]=input:sub(j+1,j+1)
    end
end

local total=0
for bi=0,(1<<h)-1 do
    for bj=0,(1<<w)-1 do
        local counter=0
        for i=0,h-1 do
            for j=0,w-1 do
                if (bi>>i)&1==0 and (bj>>j)&1==0 then
                    if c[i][j]=="#" then
                        counter=counter+1
                    end
                end
            end
        end
        if counter==k then
            total=total+1
        end
    end
end
print(total)

Measured memory_bytes: 2776
import Data.Char
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import Control.Monad
import Text.Printf
import Data.List

main1 = do
  -- w <- getLine
  -- t <- fmap (concat . map words . lines . map toLower) getContents
  let w = "computer"
      t = concat . map words . lines . map toLower $ "fdsalkfjo sda computer \nf lsdajf\n"
  putStrLn . show . length . filter (\n -> n == w) $ t

main2 = do
  dataSet <- fmap lines getContents
  let strings = map (\(s,hs) -> shuffleLoop hs (V.fromList s)) . disassembe $ dataSet
  mapM_ (putStrLn . V.toList) strings
  -- putStrLn ""

shuffleLoop [] vector = vector
shuffleLoop (h:hs) vector = shuffleLoop hs (shuffle h vector)

shuffle h vector = newVec
  where
    (fstVec,sndVec) = V.splitAt h vector
    newVec = sndVec V.++ fstVec

disassembe list = loop list []
  where
    loop ["-"] stack = stack
    loop (s:m:xs) stack = loop ys (stack ++ [(s,map read hs :: [Int])])
      where
        (hs,ys) = splitAt (read m :: Int) xs

main3 = do
  n <- readLn
  cards <- replicateM n $ fmap ((\(t:h:_) -> (t,h)) . words) getLine
  let (ts,hs) = solve3 cards
  printf "%d %d\n" ts hs

data ResultOneGame = TWin | HWin | Draw deriving Show

compereDict ([],[]) = Draw
compereDict ([],_) = HWin
compereDict (_,[]) = TWin
compereDict ((t:ts), (h:hs)) = case t `compare` h of
                                 GT -> TWin
                                 LT -> HWin
                                 EQ -> compereDict (ts, hs)

solve3 :: [(String,String)] -> (Int,Int)
solve3 list = foldl f (0,0) list
  where
    f :: (Int,Int) -> (String, String) -> (Int,Int)
    f (tScore, hScore) (tCard, hCard) = case compereDict (tCard, hCard) of
                                         TWin -> (tScore+3, hScore)
                                         HWin -> (tScore, hScore+3)
                                         Draw -> (tScore+1, hScore+1)

reverse4 (a:b:_) str = newVec
  where
    newVec = (V.take (read a) str) V.++  (V.reverse $ V.slice (read a) ((read b)-(read a)+1) str) V.++ (V.drop ((read b)+1) str)

replace4 (a:b:p:_) str = newVec
  where
    newVec = (V.take (read a) str) V.++  (V.fromList p) V.++ (V.drop ((read b)+1) str)

print4 (a:b:_) str = putStrLn . V.toList . V.slice (read a) ((read b)-(read a)+1) $ str

solve4 :: [[String]] -> V.Vector Char -> IO ()
solve4 ordersList str = loop ordersList str
  where
    loop [] _ = return ()
    loop ((order:ns):orders) s = do
      case order of
        "print" -> do
          print4 ns s
          solve4 orders s
        "reverse" -> do
          solve4 orders (reverse4 ns s)
        "replace" -> do
          solve4 orders (replace4 ns s)

main = do
  str <- fmap V.fromList getLine
  _ <- getLine
  orderList <- fmap (map words . lines) getContents
  solve4 orderList str



Measured memory_bytes: 5880
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

void rot45(int &x,int &y){
  int tmp = x + y;
  x = x - y;
  y = tmp;
}
void rot45inv(int &x,int &y){
  int tmp = (y - x) / 2;
  x = (x + y) / 2;
  y = tmp;
}

signed main(){

  int n; cin >> n;
  vector<int> x(n), y(n);
  vector<pair<int, int>> X(n), Y(n);
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    rot45(x[i], y[i]);
    X[i] = {x[i], i};
    Y[i] = {y[i], i};
    rot45inv(x[i], y[i]);
  }

  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  int xl = X[0].second, xr = X[n-1].second;
  int yl = Y[0].second, yr = Y[n-1].second;
  int ans = max(abs(x[xl] - x[xr]) + abs(y[xl] - y[xr]), abs(x[yl] - x[yr]) + abs(y[yl] - y[yr]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12708
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int cases;
int D, X;
int query;

int main()
{
	scanf("%d %d %d", &cases, &D, &X);
	int finalCnt = cases;
	while(cases--) {
		scanf("%d", &query);
		for(int i = 1; i <= 100; i++) {
			if((query * i) + 1 > D) {
				break;
			}
			else {
				finalCnt++;
			}
		}
	}
	printf("%d\n", finalCnt + X);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#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>;
typedef vector<int> vi;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a & b  & 1 ? "Odd" : "Even") << endl;

  return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

bool ok(int num)
{
    bool ok7 = false;
    bool ok5 = false;
    bool ok3 = false;

    while (num) {
        int x = num % 10;

        if (x == 7) {
            ok7 = true;
        } else if (x == 5) {
            ok5 = true;
        } else if (x == 3) {
            ok3 = true;
        }

        num /= 10;
    }

    return ok7 && ok5 && ok3;
}

ll f(int i, int num, int N, int digits)
{
    if (i >= digits) {
        if (ok(num) && num <= N) {
            return 1;
        }

        return 0;
    }

    ll res = 0;
    res += f(i+1, num*10 + 7, N, digits);
    res += f(i+1, num*10 + 5, N, digits);
    res += f(i+1, num*10 + 3, N, digits);

    return res;
}

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

    ll ans = 0;
    for (int i = 2; i <= 9; ++i) {
        ans += f(0, 0, N, i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
//#include <boost/range/algorithm.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 1e9 + 7;

namespace {
	ll Ceil(ll val, ll div)   { return (val + div - 1) / div; };
	ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; };
	ll FloorN(ll x, ll n)     { return (x - x % n); };
	bool IsOdd(ll x)          { return ((x & 1) == 1); };
	bool IsEven(ll x)         { return ((x & 1) == 0); };
	template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
	template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
};

// 処理
void Solve()
{
	ll K, T;
	cin >> K >> T;
	vector<ll> a(T);
	REP(i, T) cin >> a[i];
	sort(ALL(a), greater<ll>());

	ll ans = 0;
	if (T == 0) {
		ans = K - 1;
	} else {
		ll nokori = K - a[0];
		ll res = a[0] - nokori - 1;
		chmax(ans, res);
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main (int argc, char *argv[]) {
    using namespace std;
    int a, b, c, d, e, f;
    while (EOF != fscanf(stdin, "%d %d %d %d %d %d\n", &a, &b, &c, &d, &e, &f)) {
        float tmp1 = static_cast<float>(f)-(static_cast<float>(c)*static_cast<float>(d)/static_cast<float>(a));
        float tmp2 = static_cast<float>(e)-(static_cast<float>(b)*static_cast<float>(d)/static_cast<float>(a));
        float y = tmp1/tmp2;
        float x = (static_cast<float>(c) - static_cast<float>(b) * y) / static_cast<float>(a);
        printf("%.3f %.3f\n", x, y);        
        //printf("y=%f\n", (f-(c*d/a))/(e-(b*d/a)));
    }
    return 0;
}

Measured memory_bytes: 0
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    a = get_int()
    b = get_int()
    c = get_int()
    d = get_int()
    e = get_int()
    k = get_int()
    if abs(a - e) > k:
        print(":(")
    else:
        print("Yay!")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

struct edge_t {
    int dest;
    int weight;
};

struct vertex_t {
    vector<edge_t> edges;
    vector<int> weight;

    // for dijkstra
    bool done; // confirm or not
    int cost;  // now cost
    int from;

    bool operator<(const vertex_t &another) const { // priority --> min
        return another.cost < cost;                 // order(cost)
    }

    bool operator>(const vertex_t &another) const { // priority --> min
        return another.cost > cost;                 // order(cost)
    }

    bool operator==(const vertex_t &another) const {
        return another.cost == cost; // order(cost)
    }

    vertex_t() {
        cost = INF;
        done = false;
    }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
    int i, j, k, count = 0;
    bool flag = false;
    graph[start].cost = 0;
    REP(i, size) {
        REP(j, size) {
            vertex_t cur = graph[j];
            for (edge_t edge : cur.edges) {
                if (cur.cost + edge.weight < graph[edge.dest].cost) {
                    if (i == size - 1)
                        flag = true;
                    graph[edge.dest].cost = cur.cost + edge.weight;
                }
            }
        }
    }
    if (flag) {
        return 1;
    } else {
        return 0;
    }
}

class tree_t {
public:
    bool is_leaf;
    tree_t *right;
    tree_t *left;

    tree_t() {
        is_leaf = false;
        right = NULL;
        left = NULL;
    }
};

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

int main() {

    int N;
    cin >> N;
    vector<float> A(N);

    REP(i, N) {
        cin >> A[i];
    }

    float sum = 0;

    REP(i, N) {
        sum += 1 / A[i];
    }

    cout << 1 / sum;
};

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	char Q[51];
	char E[51];
	char pass[102];

	scanf("%s %s",Q,E);

	for(int i=0; i<51; i++){
		pass[2*i] = Q[i];
		pass[2*i+1] = E[i];
	}
	
	printf("%s",pass);

	return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m;
    cin >> n >> m;
    int time = m * 1900 + (n - m) * 100;
    
    cout << time * pow(2, m);
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

// N <= B なら、x=Nが最大値
// B < N なら、x=Bが最大値

long long fn(long long A, long long B, long long x)
{
    return (A*x/B) - A*(x/B);
}

int main() {
    long long A, B, N;
    cin >> A >> B >> N;
    if(N < B) {
        cout << fn(A, B, N) << endl;
    }
    else {
        if(A <= B) {
            cout << A-1 << endl;
        }
        else {
            // ここがめんどい
            cout << fn(A, B, B-1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
(n, m, l) = [int(i) for i in input().split()]
A = []
for nc in range(n): 
    A.append([int(i) for i in input().split()])
B = []
for mc in range(m): 
    B.append([int(i) for i in input().split()])

product = [[0 for d in range(l)] for dd in range(n)]
      
for nc in range(n):
    for lc in range(l): 
        for mc in range(m):
            product[nc][lc] += A[nc][mc] * B[mc][lc] 

for r in product: 
    print(' '.join([str(d) for d in r]))

Measured memory_bytes: 8860
# -*- coding: utf-8 -*-
n,y = map(int, input().split())

for a in range(min(n,y//10000)+1):
    for b in range(min(n-a,(y-a*10000)//5000)+1):
        if a*10000+b*5000>y:
            continue
        c = (y-a*10000-b*5000)//1000
        if a+b+c==n and 10000*a+5000*b+1000*c==y:
            print(a,b,c)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 3060
S=list(input())

count1=0
count2=0

for i in range(0,len(S),2):
    if S[i] == '0':
        count1 +=1
    else:
        count2 +=1
    

    
for j in range(1,len(S),2):
    if S[j] == '1':
        count1 +=1
    else:
        count2 +=1

if count2 >= count1:
    print(count1)
else:
    print(count2)

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

int main(){
  int N ;
  cin >> N ;
  double x[11] ;
  string u[11] ;
  for(int i=0;i<N;i++)
    cin >>x[i] >>u[i] ;
  double sum1=0 ;
  double sum2=0 ;
  for(int i=0;i<N;i++){
    if(u[i] == "JPY")
      sum1 += x[i] ;
    else
      sum2 += x[i]*380000.0 ;
  }
  cout << sum1+sum2 << endl ;
}

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>;
const int INF = 1e9;

int main() {
  int N, M;
  cin >> N >> M;
  int N2 = pow(2, N);
  vector<int> dp(N2, INF);
  dp.at(0) = 0;

  rep(i, M) {
    int a, b;
    cin >> a >> b;

    int tmp = 0;
    rep(j, b) {
      int c;
      cin >> c;
      c--;
      tmp += 1 << c;
    }
    rep(j, N2) {
      if (dp.at(j) == INF) continue;
      dp.at(j | tmp) = min(dp.at(j | tmp), dp.at(j) + a);
    }
  }

  if (dp.at(N2 - 1) == INF) {
    cout << -1 << endl;
  } else {
    cout << dp.at(N2 - 1) << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    FOR(i,1,10000){
        int c = i*8/100;
        int d = i*10/100;
        if (a==c && b==d){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 384
N = int(input())
S = list(input())

for i in range(len(S)):
  S[i] = ord(S[i])+N

  if S[i] > 90:
    S[i] = S[i] - 26
    S[i] = chr(S[i])
  else:
    S[i] = chr(S[i])
  
  
ans = ''.join(S)
print(ans)

Measured memory_bytes: 3064
def inpl(): return list(map(int, input().split()))
N, W = inpl()

DP = [0]*(W+1)
for _ in range(N):
    DP2 = [0]*(W+1)
    w, v = inpl()
    for i in range(w):
        DP2[i] = DP[i]
    for i in range(w, W+1):
        DP2[i] = max(DP[i], DP[i-w]+v)
    DP = DP2
print(DP[-1])


Measured memory_bytes: 67220
data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n-m+1):
  for y in range(n-m+1):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"



Measured memory_bytes: 2568
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    val = 0

    for j in range(K):
        TT = [T[i] for i in range(j, N, K)]

        gr = groupby(TT)
        for key, group in gr:  # groupはイテレータ。list(group)でリスト化
            """ex.
            0: [0, 0, 0]
            1: [1, 1]
            0: [0, 0, 0]
            1: [1, 1]
            0: [0]
            1: [1]
            """
            if key == 'r':
                val += math.ceil(len(list(group))/2)*P
            elif key == 's':
                val += math.ceil(len(list(group))/2)*R
            else:
                val += math.ceil(len(list(group))/2)*S

    print(val)

resolve()

Measured memory_bytes: 49076
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int lc=1,gc;
int n,a[202020];
map<int,int> mp;

int modpow(int x, int n, int m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    int x = a[i];
    for(int j=2;j*j<=a[i];j++){
      if(x%j==0){
        int cnt = 0;
        while(x%j==0){
          x/=j;
          cnt++;
        }
        mp[j]=max(mp[j],cnt);
      }
    }
    if(x>1){
      mp[x]=max(mp[x],1LL);
    }
  }
  int lc = 1;
  for(auto t:mp){
    lc = lc*modpow(t.fs,t.sc,mod)%mod;
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    ans = (ans + lc*modpow(a[i],mod-2,mod)%mod )%mod;
  }
  cout << ans << endl;
  

return 0;
}
///....


Measured memory_bytes: 1024
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] t=new int[n];
		int[] v=new int[n+1];
		Arrays.setAll(t,i->s.nextInt());
		for(int i=0;i<n;++i)
			v[i]=s.nextInt();
		for(int i=n-1;i>=0;--i)
			v[i]=Math.min(v[i],v[i+1]+t[i]);

		Arrays.parallelPrefix(t,Integer::sum);

		int cv=0,i=0,d=0;
		for(int T=0;T<t[n-1];++T){
			int remain=t[i]-T;
			if(cv-v[i+1]==remain-1&&cv<v[i]){
				d+=cv*4+1;
			}else{
				d+=cv*2;
				if(cv-v[i+1]==remain)
					cv--;
				else if(cv+1<=v[i])
					cv++;
				d+=cv*2;
			}
			if(remain==1)
				++i;
		}
		System.out.println(d/4.0);
	}
}


Measured memory_bytes: 30676
#include  <stdio.h>

int main(void)
{
    char a[3];
    scanf("%s",&a);
    
    if((a[0]!=a[2] && a[1]!=a[0] && a[1] == a[2])||(a[0]!=a[2] && a[1]==a[0] && a[1] != a[2])||(a[0]==a[2] && a[1]!=a[0] && a[1] != a[2])||(a[0]!=a[2] && a[1]==a[0] && a[1] != a[2])) {
        puts("Yes");
    }
    else if(a[0]==a[2] && a[1]==a[0] && a[1] == a[2]) {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	// Code for A - Tak and Hotels (ABC Edit)
	var N, K, X, Y int
	fmt.Scanf("%d\n%d\n%d\n%d", &N, &K, &X, &Y)

	if K < N {
		fmt.Println(X*K + Y*(N-K))
	} else {
		fmt.Println(X * N)
	}
}


Measured memory_bytes: 1832
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456][2], maryoku[213456];
signed main() {
	int n, w, d, a, q, l, r; cin >> n >> w >> d;
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < w; i++) {
			cin >> a;
			test[a][0] = h; test[a][1] = i;
		}
	}
	for (int h = 1; h <= n * w - d; h++) {
		int sx = 0, sy = 0, gx = 0, gy = 0;
		sx = test[h][0]; sy = test[h][1];
		gx = test[h + d][0]; gy = test[h + d][1];
		if (h <= d) {
			maryoku[h] = abs(gx - sx) + abs(gy - sy);
		}
		else {
			maryoku[h] = maryoku[h - d] + abs(gx - sx) + abs(gy - sy);
		}
	}
	cin >> q; 
	for (int h = 0; h < q; h++) {
		cin >> l >> r;
		if (l <= d) { l = d; }
		if (r <= d) { r = d; }
		cout << maryoku[r - d] - maryoku[l - d] << endl;
	}
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(void)
{
	int n, k, i, j;
	int ai, bi;
	int c;

	scanf("%d %d", &n, &k);

	for (i = 0; i < k; i++){
		scanf("%d %d", &ai, &bi);
		if (n + 1 - ai < ai){
			ai = n + 1 - ai;
		}
		if (n + 1 - bi < bi){
			bi = n + 1 - bi;
		}

		if (ai < bi){
			c = ((ai - 1)) % 3 + 1;
		}
		else {
			c = ((bi - 1)) % 3 + 1;
		}

		printf("%d\n", c);

		}
	return (0);
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int w, h; cin >> w >> h;
  int a = w+1, b = h+1;
  vector<int> p(w), q(h);
  for(int i=0;i<w;++i) {
    cin >> p[i];
  }
  for(int j=0;j<h;++j) {
    cin >> q[j];
  }
  vector<pair<ll, bool>> pi(w + h);
  for(int i=0;i<w;++i) {
    pi[i] = {p[i], 0};
  }
  for(int i=0;i<h;++i) {
    pi[w + i] = {q[i], 1};
  }

  sort(pi.begin(), pi.end());
  ll ans = 0;
  for(int i=0;i<w+h;++i) {
    if(pi[i].second == 0) {
      ans += pi[i].first * b;
      a--;
    } else {
      ans += pi[i].first * a;
      b--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
 lint digit(lint);

int main(){


    string s;
    cin >> s;

    if(s.length()%2){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 1; i < s.length(); i += 2){
        if(s[i-1] != 'h' || s[i] != 'i'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


}
lint digit(lint num){
    lint dig = 0;
    while(num){
        num /= 10;
        ++dig;
    }
    return dig;
}

Measured memory_bytes: 384
#include <stdio.h>
    
    int main(void){
        int i,a,b;
        char op;

        for(i=1;;i++){
            scanf("%d %c %d",&a,&op,&b);
            if(op == '+'){printf("%d\n",(a+b));}
            else if(op == '-'){printf("%d\n",(a-b));}
            else if(op == '*'){printf("%d\n",(a*b));}
            else if(op == '/'){printf("%d\n",(a/b));}
            else if(op == '?'){break;}
        }
        return 0;
    }


Measured memory_bytes: 2044
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int A, B; cin >> A >> B;
    for (int i = A; i <= B*A; i += A) {
        if (i % B == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
n = int(input())
num_list = []

for _ in range(n):
    num_list.append(int(input()))

total = sum(num_list)
if total%10 != 0:
    print(total)
else:
    min_num = 101
    for num in num_list:
        if num%10 != 0 and num < min_num:
            min_num = num
    if min_num == 101:
        print(0)
    else:
        print(total-min_num)


Measured memory_bytes: 2940
t = input()
s = input()

mxscore = -1
beststr = ''
for i in range(len(s),len(t)+1):
    check = t[i-len(s):i]
    now = 0
    for j in range(len(check)):
        if s[j] == check[j]:
            now += 1
    if now > mxscore:
        mxscore = now

print(len(s)-mxscore)



Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A[K-1] << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(RALL(a));
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -1));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= i; j++) {
            chmax(dp[i + 1][j + 1],
                  dp[i][j] + a[i].first * abs(a[i].second - j));
            chmax(dp[i + 1][j],
                  dp[i][j] + a[i].first * abs(n - i + j - 1 - a[i].second));
        }
    }
    ll ans = -LLINF;
    for(int i = 0; i <= n; i++) {
        chmax(ans, dp[n][i]);
    }
    cout << ans << endl;
}

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

int main()
{
  int A,B;
  cin >> A >> B;
  
  bool one = true;
  bool two = true;
  bool three = true;
  if(A == 1 || B == 1){one = false;}
  if(A == 2 || B == 2){two = false;}
  if(A == 3 || B == 3){three = false;}
  if(one){cout << '1' << endl;}
  else if(two){cout << '2' << endl;}
  else{cout << '3' << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> p.at(i);
	}
	vector<int> sum(n-k+1);
	for (int i = 0; i < k; ++i)
	{
		sum.at(0)=sum.at(0)+p.at(i);
	}
	double max= sum.at(0);
	for (int i = 0; i < n-k; ++i)
	{
		sum.at(i+1)=sum.at(i)-p.at(i)+p.at(i+k);
		if(max<sum.at(i+1)){
			max = sum.at(i+1);
		}
	}
  double answer;
  answer = (max+k)/2;
  cout << fixed << setprecision(7) << answer << endl;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

pos = 0
now = 0
for i, a in enumerate(A):
    now += a
    if i % 2 == 0:  # poisive
        if now <= 0:
            pos += -now + 1
            now = 1
    else:
        if now >= 0:
            pos += now + 1
            now = -1

neg = 0
now = 0
for i, a in enumerate(A):
    now += a
    if i % 2 == 0:
        if now >= 0:
            neg += now + 1
            now = -1
    else:
        if now <= 0:
            neg += -now + 1
            now = 1

print(min(pos, neg))

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

int main(){
	int N, T, A;
	cin >> N >> T >> A;
	int H[N];
	for(int i=0; i<N; i++) cin >> H[i];
	
	double dif=100000;
	int ans=0;
	for(int i=0; i<N; i++){
		double tmp=T-H[i]*0.006;
		if(abs(A-tmp)<dif){
          dif=abs(A-tmp);
          ans=i+1;
        }
      
     // cout << dif << " " << tmp << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)

n, m, q = map(int, input().split())

abcd = [0]*q
for i in range(q):
  abcd[i] = [int(x) for x in input().split()]



def dp(k, key, a):
  if k == 0:
    sub = 0
    for i in range(q):
      if key[abcd[i][1]-1] - key[abcd[i][0]-1] == abcd[i][2]:
        sub += abcd[i][3]
    return max([a, sub])
  elif k == n:
    sub = a
    for i in range(1, m+1):
      sub = max([dp(k-1, key+[i], sub), sub])
    return sub
  else:
    sub = a
    for i in range(key[-1], m+1):
      sub = max([dp(k-1, key+[i], sub), sub])
    return sub

ans = dp(n, [], 0)
print(ans)

Measured memory_bytes: 9192