akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n; cin >> n;
    n %= 10;
    if(n == 3) puts("bon");
    else if(n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
    else puts("hon");
}

Measured memory_bytes: 3632
from collections import deque
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
s = [list(input()) for _ in range(h)]
INF=10**7

queue = deque()

cost = [[INF]*w for _ in range(h)]
cost[ch-1][cw-1]=0

dxdy = [[1,0],[-1,0],[0,1],[0,-1]]
warp = []
for m in range(-2,3):
    for n in range(-2,3):
        if [m,n] not in [[0,0],[1,0],[-1,0],[0,1],[0,-1]]:
            warp += [[m,n]]

queue.append([ch-1,cw-1,0])

while queue:
    x,y,d = queue.popleft()
    for dx,dy in dxdy:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d<cost[nx][ny]:
            cost[nx][ny]=d
            queue.appendleft([nx,ny,d])
            #[print(*cost[l]) for l in range(h)]
            #print("---------------")

    for dx,dy in warp:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d+1<cost[nx][ny]:            
            cost[nx][ny]=d+1
            queue.append([nx,ny,d+1])
            #[print(*cost[l]) for l in range(h)]
            #print("---------------")


if cost[dh-1][dw-1]<INF:
    print(cost[dh-1][dw-1])
else:
    print(-1)



Measured memory_bytes: 162080
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
if(a>=13){
  cout << b;
}
else if(a<=12&&a>=6){
  cout << b/2;
}
else if(a<=5){
  cout << 0;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#define X first
#define Y second
#define clr(u,v); memset(u,v,sizeof(u));
#define in() freopen("data","r",stdin);
#define out() freopen("ans","w",stdout);
#define Clear(Q); while (!Q.empty()) Q.pop();
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int N[maxn];
struct Edge
{
    int v, to;
} E[maxn*2];
int head[maxn], cnt;
int vis[maxn];
queue <pii> Q;
void addedge(int v, int u)
{
    E[cnt].v = u, E[cnt].to = head[v];
    head[v] = cnt++;
}
void init()
{
    clr(head, -1);
    cnt = 0;
}

int main()
{
    init();
    int n, v, u;
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        scanf("%d%d", &v, &u);
        addedge(v, u);
        addedge(u, v);
    }
    Q.push(make_pair(1, 1));
    Q.push(make_pair(n, -1));
    vis[1] = 1;
    vis[n] = -1;
    while (!Q.empty())
    {
        pii temp = Q.front();
        Q.pop();
        int u = temp.X;
        for (int i = head[u]; ~i; i = E[i].to)
        {
            int v = E[i].v;
            if (vis[v]) continue;
            vis[v] = temp.Y;
            Q.push(make_pair(v, temp.Y));
        }
    }
    int A = 0, B = 0;
    for (int i = 1; i <= n; i++)
        if (vis[i] == 1) A++;
        else B++;
    if (A > B) puts("Fennec");
    else puts("Snuke");
    return 0;
}


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


int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m)
  {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--;
  t--;
  vector<vector<bool>> chk(n, vector<bool>(3, false));
  queue<pair<int, int>> q;
  q.emplace(0, s);
  while (!q.empty())
  {
    auto p = q.front();
    q.pop();
    int count = p.first;
    int crt = p.second;
    if (chk[crt][count%3])
      continue;
    chk[crt][count%3] = true;
    if (count % 3 == 0 && crt == t)
    {
      cout << count / 3 << endl;
      return 0;
    }
    for (int i : g[crt])
      q.emplace(count + 1, i);
  }
  cout << -1 << endl;
  return 0;
}

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

typedef long long int int64;
int n;
int64 a[100003],b[100003];
struct tuple {
	int64 val;
	int i;
	int k;
} t[200003];
bool cmp1(const tuple &a,const tuple &b)
{
	return a.val < b.val;
}
int stat[100003];
int main()
{
	scanf("%d",&n);
	int64 sa = 0,sb = 0;
	for(int i = 0;i < n;++i) {
		scanf("%lld%lld",&a[i],&b[i]);
		sa += a[i];sb += b[i];
		t[2*i].val = a[i];t[2*i].i = i;t[2*i].k = 0;
		t[2*i+1].val = b[i];t[2*i+1].i = i;t[2*i+1].k = 1;
	}
	std::sort(t,t+2*n,cmp1);
	int64 sc = 0;
	bool ok = false;
	for(int i = 0;i < n;++i) {
		sc += t[i].val;
		stat[t[i].i] |= (1<<t[i].k);
		if(stat[t[i].i] == 3) ok = true;
	}
	if(!ok) {
		int64 min = -1;
		for(int i = n;i < 2*n;++i) {
			int64 k = t[i].i == t[n-1].i ? t[i].val-t[n-2].val : t[i].val-t[n-1].val;
			if(min == -1 || k < min) min = k;
		}
		sc += min;
	}
	printf("%lld\n", std::min(std::min(sa,sb),sc));
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>>
#define vll vector <pair<ll,ll>>
#define vi vector <int>
#define vl vector <ll>
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;



int main()
{
    IOS;

    int n,W;
    cin>>n>>W;

    vector <pair<ll,ll>> item(n);

    f0(i,n) cin>>item[i].F>>item[i].S;

    sort(item.begin(),item.end());

    ll dp[W+1][2]={0};



    f0(i,n){
      f1(j,W){
        if(item[i].F>j) dp[j][i%2]=dp[j][(i+1)%2];
        else{
          dp[j][i%2]=max(dp[j-item[i].F][(i+1)%2]+item[i].S,dp[j][i%2]=dp[j][(i+1)%2]);
        }
      }
    }

    cout<<max(dp[W][0],dp[W][1]);



    return 0;
    }


Measured memory_bytes: 1792
import java.util.*

fun main(arr:Array<String>) {
    val pointCount = readLine()!!.toInt()
    val road = mutableMapOf<Int,MutableMap<Int,Long>>()
    (1..pointCount-1) .forEach {
        val (p_1, p_2, l) = readLine()!!.split(" ").map { it.toLong() }
        val (p1, p2) = listOf(p_1, p_2).map { it.toInt() - 1 }
        if(!road.containsKey(p1)) {
            road[p1] = mutableMapOf()
        }
        if(!road.containsKey(p2)) {
            road[p2] = mutableMapOf()
        }
        road[p1]!![p2] = l.toLong()
        road[p2]!![p1] = l.toLong()
    }
    val prc = Proc(pointCount, road)
    prc.Proc()
}

class Proc(val pointCount:Int, val roadMap:MutableMap<Int,MutableMap<Int, Long>>) {
    val color = (1..pointCount).map {Col.None }.toMutableList()
    fun Proc() {
        color[0] = Col.White
        Paint(0)
        color.forEach { println(if(it == Col.White)"0" else "1") }
    }

    fun Paint(target:Int) {
        val que = LinkedList<Int>()
        que.push(target)
        while (que.isNotEmpty()) {
            val current = que.pop()
            val currentColor = color[current]
            for((next, l) in roadMap[current]!!) {
                if(color[next] != Col.None) {
                    continue
                }
                var nextColor = currentColor
                if(l % 2 != 0L) {
                    if(currentColor == Col.White) {
                        nextColor = Col.Black
                    } else {
                        nextColor = Col.White
                    }
                }
                color[next] = nextColor
                que.push(next)
            }
        }
    }
}

enum class Col {
    White,
    Black,
    None
}


Measured memory_bytes: 128392
h,w = map(int,input().split())
n = int(input())
lst1 = list(map(int,input().split()))
ans = [[0]*w for _ in range(h)]
ret = lst1[0]
color = 1
for i in range(h):
    if i%2 == 0:
        for j in range(w):
            if ret:
                ans[i][j] = color
                ret -= 1
            else:
                ret = lst1[color]
                color += 1
                ans[i][j] = color
                ret -= 1

    else:
        for j in range(w-1,-1,-1):
            if ret:
                ans[i][j] = color
                ret -= 1
            else:
                ret = lst1[color]
                color += 1
                ans[i][j] = color
                ret -= 1

for i in ans:
    print(" ".join(map(str,i)))

Measured memory_bytes: 40688
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	var MOD int64
	MOD = 1e9 + 7
	fmt.Scan(&s)
	n := len(s)
	dp := make([][]int64, n+5)
	for i:=0; i<n+5; i++ {
		dp[i] = make([]int64, 13)
	}
	dp[0][0] = 1
	for i:=0; i<n; i++ {
		var c int
		if s[i] == '?' {
			c = -1
		} else {
			c, _ = strconv.Atoi(string(s[i]))
		}
		for j :=0; j < 10; j++ {
			if c != -1 && c != j { continue }
			for ki := 0; ki < 13 ; ki++ {
				dp[i+1][(ki*10+j) % 13] += dp[i][ki]
			}
		}
		for j :=0; j < 13 ;j++ {
			dp[i+1][j] %= MOD
		}
	}
	fmt.Println(dp[n][5])
}

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

int main(void){
  cout << setprecision(15);
  string S;cin >> S;
  int N = S.length(),m=N;
  for(int i = 1; i<N;++i) if(S[i-1]!=S[i]) m = min(m, max(i,N-i));
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
void Search_R(double n);
void Search_L(double n);
void Answer(void);
int A[10]={0};
int B[10]={0};
int main(void) {

	double l,r;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%lf %lf",&l,&r);
		Search_R(r);
		Search_L(l);
	}
	Answer();		
	return 0;
}

void Answer(void){
	int i;
	for(i=1;i<=4;i++)
		printf("%d %d\n",B[i],A[i]);
}		
void Search_R(double n){
	if(n>=1.1)               A[1]+=1;
	else if(0.6<=n && n<1.1) A[2]+=1;
	else if(0.2<=n && n<0.6) A[3]+=1;
	else if(n<0.2)           A[4]+=1;
}
void Search_L(double n){
	if(n>=1.1)               B[1]+=1;
	else if(0.6<=n && n<1.1) B[2]+=1;
	else if(0.2<=n && n<0.6) B[3]+=1;
	else if(n<0.2)           B[4]+=1;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		
		int cont = 0;
		for(int i = 0 ; i < s.length / 2; i++) {
			if(!s[i].equals(s[s.length - i -1])) {
				cont++;
			}
		}
		
		
		System.out.println(cont);
		
	}



}


Measured memory_bytes: 21844
import itertools

n, k = map(int, input().split())
p = list(map(int, input().split()))
# s = [0] + list(itertools.accumulate(p))
e = []

ans = 0
# temp = s[1]
l = 1
r = 1
# prev =

def getExp(n):
    return (n*(n+1)/2) / n

for i in range(n):
    e.append(getExp(p[i]))

s = [0] + list(itertools.accumulate(e))

ans = 0
for i in range(k, n+1):
    temp = s[i] - s[i-k]
    ans = max(ans, temp)

# print(s)
# print(e)

print(ans)

Measured memory_bytes: 80776
#include <stdio.h>

int main(void) {
    int N, K, R = 0;

    scanf("%d %d", &N, &R);

    if (N < 10) {
        printf("%d\n", R + 100 * (10 - N));
    } else {
        printf("%d\n", R);
    }

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3", "unroll-loops")
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) signed(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#ifdef DEBUG
    mt19937 gen(857204);
#else
    mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
template<class T> inline T sorted(T a) { sort(a); return a; }

signed main() {
    FAST; FIXED;
    ld l;
    cin >> l;
    cout << pow(l / 3, 3);
    #ifdef DEBUG
        cerr << "Runtime is: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];
    sort(a, a + n);
    int key = lower_bound(a, a + n, a[n - 1] / 2) - a;
    if(key > 0)
        if(abs(a[key] - a[n - 1] / 2) > abs(a[key - 1] - a[n - 1] / 2))
            key -= 1;
    if(key == n - 1) {
        cout << a[n - 1] << ' ' << a[0] << endl;
    }else {
        cout << a[n - 1] << ' ' << a[key] << endl;
    }
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int m = sc.nextInt();
        char arr[][] = new char[n][m];
        int mod = 1000000007;
        for(int i=0;i<n;i++)
        {
            String str = sc.next();
            for(int j=0;j<m;j++)
            {
                arr[i][j]=str.charAt(j);
            }
        }
        boolean flag = false;
        int res[][] = new int[n][m];
        for(int i=0;i<n;i++)
        {
            if(flag==true)
            {
                res[i][0]=0;
            }
            else
            {
            if(arr[i][0]=='#')
            {
                flag=true;
                res[i][0]=0;
            }
            else{
                res[i][0]=1;
            }
            }
        }
        flag = false;
        for(int i=0;i<m;i++)
        {
            if(flag==true)
            {
                res[0][i]=0;
            }
            else
            {
            if(arr[0][i]=='#')
            {
                flag=true;
                res[0][i]=0;
            }
            else{
                res[0][i]=1;
            }
            }
        }
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<m;j++)
            {
                if(arr[i][j]=='#')
                {
                    res[i][j]=0;
                }
                else{
                    res[i][j]= (res[i-1][j]%mod + res[i][j-1]%mod)%mod;
                }
            }
        }
        // for(int i=0;i<n;i++)
        // {
        // System.out.println(Arrays.toString(res[i]));
        // }
        System.out.println(res[n-1][m-1]);
    }
}

Measured memory_bytes: 47280
#include "bits/stdc++.h"
using namespace std;
int main(){
	map<string, int> mp;
	map<string, int>::iterator ite;
	int n,m;
	cin>>n;
	string S[110];
	for(int i=0;i<n;i++){
		cin>>S[i];
		mp[S[i]]++;
	}
	cin>>m;
	string T;
	for(int i=0;i<m;i++){
		cin>>T;
		mp[T]--;
	}
	int maxv=0;
	for(int i=0;i<n;i++){
		maxv = max(maxv, mp[S[i]]);
	}

	cout<< maxv <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int count=0;
  for(int i=0;i<N-2;i++){
    if(MY.at(i)<MY.at(i+1) && MY.at(i+1)<MY.at(i+2)){
      count++;
    }
    if(MY.at(i)>MY.at(i+1) && MY.at(i+1)>MY.at(i+2)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : March 01 2020 17:31:22 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    vvi a(3,vi(3));
    fori(i,3) fori(j,3) cin >> a[i][j];
    vvi mark(3,vi(3));
    int n;
    cin >> n;
    fori(_,n){
        int x;
        cin >> x;
        fori(i,3){
            fori(j,3){
                if(a[i][j] == x){
                    mark[i][j] = 1;
                }
            }
        }
    }
    bool ok = 0;
    bool foo = 1;
    bool foo2 = 1;
    fori(i,3){
        bool cur=1;
        fori(j,3){
            cur &= mark[i][j];
        }
        ok |= cur;
        cur = 1;
        fori(j,3){
            cur &= mark[j][i];
        }
        ok |= cur;
        foo &= mark[i][i];
        foo2 &= mark[i][2-i];
    }
    ok |= foo;
    ok |= foo2;
    cout << (ok ? "Yes":"No") << endl;




    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=250010;
typedef long long ll;
const ll mod=1000000000000000031ll,base=131,inv_base=68702290076335880ll;

int n;
ll p[N],q[N];
char s[N];
map<ll,int> cnt;

ll add(ll a,ll b) {
	return a+b>=mod?a+b-mod:a+b;
}

ll mul(ll a,ll b) {
	return (__int128)a*b%mod;
}

ll qpow(ll a,ll b) {
	ll ret=1;
	while(b) {
		if(b&1) ret=mul(ret,a);
		a=mul(a,a),b>>=1;
	}
	return ret;
}

int main() {
	cin>>n;scanf("%s",s+1);
	p[0]=1;//cerr<<qpow(base,mod-2)<<endl;
	for(int i=1;i<=n;i++) {
		p[i]=p[i-1],q[i]=q[i-1];
		if(s[i]=='+') q[i]=add(q[i],p[i]);
		else if(s[i]=='-') q[i]=add(q[i],mod-p[i]);
		else if(s[i]=='>') p[i]=mul(p[i],base);
		else p[i]=mul(p[i],inv_base);
	}
	ll ans=0;
	for(int i=n;i;i--) {
		++cnt[q[i]];
		ans+=cnt[add(mul(q[n],p[i-1]),q[i-1])];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 35584
#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 RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(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() {
  string S;
  cin >> S;
  bool ok=false, C=false;
  for(char c: S) {
    if(C) {
      if(c == 'F') ok = 1;
    } else {
      if(c == 'C') C = 1;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

signed main() {
    int n, l, ans, absl;
    
    cin >> n >> l;
    
    ans = 0;
    absl = 10000;
    for ( int i = 1; i <= n; i++ ) {
        ans += l+i-1;
        
        if ( abs(l+i-1) < abs(absl) ) {
            absl = l+i-1;
        }
    }
    
    
    cout << ans - absl << endl;
    return (0);
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
   int n;
   string s;
   vector<int> p(5);
   cin >> n;
   for(int i = 1; i <= n; i++){
	    cin >> s;
	    if (s[0] == 'M') p[0]++;
	    else if (s[0] == 'A') p[1]++;
	    else if (s[0] == 'R') p[2]++;
	    else if (s[0] == 'C') p[3]++;
	    else if (s[0] == 'H') p[4]++;   
	 }
   int cnt = 0;
   for(int i = 0; i< 5; i++){
	   for(int j = i + 1; j < 5; j++){
		 for(int k = j + 1; k < 5; k++){
			  cnt += p[i] * p[j] * p[k]; 
			} 
		 } 
	  }
   cout << cnt << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {

	long long N, K;
	cin >> N >> K;

	long long base = pow(10, 9) + 7;

	long long ans = 0;
	long long v_max = 0;
	long long v_min = 0;
	for (long long i = K; i <= (N + 1); i++) {
		v_min = i * (i - 1) / 2;
		v_min = v_min % base;
		v_max = (N + 1) * N / 2 - (N - i) * (N - i + 1) / 2;
		v_max = v_max % base;
		ans += v_max - v_min + 1;
		ans = ans % base;
		if (ans < 0) {
			ans = base + ans;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
	int a, b;
	double c;
	cin >> a >> b;
	c=b;	
	cout << a/b << " " << a%b << " " << fixed << setprecision(5) << a/c << endl;

	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
	int n,k,ans=0;scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	sort(a,a+n);
	for(int i=0;i<k;i++)ans+=a[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int r,c,n,x,y,ans[200][200];
    scanf("%d%d%d",&r,&c,&n);
    y=1,x=1;
    for(int i=1,cnt;i<=n;i++)
    {
        scanf("%d",&cnt);
        while(cnt--)
        {
            ans[x][y]=i;
            if(y==c&&x%2==1)
                y=c,x++;
            else if(y==1&&x%2==0)
                y=1,x++;
            else if(x&1)
                y++;
            else
                y--;
        }
    }
    for(int i=1;i<=r;i++)
    for(int j=1;j<=c;j++)
        printf("%d%c",ans[i][j],j==c?'\n':' ');
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> num(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    num.at(A.at(i)-1)++;
  }
  sort(num.begin(), num.end());
  int cnt=0;
  for(int i=0; i<N; i++){
    if(num.at(i)!=0) cnt++;
  }
  int ant=max(0, cnt-K);
  int ans=0;
  if(ant==0) ans=0;
  else{
    for(int i=N-cnt; i<N-cnt+ant; i++){
      ans+=num.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
int fg;
void finds(int n)
{
    if(n==0){fg = 1;return;}
    if(n<0)return ;
    int t = n;
    finds(t-4);
    finds(n-7);
    return ;
}

int main()
{
    fg = 0;
    int n;
    scanf("%d", &n);
    if(n%4==0||n%7==0)printf("Yes\n");
    else
    {
        finds(n);
        if(fg == 1)printf("Yes\n");
        else printf("No\n");
    }



    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF = ll(1e18);

void solve(long long N, std::vector<long long> A){
    ll ans = 1;
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
        // cerr <<"ans=" << ans << endl;
        if(ans ==0){
            break;
        }
        if(A[i]>(INF/ans)){
            cout << -1 << endl;
            return;
        }
        ans *= A[i];
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3988
n=int(input())
s=[str(input()) for i in range(n)]
m=int(input())
t=[str(input()) for i in range(m)]
ans=0
s_new=list(set(s))
for i in range(len(s_new)):
    if (s.count(s_new[i])-t.count(s_new[i]))>ans:
        ans=s.count(s_new[i])-t.count(s_new[i])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 1; i <= (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll n, a[210000], b[210000] = {};
    cin >> n;
    for(ll i = 2; i <= n; i++) cin >> a[i];

    for(ll i = 2; i <= n; i++){
        b[a[i]]++;
    }

    for(ll i = 1; i <= n; i++) cout << b[i] << endl;

    return 0;
}

Measured memory_bytes: 6796
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int N; cin >> N;
    int A, B; cin >> A >> B;
    if (N==1) {
        print("Hello World");
    } else {
        printf("%d\n", A + B);
    }
    
    return 0;
}

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

signed main() {

    int n;
    int l[2005];

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> l[i];
    }

    sort(l,l+n);

    int sum = 0;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; j++) {
            int x = lower_bound(l,l+n,l[i]+l[j]) - l;
            sum += max(x-i-1,0);
        }
    }
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table


def main():
    N = int(input())
    table = sieve(55555)
    P = []
    for p in table:
        if p%5==1:
            P.append(p)
    print(' '.join(map(str, P[:N])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, Y;
void func()
{
    cin >> N >> Y;
    rep(i, 0, N + 1)
    {
        rep(j, 0, N + 1 - i)
        {
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y)
            {
                printf("%d %d %d\n", i, j, N - i - j);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
}
int main()
{
    func();
}

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

int main() {
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++) {
        if(i % 2 == 0) {
            if(s[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if(s[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    if(s.size() % 2 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	using namespace std;
	int w, a, b;
	cin >> w >> a >> b;
	if (a < b)
	{
		if (a + w >= b)
			cout << 0;
		else
			cout << b - a - w;
	}
	else
	{
		if (b + w >= a)
			cout << 0;
		else
			cout << a - b - w;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i,n)cin >> h[i];
    int max_h = 0;
    int count = 0;
    rep(i,n){
	if(max(max_h,h[i]) != max_h || max_h == h[i]){
	    ++count;
	    max_h = h[i];
	}
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;
const pii Dir_Nine[9] = { 
	{0,0},{0,-1},{0,-2},
	{-1,0},{-1,-1},{-1,-2},
	{-2,0},{-2,-1},{-2,-2}
};

int main() {
	int w, h, n;
	scanf("%d %d %d", &h, &w, &n);
	priority_queue<pii, vector<pii>, greater<pii>> query;
	REP(i, n) {
		int a, b;
		scanf("%d %d", &a, &b);
		query.push({ b-1,a-1 });
	}
	ll ans[10] = {};
	map<pii, char> count;
	ll sum = 0;
	while (!query.empty()) {
		pii q = query.top();
		query.pop();
		int s = q.second, f = q.first;

		REP(i, 9) {
			pii nex = { Dir_Nine[i].first + f ,Dir_Nine[i].second + s };
			if (nex.first < 0 || nex.second < 0 || nex.first >= (w-2) || nex.second >= (h-2)) continue;
			ans[count[nex]]--;
			count[nex]++;
			ans[count[nex]]++;
		}

	}
	for (int i = 1; 10 > i; i++)
		sum += ans[i];
	printf("%lld\n", (ll)(w-2)*(h-2) - sum);
	for (int i = 1; 10 > i; i++)
		printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 57332
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
freq = Hash.new(0)
as.each do |a|
  freq[a] += 1
end

goal = freq.size - k
c = 0
freq.sort_by{|a,oc| oc}.each do |a, oc|
  break if goal <= 0
  goal -= 1
  c += oc
end
p c


Measured memory_bytes: 40960
def bubbleSort(A, N):
    s = 0
    flag = 0
    while flag == 0:
        flag = 1
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 0
                s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

n = int(input())
a = [int(i) for i in input().split()]

bubbleSort(a, n)

Measured memory_bytes: 5604
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	vector<int>p(n), q(n);
	rep(i, n)cin >> p[i];
	rep(i, n)cin >> q[i];
	vector<int>a(n);
	rep(i, n) {
		a[i] = i + 1;
	}
	map<vector<int>, int>mp;
	do {
		mp[a] = mp.size();
	} while (next_permutation(a.begin(), a.end()));
	int ans = abs(mp[p] - mp[q]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 5248
n = int(input())
B = list(map(int,input().split()))
A = [0] * n
ans = 0
A[0] = B[0]
for i in range(1,n-1):
  #print(B[i])
  A[i] = min(B[i],B[i-1])
A[n-1] = B[n-2]
print(sum(A))
#print(A)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	ll ans = 0;
	for (int j = 1; j <= N; j++) {
		ll n = N/j;
		ans += j * n * (n+1) / 2;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3632
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = sum(P[0:K])
B = [tmp]
for i in range(K, N):
    total = B[-1]-P[i-K]+P[i]
    if tmp < total:
        index = i-K+1
        tmp = total
    B.append(total)
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)


Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
const int N = 1234;
 
int col[N];
char s[N][N];
 
int main() 
{
	int h;
	scanf("%d", &h);
	int w = h;
	for (int i = 0; i < h; i++) 
		scanf("%s", s[i]);
	bool any = false;
	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++) 
			any |= (s[i][j] == '#');
	
	if (!any)
	{
		puts("-1");
		return 0;
	}
	for (int i = 0; i < h; i ++) 
		for (int j = 0; j < w; j ++)
			if (s[i][j] == '#') 
				col[j] ++;
 
	int ans = (int) 2 * h + 1;
	for (int i = 0; i < h; i ++) 
	{
		int cur = 0;
		if (col[i] == 0) cur ++;
		for (int j = 0; j < w; j ++)
			if (s[i][j] == '.')
				cur ++;
		for (int j = 0; j < w; j ++) 
			if (col[j] < h) 
				cur ++;
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  bool yellow = false;
  for(int i=0; i<N; i++){
    string arare;
    cin >> arare;
    if(arare == "Y"){
      yellow = true;
      break;
    }
  }
  if(yellow)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<bool> s(N+1, false);
    for (int i = 0; i < K; i++) {
        int d; cin >> d;
        while (d--) {
            int a; cin >> a;
            s[a] = true;
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (!s[i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

#define pii pair<int, int>
#define fi first
#define se second
#define REP(i, a, n) for (register int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (register int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (register int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (register int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

char IO;
inline int rd () {
	int res = 0;
	while ((IO = getchar()) && (IO < '0' || IO > '9'));
	while (IO >= '0' && IO <= '9') 
		res = (res << 1) + (res << 3) + (IO ^ 48), IO = getchar();
	return res;
}

const int SIZE = 100005;

int n, a[SIZE];
int b[SIZE], m;
int main () {
	n = rd();
	REP (i, 1, n) a[i] = rd();

	REP (i, 1, n) { // 不上升 len
		int l = 1, r = m, res = 0;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (b[mid] >= a[i]) res = mid, l = mid + 1;
			else r = mid - 1;
		}
		if (res == m) ++m;
		b[res + 1] = a[i];
	}

	printf ("%d\n", m);

	return 0;
}


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

main(){
  int n, dp[100001];
  cin >> n;
  dp[0]=0;
  for(int i=1;i<=n;i++){
    dp[i]=dp[i-1]+1;
    
    for(int j=6;j<=i;j*=6)dp[i]=min(dp[i],dp[i-j]+1);
    for(int j=9;j<=i;j*=9)dp[i]=min(dp[i],dp[i-j]+1);
    }
  cout << dp[n]<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int n, k = 1, answer = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a = 0;
        cin >> a;
        if (a == k) {
            ++k;
        } else {
            ++answer;
        }
    }
    cout << (answer == n ? -1 : answer) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int[] num = new int[26];

			while(sc.hasNext()) {
				String str = sc.nextLine();
				for(int i = 0;i < str.length();i++) {
					for(int j = 65;j <= 90; j++) {
						char ch = str.charAt(i);
						if(ch == (char)j || ch == (char)j + 32) {
							num[j - 65]++;
						}
					}
				}
			}

			for(int i = 97; i <= 122; i++) {
				System.out.println((char)i + " : " + num[i - 97]);
			}
		}
	}
}



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

int main(void) {
long long n, m;
int a = 0;
std::cin >> n;
m = n;
for (int i = 0; i < 10; i++) {
  a = n%10 + a;
  n = n/10;
  if (n==0) break;
}

if (m%a==0) {
  std::cout << "Yes" << '\n';
} else std::cout << "No" << '\n';

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] != T[i]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int N;
string S;

void agc031a() {
  vector<ll> c(26, 0);
  for (int i = 0; i < N; i++) {
    c[S[i] - 'a']++;
  }
  ll res = 1;
  for (int i = 0; i < 26; i++) {
    res = (res * (c[i] + 1)) % MOD;
  }
  res--;
  cout << res % MOD << "\n";
}

int main() {
  cin >> N >> S;
  agc031a();
  return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repit(it,u) for(__typeof((u).begin())it=(u).begin();it!=(u).end();++it)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define uniq(u) (u).erase(unique(all(u)),(u).end())
#define ll long
#define long int64_t
#define mp make_pair
#define pb push_back

typedef double number;
typedef vector<vector<number> > matrix;

inline number my_hypot(number x, number y) { return sqrt(x * x + y * y); }
inline void givens_rotate(number& x, number& y, number c, number s) {
    number u = c * x + s * y, v = -s * x + c * y;
    x = u, y = v;
}
vector<number> givens(matrix A, vector<number> b) {
    const int n = b.size();
    rep(i, n) repi(j, i + 1, n) {
        const number r = my_hypot(A[i][i], A[j][i]);
        const number c = A[i][i] / r, s = A[j][i] / r;
        givens_rotate(b[i], b[j], c, s);
        repi(k, i, n) givens_rotate(A[i][k], A[j][k], c, s);
    }
    for (int i = n - 1; i >= 0; --i) {
        repi(j, i + 1, n) b[i] -= A[i][j] * b[j];
        b[i] /= A[i][i];
    }
    return b;
}

const double eps = 1e-5;

int d;
vector<number> v;

vector<number> solve_eq(int m, int n){
    matrix A(d+1,vector<number>(d+1));
    vector<number> b(d+1);
    int cnt = 0;
    rep(i,d+3)if(i != m && i != n){
        b[cnt] = v[i];
        rep(j,d+1) A[cnt][j] = pow(1.0*i,1.0*j);
        cnt++;
    }
    return givens(A,b);
}

int main(){
    while(cin >> d, d){
        v.resize(d+3);
        int ans = -1;
        rep(i,d+3) cin >> v[i];
        rep(i,d+3){
            repi(j,i+1,d+3){
                vector<number> b = solve_eq(i,j);
                number e = 0, f = 0;
                rep(k,d+1) e += pow(1.0*i,1.0*k) * b[k];
                rep(k,d+1) f += pow(1.0*j,1.0*k) * b[k];
                if(abs(e-v[i]) > eps && abs(f-v[j]) < eps){
                    ans = i;
                    break;
                }
                if(abs(e-v[i]) < eps && abs(f-v[j]) > eps){
                    ans = j;
                    break;
                }
            }
            if(ans >= 0) break;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1320