akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int l[110],len[110],per[110];
int a,b,c,n;
int now;
void dfs(int f,int to,int obj,int p,int mon,int flag) {
	if(!flag) p=l[f];
	else p+=l[f];
	if(!(obj^p)) {
		now=min(now,mon);
		return;
	}
	now=min(now,mon+abs(obj-p));
	for(int i=f+1; i<=to; i++) {
		dfs(i,to,obj,p,mon+10,1);
		dfs(i,to,obj,p,mon,0);
	}
}
int main() {
	scanf("%d%d%d%d",&n,&a,&b,&c);
	int T=1;
	for(int i=1; i<=n; i++) {
		T*=i;
		scanf("%d",&len[i]);
		per[i]=i;
	}
	int ans=(1<<30),cnt=0;
	while(T--) {
		for(int i=1; i<=n; i++)
			l[i]=len[per[i]];
		for(int i=1; i<=n-2; i++)
			for(int j=i+1; j<=n-1; j++)
				for(int k=j+1; k<=n; k++) {
					now=1e9+11;
					dfs(1,i,a,0,0,0);
					int ap=now;
					now=1e9+11;
					dfs(j,k-1,b,0,0,0);
					int bp=now;
					now=1e9+11;
					dfs(k,n,c,0,0,0);
					int cp=now;
					if(ap+bp+cp<ans) ans=ap+bp+cp,cnt=0;
					cnt++;
				}
		next_permutation(per+1,per+n+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int z,i,n,ii,m,c,l;
int a[100001];
int b[100001];

bool in(int k)
{
    int d = -1, g = n, s = (d+g)/2;
    while (d+1 != g) {
        if (k == a[s]) return true;
        else if (k < a[s]) {
            g = s;
            s = (d+g)/2;
        } else if (k > a[s]) {
            d = s;
            s = (d+g)/2;
        }
    }
    return false;
}

int main()
{
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d", &l);
    for(i=0; i<l; i++)
    {
        scanf("%d",&b[i]);
        if (in(b[i])) m++;
    }
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 3168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
s = input()

def is_ok(x, idx):
	if s[idx] == "o":
		if x[idx] == "S" and x[idx-1] == x[idx+1]:
			return True
		elif x[idx] == "W" and x[idx-1] != x[idx+1]:
			return True
		else:
			return False
	elif s[idx] == "x":
		if x[idx] == "S" and x[idx-1] != x[idx+1]:
			return True
		elif x[idx] == "W" and x[idx-1] == x[idx+1]:
			return True
		else:
			return False

start = list(product(["S", "W"], repeat=2))

for i in range(4):
	ws = []
	ws.extend(start[i])
	for j in range(1, N-1):
		if ws[j] == "S":
			if s[j] == "o":
				ws.append(ws[j-1])
			else:
				if ws[j-1] == "S":
					ws.append("W")
				else:
					ws.append("S")
		elif ws[j] == "W":
			if s[j] == "x":
				ws.append(ws[j-1])
			else:
				if ws[j-1] == "S":
					ws.append("W")
				else:
					ws.append("S")
	if is_ok(ws, -1) and is_ok(ws, 0):
		print(*ws, sep="")
		break

else:
	print(-1)



Measured memory_bytes: 12628
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)

N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // gcd(ans, T[i])
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,(input().split(' '))))
b = sorted(a)

from collections import OrderedDict
od = OrderedDict()

for n,i in enumerate(a):
  od[(n+1)] = i

#print(od)

od_sorted_value = OrderedDict(
    sorted(od.items(), key=lambda x: x[1], reverse=False)
)
#print(od_sorted_value)

ans = list(od_sorted_value.items())
for i,n in ans:
  print(i)

Measured memory_bytes: 81684
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K, A, B;
  cin >> K >> A >> B;

  if(B-A<=2){
    cout << K+1 << "\n";
    return 0;
  }
  if(K<A){
    cout << K+1 << "\n";
    return 0;
  }

  ll tmp = (K-(A-1));
  ll ans = A + (tmp/2)*(B-A) + tmp%2;
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
N=int(input())
H=[int(i) for i in input().split()]

count=1
res=0
while True:
    if max(H)==0:
        break
    else:
        i=0
        try:
            while i<N:
                if H[i]==0:
                    i+=1
                else:
                    res+=1
                    while i<N and H[i]>0:
                        H[i]-=1
                        i+=1
        except:
            continue
print(res)

Measured memory_bytes: 3060
n = int(input())

tank = []
tank.append(['a'])
for i in range(n):
    tmp_tank = []
    for w in tank[i]:
        tmp_max = max(list(w))
        nxt_max = chr(ord(tmp_max)+1)
        for i in range(ord('a'), ord(nxt_max)+1):
            tmp_tank.append(w+chr(i))
    tank.append(tmp_tank)

for w in tank[n-1]:
    print(w)

Measured memory_bytes: 62928
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,it) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
using namespace std;
int n,m,i,j,da[200005],db[200005],iq[200005],rm=0;
queue<int> q;
string s;
vector<int>e[200005];
int main(){
	cin>>n>>m>>s;s=" "+s;
	rep(i,m){int x,y;
		cin>>x>>y;e[x].push_back(y);e[y].push_back(x);
	}
	rep(i,n){
		foreach(e[i],j){
			if(s[i]=='A') da[*j]++; else db[*j]++;
		}
	}
	rep(i,n)if(!da[i]||!db[i]){
		iq[i]=1;
		q.push(i);
	}
	while(!q.empty()){
		rm++;int x=q.front();q.pop();
		foreach(e[x],i){
			if(--(s[x]=='A'?da[*i]:db[*i])==0){
				if(!iq[*i]){
					iq[*i]=1;q.push(*i);
				}
			}
		}
	}
	if(rm==n)puts("No");else puts("Yes");
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

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

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;

        }
    }
}

Measured memory_bytes: 3624
N, A, B = map(int, input().split()) # 横に2個

if A < B and N > 1:
    ans = (B*(N-1)+A) -  (A*(N-1)+B) + 1
elif A < B and N == 1:
    ans = 0
elif A > B:
    ans = 0
else:
    ans = 1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,m,h,k;
int f[1111];
int c[1111];
bool used[1111];
vector< pair<int,int> > u;
vector<int> edge[111111];
int main(void){
  while(cin >> n >> m >> h >> k && n){
    u.clear();
    for(int i = 0; i < 111111; i++) edge[i].clear();
    memset(used,false,sizeof(used));
    for(int i = 1; i <= n; i++){
      cin >> c[i];
    }
    for(int i = 0; i < m; i++){
      int a,b;
      cin >> a >> b;
      edge[b].push_back(a);
    }

    for(int i = 1; i <= n; i++) f[i] = i;
    for(int i = h-1; i > 0; i--){
      for(int j = 0; j < (int)edge[i].size(); j++){
	int l = edge[i][j];
	int r = edge[i][j] + 1;
	swap(f[l],f[r]);
	if(f[l] > f[r]) swap(l,r);
	u.push_back( make_pair(f[l],f[r]) );
      }
    }
    sort(u.begin(),u.end());
    u.erase( unique(u.begin(),u.end()),u.end());

    int s = 0;
    for(int i = 1; i <= k; i++){
      s += c[f[i]];
      used[f[i]] = true;
    }

    int res = s;
    for(int i = 0; i < (int)u.size(); i++){
      int l = u[i].first;
      int r = u[i].second;
      if(used[l] && !used[r]) res = min(res,s-c[l]+c[r]);
      if(!used[l] && used[r]) res = min(res,s-c[r]+c[l]);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 5300
S = input()
n = 4

for i in range(2 ** (n - 1)):
    r = int(S[0])
    for j in range(n - 1):
        if (i >> j) & 1 == 1:
            r -= int(S[j + 1])
        else:
            r += int(S[j + 1])
    if r == 7:
        p = i
        break
    else:
        pass

for i in range(n - 1):
    print(S[i], end = '')
    if (p >> i) & 1 == 1:
        print('-', end = '')
    else:
        print('+', end = '')
print(S[3], end = '') 
print('=7')

Measured memory_bytes: 3064
n,l = (int(i) for i in input().split())
eating = float('inf')
apples = [i+l-1 for i in range(1,n+1)]
if 0 in apples:
    print(sum(apples))
elif sum(apples) < 0:
    print(sum(apples)-apples[-1])
else:
    print(sum(apples)-apples[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef long double db;
const int N = 1e5 + 5, M = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) puts("No");
  else if (a == b || b == c || a == c) puts("Yes");
  else puts("No");
}


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

import sys
import os
import math
import re
import random

tableA = {
    "A": "00000",
    "B": "00001",
    "C": "00010",
    "D": "00011",
    "E": "00100",
    "F": "00101",
    "G": "00110",
    "H": "00111",
    "I": "01000",
    "J": "01001",
    "K": "01010",
    "L": "01011",
    "M": "01100",
    "N": "01101",
    "O": "01110",
    "P": "01111",
    "Q": "10000",
    "R": "10001",
    "S": "10010",
    "T": "10011",
    "U": "10100",
    "V": "10101",
    "W": "10110",
    "X": "10111",
    "Y": "11000",
    "Z": "11001",
    " ": "11010",
    ".": "11011",
    ",": "11100",
    "-": "11101",
    "'": "11110",
    "?": "11111"}

tableB = {
    "101": " ",
    "000000": "'",
    "000011": ",",
    "10010001": "-",
    "010001": ".",
    "000001": "?",
    "100101": "A",
    "10011010": "B",
    "0101": "C",
    "0001": "D",
    "110": "E",
    "01001": "F",
    "10011011": "G",
    "010000": "H",
    "0111": "I",
    "10011000": "J",
    "0110": "K",
    "00100": "L",
    "10011001": "M",
    "10011110": "N",
    "00101": "O",
    "111": "P",
    "10011111": "Q",
    "1000": "R",
    "00110": "S",
    "00111": "T",
    "10011100": "U",
    "10011101": "V",
    "000010": "W",
    "10010010": "X",
    "10010011": "Y",
    "10010000": "Z"}

def my_solve(s):
    s = s.strip('\n')
    lst = []
    for c in s:
        lst.append(tableA[c])
    s = ''.join(lst)

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    return ans

for s in sys.stdin:
    s = s.strip('\n')
    #if s == '':
    #    break

    print(my_solve(s))
# while True:
#     try:
#         s = input()
#     except:
#         break
#
#     print(my_solve(s))

Measured memory_bytes: 11756
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,heikin;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a < 40){
		a=40;
	}
	if(b < 40){
		b=40;
	}
	if(c < 40){
		c=40;
	}
	if(d < 40){
		d=40;
	}
	if(e < 40){
		e=40;
	}
		heikin=(a + b + c + d + e)/5;
	printf("%d\n",heikin);
	return 0;
}


		


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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, M;
int A[200000];
int hm[200000], aiueo[200000];
int X[200000], Y[200000];

signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
        if (A[i] >= aiueo[A[i]]) {
            hm[A[i] - aiueo[A[i]]]++;
        }
        aiueo[A[i]]++;
    }

    for (int i = 0; i < M; i++) {
        cin >> X[i] >> Y[i];
        X[i]--;
        Y[i]--;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (hm[i] <= 0) {
            ans++;
        }
    }

    for (int i = 0; i < M; i++) {
        int p = Y[i], m = A[X[i]];
        A[X[i]] = p;
        if (p >= aiueo[p]) {
            if (hm[p - aiueo[p]] == 0) {
                ans--;
            }
            hm[p - aiueo[p]]++;
        }
        aiueo[p]++;
        if (m >= aiueo[m] - 1) {
            if (hm[m - aiueo[m] + 1] == 1) {
                ans++;
            }
            hm[m - aiueo[m] + 1]--;
        }
        cout << ans << endl;
        aiueo[m]--;
    }
    return 0;
}

Measured memory_bytes: 9344
using System;

public class Hello{
	public static void Main(){
      int N =int.Parse(Console.ReadLine());
      string[] S =Console.ReadLine().Split(' ');
      int[] array =new int[100];
      int k=1;
      for(int i=0;i<N;i++){
        array[i] = int.Parse(S[i]);
        if(array[i]%2==0){
          if(array[i]%3==0||array[i]%5==0){
            k=1;
          }
          else{
            k=0;
            break;
          }
        }
      }
       if(k==1){
         Console.WriteLine("APPROVED");
       }
       else Console.WriteLine("DENIED");
	}
} 

Measured memory_bytes: 13140
# E
import numpy as np
N, T = map(int, input().split())
# A=cost. B=value
A, B = np.array([input().split() for _ in range(N)], dtype=int).T

weight,value = A, B
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, まだ最後の食べ物を選んでない
d0 = np.zeros((N,T),int)
# dp[i][w] = i番目までからwを超えないように選んだ時の最大値, もう最後の食べ物を選んだ
d1 = np.zeros((N,T),int)
# 初期値として0番目の商品を加える
d0[0,weight[0]:] = value[0]
d1[0,:] = value[0]

for n in range(1, N):
  w = weight[n]
  # w < weight[n]
  d0[n][:w] = d0[n-1][:w]
  d1[n][:w] = np.fmax(d1[n-1][:w], d0[n-1][:w] + value[n])
  # w >= weight[n]
  d0[n][w:] = np.fmax(d0[n-1][:-w] + value[n], d0[n-1][w:])
  d1[n][w:] = np.fmax(np.fmax(d1[n-1][:-w] + value[n], d1[n-1][w:]), d0[n-1][w:] + value[n])

print(d1[-1,-1])

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

M = [None]*(max(A)+1)
T = [None]*N
for i,a in enumerate(A):
    M[a] = i

for i,a in enumerate(A):
    T[M[a]]=(i+1)%N
    M[a]=i

ptr=0
ptr_head = [ptr]
while True:
    ptr_next = T[ptr]
    if ptr_next==0: break
    if ptr_next <= ptr+1: ptr_head.append(ptr_next)
    ptr = ptr_next

period = len(ptr_head)
if T[-1]==0: period+=1

if K % period==0:
    print()
    exit()

ret = []
ptr = ptr_head[K % period - 1]
while ptr<N:
    ptr_next = T[ptr]
    if ptr_next > ptr+1:
        ptr = ptr_next
    elif ptr_next==0 and ptr!=N-1:
        break
    else:
        ret.append(A[ptr])
        ptr+=1

print(' '.join(map(str, ret)))

Measured memory_bytes: 44504
use proconio::input;
use proconio::marker::Usize1;
use std::collections::HashMap;

#[allow(dead_code)]
struct UFT {
    par: Vec<usize>,
    size: Vec<usize>,
    n: usize,
}

#[allow(dead_code)]
impl UFT {
    fn new(n: usize) -> Self {
        let par = (0..n).collect();
        let size = vec![1; n];
        Self { par, size, n }
    }
    fn find(&mut self, a: usize) -> usize {
        if self.par[a] == a {
            a
        } else {
            self.par[a] = self.find(self.par[a]);
            self.par[a]
        }
    }
    fn unite(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.find(a);
        let mut y = self.find(b);
        if x == y {
            x
        } else {
            if self.size[x] < self.size[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.size[x] += self.size[y];
            self.par[y] = x;
            x
        }
    }
    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        K: usize,
        L: usize,
        PQ: [(Usize1, Usize1); K],
        RS: [(Usize1, Usize1); L],
    }

    let mut uft1 = UFT::new(N);
    let mut uft2 = UFT::new(N);
    let mut map = HashMap::new();

    for &(a, b) in &PQ {
        uft1.unite(a, b);
    }
    for &(a, b) in &RS {
        uft2.unite(a, b);
    }

    for i in 0..N {
        let cnt = map.entry((uft1.find(i), uft2.find(i))).or_insert(0);
        *cnt += 1;
    }

    for i in 0..N {
        print!("{} ", map.get(&(uft1.find(i), uft2.find(i))).unwrap());
    }
}


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

#define int long long

const int N = 44 + 5;
int fib[N];

void pre(){
  fib[0] = 1, fib[1] = 1;
  for(int i = 2; i < N; i++){
	   fib[i] = fib[i - 1] + fib[i - 2];  
	}	
}

int32_t main(){
	pre();
	int n;
	cin >> n;
	cout << fib[n] << endl;
	
}



Measured memory_bytes: 3104
n = gets
black_board = gets.split(' ').map(&:to_i)
count = 0

while true
  break unless black_board.all?{ |i| i % 2 == 0 }

  black_board = black_board.map do |s|
    s / 2
  end

  count += 1
  break unless black_board.all?{ |i| i % 2 == 0 }
end

puts count

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

int main(){
    int N,M,Q;
    while(cin>>N>>M>>Q,N){
        int memo[M][N];
        fill(memo[0],memo[M],0);
        string SW=string(N,'0');
        for(int q=0;q<Q;q++){
            string S,B;
            cin>>S>>B;
            for(int s=0;s<N;s++){
                if(S[s]=='1'){
                    if(SW[s]=='0') SW[s]='1';
                    else SW[s]='0';
                }
            }
            for(int s=0;s<N;s++){
                for(int b=0;b<M;b++){
                    if(SW[s]=='1'){
                        if(B[b]=='0'){
                            memo[b][s]=-1;
                        }else{
                            if(memo[b][s]!=-1)memo[b][s]=1;
                        }
                    }else{
                        if(B[b]=='1') memo[b][s]=-1;
                    }
                }
            }
        }
        for(int b=0;b<M;b++){
            int sw = -1;
            for(int s=0;s<N;s++){
                if(memo[b][s]==1){
                    if(sw==-1) sw=s;
                    else if(sw>-1) sw=-2;
                }
            }
            if(sw==-1){
                for(int s=0;s<N;s++){
                    if(memo[b][s]==0){
                        if(sw==-1) sw=s;
                        else if(sw>-1) sw=-2;
                    }
                }
            }
            if(sw<0)cout<<'?';
            else{
                if(sw<10){
                    cout<<sw;
                }else{
                    cout<<char('A'+sw-10);
                }
            }
        }
        cout<<endl;
    }

    return 0;
}

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

int a[200001];
int b[200001];
int main() {
   int n,p,q;
   cin>>n;
   
   for(int i=0;i<n;i++){
   cin>>a[i];
   b[i]=a[i];}
   sort(a,a+n);
   
   p=a[n-1];
   q=a[n-2];
   
   for(int i=0;i<n;i++){
       if(b[i]==p)
       cout<<q<<"\n";
       else
       cout<<p<<"\n";
   }
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N;
	int r[100][2];
	int b[100][2];
	int pr[100]={0},pb[100]={0};
	int pairnum=0;
	vector<pint> redy,bluex;
	scan(N);
	rep(i,N){
		scan(r[i][0]);scan(r[i][1]);
		pint ry(r[i][1],i);
		redy.push_back(ry);
	}
	rep(i,N){
		scan(b[i][0]);scan(b[i][1]);
		pint bx(b[i][0],i);
		bluex.push_back(bx);
	}
	sort(redy.begin(),redy.end());
	sort(bluex.begin(),bluex.end());
	rep(i,N){
		int rindex=-1;
		int rymax=-1;
		rep(j,N){
			if(r[j][0]<bluex[i].first&&r[j][1]<b[bluex[i].second][1]&&pr[j]==0){
				if(r[j][1]>rymax){
					rindex=j;
					rymax=r[j][1];
				}
			}
		}
		if(rindex>=0){
			pr[rindex]=1;
			pairnum++;
		}
	}
	prin(pairnum);
	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        res += 2 * min(a, k - a);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   string s;
   cin>>s;

   int sum=0;
   rep(i, s.size()) sum+=s[i]-'0';
   bool ok=sum%9==0;

   if(ok) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3724
n=int(input())
data=[[i for i in input().split()]+[_] for _ in range(n)]
for i in range(n):
    data[i][1]=int(data[i][1])
data=sorted(sorted(data,key=lambda x:x[1])[::-1],key=lambda x:x[0])
print(*[k+1 for i,j,k in data],sep="\n")

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int digits(int x) {
	return x / 10000 + x % 10000 / 1000 + x % 1000 / 100 + x % 100 / 10 + x % 10;
}

int main(){
	int N;
	cin >> N;
	int ans = -1;
	for (int i = 1;i <= (N + 1)/2;++i) {
		if (ans < 0) {
			ans = digits(i) + digits(N - i);
		}
		else if (digits(i) + digits(N - i) < ans) {
			ans = digits(i) + digits(N - i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 5001;
long long INF = 1000000000000;
struct edge { int from, to, cost; };
int main()
{
  int n,m,p,i,j,c,t;
  edge es[N_MAX];
  long long d[N_MAX],res;
  cin >> n >> m >> p;
  for(i=0;i<m;i++){
    cin >> es[i].from >> es[i].to >> c;
    es[i].cost=p-c;
  }
  d[1]=0;
  fill(d+2,d+n+1,INF);
  j=0;
  while(true){
    bool update=false;
    for(i=0;i<m;i++){
      edge e=es[i];
      if(d[e.from]<INF && d[e.to]>d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        update=true;
      }
    }
    if(!update) break;
    j++;
    if(j==n-1)
      t=d[n];
    if(j==3*n){
      if(d[n]<t){
        cout << "-1" << endl;
        return 0;
      }else{
        break;
      }
    }
  }
  res=max(-d[n],(long long)0);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());

function main() {
    var v1 = o.getArray(0);
    var H = +v1[0];
    var W = +v1[1];
    var K = +v1[2];

    var cn = [];
    for (var i = 0; H > i; i++) {
        cn.push(o.getValue(i + 1));
    }

    var result = 0;
    for (let bit = 0; bit < (1 << H); bit++) {
        for (let wbit = 0; wbit < (1 << W); wbit++) {
            let count = 0;
            for (let i = 0; i < H; i++) {
                if (bit & (1 << i)) continue;
                for (let j = 0; j < W; j++) {
                    if (wbit & (1 << j)) continue;
                    if (cn[i][j] === '#') {
                        count++;
                    }
                }
            }
            if (count === K) {
                result++;
            }
        }
    }
    return result;
}

Measured memory_bytes: 32328
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

template <typename T>
struct WeightedUnionFind {
  vector<int> data;
  vector<T> ws;

  WeightedUnionFind() {}

  WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}

  int find(int k) {
    if (data[k] < 0) return k;
    auto par = find(data[k]);
    ws[k] += ws[data[k]];
    return data[k] = par;
  }

  T weight(int t) {
    find(t);
    return ws[t];
  }

  bool unite(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = find(x), y = find(y);
    if (x == y) return false;
    if (data[x] > data[y]) {
      swap(x, y);
      w *= -1;
    }
    data[x] += data[y];
    data[y] = x;
    ws[y] = w;
    return true;
  }

  T diff(int x, int y) { return weight(y) - weight(x); }
};

int main() {
  int n, m;
  cin >> n >> m;
  WeightedUnionFind<int> tree(n);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    if (tree.find(a) != tree.find(b)) {
      tree.unite(a, b, c);
    } else {
      if(tree.diff(a,b) != c){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1152
import java.lang.StringBuffer;
import java.lang.System;

class Main {
    public static void main(String[] a) {
        for(int i = 1; i < 10; i++) {
            for(int j = 1; j < 10; j++) {
                StringBuffer str = new StringBuffer();
                str.append(i);
                str.append("x");
                str.append(j);
                str.append("=");
                str.append(i*j);
                System.out.println(str.toString());
            }
        }
    }
}

Measured memory_bytes: 16856
def solve():
    _ = int(input())
    ax = list(map(int, input().split()))
    ans = 0

    for a in ax:
        i = a
        while i % 2 == 0:
            i = i//2
            ans += 1

    print(ans)


# Solve
if __name__ == "__main__":
    solve()


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

int main() {

  ll H, N;
  cin >> H >> N;

  vector<ll> A;
  ll temp;
  REP(i, 0, N) {
    cin >> temp;
    A.push_back(temp);
  }

  // sort(A.begin(), A.end(), greater<ll>());
  // debug
  // REP(i, 0, N) {
  //   cout << A[i] << " ";
  // }
  // cout << endl;

  ll sum = 0;
  REP(i, 0, N) {
    sum = sum + A[i];
  }

  if (H <= sum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1400
s = input()
t = int(s, 2)
N = len(s)
if N%2==0:
    a = '10'*(N//2)
    b = '01'*(N//2)
else:
    a = '10'*(N//2)+'1'
    b = '01'*(N//2)+'0'
a = int(a, 2)
b = int(b, 2)
print(min(str(bin(t^a))[2:].count('1'), str(bin(t^b))[2:].count('1')))


Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    cout << (a + b >= x ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  double v[N];
  REP(i, N) cin >> v[i];
  sort(v,v+N);
  double ans = v[0];
  REP(i, N-1) {
    ans = (ans + v[i+1])/2;
  }
  cout << ans << '\n';
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{

    int N,M;
    string Astr,Bstr;
    char A[60][60]={},B[60][60]={};

    cin>>N>>M;

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

        for(int j=0;j<Astr.length();j++){
            A[i][j]=Astr[j];
        }
    }

    for(int i=0;i<M;i++){
        cin>>Bstr;
        for(int j=0;j<Bstr.length();j++){
            B[i][j]=Bstr[j];
        }
    }

    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){

            //開始地点ループ
            int f=0;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[i+k][j+l]!=B[k][l]){
                        f=1;
                        break;
                    }
                }
                if(f==1)break;
            }


            if(f==0){
                cout<<"Yes"<<endl;
                return 0;
            }

        }
    }

    cout<<"No"<<endl;

    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

void update(int a, int b, priority_queue<int>& less,
            priority_queue<int, vector<int>, greater<int>>& more,
            int& dless, int& dmore, int& off) {
    off += b;

    int n = less.size(), m = more.size();

    if(n == 0) {
        less.push(a);
        dless += a;
    } else if(n < m) {
        if(a > more.top()) {
            dmore -= more.top();
            less.push(more.top());
            dless += more.top();
            more.pop();
            dmore += a;
            more.push(a);
        } else {
            dless += a;
            less.push(a);
        }
    } else if(n > m) {
        if(a < less.top()) {
            dless -= less.top();
            more.push(less.top());
            dmore += less.top();
            less.pop();
            dless += a;
            less.push(a);
        } else {
            dmore += a;
            more.push(a);
        }
    } else {
        if(a > more.top()) {
            dmore += a;
            more.push(a);
        } else {
            less.push(a);
            dless += a;
        }
    }
}

void print(priority_queue<int>& less, priority_queue<int, vector<int>, greater<int>>& more,
           int dless, int dmore, int off) {
    int n = less.size(), m = more.size();
    if(m == 0) {
        cout << less.top() << " " << off << endl;
    } else if(n < m) {
        int mid = more.top();
        int dist = dmore-mid*more.size() + mid*less.size()-dless;
        cout << mid << " " << dist+off << endl;
    } else {
        int mid = less.top();
        int dist = mid*less.size()-dless + dmore-mid*more.size();
        cout << mid << " " << dist+off << endl;
    }
}

int32_t main() {

    int q; cin >> q;
    priority_queue<int> less;
    priority_queue<int, vector<int>, greater<int>> more;
    int dless = 0, dmore = 0, off = 0;
    
    while(q--) {
        int i; cin >> i;
        if(i == 1) {
            int a, b; cin >> a >> b;
            update(a, b, less, more, dless, dmore, off);
        } else {
            print(less, more, dless, dmore, off);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3828
require 'set'

n = gets.to_i
A = gets.split.map(&:to_i)
q = gets.to_i
M = gets.split.map(&:to_i)

C = Set.new

1.upto(A.size) do |n|
  A.combination(n).each do |arr|
    C << arr.inject(0, :+)
  end
end

M.each do |m|
  puts C.include?(m) ? 'yes' : 'no'
end

Measured memory_bytes: 9716
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#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
using namespace std;


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

/* vector<int> A(N); */
/* xの二乗
 pow(x, 2.0) */
 
int main() {
  
  long long N,K,count=0;
  cin >> N >> K;
  vector<int> H(N);
  
  rep(i,N){
  	cin >> H.at(i);
  }
  
  sort(H.begin(), H.end()); // vector
  
  rep(i,N-K){
    count+=H.at(i);
  }
  
  cout << count << endl;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
const LL mod=(1E9)+7;


int main()
{
    LL n;
    cin>>n;
    for(LL i=0; i<=1000; i++)
    {
        for(LL j=0; j<=1000; j++)
        {
            LL x=i*i*i*i*i;
            LL y=j*j*j*j*j;
            if(x+y==n)
            {
                cout<<i<<" "<<-j<<"\n";
                return 0;
            }
            if(x-y==n)
            {
                cout<<i<<" "<<j<<"\n";
                return 0;
            }
        }
    }

}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000003

typedef long long ll;
typedef pair<ll,ll> P;

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

ll fact[1111111];

ll func(ll x, ll n){
	if(n > MOD)return 0;

	ll l = max(0LL, x - 1);
	ll r = (x + n - 1) % MOD;
	if(l > r)return 0;
	else return mod_div(fact[r], fact[l]);
}

void solve() {
	ll x, d, n;cin >> x >> d >> n;
	if(d == 0){
		cout << mod_pow(x, n) << endl;
		return;
	}

	cout << func(mod_div(x, d), n) * mod_pow(d, n) % MOD << endl;
}

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

	fact[0] = 1;
	for(ll i = 1;i < 1111111;i++){
		fact[i] = fact[i-1] * i % MOD;
	}

	int q;cin >> q;
	REP(i, q)solve();

	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n;
    cin>>n;
    LL cnt=0;
    for(int i=1;i<=360;i++){
        cnt=cnt+n;
        if(cnt%360==0){cout<<i<<endl;return 0;}
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  map<int, int> num;
  rep(i, k){
    int d;
    cin >> d;
    rep(i, d){
      int a;
      cin >> a;
      num[a] = 1;
    }
  }
  int ans = n - num.size();
  cout << ans << endl;
}

Measured memory_bytes: 3632
N,K,C=map(int,input().split())
S=input()
i=0
data1=[0 for i in range(0,N)]
if S[0]=='o':
    for j in range(0,C+1):
        if N>j:
            data1[j]=(1,min(N,C+1))
    i=C+1
else:
    data1[0]=(0,1)
    i=1
while N-1>=i:
    if S[i]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data1[i+j]=(data1[i-1][0]+1,min(i+C+1,N))
        i+=C+1
    else:
        data1[i]=(data1[i-1][0],i+1)
        i+=1

data2=[0 for i in range(0,N)]
if S[-1]=='o':
    for j in range(0,C+1):
        if N>j:
            data2[j]=1
    i=C+1
else:
    data2[0]=0
    i=1
while N-1>=i:
    if S[-i-1]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data2[i+j]=data2[i-1]+1
        i+=C+1
    else:
        data2[i]=data2[i-1]
        i+=1

if N==1:
    print(1)
else:
    for i in range(0,N):
        if S[i]=='o':
            if i==0:
                if K>data2[N-2]:
                    print(i+1)
            elif N-1>i:
                work,nextday=data1[i-1]
                if nextday!=N:
                    nextday=max(nextday,i+1)
                    if K>work+data2[N-1-nextday]:
                        print(i+1)
                else:
                    if K>work:
                        print(i+1)
            elif i==N-1:
                if K>data1[N-2][0]:
                    print(i+1)



Measured memory_bytes: 68088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}
const int N=200050;
int len[N];
char s[N];
int main()
{
	int n,i;
	scanf("%s",s+1);
	n=strlen(s+1);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='A') len[i]=len[i-1]+1;
		if(s[i]=='C')
		{
			if(s[i-1]=='B')
			{
				ans+=len[i-2];
				len[i]=len[i-2];
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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


int main() {
	int N;
	int d[110];
	cin >> N;
	for (int i = 0; i < N; ++i)cin >> d[i];

	sort(d, d + N);
	int pre = d[0];
	int ans = 1;
	for (int i = 1; i < N; ++i) {
		if (pre != d[i])++ans, pre = d[i];
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    FOR(i,0,N)  if(dist.at(i)==-1){
        No();
        return 0;
    }  
    Yes();
    for (int v = 1; v < N; ++v) cout << dist[v]+1 << endl;
}

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

long long n;
long long memo[4][3][10] = {0};

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    memo[--b][--f][--r] += v;
  }
  for(int i = 0; i < 4; ++i) {
    for(int j = 0; j < 3; ++j) {
      for(int k = 0; k < 10; ++k) {
        cout << " " << memo[i][j][k];
      }
      cout << endl;
    }
    if(i != 3) cout << "####################" << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> p(n);
    rep(i, n) {
        std::cin >> p[i].first >> p[i].second;
    }
    double ans = 0;
    rep(i, n) {
        repeat(j, i + 1, n) {
            ans += std::sqrt((p[i].first - p[j].first) * (p[i].first - p[j].first) + (p[i].second - p[j].second) * (p[i].second - p[j].second));
        }
    }
    ans *= 2;
    ans /= n;
    std::cout << std::setprecision(16) << ans << std::endl;
}

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

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

int main()
{
int H,N,i,sum=0;
cin>>H>>N;
int A[N];
for(i=0;i<N;i++){
    cin>>A[i];
}
for(i=0; i<N; i++){
    sum=sum+A[i];
}
if(sum>=H){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
    return 0;
}


Measured memory_bytes: 640
n = int(input())
mask = 0b111111
mod = 10**9+7
dp = [[0]*4**3 for _ in range(n+1)]
dp[0][63] = 1
for i in range(n):
  for bit in range(4**3):
    for x in range(4):
      nb = bit<<2&63|x
      f = nb == 6 or nb == 9 or nb == 33
      f |= bit&51 == 2 and x == 1
      f |= bit&60 == 8 and x == 1
      if f:
        continue
      dp[i+1][nb] += dp[i][bit]
      dp[i+1][nb] %= mod
print(sum(dp[-1])%mod)

Measured memory_bytes: 3188