akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modBase = 1000000007 :: Integer

a *% b = ( a * b ) `mod` modBase

primeFactorization 1 = []
primeFactorization n = f 2 n
	where
		f p n
			| n == p = [p]
			| n `mod` p == 0 = p : f p ( n `div` p )
			| otherwise = f ( p + 1 ) n

nCr 0 _ = 1
nCr _ 0 = 1
nCr n r = nCr ( n - 1 ) ( r - 1 ) * n `div` r

nHr n r = nCr ( n + r - 1 ) r

main = do
	[ n, m ] <- map fromIntegral <$> readInts
	let degrees = map ( fromIntegral . length ) $ group $ primeFactorization m
	print $ foldl (*%) 1 $ map ( n `nHr` ) degrees

Measured memory_bytes: 892
import math
N = int(input())
M = int(math.sqrt(N))
M2 = int(math.sqrt(N-1))
y = []
for i in range(1,M2+1):
    if (N-1)%i == 0:
        m = (N-1)//i
        if not m == 1:
            y.append(m)
        if i == 1 or i == m:
            continue
        else:
            y.append(i)
count = len(y)

y = []
for i in range(1,M+1):
    if N%i == 0:
        m = N//i
        y.append(m)
        if i == 1 or i == m:
            continue
        else:
            y.append(i)

for i in y:
    NN = N
    while NN%i == 0:
        NN /= i
    # print(NN)
    if int(NN) % i == 1:
        count += 1
        # print(i)

print(count)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    REP(i, k) {
        int d;
        cin >> d;
        int x;
        REP(j, d) {
            cin >> x;
            x--;
            a[x]++;
        }
    }
    int ans = 0;
    REP(i, n) if (a[i] == 0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public City(long n){
      num = n;
    }
 
  }
 
  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ');
    var N = int.Parse(temp.ElementAt(0));
    var M = temp.ElementAt(1);
    var list = new List<List<long>>(); 
    var ans = 0; 

    for(var i = 0; i < N; i++){
      list.Add(Console.ReadLine().Split(' ').Select(long.Parse).ToList());
    }
  var tlist = new List<long>();
   tlist = list[0].Skip(1).ToList();
   for(var i = 0; i < N; i++){
      tlist = list[i].Skip(1).Intersect(tlist).ToList();
      ans = tlist.Count();  
   }


    Console.WriteLine(ans);
  }

}

Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline


def dijkstra(s, G):
    pq = []
    d = [float('inf')] * len(G)
    d[s] = 0
    heappush(pq, (0, s))

    while pq:
        c, v = heappop(pq)
        if d[v] < c:
            continue
        for t, c in G[v].items():          #  ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
            if d[t] > d[v] + c: #  ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
                d[t] = d[v] + c
                heappush(pq, (d[t], t)) #  python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
    return d


def main(args):
    while True:
        n, k = map(int, input().split())
        if n == 0 and k == 0:
            break

        d = [{} for _ in range(n+1)]
        costs = [[float('inf')]*(n+1) for _ in range(n+1)]
        updated = False
        for _ in range(k):
            data = [int(x) for x in input().split()]
            if data[0] == 0:
                f, t = data[1], data[2]
                if updated:
                    costs[f] = dijkstra(f, d)
                if costs[f][t] == float('inf'):
                    print(-1)
                else:
                    print(costs[f][t])
            else:
                f, t, c = data[1], data[2], data[3]
                if t in d[f]:
                    d[f][t] = min(d[f][t], c)
                else:
                    d[f][t] = c
                if f in d[t]:
                    d[t][f] = min(d[t][f], c)
                else:
                    d[t][f] = c
                updated = True


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int x=b-a;
    int y=c-b;
    if(x==y)
            {
                cout<<"YES"<<endl;

            }
        else
             {
                cout<<"NO"<<endl;

            }
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string>
#include<bits/stdc++.h>

#define ll long long

using namespace std;

int main()
{
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	if(x1==0)
		cout<<"1";
	else if(x2==0)
		cout<<"2";
	else if(x3==0)
		cout<<"3";
	else if(x4==0)
		cout<<"4";
	else
		cout<<"5";
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long arr1[100100] , arr[100100];
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i<=n ; i++) scanf("%lld" , &arr[i]) , arr1[i] = arr[i];
    long long ans1 = 0 , ans2 = 0;
    long long sum = 0;
    for(int i = 1 ; i<=n ; i++)
    {
        arr[i]+=arr[i-1];
        if(i%2==1)
        {
            if(arr[i]<=0) ans1+=(1-arr[i]) , arr[i] = 1;
        }
        else
        {
            if(arr[i]>=0) ans1+=(arr[i]+1) , arr[i] = -1;
        }
    }

    for(int i = 1 ; i<=n ; i++)
    {
        arr1[i]+=arr1[i-1];
        if(i%2==0)
        {
            if(arr1[i]<=0) ans2+=(1-arr1[i]) , arr1[i] = 1;
        }
        else
        {
            if(arr1[i]>=0) ans2+=(arr1[i]+1) , arr1[i] = -1;
        }
    }
    cout<<min(ans1 , ans2)<<endl;
    return 0;
}


Measured memory_bytes: 1792
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

p = "MARCH"
n = ip()                                     #入力整数1つ
#n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
# a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
c = [0 for i in range(5)]
for i in range(n):
    if a[i][0] in p:
        b = p.index(a[i][0])
        c[b]+=1
s = 0
for i in range(3):
    for k in range(i+1,4):
        for l in range(k+1,5):
            s+=c[i]*c[k]*c[l]
print(s)

Measured memory_bytes: 20364
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll r;
	cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n, k;
    cin >> n >> k;
    vector<int> dp(k+1, 0);     // dp[k] = 0 if there is no winning move from here
    
    vector<int> v(n);
    for(int j = 0; j < n; j++) cin >> v[j];
    for(int i = 1; i <= k; i++){
        for(auto j : v)
            if(j <= i && !dp[i - j]) dp[i] = 1;
    }
    if(dp[k]) cout << "First";
    else cout << "Second";
    return 0;
}

Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector < long long int >v(N);
	vector < long long int >w(N);
	for (auto &i : v)cin >> i;
	for (auto &i : w)cin >> i;
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());
	reverse(w.begin(), w.end());
	L = -1;
	R = MOD * MOD;
	while (R - L > 1) {
		long long int mid = (L + R) / 2;
		long long int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += max(0LL, v[i] - mid / w[i]);
		}
		if (sum <= K)R = mid;
		else L = mid;
	}
	cout << R << endl;
}



Measured memory_bytes: 3456
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int isOnSegment(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
    (dot(b-a, c-a) > -EPS) &&
    (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return isOnSegment(a1,a2,b1) || isOnSegment(a1,a2,b2)
      || isOnSegment(b1,b2,a1) || isOnSegment(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
      ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}


int main(void){

  int q;
  cin >> q;
  while(q--){
    point a,b,c,d;
    cin >> a.x >> a.y >> b.x >> b.y;
    cin >> c.x >> c.y >> d.x >> d.y;
    if(is_intersected_ls(a,b,c,d))cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,A,B,C;
  A=0;
  B=0;
  cin>>N;
  for(int i=0;i<=N;i++){
    if(i==0){
      A=2;}
    else if(i==1){
      A=1;}
    else if(i==2){
      A+=2;
    B=1;
    C=1;}
    else{
      B=A;
      A+=C;
      C=B;}
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
--bin search

import Data.Array


--assume that input array was sorted by assending

find::Array Int Int ->Int->(Int,Int)->Bool
find ar x (start,end)  =  let mid = div (start + end) 2 in
                          if (ar!mid ==x) || (ar!start ==x) || (ar!end ==x) then True else
                          if end - start <=1 then False else
                          if (ar!mid) > x then find ar x (start,mid) else
                          if (ar!mid) < x then find ar x (mid+1,end) else  False


--first
solver::Array Int Int -> [Int] -> Int
solver s t = sum (map (\ x -> if find s x (bounds s) then 1 else 0) t)

main::IO()
main = do
  nc<-getLine
  let n = read nc
  sc<-getLine
  let s = map read (words sc)::[Int]
  let s_arr = listArray (1,n) s
  _<-getLine
  tc<-getLine
  let t = map read (words tc)::[Int]
  print (solver s_arr t)

Measured memory_bytes: 63336
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int l = ReadInt();
            double ans = Pow((double)l / 3, 3);
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static string YesNo(bool condition) => condition ? "Yes" : "No";
        static string YESNO(bool condition) => condition ? "YES" : "NO";

        #endregion
    }
}

Measured memory_bytes: 13140
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
m = 0
s = 0
for i in l:
    if m<i:
        m = i
        s = l.index(i)

l[s]=l[s]/2
ans = 0
for i in l:
    ans += i
print(int(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

int n;
vector<int> d;

bool check(int x) {
        bool f = true;
        while (x > 0) {
                for (auto i : d) {
                        if (i == (x % 10)) f = false;
                }
                x /= 10;
        }
        return f;
}

signed main() { 
        int k;
        cin >> n >> k;
        rep(i, k) d.push_back(in());
        while (true) {
                if (check(n)) break;
                else n ++;
        }
        cout << n << endl;
        return 0;
}               



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	map<string, ll> vote;
	ll N,m=0;
	cin >> N;
	rep(i, N) {
		string S;
		cin >> S;
		if (vote.count(S)) {
			vote.at(S)++;
			m = max(m, vote.at(S));
		}
		else {
			vote[S] = 1;
			m = max(m, vote.at(S));
		}
	}
	for (auto p : vote) {
		auto k = p.first;
		auto v = p.second;
		if (v == m) {
			cout << k << endl;
		}
		
	}



}

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


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

    int jud=0;

    for(int i=1;i<10;i++){
        if(N%i==0&&(1<=(N/i)&&(N/i)<=9)){
            cout<<"Yes"<<endl;
            jud = 1;
            break;
        }

    }
    if(jud==0){
        cout<<"No"<<endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,m,n,l;
	ll a,b,c;
	cin>>n>>m>>k;
	int mat[n+1][m+1];
	int cost1[n+1];
	fl(i,n) {
		cin>>cost1[i];
		fl(j,m) {
			cin>>mat[i][j];
		}
	}
	vector<int>v2;
	fl(i,n) {
		v2.pb(i);
	}
	vector<int>v1[n+1];
	queue<vector<int> >q1;
	fl(i,n) {
		v1[i].pb(v2[i]);
		q1.push(v1[i]);
	}
	vector<int>temp,temp1;
	vector<vector<int> >subset;
	while(!q1.empty()) {
		temp=q1.front();
		subset.pb(temp);
		q1.pop();
		fl(i,v2.size()) {
			temp1=temp;
			if(v2[i]>temp[temp.size()-1]) {
				temp1.pb(i);
				q1.push(temp1);
			}
		}
	}
	ll ans=LONG_MAX;
	fl(i,subset.size()) {
		temp=subset[i];
		vector<int>check(m+1,0);
		ll cost=0;
		bool flag=0;
		fl(j,temp.size()) {
			cost+=cost1[temp[j]];
			fl(l,m) {
				check[l]+=mat[temp[j]][l];
			}
		}
		fl(j,m) {
			if(check[j]<k) {
				flag=1;
				break;
			} 
		}
		if(!flag) ans=min(ans,cost);
	}
	if(ans==LONG_MAX) ans=-1;
	cout<<ans<<"\n";
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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

int main() {
   int hour = 0;
   int unitPricePlanA = 0;
   int pricePlanA = 0, pricePlanB = 0;
  
  cin >> hour >> unitPricePlanA >> pricePlanB;
  
  pricePlanA = unitPricePlanA * hour;
  
  if(pricePlanA < pricePlanB)
  {
    cout << pricePlanA << endl;
  }
  else
  {
    cout << pricePlanB << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
using namespace std;

#define int int64_t
#define pb push_back
#define pbb pop_back
#define pf pop_front
#define pff push_front
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;

const int INF = 1e12, MOD = 1e9 + 7, MAXN = 1e5 + 7, MAX = 5;
const ld EPS = 1e-9, PI = acos(-1);

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
    cout.precision(10);

    int n, k;
    cin >> n >> k;
    vector<int> nums(n);
    for (int i = 0; i < n; ++i)
        cin >> nums[i];

    vector<int> neg, pos;
    for (int i = 0; i < n; ++i) {
        if (nums[i] < 0)
            neg.pb(nums[i]);
        else if (nums[i] == 0)
            k--;
        else
            pos.pb(nums[i]);
    }

    if (k == 0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = INF;
    if (neg.size() >= k)
        ans = min(ans, abs(neg[neg.size() - k]));
    if (pos.size() >= k)
        ans = min(ans, pos[k - 1]);
    for (int now = max((int)0, (int)(neg.size() - k + 1)); now < neg.size() && k - (neg.size() - now) <= pos.size(); ++now) {
        //cout << now << " " << k - (neg.size() - now) - 1 << " " << neg[now] << " " << pos[k - (neg.size() - now) - 1] << endl;
        ans = min(ans, abs(neg[now]) + pos[k - (neg.size() - now) - 1] + min(abs(neg[now]), pos[k - (neg.size() - now) - 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2424
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner  scn=new Scanner(System.in);
		double n=scn.nextDouble();
		double []arr=new double[5];
		double min=n;
		for(int i=0;i<5;i++) {
			arr[i]=scn.nextDouble();
			if(arr[i]<min) {
				min=arr[i];
			}
		}
		String d=new DecimalFormat("#").format(4+Math.floor((n/min))+(n%min!=0?1:0));
		
			System.out.println(d);
		
	}

}


Measured memory_bytes: 25300
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;

int main(void) {
    ll N, K;
    cin >> N >> K;
    ll x, y;
    char c;
    ll i, j;
    ll cnt[4*K+2][4*K+2];
    ll sum[4*K+2][4*K+2];
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    
    for(i=0; i<N; i++) {
        cin >> x >> y >> c;
        if(c=='W') {
            y+=K;
        }
        x%=2*K; y%=2*K;
        x++; y++;
        cnt[x][y]++;
        cnt[x][y+2*K]++;
        cnt[x+2*K][y]++;
        cnt[x+2*K][y+2*K]++;
    }
    
    
    
    
    for(i=1; i<=4*K; i++) {
        for(j=1; j<=4*K; j++) {
            sum[i][j]=cnt[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    
    ll ans=0;
    for(i=1; i<=2*K; i++) {
        for(j=1; j<=2*K; j++) {
            ll sqr1=sum[i+K-1][j+K-1]-sum[i-1][j+K-1]-sum[i+K-1][j-1]+sum[i-1][j-1];
            ll sqr2=sum[i+2*K-1][j+2*K-1]-sum[i+K-1][j+2*K-1]-sum[i+2*K-1][j+K-1]+sum[i+K-1][j+K-1];
            ans=max(ans, sqr1+sqr2);
        }
    }
    
    prin(ans);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(L.begin(), L.end());
  ll ans = 0;
  rep(i, n-2)rep2(j, i+1, n-1)rep2(k, j+1, n){
    if (L[i] == L[j] || L[j] == L[k]) continue;
    if (L[i] + L[j] > L[k]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23508
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

//---------------------------------------------------------------
// 整数 N が与えられます。
// 1 以上 N 以下の整数のうち、七五三数 は何個あるでしょうか？
//
// ここで、七五三数とは以下の条件を満たす正の整数です。
//
// 十進法で表記したとき、数字 7, 5, 3 がそれぞれ 
// 1 回以上現れ、これら以外の数字は現れない。
//---------------------------------------------------------------

long N;


int count(long s = 0, int seven=0, int five=0, int three=0) {
//    cout << "start " << s << endl;
    if(s > N) {
//	if(s != "" && atoi(s.c_str()) > N){
//	    cout << s << " > " << N << endl;
	    return 0;
	}
	int cnt = 0;
    if(seven > 0 && five > 0 && three > 0) {
//	if(s.find("7") != string::npos && s.find("5") != string::npos  && s.find("3") != string::npos) {
//	    cout << "[" << s << "]  cnt = 1" << endl;
		cnt += 1;
	}
//	cout << cnt << " " << s <<  "7" << endl;
//	cnt += count(s + "7", 1, five, three);
	cnt += count(s * 10 + 7, 1, five, three);
//	cout << cnt << " " << s <<  "5" << endl;
//	cnt += count(s + "5", seven, 1, three);
	cnt += count(s * 10 + 5, seven, 1, three);
//	cout << cnt << " " << s <<  "3" << endl;
//	cnt += count(s + "3", seven, five, 1);
	cnt += count(s * 10 + 3, seven, five, 1);
//	cout << "return " << cnt << endl;
	return cnt;
}

signed main(){
	cin >> N;

	cout << count() << endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let x = get!(usize);
    println!("{}", x/500*1000+(x-x/500*500)/5*5);
}


Measured memory_bytes: 8572
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N, A, B, n;

  std::cin >> N >> A >> B;

  n = N / (A + B);

  N -= n * (A + B);

  assert(N >= 0);

  std::cout << n * A + std::min(N, A) << std::endl;

  return 0;
}


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

public class Main {

    static class Question {
        int A, B;
        
        public void main(FastScanner in, PrintWriter out) {
            A = in.nextInt();
            B = in.nextInt();
            if (A % 3 == 0 || B % 3 == 0|| (A + B) % 3 == 0) out.println("Possible");
            else out.println("Impossible");
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) p( o[i][j] + " " );
                pl("");
            }
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Question q = new Question();
        q.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public void close() throws IOException { br.close(); }
    }
}


Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

int q, h, s, d, n;

int main(void) {
  scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
  h = min(h, 2 * q);
  s = min(s, 2 * h);
  d = min(d, 2 * s);

  li ans = (li)n / 2 * d + (li)n % 2 * s;
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
A = []
while True:
	a = [int(i) for i in input().split()]
	if a == [0,0]:
		break
	A.append(a)
	
for i in range(len(A)):
	if A[i][0] > A[i][1]:
		s = A[i][0]
		A[i][0] = A[i][1]
		A[i][1] = s
		
	print(A[i][0],A[i][1])


Measured memory_bytes: 6248
'use strict'

function main(input) {
    let obj = { 'A':true, 'T':true, 'C':true, 'G':true }
    input = input.split('')
    let max = 0;
    let tmp = 0;
    for (let i = 0; i < input.length; i++) {
        let str = input[i]
        if (obj[str]) {
            tmp += 1
            max = Math.max(tmp, max)
        }
        else {
            tmp = 0
        }
    }
    console.log(max)

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(h.at(i) >= k){
      cnt++;
    } else {
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3796
N = long(raw_input())
A = long(raw_input())
B = long(raw_input())
C = long(raw_input())
D = long(raw_input())
E = long(raw_input())

list = [A, B, C, D, E]
#print(list)

#slist = sorted(list, reverse=True)
#print(slist)

#list10 = map(lambda x: x % 10, list)
#print(list10)
lminindex = list.index(min(list))
#list.pop(lminindex)
min = list[lminindex]
#print(min)

T1 = -(-N // min) + 4
print(T1)


Measured memory_bytes: 2568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<int, pii> pipii;

pii l[100005];

void solve() {
  int n, h;
  cin >> n >> h;
  vector<int> use;
  int sustain = 0;
  for(int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    use.push_back(b);
    sustain = max(sustain, a);
  }
  sort(use.begin(), use.end());
  reverse(use.begin(), use.end());
  ll lhs = 1;
  ll rhs = 1e9;
  while(lhs != rhs) {
    ll mid = (lhs+rhs)/2;
    ll t = mid;
    ll did = 0;
    for(int out: use) {
      if(out <= sustain || t == 0) break;
      t--;
      did += out;
    }
    did += t * sustain;
    if(did >= h) rhs = mid;
    else lhs = mid+1;
  }
  cout << lhs << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	int n,k;
	cin>>n>>k;
	cout<<(n+k-1)/k;
	return 0;
}

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

using ll=long long;

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
typedef long long ll;
const int MOD = 1000000007;

int D;
vector<int> cs(26);
vector<vector<int>> ss;

int calc_score(vector<int>& out) {
    int sat = 0;
    vector<int> lasts(26, 0);
    rep(d, D) {
        int j = out[d] - 1;
        lasts[j] = d + 1;
        rep(i, 26) sat -= (d+1-lasts[i])*cs[i];
        sat += ss[d][j];
    }
    return sat; 
}

pair<int, int> calc_prepro(int x, int d, vector<int>& outs) {
    int pre = 0, pro = D+1;
    rep(i, D) {
        if (outs[i] == x) {
            if (i < d - 1) pre = max(i+1, pre);
            if (i > d - 1) pro = min(i+1, pro);
        }
    }
    return {pre, pro};
}

int tosum(int n) {
    return n*(n+1)/2;
}

int calc_partial_score(int x, vector<int> outs) {
    int s = 0, last = 0;
    rep(d, D) {
        if (outs[d] == x) {
            s += tosum(d-last)*cs[x-1];
            last = d + 1;
        }
        // s += (d+1-last)*cs[x-1];
    }
    s += tosum(D-last)*cs[x-1];
    return s;
}

int chage_outs(int d, int to, vector<int>& outs, int score) {
    int from = outs[d-1];
    score -= -calc_partial_score(from, outs); 
    score -= -calc_partial_score(to, outs); 
    score -= ss[d-1][from-1];
    outs[d-1] = to;
    score += -calc_partial_score(from, outs); 
    score += -calc_partial_score(to, outs); 
    score += ss[d-1][to-1];
    return score; 
}


int main() {
    cin >> D;
    rep(i, 26) cin >> cs[i];
    ss.resize(D, vector<int>(26)); 
    vector<int> outs(D);
    rep(i, D) {
        int max_score = 0;
        rep(j, 26) {
            cin >> ss[i][j]; 
            if (ss[i][j] > max_score) {
                max_score = ss[i][j];
                outs[i] = j + 1; 
            }
        }  
    }

    vector<set<int>> outdays(26);
    rep(d, D) {
        int o = outs[d];
        outdays[o-1].insert(d+1);
    } 
    rep(i, D) cin >> outs[i];
    int M;
    cin >> M;
    vector<int> ds(M), qs(M); 
    rep(i, M) cin >> ds[i] >> qs[i];
    int score = calc_score(outs);
    rep(i, M) {
        score = chage_outs(ds[i], qs[i], outs, score);
        cout << score << endl;
    } 
}

Measured memory_bytes: 3960
#include<iostream>
#include<algorithm>

using namespace std;

#define MAX 100001

int Partition(int A[], int p, int r) {
	int x, i;

	x = A[r];
	i = p - 1;

	for (int j = p; j <= r - 1; j++) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i + 1;

}

int main() {

	int A[MAX], size, i, p;
	cin >> size;
	for (i = 0; i<size; i++) {
		cin >> A[i];
	}
	p = Partition( A, 0, size - 1);
	for (i = 0; i<size; i++) {
		if (i == p)cout << "[" << A[i] << "]";
		else cout << A[i];
		if (i != size - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> board(h);
    rep(i, h) cin >> board[i];
    int ans = INF;
    rep(par, 1 << (h - 1)) {
        int n = __builtin_popcount(par);
        vector<int> A(n + 1, 0);
        int cnt = n;
        int last = 0;
        rep(j, w) {
            int idx = 0;
            rep(i, h) {
                A[idx] += board[i][j] - '0';
                if (par >> i & 1) idx++;
            }
            rep(i, n + 1) {
                if (A[i] > k) {
                    cnt++;
                    rep(a, n + 1) A[a] = 0;
                    if (j == last) {
                        goto end;
                    }
                    last = j;
                    j--;
                    break;
                }
            }
        }
        chmin(ans, cnt);
        end:;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3668
s = list(input())
d = {}
keys = set()
for i,name in enumerate(s):
    if name not in d:
        d[name] = 0
        keys.add(name)
    else:
        d[name] += 1
ans = "No"
if len(keys) == 2:
    a = keys.pop()
    b = keys.pop()
    if d[a] == 1 and d[b] == 1:
        ans = "Yes"

print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

int main(){
  int n,x;
  int i,j,k;
  int count;
  
  while (1){
    scanf("%d%d",&n,&x);
    if (n == 0 && x == 0) break;
    count = 0;
    for (i = 1 ; i <= n ; i++)
      for (j = i + 1 ; j <= n ; j++)
	for (k = j + 1 ; k <= n ; k++ )
	  if (i+j+k == x) count++;
  
  printf("%d\n",count);
  }
  
  return 0;
}



Measured memory_bytes: 2144
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = list(map(int, input().rstrip('\n').split()))
    c = list(map(int, input().rstrip('\n').split()))
    t = sum(b)
    for i in range(1, n):
        if a[i] == a[i-1] + 1:
            t += c[a[i-1] - 1]
    print(t)


if __name__ == '__main__':
    slove()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[333333];

int hoge[333333];

signed main(){
    cin>>N;
    rep(i,3*N)cin>>A[i];

    priority_queue<int>que;
    int sum=0;
    rep(i,N)que.push(-A[i]),sum+=A[i];
    hoge[N]=sum;
    for(int i=N;i<3*N;i++){
        sum+=A[i];
        que.push(-A[i]);
        sum-=(-que.top());
        que.pop();
        hoge[i+1]=sum;
    }

    que=priority_queue<int>();
    sum=0;
    for(int i=3*N-1;i>=2*N;i--){
        sum+=A[i];
        que.push(A[i]);

    }
    hoge[2*N]-=sum;
    for(int i=2*N-1;i>=0;i--){
        sum+=A[i];
        que.push(A[i]);
        sum-=que.top();
        que.pop();
        hoge[i]-=sum;
    }

    int ans=LLONG_MIN;
    for(int i=N;i<=2*N;i++)chmax(ans,hoge[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i < int(n); ++i)

const long long INF = 1e12 + 1;

int main() {
	long long n, m;
	cin >> n >> m;

	m /= 2;

	cout << min(m, (n + m) / 2) << endl;
}

Measured memory_bytes: 256
n=int(input())
x=[]
y=[]
for i in range(n):
  xx,yy=map(int,input().split())
  x.append([xx,i])
  y.append([yy,i])
x.sort()
y.sort()
px=[[x1-x0,i0,i1] for (x0,i0),(x1,i1) in zip(x,x[1:])]
py=[[y1-y0,i0,i1] for (y0,i0),(y1,i1) in zip(y,y[1:])]
p=px+py
x=[]
y=[]
px=[]
py=[]
p.sort()
r=[i for i in range(n)]
rank=[1 for i in range(n)]
def root(x):
  if x==r[x]:
    return x
  else:
    r[x]=root(r[x])
    return r[x]
def union(path):
  rx=root(path[1])
  ry=root(path[2])
  if rx==ry:
    return 0
  else:
    if rank[rx]>rank[ry]:
      r[rx]=ry
      rank[rx]+=rank[ry]
    else:
      r[ry]=rx
      rank[ry]+=rank[rx]
    return path[0]
ans=0
for i in range(len(p)):
  ans+=union(p[i])
print(ans)

Measured memory_bytes: 62700
#include<iostream>
using namespace std;
int main()
{
          long long a,b;
          cin>>a>>b;
          if(a%2 == b%2)
          {
                    cout<<(a+b)/2<<endl;
          }
          else
          {
                    cout<<"IMPOSSIBLE\n";
          }
return 0;
}


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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define li long long
#define ld long double
#define x first
#define y second
#define pt pair<int, int>
#define pll pair<li, li>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

using namespace std;


const int INF = 1e9;
const int MOD = 1e9 + 7;
const li INF64 = 1e18;
const ld EPS = 1e-7;

mt19937 myrand(time(NULL));

const int N = 51;

int n, p;
int a[N];

bool read(){
	if(scanf("%d%d", &n, &p) != 2)
		return 0;
	forn(i, n)
		scanf("%d", &a[i]);
	return 1;
}


void solve(){
	li e = 1, o = 0;
	
	forn(i, n)
		if (a[i] % 2 == 0){
			e *= 2;
			o *= 2;
		}
		else{
			li tmp = e;
			e += o;
			o += tmp;
		}
	
	printf("%lld\n", p ? o : e);
}


int main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
	#endif
	while(read())
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i;
    scanf("%d",&i);
    printf("%d\n",a[i-1]);
  return 0;
}


Measured memory_bytes: 256
<?php
$a = array();
fscanf(STDIN, "%d", $n);
for($i = 0;$i < 5;$i ++) {
	fscanf(STDIN, "%d", $a[$i]);
}

$min = min($a);
$div = intval(($n - 1) / $min);
$ret = $div + 5;
print($ret."\n");

?>

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
#define F(n) for(int i = 0; i < n; ++i)
#define Debug cout<<endl<<"I AM IRONMAN"<<endl

int main ()
{
    fastio;
    ll ans=0,black=0;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='B')
        {
            black++;
        }
        else
        {
            ans+=black;
        }
        
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3760