akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.List
import Data.Ord

data Restaurant = Restaurant {number :: Int, city :: String, score :: Int}
  deriving (Show, Eq)

instance Ord Restaurant where
  compare r1 r2 = compare (city r1) (city r2) `mappend` compare (score r2) (score r1)

toRecords :: Int -> [[String]] -> [Restaurant]
toRecords _ [] = []
toRecords counter ([s1, s2]:xs) = Restaurant counter s1 (read s2):toRecords (counter + 1) xs

main :: IO ()
main = do
  n <- readLn
  input <- replicateM n $ words <$> getLine
  let list = toRecords 1 input
  mapM_ (print . number) $ sort list


Measured memory_bytes: 1020
import collections


def main():
    N = int(input())

    SN = []
    for _ in range(N):
        S = input()
        SN.append(S)

    SN_counter = collections.Counter(SN)
    most_count = SN_counter.most_common()[0][1]

    for S in sorted([S for S in SN_counter if SN_counter[S] == most_count]):
        print(S)


main()


Measured memory_bytes: 45028
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n,k int
    fmt.Scan(&n,&k)
    ans := 1
    for i:=0;i<n;i++{
        if ans * 2 < ans + k{
            ans *= 2
        } else {
            ans += k
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}


Measured memory_bytes: 640
def e_travel_by_car(INF=float('inf')):
    from copy import deepcopy
    from scipy.sparse.csgraph import floyd_warshall
    N, M, L = [int(i) for i in input().split()]
    Roads = [[int(i) for i in input().split()] for j in range(M)]
    Q = int(input())
    Queries = [[int(i) for i in input().split()] for j in range(Q)]

    graph = [[INF] * N for _ in range(N)]
    for k in range(N):
        graph[k][k] = 0
    fuel = deepcopy(graph)

    for a, b, c in Roads:
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = c
    dist = floyd_warshall(graph)

    for i in range(N):
        for j in range(N):
            fuel[i][j] = int(dist[i][j] <= L)
    fuel = floyd_warshall(fuel)

    ans = [-1 if fuel[s - 1][t - 1] == INF else int(fuel[s - 1][t - 1]) - 1 for s, t in Queries]
    return '\n'.join(map(str, ans))

print(e_travel_by_car())

Measured memory_bytes: 41632
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <numeric>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  vector<int> D(N);
  for (int i = 0; i < N; i++) D[i] = V[i] - C[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (D[i] > 0) ans += D[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 303
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,gu,dp[N][N][N],a[N],ans,sum[N];
char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1),m=read();
	s[++n]='0';
	m=min(n,m);
	for(int i=1;i<=n;++i){
		if(s[i]=='0')++gu;
		else ++a[gu+1];
	}
	for(int i=1;i<=gu;++i){
		sum[i]=a[i]+sum[i-1];
	}
	dp[0][0][0]=1;
	for(int i=1;i<=gu;++i){
		for(int j=sum[i];j<=n-gu;++j){
			int lim=min(j,n-sum[i-1]-gu);
			for(int k=0;k<=m;++k){
				for(int p=0;p<=lim;++p){
					if(max(0,p-a[i])<=k)dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-p][k-max(0,p-a[i])])%mod;
				}
			}
		}
	}
	for(int k=0;k<=m;++k){
		ans=(ans+dp[gu][n-gu][k])%mod;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 30244
import math
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

n=ii()
s=ip()
ans=1
for i in range(1,n):
    if(s[i]!=s[i-1]):
        ans+=1
print(ans)        

Measured memory_bytes: 72312
N = int(input())
lst_H = list(map(int, input().split()))


ans = "Yes"
lst_H[0] -= 1
for i in range(1, N):
    if lst_H[i - 1] < lst_H[i]:
        lst_H[i] -= 1
    elif lst_H[i - 1] == lst_H[i]:
        continue
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long subnum(long _S, long _start, long _end) {
    long big = 1, small = 1;
    for (long i = 0; i < _end; i++) big *= 10;
    for (long i = 0; i < _start; i++) small *= 10;

    return ((_S / small) * small - (_S / big) * big) / small;
}

int main () {
    string sS;
    cin>>sS;
    long S = atol(sS.c_str());
    long sum = 0;
    for (long n = 0; n < (1 << (sS.length()-1)); n++) {
        long start = 0;
        for (long i = 1; i < sS.length(); i++) {
            if (n & (1 << (i-1))) {
                sum += subnum(S, start, i);
                start = i;
            }
        }
        sum += subnum(S, start, sS.length());
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappush, heappop

N = int(input())
xy = [[int(i) for i in input().split()] for j in range(N)]

xsort_n = sorted(range(N), key=lambda n:xy[n][0])
ysort_n = sorted(range(N), key=lambda n:xy[n][1])
neighbours = defaultdict(list)

for i in range(N-1):
    x1 = xsort_n[i]
    x2 = xsort_n[i+1]
    xd = xy[x2][0] - xy[x1][0]
    y1 = ysort_n[i]
    y2 = ysort_n[i+1]
    yd = xy[y2][1] - xy[y1][1]
    neighbours[x1].append((x2, xd))
    neighbours[x2].append((x1, xd))
    neighbours[y1].append((y2, yd))
    neighbours[y2].append((y1, yd))

is_used = [0] * N
h = []
heappush(h, (0, 0))
result = 0

while h:
    d, n = heappop(h)
    if is_used[n]:
        continue
    result += d
    is_used[n] = 1
    for ni, nd in neighbours[n]:
        if not is_used[ni]:
            heappush(h, (nd, ni))

print(result)


Measured memory_bytes: 124888
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,pm,pe,pj;
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>pm>>pe>>pj;
      if(pm==100||pe==100||pj==100||(pe+pm)/2>=90||(pe+pm+pj)/3>=80){
	cout<<'A'<<endl;
      }
      else if((pe+pm+pj)/3>=70||((pe+pm+pj)/3>=50&&(pe>=80||pm>=80))){
	cout<<'B'<<endl;
      }
      else{
	cout<<'C'<<endl;
      }
    }
  }
}

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

INF = 10 ** 12

dp1 = [[-INF] * (N + 1) for _ in range(N + 1)] #X - Yの最大値
dp2 = [[+INF] * (N + 1) for _ in range(N + 1)] #X - Yの最小値

if N % 2 == 0: #偶数-->最後の一個はY
    for i in range(N):
        dp2[i][i + 1] = -A[i]
        # print (dp2[i][i + 1], end =' ')
    # print ()
    for k in range(2, N + 1):
        if k % 2 == 1:
            for i in range(N - k + 1):
                dp2[i][i + k] = min(dp1[i][i + k - 1] - A[i + k - 1], dp1[i + 1][i +k] - A[i])
                # print (dp2[i][i + k], end = ' ')
            # print ()
        else:
            for i in range(N - k + 1):
                dp1[i][i + k] = max(dp2[i][i + k - 1] + A[i + k - 1], dp2[i + 1][i + k] + A[i])
                # print (dp1[i][i + k], end = ' ')
            # print ()
    print (dp1[0][N])



else: #奇数-->最後の一個はX
    for i in range(N):
        dp1[i][i + 1] = A[i]
        # print (dp1[i][i + 1], end =' ')
    # print ()
    for k in range(2, N + 1):
        if k % 2 == 0:
            for i in range(N - k + 1):
                dp2[i][i + k] = min(dp1[i][i + k - 1] - A[i + k - 1], dp1[i + 1][i +k] - A[i])
                # print (dp2[i][i + k], end = ' ')
            # print ()
        else:
            for i in range(N - k + 1):
                dp1[i][i + k] = max(dp2[i][i + k - 1] + A[i + k - 1], dp2[i + 1][i + k] + A[i])
                # print (dp1[i][i + k], end = ' ')
            # print ()
    print (dp1[0][N])


Measured memory_bytes: 176392
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val D = sc.next().toInt()
        val c = IntArray(26) { sc.next().toInt() }
        val s = Array(D) { IntArray(26) { sc.next().toInt() } }
        val t = IntArray(D) { sc.next().toInt() }

        val d = IntArray(26)
        var ans = 0L
        for (i in 0 until D) {
            ans += s[i][t[i] - 1]
            d[t[i] - 1] = i + 1
            for (j in 0 until 26) {
                ans -= c[j] * (i + 1 - d[j])
            }
            pw.println(ans)
        }
    }
}


Measured memory_bytes: 42836
#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 A, B, C, K; cin >> A >> B >> C >> K;

    if (K <= A){
        cout << K << endl;
    } else if (K <= A+B){
        cout << A << endl;
    } else {
        cout << A - (K - (A+B)) << endl; 
    }
}

Measured memory_bytes: 3632
#include <iostream>

int main(){
    long long int n, k;
    std::cin >> n >> k;
    long long int sum = 0;
    const int mod = 1000000007;
    for (long long int i = k; i <= n+1; ++i)
    {
      sum += i * (n - i + 1) + 1;
      sum %= mod;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import Counter
from itertools import permutations

n=int(input())

def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr


fcr_l=[]
for i in range(1,n+1):
  fcr=factorization(i)
  fcr_l+=fcr


c=Counter(fcr_l)
fcr_st=set(fcr_l)

ans=[]
for p,q,r in permutations(fcr_st,3):
  if c[p]>=74:
    ans.append(p**74)
  if c[p]>=24 and c[q]>=2:
    ans.append((p**24)*(q**2))
  if c[p]>=14 and c[q]>=4:
    ans.append((p**14)*(q**4))
  if c[p]>=4 and c[q]>=4 and c[r]>=2:
    ans.append((p**4)*(q**4)*(r**2))

print(len(set(ans)))

Measured memory_bytes: 9464
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double [] a = new double [N];
        double [] b = new double [N];
        double sum =0;
        int ans =0;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            sum+=a[i];
        }
       
        double ave = sum/(double)N;
       
        
        for(int i=0; i<N; i++){
            if(a[i]>=ave){
                b[i] = a[i] - ave;
            }else{
                b[i] = ave - a[i];
            }
        }
        
        double min =b[0];
        for(int i=1; i<N; i++){
            if(min>b[i]){
                ans = i;
                min = b[i];
            }
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 22996
#pragma GCC optimization_level 3
#include<bits/stdc++.h>
using namespace std;

bool is_prime(int x){
    if (x<=1)
    {
        return false;
    }
    for (size_t i = 2; i*i <= x; i++)
    {
        if (x%i==0)
        {
            return false;
        }
        
      
    }
    return true;
    
    
}
int main(){
    int a;
    cin>>a;
    
    int x = a;

    while (!is_prime(x))
    {
        x++;
    }
    cout << x; 
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	ll h,w;
	while(rl2(h,w),h,w)
	{
		if(h==0&&w==0)
			break;
		char key[50][50];
		map<char,PII>mp;
		fr(i,0,h)
			fr(j,0,w)
			{
				cin>>key[i][j];
				mp[key[i][j]]=MP(i,j);
			}
		string str;
		cin>>str;
		ll ct=0;
		PII pk=MP(0,0);
		fr(i,0,str.size())
		{
			PII tp=mp[str[i]];
			ct+=abs(pk.F-tp.F)+abs(pk.S-tp.S)+1;
			pk=tp;
		}
		wl(ct);
		NL;
	}

	return 0;
}




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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1400;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--; r--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = -1;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            cnt[c[R]]--;
            types -= !cnt[c[R]];
            R--;
        }
        while(R < r){
            R++;
            types += !cnt[c[R]];
            cnt[c[R]]++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15436
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>

#define MOD 1000000007

using namespace std;

int main()
{
	char input[100001];
	string str;
	int n;
	int i, j, k;
	long long dp[2][13] = { 0, };
	long long pos[2][13] = { 0, };
	int ptr;

	scanf("%s", input);

	str = input;

	n = str.size();

	for (i = 0; i < 13; i++)
	{
		pos[0][i] = i % 13;
	}

	if (str[n - 1] == '?')
	{
		for (i = 0; i < 10; i++)
		{
			dp[0][i] = 1;
		}
	}

	else
	{
		dp[0][str[n - 1] - '0'] = 1;
	}

	for (i = 1; i < n; i++)
	{
		ptr = n - i - 1;

		for (j = 0; j < 13; j++)
		{
			pos[i % 2][j] = pos[!(i % 2)][(j * 10) % 13];
		}

		if (str[ptr] == '?')
		{
			for (j = 0; j < 13; j++)
			{
				dp[i % 2][j] = 0;
			}

			for (k = 0; k < 10; k++)
			{
				for (j = 0; j < 13; j++)
				{
					dp[i % 2][(j + pos[i % 2][k]) % 13] = (dp[i % 2][(j + pos[i % 2][k]) % 13] + dp[!(i % 2)][j]) % MOD;
				}
			}
		}

		else
		{
			for (j = 0; j < 13; j++)
			{
				dp[i % 2][j] = 0;
			}

			for (j = 0; j < 13; j++)
			{
				dp[i % 2][(j + pos[i % 2][str[ptr] - '0']) % 13] = dp[!(i % 2)][j];
			}
		}
	}

	printf("%lld\n", dp[!(n % 2)][5]);

	return 0;
}


Measured memory_bytes: 384
import math

n=int(input())

def is_prime(n):
    if n <= 1:
        return False

    if n == 2:
        return True

    if n % 2 == 0:
        return False

    for i in range(3, math.ceil(math.sqrt(n)), 2):
        if n % i == 0:
            return False

    return True


for i in range(n, 10**6):
  if is_prime(i):
    print(i)
    break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
typedef long long ll;
const int INF=1e+09;
int X,Y,A,B,C;

int main(){    
    cin >> X >> Y >> A >> B >> C;
    priority_queue<ll> p;
    priority_queue<ll> q;
    priority_queue<ll> r;
    priority_queue<ll> all;
    ll tmp;
    rep(i,A){
        cin >> tmp;
        p.push(tmp);
    }

    rep(i,B){
        cin >> tmp;
        q.push(tmp);
    }

    rep(i,C){
        cin >> tmp;
        r.push(tmp);
    }

    rep(i,X){
        ll in=p.top();
        all.push(in);
        p.pop();
    }

    rep(i,Y){
        ll in=q.top();
        all.push(in);
        q.pop();
    }

    rep(i,C){
        ll in=r.top();
        all.push(in);
        r.pop();
    }

    ll ans=0;
    rep(i,X+Y){
        ll out = all.top();
        ans += out;
        all.pop();
    }

    cout << ans << endl;



}

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;
llong solve(llong a, llong b, llong n);
int main()
{
    llong n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    printf("%lld", solve(a, b, n));
    return 0;
}
llong solve(llong a, llong b, llong n)
{
    if (a > b)
        return solve(b, a, n);
    if ((b - a) & 1)
        return min(n - b + 1 + solve(a + n - b + 1, n, n), a + solve(1, b - a, n));
    return (b - a) >> 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int n;
lint dp[101][4][4][4];
const lint MOD = 1e9+7;

signed main(){
  cin >> n;
  dp[0][3][3][3] = 1;
  for(int i = 0; i < n; i++){
    for(int c1 = 0; c1 < 4; c1++){
      for(int c2 = 0; c2 < 4; c2++){
        for(int c3 = 0; c3 < 4; c3++){
          for(int c4 = 0; c4 < 4; c4++){
            if(c2 == 0 && c3 == 1 && c4 == 2) continue;
            if(c2 == 1 && c3 == 0 && c4 == 2) continue;
            if(c2 == 0 && c3 == 2 && c4 == 1) continue;
            if(c1 == 0 && c2 == 1 && c4 == 2) continue;
            if(c1 == 0 && c3 == 1 && c4 == 2) continue;
            dp[i + 1][c2][c3][c4] += dp[i][c1][c2][c3];
            dp[i + 1][c2][c3][c4] %= MOD;
          }
        }
      }
    }
  }
  lint ans = 0;
  for(int c1 = 0; c1 < 4; c1++){
    for(int c2 = 0; c2 < 4; c2++){
      for(int c3 = 0; c3 < 4; c3++) ans += dp[n][c1][c2][c3], ans %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>a(5);
    rep(i,5){
        cin>>a[i];
    }

    sort(all(a));

    if(N%a[0]==0){
        cout << N/a[0] + 4 << endl;
    }else{
        cout << N/a[0] + 5 << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3496
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a,b;
    cin >> a >> b;

    ll ret = mygcd(a,b);

    vector<ll> fct(1,0);

    ll t = 2;
    ll x = ret;
    while(t*t <= ret){
        if(x % t == 0){
            x/=t;
            if(fct.back() != t)fct.push_back(t);
            t--;
        }
        t++;
    }

    if(x != 1){
        fct.push_back(x);
    }

    cout << fct.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n;cin>>n;
    string WorE;
    vector<ll> a(n);
    cin>>WorE;

    for(i=0;i<n;i++){
        if(WorE[i]=='W'){
            a[i]=1;
        }else{
            a[i]=0;
        }
    }

    pre_process(a,sum);//累積和の作成

    ll min=300001,ans;
    for(i=0;i<=n;i++){
        ans=query(0,i,sum)+(n-i-query(i,n,sum));
        if(ans<min){min=ans;}
    }

    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

int main()
{
    int N, M = 0;
    cin >> N >> M;
    bool unLike[M] = {};

    for(int i = 0; i < N; i++)
    {
        int K;
        cin >> K;

        bool A[M] = {};

        for(int j = 0; j < K; j++)
        {
            int a;
            cin >> a;
            A[a - 1] = true;
        }

        for(int j = 0; j < M; j++)
        {
            if(!A[j])
                unLike[j] = true;
        }
    }

    auto count = count_if(&unLike[0], &unLike[M], [](bool x){ return !x;});
    
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int main() {
  ull h;
  cin >> h;

  ull m = 1;
  ull sum = 0;
  while (h >= 1) {
    h >>= 1;
    sum += m;
    m <<= 1;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		var y=Abs(s[2]-s[0]);
		var x=Abs(s[3]-s[1]);
		var g=Gcd(y,x);
		x/=g;
		y/=g;
		Console.WriteLine("{0}",(x+y-1)*g);
	}
	static long Gcd(long a,long b){
		long c=Max(a,b)%(b=Min(a,b));
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27552
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int ret = n * 800 - (n / 15) * 200;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz

n=int(input())
xy=[list(map(int,input().split()))+[i] for i in range(n)]
G=[]

# MSTを求める
xy.sort()
for j in range(1,n):
  sx,sy,si=xy[j-1]
  tx,ty,ti=xy[j]
  G.append((min(abs(sx-tx),abs(sy-ty)),si,ti))

xy.sort(key=lambda x:x[1])
for j in range(1,n):
  sx,sy,si=xy[j-1]
  tx,ty,ti=xy[j]
  G.append((min(abs(sx-tx),abs(sy-ty)),si,ti))

# Kruskal 法
u=UnionFind(n)
ans=0
G.sort()
for c,x,y in G:
  if u.root_same(x,y):continue
  u.unite(x,y)
  ans+=c
print(ans)


Measured memory_bytes: 49660
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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

int main() {
    int n;
    cin>>n;
    int jud=0;

    for(int i=0;i<26;i++) {
        for (int j = 0; j < 15; j++) {
            if (4 * i + 7 * j == n) {
                jud++;
            }
        }
    }

    if(jud>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	
	typedef long long ll;
	#define pi 3.14159265 
	#define EPS 1e-8
	
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"
 
	const ll INF=(ll)2e18;
	

	
	int main()
	{
		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
			
		
	
		 ll s,w;
		 cin>>s>>w;
		 if(s<=w)
			cout<<"unsafe";
		 else
			cout<<"safe";
		 
	}


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

static const int MAX = 100;
static const int long long INFTY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd() {
  for ( int k = 0; k < n; k++ )
    for ( int i = 0; i < n; i++ ) {
      if ( d[i][k] == INFTY ) continue;
      for ( int j = 0; j < n; j++ ) {
        if ( d[k][j] == INFTY ) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ )
      d[i][j] = ( (i == j) ? 0 : INFTY );

  for ( int i = 0; i < e; i++ ) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for ( int i = 0; i < n; i++ ) if ( d[i][i] < 0 ) negative = true;

  if ( negative ) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for ( int i = 0; i < n; i++ ) {
      for ( int j = 0; j < n; j++ ) {
        if ( j ) cout << " ";
        if ( d[i][j] == INFTY ) cout << "INF";
        else cout << d[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64
vector<P>G[1000];
int n,u,k;
const int INF=100000000;
int ans[1000];

int main(){
	int from,cost;
	cin>>n;

	rep(i,n){
		cin>>u>>k;
		rep(i,k){
				cin>>from>>cost;
				G[u].push_back(mp(from,cost));
		}
	}
	rep(i,n)ans[i]=INF;
	//ans[0]=0;
	priority_queue<P,vector<P>,greater<P> >que;//firstスタートからの重みsecond頂点
	que.push(mp(0,0));
	
	while(!que.empty()){
		P now=que.top();
		que.pop();
		if(ans[now.second]!=INF)continue;
		int index=now.second;
		ans[index]=now.first;
		//cout<<now.first<<endl;
		for(int i=0;i<G[now.second].size();i++)que.push(mp(now.first+G[index][i].second,G[index][i].first));//次への経路長、頂点番号
	}
	for(int i=0;i<n;i++)cout<<i<<" "<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define N 200005
char s[N];
long long tot=0,suf[N];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	int i=0,lp=0;
	for(;i<len;)
	{
		if(s[i]=='B'&&s[i+1]=='C') tot++,suf[tot]=lp,i+=2;
		else
		{
			if(s[i]=='A') lp++;
			else lp=0;
			i++;
		}
	}
	long long ans=0;
	for(int i=tot;i>=1;i--)
	{
		ans=ans+suf[i];	 
	}
	cout<<ans<<endl;
	
	
	
	
	return 0; 
} 

Measured memory_bytes: 4456
#pragma warning(disable:4996)

#include<iostream>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include <assert.h>
#define pb push_back
#define INF 0x3F3F3F3F //int 下较大值
#define inf 0x3F3F3F3F3F3F3F3F  // ll 下较大值 
#define moD 1000000003
#define pii pair<ll,ll>
#define eps 1e-10
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
typedef  long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll Mod = 998244352;
const int maxn = 2e6 + 10;
const double Inf = 10000.0;
const double PI = acos(-1.0);
using namespace std;


int bitcount(int x) {
    return x == 0 ? 0 : bitcount(x / 2) + (x & 1);
}


ll mul(ll a, ll b, ll m) {
    ll res = 0;
    while (b) {
        if (b & 1) res = (res + a) % m;
        a = (a + a) % m;
        b >>= 1;
    }
    return res % m;
}

ll quickPower(ll a, ll b, ll m) {
    ll base = a;
    ll ans = 1ll;
    while (b) {
        if (b & 1) ans = mul(ans, base, m);
        base = mul(base, base, m);
        b >>= 1;
    }
    return ans;
}

ll ksm(ll a, ll b, ll m) {
    ll base = a % m;
    ll ans = 1ll;
    while (b) {
        if (b & 1) ans *= base, ans %= m;
        base *= base, base %= m;
        b >>= 1;
    }
    return ans;
}



ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll Lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

ll readll() {
    ll x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

ull readull() {
    ull x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}

void Put(ll x) {
    if (x < 0) putchar('-'), x *= -1;
    if (x > 9) Put(x / 10);
    putchar(x % 10 + '0');
}

int main() {
    int n = readint();
    ll res = ksm(10, n, MOD);
    res += ksm(8, n, MOD);
    res = (res - 2 * ksm(9, n, MOD) % MOD + MOD) % MOD;
    Put(res);
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<algorithm>
using namespace std;
int dat[8];
int set[]={1,4,1,4,1,2,1,2};
int ans[8];
int main(){
	while(~scanf("%d",dat)){
		for(int i=1;i<8;i++)scanf("%d",dat+i);
		int m=0;
		int n=99999999;
		for(int i=0;i<8;i++){
			int count=0;
			int val=0;
			for(int j=0;j<8;j++){
				count+=min(set[(i+j)%8],dat[j]);
				val*=10;
				val+=set[(i+j)%8];
			}
			if(count>m){
				m=count;
				n=val;
				for(int j=0;j<8;j++)ans[j]=set[(i+j)%8];
			}else if(count==m&&val<n){
				n=val;
				for(int j=0;j<8;j++)ans[j]=set[(i+j)%8];
			}
		}
		printf("%d",ans[0]);
		for(int i=1;i<8;i++)printf(" %d",ans[i]);
		printf("\n");
	}
}

Measured memory_bytes: 0
N = int(input())
Ai = input().split()
Bi = input().split()
Ci = input().split()
tA = 0
ret = 0
for A in Ai:
    ret += int(Bi[int(A) - 1])
    if(tA != 0 and tA + 1 == int(A)):
        ret += int(Ci[int(A) - 2])
    tA = int(A)
print(ret)

Measured memory_bytes: 3064
def intget():
    return int(input())

def countup_coin(coin_unit, coin_nums):
    ret = []
    for i in range(0, coin_nums+1):
        ret += [coin_unit * i]

    return ret


i_500 = intget()
i_100 = intget()
i_50 = intget()
expect = intget()

ptn_count = 0

coin_ptn_500 = countup_coin(500, i_500)
coin_ptn_100 = countup_coin(100, i_100)
coin_ptn_50 = countup_coin(50, i_50)

for i in coin_ptn_500:
    for j in coin_ptn_100:
        for k in coin_ptn_50:
            if (i + j + k) == expect:
                ptn_count += 1

print(ptn_count)


Measured memory_bytes: 3064
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a*b)) << endl;
}

Measured memory_bytes: 768
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    long a = nextLong();
    long b = nextLong();
    long k = nextLong();

    long ans1 = a;
    long ans2 = b;

    if(a>=k){
      ans1 = a-k;
      ans2 = b;
    }
    else{
      long sa = k-a; //saだけ青木から減らす
      if(b>=sa){
        ans1 = 0;
        ans2 = b-sa;
      }
      else{
        ans1 = 0;
        ans2 = 0;
      }

    }

    System.out.println(ans1+" "+ans2);


  }

  static String next(){
    return sc.next();
  }

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

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

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 22740
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;


int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);
        string str;
        cin >> str;
        cout << (str == "ABC" ? "ARC" : "ABC");

}


Measured memory_bytes: 3588
H, W, K = list(map(int, input().split()))

M = [input().strip() for _ in range(H)]


def count(m):
    res = 0
    for j in range(H):
        for i in range(W):
            if m[j][i] == "#":
                res += 1
    return res


ans = 0

for j in range(2 ** H):
    for i in range(2 ** W):
        tmp = []
        for m in range(len(M)):
            tmp.append(M[m])

        for m in range(6):
            if j >> m & 1 == 1:
                tmp[m] = "r" * W

        for m in range(6):
            if i >> m & 1 == 1:
                for h in range(H):
                    tmp[h] = tmp[h][0:m] + "r" + tmp[h][m+1:]
        if count(tmp) == K:
            ans += 1

print(ans)


Measured memory_bytes: 69216
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    cin >> N;
    vi a(N), b(N);
    cin >> a >> b;
    bool flag = 1;
    while (1) {
        int cnt1 = 0;
        int cnt2 = 0;
        for (int i = 0; i < N; i++) {
            dump(a, b);
            if (a[i] == b[i]) {
                cnt1++;
                continue;
            }
            int tmp;
            if (i == 0) {
                tmp = b[N - 1] + b[1];
            } else if (i == N - 1) {
                tmp = b[N - 2] + b[0];
            } else {
                tmp = b[i - 1] + b[i + 1];
            }
            if (b[i] < tmp) {
                cnt2++;
            } else {
                if (a[i] >= b[i] % tmp) {
                    if ((b[i] - a[i]) % tmp == 0) {
                        ans += (b[i] - a[i]) / tmp;
                        b[i] = a[i];
                    } else {
                        flag = 0;
                        break;
                    }
                } else {
                    ans += b[i] / tmp;
                    b[i] %= tmp;
                }
            }
        }
        if (cnt2 == N) {
            flag = 0;
        }
        if (cnt1 == N || flag == 0) {
            break;
        }
    }

    if (flag) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

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

int main()
{
    int n , k; cin >> n >> k;
    long long h[n];
    for(int i=0 ; i<n ; i++)
        cin >> h[i];
    long long cost[n] = {0};
    cost[1] = abs(h[0] - h[1]);
    for(int i=2 ; i<n ; i++)
    {
        long long c = 1000000000000;
        int j;
        if(i<k) j=0; else j=i-k;
        for(j ; j<i ; j++)
            c = min(c , cost[j] + abs(h[j] - h[i]));
        cost[i] = c;
    }
    cout << cost[n-1];
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
using namespace std;
struct sb
{
    int a,b,c;
}f[100005];
bool cmp(sb u,sb w)
{
    if(u.a==w.a)
        return u.c<w.c;
    else
        return u.a<w.a;
}
int main()
{
    int n,m,i,j,anc=1;
    int s[100005],p[100005];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
    scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].c);
    sort(f,f+n,cmp);
    s[0]=f[0].c;
    p[0]=f[0].b;
    for(i=1;i<n;i++)
    {
        for(j=0;j<anc;j++)
        {
           if(s[j]==f[i].c)
           {
               p[j]=f[i].b;
               break;
           }
           else
           {
               if(p[j]<f[i].a)
               {
                   p[j]=f[i].b;
                   s[j]=f[i].c;
                   break;
               }
           }
        }
        if(j==anc)
        {
            p[anc]=f[i].b;
            s[anc]=f[i].c;
            anc++;
        }
    }
    printf("%d\n",anc);
}


Measured memory_bytes: 1280
b,e = map(int,input().split())
r = [0]*1000
for _ in range(int(input())):
  b1,e2 =map(int,input().split())
  for x in range(b1,e2):
      r[x] = 1
def check():
  for x in range(b,e):
    if r[x] ==1:
      return 1
  return 0
print(check())


Measured memory_bytes: 5600
#include <cstdio>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    set <string> S;
    int used[26][26];
    for ( int i = 0; i < 26; i++ ) {
        for ( int j = 0; j < 26; j++ ) {
            used[i][j] = 0;
        }
    }
    bool first = true;
    char prev;
    string A;
    for ( int i = 0; i < 100; i++ ) {
        if ( first ) {
            A = "a";
        } else {
            int t = prev - 'a';
            int minj = 0;
            int minu = used[t][0];
            for ( int j = 0; j < 26; j++ ) {
                if ( used[t][j] < minu ) {
                    minj = j;
                    minu = used[t][j];
                }
            }

            A = "";
            A += prev;
            for ( int j = 0; j <= used[t][minj]; j++ ) {
                A += 'a';
            }
            char y = minj + 'a';
            A += y;
            used[t][minj]++;
        }
        first = false;
        if ( A.size() > 10 || S.count(A) ) {
            i--;
            continue;
        }
        S.insert(A);
        printf( "?%s\n", A.c_str() ); fflush( stdout );
        char buf[256];
        scanf( "%s", buf );
        string B = buf;
        if ( S.count(B) || B[0] != A[A.size()-1] ) {
            printf( "!OUT\n" );
            break;
        }
        S.insert(B);
        prev = B[B.size()-1];
    }
    
    return 0;
}

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

using namespace std;
using LL = long long;

const int maxn = 110;
int n, k;
int d[maxn], a[maxn];
int vis[maxn];

signed main() {
  // freopen("in", "r", stdin);
  scanf("%d %d", &n, &k);
  memset(vis, 0, sizeof vis);
  int x;
  for (int i = 1; i <= k; i++) {
    scanf("%d", &d[i]);
    for (int j = 0; j < d[i]; j++) {
      scanf("%d", &x);
      vis[x]++;
    }
  }
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) ret++;
  }
  printf("%d\n", ret);
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}
 
#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}
 
ll dp[3333][2];
 
void modadd(ll &a, ll b){
	a += b;
	a %= MOD;
}
int main(){
  int h,w,n;cin>>h>>w>>n;
  dp[0][0]=1;
  vector<pair<int,int>>kabe(n);
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    kabe[i]=mp(a,b);
  }
  kabe.pb(mp(1,1));
  kabe.pb(mp(h,w));
  sort(ALL(kabe));
  for(int i=0;i<kabe.size();i++){
    for(int k=0;k<2;k++){
      if(dp[i][k]){
	for(int j=i+1;j<kabe.size();j++){
	  if(kabe[i].F<=kabe[j].F&&kabe[i].S<=kabe[j].S){
	    modadd(dp[j][(k+1)%2],dp[i][k]*combination((kabe[j].F-kabe[i].F)+(kabe[j].S-kabe[i].S),kabe[j].S-kabe[i].S)%MOD);
	  }
	}
      }
    }
  }
  cout<<(dp[n+1][1]-dp[n+1][0]+MOD)%MOD<<endl;
  return 0;
}

Measured memory_bytes: 3072