akhauriyash/Code-Regression huggingface dataset:
import math

n=int(input())
listx=[]
listy=[]

for i in range(n):
  x,y = map(int,input().split())
  listx.append(x)
  listy.append(y)

#print(listx)
#print(listy)
listl=[]
if n==2:
	ans=((listx[1]-listx[0])**2+(listy[1]-listy[0])**2)**0.5



else:
	for i in range(n-1):
		for j in range(i+1,n):
			l=((listx[i]-listx[j])**2+(listy[i]-listy[j])**2)**0.5
			listl.append(l)
	ll=sum(listl)	
	ans=2*ll/n

print(ans)

Measured memory_bytes: 38384
n = int(input())
ans = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans += i
    if i >= n:
        print(ans)
        exit()


Measured memory_bytes: 9168
"""
https://abc073.contest.atcoder.jp/tasks/abc073_b
"""
n=int(input())
a=0
lr=[]
for i in range(n):
    lr.append([j for j in input().split()])
#print(lr)

for i in range(n):
    a=a-int(lr[i][0])+int(lr[i][1])+1
print(a)


Measured memory_bytes: 3188
n = int(input())
A = list(map(int, input().split()))

count = 0
absmin = abs(A[0])

for i in range(n):
  if A[i] < 0:
    count += 1
    A[i] = - A[i]
  if A[i] < absmin:
    absmin = A[i]

if count % 2 == 0:
  print(sum(A))
else:
  print(sum(A) - 2 * absmin)

Measured memory_bytes: 14284
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> p(n), a(n), b(n);
    rep(i, 0, n)
    {
        int pp;
        cin >> pp;
        p[--pp] = i + 1;
    } 
        



    ll cumsum = 0;
    rep(i, 0, n)
    {
        cumsum += p[i] - 1;
        a[i] = cumsum + i + 1;
    }
    cumsum = 0;
    rrep(i, n, 0)
    {
        cumsum += p[i] - 1;
        b[i] = cumsum + n - i;
    }
    rep(i, 0, n)
        printf("%ld ", a[i]);
    puts("");
    rep(i, 0, n)
        printf("%ld ", b[i]);
    puts("");
    
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

string S,R;
char T[5]="ACGT";
int U,a,q;

int power[12]={1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304};

bool V;

bool x1[4];
bool x2[16];
bool x3[64];
bool x4[256];
bool x5[1024];
bool x6[4096];
bool x7[16384];
bool x8[65536];
bool x9[262144];
bool x10[1048576];
bool x11[4194304];
bool x12[16777216];

void insert(){
	U=0;
	for(int i=0;i<S.size();i++){
		for(int j=0;j<4;j++){
			if(T[j]==S[i]){
				U += power[i]*j;
			}
		}
	}
	a=S.size();
	if(a==1){
		x1[U]=true;
	}
	if(a==2){
		x2[U]=true;
	}
	if(a==3){
		x3[U]=true;
	}
	if(a==4){
		x4[U]=true;
	}
	if(a==5){
		x5[U]=true;
	}
	if(a==6){
		x6[U]=true;
	}
	if(a==7){
		x7[U]=true;
	}
	if(a==8){
		x8[U]=true;
	}
	if(a==9){
		x9[U]=true;
	}
	if(a==10){
		x10[U]=true;
	}
	if(a==11){
		x11[U]=true;
	}
	if(a==12){
		x12[U]=true;
	}
}

void find(){
	U=0;
	V=false;
	for(int i=0;i<S.size();i++){
		for(int j=0;j<4;j++){
			if(T[j]==S[i]){
				U += power[i]*j;
			}
		}
	}
	a=S.size();
	if(a==1 && x1[U]==true){
		V=true;
	}
	if(a==2 && x2[U]==true){
		V=true;
	}
	if(a==3 && x3[U]==true){
		V=true;
	}
	if(a==4 && x4[U]==true){
		V=true;
	}
	if(a==5 && x5[U]==true){
		V=true;
	}
	if(a==6 && x6[U]==true){
		V=true;
	}
	if(a==7 && x7[U]==true){
		V=true;
	}
	if(a==8 && x8[U]==true){
		V=true;
	}
	if(a==9 && x9[U]==true){
		V=true;
	}
	if(a==10 && x10[U]==true){
		V=true;
	}
	if(a==11 && x11[U]==true){
		V=true;
	}
	if(a==12 && x12[U]==true){
		V=true;
	}
	if(V==true){
		cout<<"yes"<<endl;
	}
	else{
		cout<<"no"<<endl;
	}
}

int main(){
	memset(x1,false,sizeof(x1));
	memset(x2,false,sizeof(x2));
	memset(x3,false,sizeof(x3));
	memset(x4,false,sizeof(x4));
	memset(x5,false,sizeof(x5));
	memset(x6,false,sizeof(x6));
	memset(x7,false,sizeof(x7));
	memset(x8,false,sizeof(x8));
	memset(x9,false,sizeof(x9));
	memset(x10,false,sizeof(x10));
	memset(x11,false,sizeof(x11));
	memset(x12,false,sizeof(x12));
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>R>>S;
		if(R=="insert"){
			insert();
		}
		if(R=="find"){
			find();
		}
	}
	return 0;
}

Measured memory_bytes: 25048
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define PI (acos(-1))
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
 
const int MOD = 1e9+7;
const int INF = 1001001001;
const ll LINF = 1e18;
 
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; }

int odd[100005];
int even[100005];

signed main()
{
  string s; ll k;
  cin>>s>>k;
  string ans="1";
  for(ll i; i<k; i++){
    if(s[i]!='1'){
      ans=s[i];
      break;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	int a=0,b=0;
	int na,nb;
	int nc;
	while(1){
	cin>>nc;
	if(nc==0) break;
	a=b=0;
	for(int i=0;i<nc;i++){
		cin>>na>>nb;
		if(na>nb) a+=(na+nb);
		else if(na<nb) b+=(na+nb);
		else {a+=na;b+=nb;}
	}
	cout<<a<<" "<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, raw_input().split())
paths = []
for _ in xrange(m):
	a, b = map(int, raw_input().split())
	paths.append((a, b))
hop2 = set()
for a, b in paths:
	if a == 1:
		hop2.add(b)
flag = 0
for a, b in paths:
	if a in hop2:
		if b == n:
			flag = 1
			break

if flag:
	print "POSSIBLE"
else:
	print "IMPOSSIBLE"



Measured memory_bytes: 31740
/*=======================
Author    : Shounak Dey
Filename  : b.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll a,b,x;
	cin >> a >> b >> x;
	ll r = b/x;
	r -= a/x - ((a%x)==0);
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
    long long k;
    cin >> k;
    long long t = 0;
    for(long long i=1;i<2000000;i++) {
        t = (t*10+7)%k;
        if(t==0) {
            cout << i << endl;
            return 0;
        }
        
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3552
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	return s
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextString()
	for _, str := range n {
		if string([]rune{str}) == "7" {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

ll mod = 1e9 + 7;

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

    ll t = 1;
    ll nine = 1;
    ll eight = 1;
    
    for(int i = 0; i < n; i++) {
        t = (t * 10) % mod;
        nine = (nine * 9) % mod;
        eight = (eight * 8) % mod;
    }

    ll res = ((t - (2 * nine) % mod + eight) + mod) % mod;

    cout << res << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
string aa[213456]; int test[213456];
signed main() {
	int n, a, b = 0, ans = 0; string s, w; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> s >> a;
		aa[h] = s; test[h] = a;
	}
	cin >> w;
	for (int h = 0; h < n; h++) {
		if (aa[h] == w) {
			b++;
		}
		else if (b != 0) {
			ans += test[h];
		}
	}
	cout << ans << endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
};

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main() {
	ll x, y;
	cin >> x >> y;
	if (y > x * 2 || x > y * 2) {
		cout << 0 << endl;
		return 0;
	}
	modint sum = 0;
	Factorial f(x + y);
	for (int i = 0; i <= x; i++) {
		ll dx = x - i;
		ll dy = y - i * 2;
		if (dx < 0 || dy < 0) continue;
		if (dx != dy * 2) continue;
		int j = dy;
		sum += f.cmb(i + j, i);
	}
	cout << sum.a << endl;
    return 0;
}



Measured memory_bytes: 34696
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())

    for i in range(1, 10 ** 4):
        if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
            print(i)
            break
    else:
        print(-1)


if __name__ == '__main__':
    resolve()


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

int main() {
    string s;
    cin >> s;
    string f="",b="";
    f += s.at(0);
    f += s.at(1);
    b += s.at(2);
    b += s.at(3);
    int inf,inb;
    inf = atoi(f.c_str());
    inb = atoi(b.c_str());
    //cout << inf << inb <<endl;
    if((inf>=13||inf==0)&&inb<=12&&inb>=1){
        cout << "YYMM" << endl;
    }else if(inf<=12&&inb<=12&&inf>=1&&inb>=1){
        cout << "AMBIGUOUS" << endl;
    }else if((inb>=13||inb==0)&&inf<=12&&inf>=1){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();
			
			long result = Long.MIN_VALUE;
			result = Math.max(result, a*c);
			result = Math.max(result, a*d);
			result = Math.max(result, b*c);
			result = Math.max(result, b*d);
			
			System.out.println(result);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 35780
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define val const auto
#define var auto

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template<typename T,std::size_t N>
struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
template<typename T>
struct _v_traits<T,1> {using type = std::vector<T>;};
template<typename T,std::size_t N=1>
using vec = typename _v_traits<T,N>::type;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            os << ",";
        }
        os << *it;
    }
    return os << "}";
}

template <typename T>
T read_next(){
    T ret; cin >> ret;
    return ret;
}


template<typename T>
void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){
    sort(v.begin(), v.end(), comp);
}
template<typename T>
std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){
    isort(v);
    return v;
}
template<typename T1, typename T2>
std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){
    std::vector<T2> t; t.reserve(v.size());
    for(const auto& i: v) t.push_back(f(i));
    return t;
}
std::vector<std::string> split(std::string str, char delim){
    std::vector<std::string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != std::string::npos){
        res.push_back(std::string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(std::string(str, current, str.size() - current));
    return res;
}
string join(const std::vector<string>& v, string delim){
    string ret = "";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            ret += delim;
        }
        ret += *it;
    }
    return ret;
}


using i64 = int64_t;
using i32 = int32_t;

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

    int c_index = 100000;
    int f_index = -1;

    string s; cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'C') c_index = i;
        if(s[i] == 'F') f_index = i;
    }
    if(c_index < f_index){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
import os
import pprint
from queue import Queue

"""Topological Sort"""

#fd = os.open('GRL_4_B_5.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

V, E = list(map(int, input().split()))
G = [[] for i in range(V)]
indig = [0] * V # ??\?¬???°
for i in range(E):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    indig[t] += 1

q = Queue()
out = []

def bfs(node_index):
    q.put(node_index)

    while not q.empty():
        u = q.get()
        out.append(u)

        # u?????????????????§u?????????indig????????????
        for index in G[u]:
            indig[index] -= 1
            if indig[index] == 0:
                q.put(index)

# bfs?????????
indig_copy = indig[:]
for i in range(V):
    if indig_copy[i] == 0:
        bfs(node_index=i)

for v in out:
    print(v)

Measured memory_bytes: 12176
#include <iostream>

using namespace std;

const int MAX = 1000000;
bool hamming[MAX];

int main(){
	int ps[3] = {2, 3, 5};
	int n, m;
	for(int i = 0;i < MAX;++i){
		n = i + 1;
		for(int j = 0;j < 3;++j){
			while(n % ps[j] == 0) n /= ps[j];
		}
		hamming[i] = n == 1 ? true : false;
	}
	while(cin >> m, m){
		cin >> n;
		int c = 0;
		--m;
		for(int i = m;i < n;++i){
			if(hamming[i]) ++c;
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll dp[4][4];
  repl(i,1,4) repl(j,1,4) cin>>dp[i][j];
  ll flg = 0;
  if((dp[1][1] - dp[2][1] != dp[1][2] - dp[2][2] ) || (dp[1][2] - dp[2][2] != dp[1][3] - dp[2][3])) flg++;
  if((dp[2][1] - dp[3][1] != dp[2][2] - dp[3][2] ) || (dp[2][2] - dp[3][2] != dp[2][3] - dp[3][3])) flg++;
  if((dp[1][1] - dp[1][2] != dp[2][1] - dp[2][2] ) || (dp[2][1] - dp[2][2] != dp[3][1] - dp[3][2])) flg++;
  if((dp[1][2] - dp[1][3] != dp[2][2] - dp[2][3] ) || (dp[2][2] - dp[2][3] != dp[3][2] - dp[3][3])) flg++;
  if(flg==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import deque

S = deque(input())
Q = int(input())
SWITCH = False

for i in range(Q):
    v = list(input().split())
    if v[0] == '1':
        SWITCH = not SWITCH

    else:
        if v[1] == '1':
            if SWITCH==False:
                S.appendleft(v[2])
            else:
                S.append(v[2])
        else:
            if SWITCH==False:
                S.append(v[2])
            else:
                S.appendleft(v[2])

S = ''.join(S)

if SWITCH:
    print(S[::-1])
else:
    print(S)

Measured memory_bytes: 8436
// Problem : B - Palindrome-philia
// Contest : AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_b
// Memory Limit : 1024,000000 MB
// Time Limit : 2000,000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;

  string s;
  cin >> s;

  int ans = 0;

  for (int i = 0; i < (int)s.size() / 2; ++i) {
    if (s[i] != s[s.size() - i - 1])
      ++ans;
  }

  cout << ans;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    it = map(int, input().split())
    x = 0
    for c in it:
        x += 1 << (c-1)
    can_open.append(x)

n_bit = 1 << n
INF = 10**18
dp = [[INF]*(m+1) for _ in range(n_bit)]
dp[0][0] = 0

for j in range(n_bit):
    for i in range(m):
        dp[j][i+1] = min(dp[j][i+1], dp[j][i])
        dp[j | can_open[i]][i +
                            1] = min(dp[j | can_open[i]][i+1], dp[j][i+1]+cost[i])

print(dp[-1][-1] if dp[-1][-1] != INF else -1)


Measured memory_bytes: 78680
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int stage = N;
    int di[] = new int[N];

    for(int i = 0; i<N; i++){ //とりあえず配列に全部代入
      di[i] = sc.nextInt();
    }

    Arrays.sort(di);//ソート（昇順）

    for(int i =0; i<N; i++ ) {
      if(i != N-1) {
        if(di[i] == di[i+1]){
          stage--;
        }
      }
    }
    System.out.println(stage);
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

int n, x[1005], y[1005];
vector<int> vt;
int main() {
	int i, j;
	cin>>n;
	for(i=0; i<n; i++) {
		cin>>x[i]>>y[i];
		if((int)abs(x[i]) + (int)abs(y[i]) & 1 ^ (int)abs(x[0]) + (int)abs(y[0]) & 1) {
			cout<<-1; return 0;
		}
	}
	for(i=30; i>=0; i--) vt.push_back(1<<i);
	if((int)abs(x[0]) + (int)abs(y[0]) & 1 ^ 1) vt.push_back(1);
	cout<<vt.size()<<endl;
	for(i=0; i<vt.size(); i++) cout<<vt[i]<<' ';
	puts("");
	for(i=0; i<n; i++, puts("")) for(j=0; j<vt.size(); j++) {
		if((int)abs(x[i]) > (int)abs(y[i])) {
			if(x[i] > 0) putchar('R'), x[i] -= vt[j];
			else putchar('L'), x[i] += vt[j];
		} else {
			if(y[i] > 0) putchar('U'), y[i] -= vt[j];
			else putchar('D'), y[i] += vt[j];
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int dp[n][3];
	int mat[n][3];
	for(int i=0;i<n;i++){
		cin>>mat[i][0]>>mat[i][1]>>mat[i][2];
	}
	dp[0][0]=mat[0][0];
	dp[0][1]=mat[0][1];
	dp[0][2]=mat[0][2];
	for(int i=0;i<n-1;i++){
		dp[i+1][0]=max(dp[i][1],dp[i][2])+mat[i+1][0];
		dp[i+1][1]=max(dp[i][0],dp[i][2])+mat[i+1][1];
		dp[i+1][2]=max(dp[i][1],dp[i][0])+mat[i+1][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Here your code !
    unsigned long long int a[3];
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a,a+3);
    
    if(a[0]%2 == 0 || a[1]%2 == 0 || a[2]%2 == 0){
        cout << 0 << endl;
        return 0;
    }else{
        cout << a[0] * a[1] << endl;
    }
}


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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T>>& v) {
  o << "[";
  for (const vector<T>& x : v)
    o << x << ",\n";
  return o << "]";
}

const int INF = 1e18;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int awake = (h2-h1)*60 + m2 - m1;
  assert(awake >= k);
  cout << awake - k << endl;
}


Measured memory_bytes: 3636
def knapsack(N, W, weight, value):
  inf = float("inf")
  dp = [[-inf]*(W+1) for _ in range(N+1)]
  for i in range(W+1):
    dp[0][i] = 0
  
  for i in range(N):
    for j in range(W+1):
      if weight[i] <= j:
        dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i])
      else:
        dp[i+1][j] = dp[i][j]
  return dp[N][W]
  
N, W = map(int, input().split())
weight, value = [], []
for i in range(N):
  w, v = map(int, input().split())
  weight.append(w)
  value.append(v)

print(knapsack(N, W, weight, value))
  

Measured memory_bytes: 296680
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    while (true) {
        val H =scanner.nextInt()
        val W =scanner.nextInt()
        if (H == 0 && W == 0) {
            break
        }
        // W, Hが3以上である前提より
        val rectangle =
            listOf("#".repeat(W))
                .plus((2..H - 1).map { "#" + ".".repeat(W - 2) + "#" }).toList()
                .plus("#".repeat(W))
        println(rectangle.joinToString("\n"))
        println()
    }
}



Measured memory_bytes: 28448
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N,H;
    cin >> N >> H;
    pair<ll,ll> P[N];
    ll mxa=0,mxb=INF;
    for(ll i=0;i<N;i++){
        cin >> P[i].second >> P[i].first;
    }
    sort(P,P+N);
    reverse(P,P+N);

    ll I=0;
    for(ll i=0;i<N;i++){
        if(mxa<=P[i].second){
            mxa = P[i].second;
            mxb = P[i].first;
            I = i;
        }
    }
    ll ans=0;
    for(ll i=0;i<N;i++){
        if(P[i].first>=mxa&&I!=i){
            H = H-P[i].first;
            ans++;
            if(H<=0){
                cout << ans << endl;
                return 0;
            }else if(H-mxb<=0){
                cout << ans+1 << endl;
                return 0;
            }
        }
    }
    H = H-mxb;
    ans++;
    if(H%mxa==0){
        cout << ans + H/mxa << endl;
    }else{
        cout << ans + H/mxa + 1 << endl; 
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n;
   cin>>n;
   int m;
   vector<int> ans;
   int sum=0;
   for(int i=1;i<=n+10;i++){
       if(sum>n){
           m=sum-n;
           break;
       }
       sum+=i;
       ans.push_back(i);
   }
   for(int i=0;i<ans.size();i++){
       if(ans[i]!=m)cout<<ans[i]<<endl;
   }
}

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void)
{
    char str[20];
    char rstr[20];
    int i;
    int len;

    scanf("%s", str);

    len = strlen(str) - 1;

    i = 0;
    while (str[i] != '\0') {
        rstr[i] = str[len - i];
        i++;
    }
    rstr[i] = '\0';

    printf("%s\n", rstr);

    return (0);
}

Measured memory_bytes: 524
import itertools, copy

H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

ans = float("inf")
for n_horizontal_cut in range(H):
    for horizontal_cut_idx in list(itertools.combinations(list(range(1,H)), n_horizontal_cut)):
        horizontal_cut_idx = [0] + list(horizontal_cut_idx) + [H]
        n_vertical_cut = 0
        n_white_choco = [0] * (n_horizontal_cut+1)
        for w in range(W):
            tmp_idx = 0
            tmp_n_white_choco = copy.copy(n_white_choco)
            for h in range(H):
                if h >= horizontal_cut_idx[tmp_idx+1]:
                    tmp_idx += 1
                if S[h][w] == 1:
                    n_white_choco[tmp_idx] += 1
            if max(n_white_choco) > K:
                n_vertical_cut += 1
                n_white_choco = [n_white_choco[i] - tmp_n_white_choco[i] for i in range(n_horizontal_cut+1)]
                if max(n_white_choco) > K: # 1列の区間でホワイトチョコ数がオーバーする場合
                    break
        else:
            ans = min(ans, n_horizontal_cut + n_vertical_cut)

print(ans)

Measured memory_bytes: 51164
import java.util.* ; 
import java.math.*;
class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);

	BigInteger x = scan.nextBigInteger();
     BigInteger y = scan.nextBigInteger() ;
    
   int z  = x.compareTo(y) ;
      if(z < 0 )
      {
        System.out.println("LESS");
      }else if(z>0){
        System.out.println("GREATER");
      }else{
        System.out.println("EQUAL");
      }
    

     
  }
}


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

int main()
{
    int K;
    cin >> K;
    string S;
    cin >> S;

    if (S.length() <= K) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
 
// ABC 19-C
// http://abc019.contest.atcoder.jp/tasks/abc019_3
 
public class Main {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		char[] c1 = in.next().toCharArray();
		char[] c2 = in.next().toCharArray();
		
		for (int i = 0; i < c2.length; i++) {
			System.out.printf("%c", c1[i]);
			System.out.printf("%c", c2[i]);
		}
		if (c1.length > c2.length) {
			System.out.printf("%c", c1[c1.length - 1]);
		}
		System.out.println();
//		int t = in.nextInt();
//		int num = 1;
//		while (t-- > 0) {
//			int n = in.nextInt();
//			
//			while (!isTidy(n)) {
//				n--;
//			}
//			System.out.printf("Case #%d: %d\n", num, n);
//			num++;
//		}
	}	
	
	public static boolean isTidy(int n) {
		if (n < 10) {
			return true;
		}
		int pre = n % 10;
		n /= 10;
		int curr = n % 10;
		
		while (n > 0) {
			if (pre < curr) {
				return false;
			}
			pre = curr;
			n /= 10;
			curr = n % 10;
		}
		return true;
	}
}


Measured memory_bytes: 22612
program bbb
implicit none

integer :: s, i, j, p
integer,dimension(1000000) :: a

read*, s

p=0
a=0
a(1)=s

do i=2,1000000
if(mod(a(i-1),2)==0) then
a(i)=a(i-1)/2
else
a(i)=3*a(i-1)+1
end if
p=a(i)
 do j=1,i-1
 if(p==a(j)) then
 write(*,'(i0)') i
 return
 end if
 end do
end do

end program

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

int n, k;
int a[N];

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    int ans = 0;
    for (int q = 0; q <= min(k, n); ++q)
    {
        for (int l = 0; l <= q; ++l)
        {
            int r = q - l;
            vector<int> v;
            for (int i = 1; i <= l; ++i)
            {
                v.push_back(a[i]);
            }
            for (int i = n - r + 1; i <= n; ++i)
            {
                v.push_back(a[i]);
            }
            sort(v.begin(), v.end());
            reverse(v.begin(), v.end());

            int qq = k - q;
            while (1)
            {
                if (qq == 0)
                    break;
                if (v.empty())
                    break;
                if (v.back() >= 0)
                    break;
                v.pop_back();
                --qq;
            }

            int yans = 0;
            for (int i = 0; i < v.size(); ++i)
                yans += v[i];
            ans = max(ans, yans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int n; cin>>n;
    vector<int> a(n), b(n), c(n);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];

    vector<vector<ll>> dp(n+1, vector<ll>(3, 0));
    for(int i=0; i<n; i++){
        chmax(dp[i+1][0], max(dp[i][1], dp[i][2]) + a[i]);
        chmax(dp[i+1][1], max(dp[i][0], dp[i][2]) + b[i]);
        chmax(dp[i+1][2], max(dp[i][0], dp[i][1]) + c[i]);
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='x') cnt++;
  }
  if(8<=cnt) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}



Measured memory_bytes: 256
S = input()
A = S[:2]
B = S[2:]
if 0<int(A)<13:
  if 0<int(B)<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0<int(B)<13:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 2940
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for i in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11708
from queue import Queue
N, M = map(int, input().split())

root = [[] for _ in range(N)]
#print(root)
for i in range(M):
    A, B = map(int, input().split())
    root[A-1].insert(len(root[A-1]), B)
    root[B-1].insert(len(root[B-1]), A)
room = [0]*N

q = Queue()
for k in root[0]:
    room[k-1] = 1
    q.put(k)
while not q.empty():
    a = q.get()
    for j in root[a-1]:
        if room[j-1] == 0:
            q.put(j)
            room[j-1] = a
if 0 in room[1:]:
    print("No")
else:
    print("Yes")
    for ans in room[1:]:
        print(ans)


Measured memory_bytes: 35100
#include <iostream>
#include <string>
using namespace std;
int H=0;
void maxheapify(int A[],int i){
    int largest;
    int l=2*i;
    int r=(2*i)+1;
    if(l<=H && A[l]>A[i]){
        largest=l;
    }
    else{
        largest=i;
    }
    if(r<=H && A[r]>A[largest]){
        largest=r;
    }
    if(largest!=i){
        int tmp=A[i];
        A[i]=A[largest];
        A[largest]=tmp;
        maxheapify(A,largest);
    }
}    
int extract(int A[]){
    if(H<1){
        return false;
    }
    int max=A[1];
    A[1]=A[H];
    H=H-1;
    maxheapify(A,1);
    return max;
}
void increasekey(int A[],int i,int key){
    if(key<A[i]){
        return;
    }
    A[i]=key;
    while(i>1 && A[i/2]<A[i]){
        int tmp=A[i];
        A[i]=A[i/2];
        A[i/2]=tmp;
        i=i/2;
    }
}

void insert(int A[],int key){
    H++;
    A[H]=-1000000000;
    increasekey(A,H,key);
}
int main(){
    string s;
    int key,A[10000000];
    cin>>s;
    while(s!="end"){
        if(s=="insert"){
            cin>>key;
            insert(A,key);
        }
        else{
            cout<<extract(A)<<endl;
        }
        cin>>s;
    }
    return 0;
}


Measured memory_bytes: 6956
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	map<int,ll> cnt;
	vector<int> ar(n);
	for(int i=0;i<n;i++) cin >> ar[i];
	ll ans = 0;
	for(int i=0;i<n;i++){
		int temp = i-ar[i];
		ans += cnt[temp];
		cnt[i+ar[i]]++;
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    string ans="APPROVED";
    vector<ll> a(n);
    for(ll i=0; i<n; i++) {
        cin>>a[i];
    }

    for(ll i=0; i<n; i++) {
        if(a[i]%2 == 0){
            if(a[i]%3 == 0 || a[i]%5 == 0){
                continue;
            }else{
                ans = "DENIED";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var i = parseInt(input[0].split(" ")[1]);
  var ans = n-i+1;

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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



int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k,n;
	cin>>k>>n;
	if(n < 2)
		{
			cout<<0;
			return 0;
		}
	vector<int> arr(n);
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr.begin(),arr.end());
	int res=arr[n-1]-arr[0];
	for(int i=0;i<n-1;i++){
		res=min(k-arr[i+1]+arr[i],res);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+1]={0},count=0;
    while(k--){
        int d,x;
        cin>>d;
        for (int i=0;i<d;i++){
            cin>>x;
            a[x]++;
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]==0) count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int d,g;
    cin>>d>>g;
    vector<int> p(11);
    vector<int> c(11);
    for(int i=0;i<d;i++){
        cin>>p[i]>>c[i];
    }
    int ans=1e9;
    for(int mask=0;mask<(1<<d);mask++){
        int s=0,num=0,rest_max=-1;
        for(int i=0;i<d;i++){
            if(mask&(1<<i)){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }
            else rest_max=i;
        }
        if(s<g){
            int s1=100*(rest_max+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest_max])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 1;
    ll temp = Y;
    while (true)
    {
        temp /= 2;
        if (temp < X)
        {
            break;
        }
        ++ans;
    }
    cout << ans << endl;
}


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

int main(){
	/*input*/
	char s[10];
	cin >> s;
	/*calculation*/
	int i = 0;
	int max = 0;
	int dmax = 0;
	while(s[i]){
		switch(s[i]){
			case 'A':
			case 'C':
			case 'G':
			case 'T':
				dmax++;	
			break;
			default:
				if(max < dmax){
					max = dmax;
				}
				dmax = 0;
			break;
		}
		if(max < dmax){
			max = dmax;
		}
		i++;
	}
	/*output*/
	cout << max << endl; 
}


Measured memory_bytes: 256
a = gets.chomp.split(" ").map(&:to_i)
costs = []
a.permutation(3).each do |e|
    cost = 0
    3.times do |i|
        next if i == 0
        cost += (e[i] - e[i - 1]).abs
    end
    costs.push(cost)
end
puts costs.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];
  vector<int> ans;
  for(int i=n-1; i>=0; i--){
    int index;
    rep(j, i+1){
      if(vec[j] > i+1){
        cout << -1 << endl;
        return 0;
      }
      if(vec[j] == j+1){
        index = j;
      }
    }
    ans.push_back(vec[index]);
    vec.erase(vec.begin() + index);
  }
  reverse(all(ans));
  rep(i, n) cout << ans[i] << endl;
  return 0;
}
  
  

Measured memory_bytes: 3612
#include<stdio.h>
int N, A, B, a, b, i;
char c;
int main(void){
  scanf("%d%d%d\n", &N, &A, &B);
  A+=B;
  for(i=0; i<N; i++){
    c=getchar();
    if(a==A || c=='c'){
      puts("No");
    }else if(c=='a'){
      puts("Yes");
      a++;
    }else if(c=='b' && b<B){
      puts("Yes");
      a++; b++;
    }else{
      puts("No");
    }
  }
}


Measured memory_bytes: 512
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, P;
    cin >> A >> P;
    int pieces = A * 3 + P;
    cout << pieces / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
def main():
    n, q = map(int, input().split())
    queue = [[x for x in input().split()] for _ in range(n)]
    queue = [(x[0], int(x[1])) for x in queue]

    elapsed_time = 0
    while len(queue) > 0:
        process, time = queue.pop(0)
        if time > q:
            queue.append((process, time - q))
            elapsed_time += q
        else:
            elapsed_time += time
            print('{} {}'.format(process, str(elapsed_time)))
            
    return


main()


Measured memory_bytes: 17020
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    cout << 3*n*n << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int h, w;
int a[1005], b[1005];
signed main() {
	cin >> h >> w;
	rep(i, h)cin >> a[i];
	rep(i, w)cin >> b[i];
	sort(a, a + h); sort(b, b + w);
	rep(i, h) {
		if (upper_bound(a, a + h, a[i]) - lower_bound(a, a + h, a[i]) > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, w) {
		if (upper_bound(b, b + w, b[i]) - lower_bound(b, b + w, b[i]) > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	int ans = 1;
	for (int i = h * w; i > 0; i--) {
		if (!(upper_bound(a, a + h, i) - lower_bound(a, a + h, i)) && !(upper_bound(b, b + w, i) - lower_bound(b, b + w, i))) {
			ans *= (h - (lower_bound(a, a + h, i) - a)) * (w - (lower_bound(b, b + w, i) - b)) - (h * w - i);
		}
		else if (upper_bound(a, a + h, i) - lower_bound(a, a + h, i) && !(upper_bound(b, b + w, i) - lower_bound(b, b + w, i))) {
			ans *= w - (lower_bound(b, b + w, i) - b);
		}
		else if (upper_bound(b, b + w, i) - lower_bound(b, b + w, i) && !(upper_bound(a, a + h, i) - lower_bound(a, a + h, i))) {
			ans *= h - (lower_bound(a, a + h, i) - a);
		}
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256