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

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

    int n;
    cin>>n;
    int p[4],t[4];
    for(int i=0;i<4;i++){
        cin>>p[i];
    }
    for(int i=0;i<4;i++){
        cin>>t[i];
    }
    int ans=1e9;
    for(int i=0;t[0]*i<=n+t[0];i++){
        int a = t[0]*i;
        if(a>=n){
            int ret=p[0]*i;
            ans=min(ans,ret);
        }
        for(int j=0;j*t[1] + a <=n+t[1];j++){
            int b=j*t[1];
            if(a+b>=n){
                int ret=p[0]*i+p[1]*j;
                ans=min(ret,ans);
            }
            for(int k=0;k*t[2]+a+b<=n+t[2];k++){
                int c=k*t[2];
                if(a+b+c>=n){
                    int ret =p[0]*i+p[1]*j+k*p[2];
                    ans=min(ans,ret);
                }
                int d=(n-a-b-c)/t[3];
                if(a+b+c+d*t[3]<n) d++;
                if(d<=0) continue;
                int ret=i*p[0]+j*p[1]+k*p[2]+d*p[3];
                ans=min(ans,ret);
            }
        }
    }
    cout<<ans<<endl;

    
}


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

int main(){
    int H[100],M[100];
  	int k = 0;
  	while(true){
    	cin >> H[k] >> M[k];
      	if((H[k] == 0)&&(M[k] == 0))
          	break;
      	k++;
    }
  	for(int l = 0; l < k; l++){
  		for(int i = 0; i < H[l]; i++){
        	for(int j = 0; j < M[l]; j++){
            	cout << "#";
        	}
        	cout << endl;
    	}	
    	cout << endl;
    }
}


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

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

using namespace std;
using lint = long long;

int main(void)
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    

    vector<vector<int>> num(N+1, vector<int>(10, 0));
    for(int i = 0; i < N; i++){
        rep(k, 10) num[i+1][k] = num[i][k];
        num[i+1][S[i]-'0']++;
        //cout << num[i+1][S[i]-'0'] << endl;
    }
    int ans[10][10][10] = {0};
    for(int i = 0; i < N; i++){
        bool n_flag[10] = {false};
        for(int j = i+1; j < N; j++){
            if(n_flag[S[j]-'0']) continue;
            n_flag[S[j]-'0'] = true;
            for(int k = 0; k < 10; k++){
                if(num[N][k] - num[j+1][k] > 0){
                    ans[S[i]-'0'][S[j]-'0'][k] = 1;
                    //cout << i << " " << j  << " " << k << endl;
                }
            }
        }
    }
    int ans_num = 0;
    rep(i, 10)rep(j, 10)rep(k, 10)ans_num += ans[i][j][k];
    cout << ans_num << endl;
    return 0;

}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int a, b, MAX, ice[90][90], x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
void waru(int c, int d, int e) {
	ice[c][d] = false;
	MAX = max(MAX, e);
	for (int i = 0; i < 4; i++) {
		int dx = c + x[i], dy = d + y[i];
		if (dx >= 0 && dx < a&&dy >= 0 && dy < b&&ice[dx][dy])waru(dx,dy,e+1);
	}
	ice[c][d] = true;
}
int main() {
	while (cin >> b >> a, a | b) {
		MAX = 0;
		for (int c = 0; c < a; c++) {
			for (int d = 0; d < b; d++) {
				cin >> ice[c][d];
			}
		}
		for (int c = 0; c < a; c++) {
			for (int d = 0; d < b; d++) {
				if (ice[c][d])waru(c, d, 1);
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }
int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int N,g,ans=0;

int main(){
    cin>>N;
    int A[N];
    cin>>A[0];
    g=A[0];
    repi(i,1,N){
        cin>>A[i];
        g=gcd(g,A[i]);
    }
    while(g%2==0){
        g/=2;
        ans++;
    }
    out(ans);
}


Measured memory_bytes: 256
n, h, *k = map(int, open(0).read().split())
a = max(k[::2]); b = sorted(k[1::2], reverse = True)

ans = 0
while ans < n and b[ans] > a and h > 0:
    h -= b[ans]
    ans += 1
if h > 0: ans += (h + a - 1) // a
print(ans)

Measured memory_bytes: 25124
import math
N = input()
d = list(map(int, list(N)))
N = int(N)

comb = [0] * 10 * 10
for i in range(1,N + 1):
  top = str(i)[0]
  bot = str(i)[-1]
  pair = 0
  pair = int(str(i)[0]) * 10 + int(str(i)[-1])
  comb[pair] += 1

ans = 0

for i, var in enumerate(comb):
  top = int(str(i)[0])
  bot = int(str(i)[-1])
  if top == bot:
    ans += var ** 2
  else:
    ans += comb[top * 10 + bot] * comb[top + bot * 10]
    

print(ans)




Measured memory_bytes: 73588
import java.util.Scanner;

// https://atcoder.jp/contests/abc141/submissions/7542028がjavaだとTLEせず通るのかテスト
// 結合なしで普通に出力する場合
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long K = Long.parseLong(sc.next());
        int Q = Integer.parseInt(sc.next());

        int[] A = new int[Q];
        for (int i = 0; i < Q; i++) {
            A[i] = Integer.parseInt(sc.next());
        }

        solve(N, Q, K, A);
    }

    public static String solve(int n, int q, long k, int[] a) {
        long[] dp = new long[n];
        for (int i = 0; i < q; i++) {
            int winner = a[i];
            dp[winner - 1] = dp[winner - 1] + 1;
        }

        for (long element : dp) {
            System.out.println(q - k >= element ? "No" : "Yes");
        }
        return null;
    }
}



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

int main(){
  int n,k;
  cin >> n >> k;
  
  int ans = 0;
  
  while(n){
    n /= k;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
   string s;
   cin>>s;
   
   if(s[5]=='1')
     cout<<"TBD";
   else if(s[6]-'0'>4)
       cout<<"TBD";
       
       else
       cout<<"Heisei";
 return 0;
}

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

using namespace std;
typedef pair<double, double> P;
const double eps = 1e-9;

double dist(P p1)
{
	return(sqrt(p1.first * p1.first + p1.second * p1.second));
}

double dot(P p1, P p2)
{
	return(p1.first * p2.first + p1.second * p2.second);
}

double det(P p1, P p2)
{
	return(p1.first * p2.second - p1.second * p2.first);
}

void solve()
{
	double D;
	while(cin >> D, D)
	{
		P p, v;
		cin >> p.first >> p.second >> v.first >> v.second;
		if(fabs(det(p, v)) < eps)
		{
			double d = dist(p);
			if(dot(p, v) < 0 && d <= D)
			{
				printf("%.8f\n", d);
			}
			else if(dot(p, v) > 0 && 2 - d <= D)
			{
				printf("%.8f\n", 2 - d);
			}
			else
			{
				cout << "impossible" << endl;
			}
		}
		else
		{
			cout << "impossible" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll y,z,n,p,m=0,k,h,w,sum=0,sum_a=0,sum_b=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u,v;
    bool ok=true;
    cin >> n;
    VL a(n),b(n+1);
    bool c[n];
    b[0] = 0;
    rep(i,n){
        cin >> a[i];
        c[i] = false;
    }
    sort(ALL(a));
    c[n-1]=true;
    for(int i=1;i<n;i++){
        b[i] = a[i-1] + b[i-1];
    }
    for(int i=n-2; i>=0; i--){
        if(2*(b[i]+a[i]) >= a[i+1]){
            if(c[i+1]==true){
                ans++;
                c[i] = true;
            }
        }
    }
    if(2*a[0] >= a[n-1]){
        cout << n << endl;
        return 0;
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1920
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

result = []
for i in range(n):
    nums = result[::]
    result.append(a[i])
    for n in nums:
        result.append(n + a[i])

for mi in m:
    ans = 'yes' if mi in result else 'no'
    print(ans)



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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    string S;
    cin >> N >> S;

    if(N % 2)
    {
        cout << "No\n";
        return 0;
    }

    for(int i=0; i<N/2; i++)
    {
        if(S[i] != S[i+N/2])
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

set<ll>pos[3];
vector<ll>pos1[3];


int main(void){
    ll n;
    string s;
    map<char,ll>t;
    map<ll,char>tinv;
    t['R']=0;
    t['G']=1;
    t['B']=2;
    tinv[0]='R';
    tinv[1]='G';
    tinv[2]='B';
    cin>>n>>s;
    for(ll i=0;i<n;i++){
        pos[t[s[i]]].insert(i);
        pos1[t[s[i]]].push_back(i);
    }
    ll ans = 0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(s[i]==s[j])continue;
            ll index=0;
            for(ll k=0;k<3;k++){
                if(s[i]==tinv[k])continue;
                if(s[j]==tinv[k])continue;
                index=k;
                break;
            }
            ll d=j-i;
            auto itr = upper_bound(pos1[index].begin(),pos1[index].end(),j);
            if(itr==pos1[index].end())continue;
            ll index1=itr-pos1[index].begin();
            //cout<<index1<<endl;
            ll siz = (ll)pos1[index].size();
            ans+=siz-index1;
            //cout<<siz-index1<<endl;
            if(pos[index].count(j+d)==1)ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3848
package main

import "fmt"

func main() {
	var Q, H, S, D, N int
	fmt.Scan(&Q, &H, &S, &D, &N)
	Q, H, S, D, N = 4*Q, 4*H, 4*S, 4*D, 4*N
	dp := make([]int, 20)
	for i := 0; i < 9; i++ {
		dp[i] = Q * i
	}
	for i := 0; i < 8; i++ {
		dp[i+1] = Min(dp[i+1], dp[i]+Q)
		dp[i+2] = Min(dp[i+2], dp[i]+H)
		dp[i+4] = Min(dp[i+4], dp[i]+S)
		dp[i+8] = Min(dp[i+8], dp[i]+D)
	}
	fmt.Println((N/8*dp[8] + dp[N%8]) / 4)
}

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


Measured memory_bytes: 1768
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
int a[104];
int main(){
  scanf("%d",&n);
  for (int i=0;i<n;i++)scanf("%d",a+i);
  sort(a,a+n);
  int ans=1;
  for (int i=1;i<n;i++)ans+=(a[i]!=a[i-1]);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[h, n] <- readToListN 2 <$> BS.getLine
	as <- readToListN n <$> BS.getLine
	putStrLn $ if sum as >= h then "Yes" else "No"


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

int main(void){
  vector<int> v;
  int cnt[100000],num[100000];
  int n,m,l,x,y;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int t; cin >> t;
    v.push_back(-t);
  }
  sort(v.begin(), v.end());
  m = l = 0;
  for (int i=0; i<n; i++){
    if (v[i]!=l){
      cnt[m]=1;
      num[m]=v[i];
      m++;
    } else {
      cnt[m-1]++;
    }
    l = v[i];
  }
  x = y = 0;
  for (int i=0; i<m; i++){
//    cout << cnt[i] << " " << num[i] << endl;
    if (cnt[i]>=4 && x==0 && y==0) x=y=num[i];
    else if (cnt[i]>=2 && x==0) x=num[i];
    else if (cnt[i]>=2) y=num[i];
    if (x*y) break;
  }
  cout << ((long long)x*y) << endl;
  return 0;
}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        int[] cnt = new int[26];
        Arrays.fill(cnt,0);

        String txt = in.nextLine();

        for(int i=0;i<txt.length();i++){
            cnt[txt.charAt(i)-'a']++;
        }

        for(int i=0;i<26;i++){
            if(cnt[i]%2 != 0){
                out.print("No");
                return;
            }
        }

        out.print("Yes");
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }

    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 24916
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = np.zeros(200000)
for _ in range(n):
  l, r = rm()
  li[l:r+1] = 1
print(int(sum(li)))









Measured memory_bytes: 27380
//逆

#include<iostream>
#include<algorithm>
#include<bitset>

#include<cmath>
#include<cstring>
#include<climits>

#include<vector>
#include<set>
#include<map>
#include<unordered_set>
//#include<unordered_map>
#include<tr1/unordered_map>

#include<fstream>
#include<chrono>

using namespace std;
using namespace std::tr1;
using namespace std::chrono;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef vector<int> v32;
typedef vector<ll> v64;

const ll MOD7 = 1e9 + 7;
const ll MOD9 = 1e9 + 9;
const ll INF  = 1LL << 57LL;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ITER iterator
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define ones __builtin_popcount
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
    // DANGER;
    ofstream out("output.txt");

    // ll t;
    // cin>>t;

    auto start = high_resolution_clock::now();

    ll n, k;
    cin>>n>>k;
    ll a[n];
    rep(i,0,n-1) cin>>a[i];

    ll dp[n];
    mem( dp,1 );
    dp[0] = 0;//, dp[1] = abs( a[1]-a[0] );
    // rep(i,2,n-1) dp[i] = min( dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]) );
    
    rep(i,1,n-1)
    {
        for(ll ind = i-k<0 ? 0 : i-k; ind<i; ind++)
        dp[i] = min( dp[i],dp[ind]+abs( a[i]-a[ind] ) );
    }

    cout<<dp[n-1]<<"\n";

    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

const int kMaxv = 4000010;
typedef long long int64;

bitset<kMaxv> Knapsack(vector<int>& a, int n) {
	bitset<kMaxv> knap;
	knap.set(0);
	for (int i = 1; i <= n; ++i) {
		knap = knap | (knap << a[i]);
	}
	return knap;
}

void Solve() {
	int n;
	cin >> n;

	vector<int> a(n + 1);

	double ave = 0;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		ave += a[i] * 0.5;
	}

	auto b = Knapsack(a, n);

	for (int i = 1; i < kMaxv; ++i) {
		if (b.test(i) && i >= ave) {
			cout << i << "\n";
			return;
		}
	}
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 2176
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll max = a * c;
    if (max < a * d)max = a * d;
    if (max < b * c)max = b * c;
    if (max < b * d)max = b * d;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        int K = sc.nextInt();
	        
	        int[] cnth=new int[H];
	        int cntf=0;
	        char[][] s = new char[H][W];
	        for(int i=0;i<H;i++) {
        		String c=sc.next();
	        	for(int j=0;j<W;j++) {
	        		s[i][j]=c.charAt(j);
	        		if(s[i][j]=='#')cnth[i]++;
	        	}
	        	if(cntf==0&&cnth[i]!=0) {
	        		cntf=i+1;
	        	}
	        }
	        
	        int ans=0;
			int flg=0;
	        int[][] m=new int[H][W];
	        for(int i=cntf-1;i<H;i++) {
	        	for(int j=0;j<W;j++) {
	        		if(cnth[i]==0) {
	        			m[i][j]=m[i-1][j];
	        		} else {
	        			if(j==0) {
		        			ans++;	        					
	        				flg=0;
	        			}
	        			if(s[i][j]=='#') {
	        				if(flg==0) {
	        					flg++;
	        				} else {
	        					ans++;
	        				}
	        			}
	        			m[i][j]=ans;
	        			
	        		}
	        	}
	        }
	        
	        for(int i=cntf-2;i>=0;i--) {
	        	for(int j=0;j<W;j++) {
	        		m[i][j]=m[i+1][j];
	        	}
	        }
	        StringBuffer sf=new StringBuffer();
	        for(int i=0;i<H;i++) {
	        	for(int j=0;j<W;j++) {
	        		sf.append(m[i][j]);
	        		if(j==W-1) {
		        		sf.append("\n");
	        		} else {
		        		sf.append(" ");
	        		}
	        	}
	        }
	        System.out.println(sf);
	 }
	 

}

Measured memory_bytes: 30984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 10;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
inline int add(int a, int b) { a += b; if (a >= mod) return a - mod; return a; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

int n;
ll m; // debuged, m is ll+
vector<ll> a; // debuged, ll in check, x is ll

ll check(ll x) { // x以上 mペア ok?
    ll sum = 0;
    rep(i, n) {
      int it = lb(a, x - a[i]);
      sum += n - it;
      // if (sum >= m) return sum; debuged
    }
    if (sum >= m) return sum; // debuged, add if statement
    return 0;
}

template<typename T>
void binary_search(T ok, T ng) {
    while (abs(ng - ok) > 1) {
        T mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    
    vector<ll> acc;
    acc.eb(0);
    rep(i, n) acc.eb(acc.back() + a[i]);
    ll ans = 0;
    rep(i, n) {
      int it = lb(a, ok - a[i]);
      ans += 1LL * (n - it) * a[i] + (acc[n] - acc[it]);
    }

    ans -= (check(ok) - m) * ok;
    cout << ans << endl;
    /*
    mより多い分すべて下端の値
    そうじゃなければ, 下端の値上げれる
    */
}

void solve() {
  cin >> n >> m;
  a.resize(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  binary_search(0LL, 200005LL); // debuged, 10000000001LL to 200005LL
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int A, B, V, W, T;
	cin>>A>>V>>B>>W>>T;
	cout<<(abs(A-B)<=1LL*(V-W)*T ? "YES\n":"NO\n");
	return 0;
}

Measured memory_bytes: 3668
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long K, A, B;
    scan(K, A, B);
    if (B < A)
    {
        writeln(1 + K);
    }
    else
    {
        long k = K;
        k -= A - 1;
        long r = A + (B - A) * (k / 2) + (k & 1);
        max(1 + K, r).writeln();
    }
}


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

int main(void){
    int N;
    cin >> N;
    int C[N],V[N];
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }

    int sub,rel = 0;
    for(int i = 0; i < N; i++) {
        sub = C[i] - V[i];
        if(sub >= 0){
            rel += sub;
        }
    }

    cout << rel <<endl;

    return 0;
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    N = get_input(int)
    A = get_inputs(int)


    idx2children = [[] for _ in range(N+1)]
    for i in range(2, N+1):
        idx2children[A[i-2]].append(i)

    for i in range(1, N+1):
        print(len(idx2children[i]))



    










if __name__ == '__main__':
    main()


Measured memory_bytes: 62460
#include<cstdio> 
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
#define fir first
#define sec second
#define mp make_pair
using namespace std;

namespace flyinthesky {

	const LL MO = 1e9 + 7;

	int n, a[200000 + 5], b[200000 + 5], lst[200000 + 5], tax[200000 + 5];
	LL dp[200000 + 5];

    void clean() {
    }
    int solve() {
    	
    	clean();
    	cin >> n;
    	for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
    	
    	int tmp = n; n = 0;
    	for (int i = 1; i <= tmp; ++i) if (b[i] != b[i - 1]) a[++n] = b[i];
    	
    	for (int i = 1; i <= n; ++i) lst[i] = tax[a[i]], tax[a[i]] = i;
    	
    	dp[0] = 1;
    	for (int i = 1; i <= n; ++i) {
    		dp[i] = dp[i - 1];
    		if (lst[i]) (dp[i] += dp[lst[i]]) %= MO;
		}
		
		cout << dp[n];
    	
        return 0;
    }  
}
int main() {
    flyinthesky::solve();
    return 0;
}
/*
*/

Measured memory_bytes: 4992
N, A = gets.split.map(&:to_i)
Xs = [nil] + gets.split.map(&:to_i)

XM = (Xs.compact + [A]).max
SM = XM * N
@dp = Array.new(N + 1){Array.new(N + 1){Array.new(SM + 1, 0)}}
@dp[0][0][0] = 1
(1 .. N).each do |i|
  (0 .. i).each do |j|
    (0 .. SM).each do |k|
      @dp[i][j][k] = @dp[i - 1][j][k] + ((j >= 1 && k >= Xs[i]) ? @dp[i - 1][j - 1][k - Xs[i]] : 0)
    end
  end
end
puts (1 .. N).inject(0){|s, j| s + @dp[N][j][j*A]}

Measured memory_bytes: 52604
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
const ll INF = 1LL << 60;
int main() {
	int n;
	ll a, b;
	scanf("%d%lld%lld", &n, &a, &b);
	vector<int> p(n);
	vector<ll> dp(n + 1, INF), ndp(n + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i]);
		fill(ndp.begin(), ndp.end(), INF);
		for (int j = 0; j <= n; ++j) {
			ll cost;
			if (p[i] > j) cost = a;
			else cost = b;
			ndp[j] = min(ndp[j], dp[j] + cost);
			if (j < p[i]) ndp[p[i]] = min(ndp[p[i]], dp[j]);
		}
		swap(ndp, dp);
	}
	ll ans = *min_element(dp.begin() + 1, dp.end());
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n,q;
vl edge[200010];
vp p;
vl query(200010,0);
vl ans(200010,0);
vl visited(200001,0);

void input(void){
    ll a,b;
   cin>>n>>q;
   rep(i,n-1){
       cin>>a>>b;
       edge[a].push_back(b);
       edge[b].push_back(a);
   }
   rep(i,q){
       cin>>a>>b;
       query[a]+=b;
   }
}
void bfs(ll x,ll y){
    visited[x]=1;
    ans[x]=y+query[x];
    rep(i,edge[x].size()){
        if(visited[edge[x][i]]==0){
            bfs(edge[x][i],query[x]+y);
        }
    }
}
void solve(void){
    bfs(1,0);
    rep(i,n){
        cout<<ans[i+1]<<endl;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 27392
#coding:utf-8
N,T=map(int,raw_input().split())
A=map(int,raw_input().split())
A.reverse()
ma=-1
B=[-1145181919810]*N
for i in range(len(A)):
    if ma<A[i]:ma=A[i]
    else:B[i]=ma-A[i]
mi=max(B)
ans=0
for b in B:
    if b==mi:ans+=1
print(ans)

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

int main() {
	// your code goes here
	int n;
	long long sum;
	cin>>n;
	int arr[n],dp[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	for(int i=2;i<n;i++)
	{
		if(dp[i-1]+abs(arr[i]-arr[i-1])<dp[i-2]+abs(arr[i]-arr[i-2]))
			dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
		else
			dp[i]=dp[i-2]+abs(arr[i]-arr[i-2]);
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int a, sum = 0, i;
  double b, ave, sum2 = 0.0;

  i = 0;
  while (scanf("%d,%lf", &a, &b) != EOF) {
    sum += a * (int)b;
    sum2 += b;
    i++;
  }
  
  ave = sum2 / i;
  if (ave - ((int)ave + 1) >= -0.5)
    ave += 1.0;
  
  printf("%d\n%d\n", sum, (int)ave);

  return 0;
}

Measured memory_bytes: 624
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S= one_str()

Q = one_int()

Qs = [ input() for i in range(Q)]
def ss(S, Qs):
    is_not_ac=False
    head = ""
    tail = ""
    for temp in Qs:
#         temp = input()
        if len(temp)>=2:
            T, F, C = temp.split()
            if F=="1":
                if is_not_ac:
                    tail += C
                else:
                    head += C
            else:
                if is_not_ac:
                    head += C
                else:
                    tail += C
        else:        
            is_not_ac = not is_not_ac
    if is_not_ac:
        return tail[::-1] + S[::-1] + head
    else:
        return head[::-1] + S + tail


print(ss(S,Qs))

Measured memory_bytes: 16804
#include <string>
#include <iostream>
using namespace std;
bool check(string s, string t, string u) {
	int ls = 0, lt = 0;
	for(int i = 0; i < u.size(); i++) {
		if(i % 2 == 0) {
			while(ls <= s.size()) {
				if(ls == s.size()) return false;
				if(u[i] == s[ls]) {
					ls++;
					break;
				}
				ls++;
			}
		}
		else {
			while(lt <= t.size()) {
				if(lt == t.size()) return false;
				if(u[i] == t[lt]) {
					lt++;
					break;
				}
				lt++;
			}
		}
		// cout << i << ' ' << ls << ' ' << lt << endl;
	}
	return true;
}
int main() {
	string s, t;
	cin >> s >> t;
	if(check(s, t, s) || check(t, s, s)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3196
#include<stdio.h>
#include<math.h>
#include<string.h>
#define ll long long
using namespace std;
const int maxn=1e5;
const ll mod=1e9+7;
bool check[maxn+10];
int prime[maxn+10];
int mu[maxn+10];
ll sum[maxn+10];
int n,k;
void mo()
{
    memset(check,0,sizeof(check));
    mu[1]=1;
    int tot=0;
    for(int i=2;i<=maxn;i++)
    {
        if(!check[i]){prime[tot++]=i;mu[i]=-1;}
        for(int j=0;j<tot;j++)
        {
            if(i*prime[j]>maxn) break;
            check[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                mu[i*prime[j]]=0;break;
            }
            else
                mu[i*prime[j]]=-mu[i];
        }
    }
    for(int i=1;i<=maxn;i++)
        sum[i]=(sum[i-1]+mu[i])%mod;
}
ll fpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    mo();
    ll ans=0;
    for(int i=1;i<=k;i++)
    {
        ll res=0;
        for(int j=1;j<=k/i;j++)
            res=(res+mu[j]*fpow(k/i/j,n)%mod)%mod;
        ans=(ans+res*i%mod)%mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3048
#include<stdio.h>
int main()
{
	char a[10001];
	int i=0;
	int b;
	int c = 0, c1 = 0;
	while (scanf("%s", &a) != EOF){
		c = 0;
		c1 = 0;
		i = 0;
		while (a[i + 2] != EOF){
			if (a[i] == 'J'&&a[i + 1] == 'O'&&a[i + 2] == 'I'){
				c++;

			}
			if (a[i] == 'I'&&a[i + 1] == 'O'&&a[i + 2] == 'I'){
				c1++;
			}
			i++;
		}
		for (b = 0; b < 10000; b++){
			a[b] = 0;
		}
printf("%d\n%d\n", c, c1);	
	}
	return 0;
	
}

Measured memory_bytes: 552
#include<stdio.h>
int main()
{
    int a,b,c,i,count=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        {
             count++;



        }

    }
     printf("%d\n",count);
    return 0;
}



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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    // 入力
    int D,N;
    cin>>D>>N;
    if(N==100) cout<<(int)pow(100,D)*(N+1)<<endl;
    else cout<<(int)pow(100,D)*N<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	ll a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	int ans=0;
	//if((b+a-1)/a<=n){
	//	ans=max(1ll*ans,((b+a-1)/a)*a/b-a*((b+a-1)/a/b));
	//}
	n=min(n,b-1);
	ans=max(ans*1ll,(a*n)/b-a*(n/b));
	//for(int i=0;i<=min(a,n);i++){
	//	ans=max(1ll*ans,(a*i)/b-a*(i/b));
	//}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

ll gcd(ll a,ll b)
{
	if(a==0)
		return b;
	else
		return(gcd(b%a,a));
}

ll lcm(ll a,ll b)
{
	ll ans=(a*b)/gcd(a,b);
	return ans;
}

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	ll te=1,test,i,j,n,m,flag,k,p,temp;
	//cin>>te;
	
	for(test=1;test<=te;test++)
	{
		string s;
		cin>>s;
		n=s.length();
		temp=0;
		fore(i,n)
		{
			temp+=(s[i]-'0');
		}

		if(temp%9==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		/*vll a(n);
		fore(i,n)
		{
			cin>>a[i];
		}*/


		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

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

int main() {
  int n;
  int a, b;

  cin >> n;
  switch(n) {
  case 1:
    cout << "Hello World" << endl;
    break;
  case 2:
    cin >> a >> b;
    cout << a + b << endl;
    break;
  default:
    break;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N,M;
	cin >> N >> M;
	int a[50],b[50];
	vector<int> tonari[50];
	for(int i=0; i<M; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		tonari[a[i]].push_back(b[i]);
		tonari[b[i]].push_back(a[i]);
	}

	int ans = 0;
	for(int i=0; i<M; i++){
		bool already[50] = {};
		already[a[i]] = true;
		queue<int> que;
		que.push(a[i]);
		bool notBridge = false;
		while(!que.empty()){
			int now = que.front();
			que.pop();
			if(now == b[i]){
				notBridge = true;
				break;
			}
			for(int j=0; j<tonari[now].size(); j++){
				int next = tonari[now][j];
				if(!already[next] && !(now==a[i] && next==b[i])){
					already[next] = true;
					que.push(next);
				}
			}
		}
		if(!notBridge) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [0 for _ in range(n + 1)]
for i in range(m):
    A = int(input())
    a[A] = 1

tmp = [0 for _ in range(n + 1)]
tmp[0] = 1

for i in range(1, n + 1):
    if a[i] == 1:
        tmp[i] = 0
    else:
        if i - 2 >= 0:
            tmp[i] += tmp[i - 2]
        if i - 1 >= 0:
            tmp[i] += tmp[i - 1]
        tmp[i] %= 1000000007

print(tmp[n] % 1000000007)

Measured memory_bytes: 7816
# A
n = int(input()) 
h = list(map(int, input().split()))
dp = [0]*(n+1)

for i in range(2, n+1):
    h_index = i-1
    if i == 2:
        dp[i] = abs(h[h_index-1] - h[h_index])
    else:
        dp[i] = min(dp[i-1] + abs(h[h_index-1] - h[h_index]), dp[i-2] + abs(h[h_index-2] - h[h_index]))
print(dp[-1])

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll a[100010];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll k,m;
	ll x,y;
	for(k=n-1;k>=0;k--)
	{
		if(a[k]==a[k-1])
		{
			x=a[k];
			break;
		}
	}
	//cout<<k<<" ";
	for(m=k-2;m>=0;m--)
	{
		if(a[m]==a[m-1])
		{
			y=a[m];
			break;
		}
	}
	if(k<0||m<0)
	{
		cout<<"0"<<endl;
	}
	else
	{
		cout<<x*y<<endl;
	}
	return 0;
}

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

namespace _001_FindingMissingCards
{

    class Program
    {
        static void Main()
        {
            string word = Console.ReadLine();
            Boolean cont = true;
            int wc = 0;

            while (cont)
            {
                string sent = Console.ReadLine();
                if (sent == "END_OF_TEXT")
                {
                    cont = false;
                }
                else
                {
                    string[] sentWords = sent.Split(' ');
                    foreach (string tmpWord in sentWords)
                    {
                        if (tmpWord.ToLower() == word.ToLower())
                        {
                            wc++;
                        }
                    }
                }
            }
            Console.WriteLine(wc);
        }
    }
}

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

int main(){
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for(int i = A; i <= B; i++){
    bool palindromic = true;
    if(i / 10000 != i % 10){
      palindromic = false;
    }
    if((i / 1000 % 10) != (i % 100) / 10){
      palindromic = false;
    }
    if(palindromic){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> sc(m);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        sc[i] = make_pair(x, y);
    }

    long min = (n == 1 ? 0 : pow(10, n - 1));
    long max = pow(10, n);
    for (long i = min; i < max; i++) {
//        cout << i << endl << endl;
        bool flag = true;
        string tmp = to_string(i);
        for (int j = 0; j < m; j++) {
//            cout << tmp.substr(sc[j].first-1, 1) << "   ";
//            cout << stoi(tmp.substr(sc[j].first-1, 1)) <<  " / " << sc[j].second << endl;
            if(stoi(tmp.substr(sc[j].first-1, 1)) == sc[j].second) {
//                cout << "true" << endl;
            } else {
//                cout << "false" << endl;
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n;
char s[N];

int main() {
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++) {
		if(s[i]=='?') s[i]='D';
		cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>edge[2][100005],path[100005]; int n;
int col[100005],dw[100005];
bool bad;
int dfs(int v,int u,int t){
	vector<int>vec; int c = 0;
	for(int i=0;i<edge[t][v].size();i++){
		if(edge[t][v][i] == u) continue;
		int f = dfs(edge[t][v][i],v,t); c++;
		vec.pb(f);
	}
	if(t == 1 && ((dw[v]==1 && c%2 == 1) || (dw[v]==-1 && c%2 == 0))) bad=1;
	dw[v] = (c%2==0?1:-1);
	if(c%2 == 0) vec.pb(v);
	assert(vec.size()%2 == 1);
	for(int i=0;i<vec.size();i+=2){
		if(i+1 >= vec.size()) break;
		path[vec[i]].pb(vec[i+1]);
		path[vec[i+1]].pb(vec[i]);
	}
	return vec[vec.size()-1];
}
void dfs2(int v){
    for(int i=0;i<path[v].size();i++){
        if(col[path[v][i]]) continue;
        col[path[v][i]] = -1*col[v];
        dfs2(path[v][i]);
    }
}
int r[2];
int main(){
	scanf("%d",&n);
	rep(q,2) repn(i,n){
		int a; scanf("%d",&a);
		if(a!=-1) edge[q][a].pb(i);
		else r[q] = i;
	}
	rep(q,2){
		dfs(r[q],-1,q);
	}
	if(bad){
		puts("IMPOSSIBLE");
		return 0;
	}
	repn(i,n){
	    if(dw[i] == 1 && col[i] == 0){
	        col[i] = 1;dfs2(i);
	    }
	}
	puts("POSSIBLE");
	repn(i,n){
		if(dw[i] == -1) puts("0");
		else{
			if(col[i] != 0) printf("%d\n",col[i]);
			else puts("1");
		}
	}
}

Measured memory_bytes: 23424