akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n==3){
        if(s=="ooo")cout<<"SSS"<<endl;
        else if(s=="xxx")cout<<"WWW"<<endl;
        else cout<<"-1"<<endl;
        return 0;
    }
    for(int j=0;j<4;j++){
        vector<char>x(n);
        int last;
        if(j==0){
            x[0]='S';
            x[1]='S';
            if(s[0]=='o')last='S';
            else last='W';
        }
        if(j==1){
            x[0]='S';
            x[1]='W';
            if(s[0]=='o')last='W';
            else last='S';
        }
        if(j==2){
            x[0]='W';
            x[1]='S';
            if(s[0]=='o')last='W';
            else last='S';
        }
        if(j==3){
            x[0]='W';
            x[1]='W';
            if(s[0]=='o')last='S';
            else last='W';
        }
        for(int i=0;i<n-1;i++){
            if(x[i]=='S' && x[i-1]=='S' && s[i]=='o')x[i+1]='S';
            if(x[i]=='S' && x[i-1]=='S' && s[i]=='x')x[i+1]='W';
            if(x[i]=='S' && x[i-1]=='W' && s[i]=='o')x[i+1]='W';
            if(x[i]=='S' && x[i-1]=='W' && s[i]=='x')x[i+1]='S';
            if(x[i]=='W' && x[i-1]=='S' && s[i]=='o')x[i+1]='W';
            if(x[i]=='W' && x[i-1]=='S' && s[i]=='x')x[i+1]='S';
            if(x[i]=='W' && x[i-1]=='W' && s[i]=='o')x[i+1]='S';
            if(x[i]=='W' && x[i-1]=='W' && s[i]=='x')x[i+1]='W';
        }
             if(x[n-1]=='S' && x[n-2]=='S' && s[n-1]=='o' && x[0]=='W')continue;
        else if(x[n-1]=='S' && x[n-2]=='S' && s[n-1]=='x' && x[0]=='S')continue;
        else if(x[n-1]=='S' && x[n-2]=='W' && s[n-1]=='o' && x[0]=='S')continue;
        else if(x[n-1]=='S' && x[n-2]=='W' && s[n-1]=='x' && x[0]=='W')continue;
        else if(x[n-1]=='W' && x[n-2]=='S' && s[n-1]=='o' && x[0]=='S')continue;
        else if(x[n-1]=='W' && x[n-2]=='S' && s[n-1]=='x' && x[0]=='W')continue;
        else if(x[n-1]=='W' && x[n-2]=='W' && s[n-1]=='o' && x[0]=='W')continue;
        else if(x[n-1]=='W' && x[n-2]=='W' && s[n-1]=='x' && x[0]=='S')continue;
        else if(x[0]=='S' && x[1]=='S' && s[0]=='o' && x[n-1]=='W')continue;
        else if(x[0]=='S' && x[1]=='S' && s[0]=='x' && x[n-1]=='S')continue;
        else if(x[0]=='S' && x[1]=='W' && s[0]=='o' && x[n-1]=='S')continue;
        else if(x[0]=='S' && x[1]=='W' && s[0]=='x' && x[n-1]=='W')continue;
        else if(x[0]=='W' && x[1]=='S' && s[0]=='o' && x[n-1]=='S')continue;
        else if(x[0]=='W' && x[1]=='S' && s[0]=='x' && x[n-1]=='W')continue;
        else if(x[0]=='W' && x[1]=='W' && s[0]=='o' && x[n-1]=='W')continue;
        else if(x[0]=='W' && x[1]=='W' && s[0]=='x' && x[n-1]=='S')continue;
        else{
            for(int i=0;i<n;i++)cout<<x[i];
            cout<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll d, n;
    cin >> d >> n;
    ll ans = pow(100, d) * ((n == 100) ? 101 : n);
    cout << ans << '\n';
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"strconv"
	"os"
	"strings"
)

const MAX int = 5e5
var A []int = make([]int, MAX + 1)
var N int


func maxHeapify(i int) {
	l := 2 * i
	r := 2 * i + 1
	var largest int
	if l <= N && A[l] > A[i] {
		largest = l
	} else {
		largest = i
	}
	if r <= N && A[r] > A[largest] {
		largest = r
	}

	if largest != i {
		A[i], A[largest] = A[largest], A[i]
		maxHeapify(largest)
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N = nextInt(scanner)
	for i:=1; i<=N; i++ {
		A[i] = nextInt(scanner)
	}
	for i:=N/2; i>=1; i-- {
		maxHeapify(i)
	}
	fmt.Printf(" %s\n", strings.TrimRight(fmt.Sprint(A[1:N+1])[1:], "]"))
}


Measured memory_bytes: 22640
x = list(map(int, input().split()))

a = x[0]
b = x[1]
c = x[2]
k = x[3]

if a >= k:
  print(k)
else:
  count = k - a
  if b >= count:
    print(a)
  else:
    count = k - a - b
    ans = a - count
    print(ans)

Measured memory_bytes: 9188
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d\n", &n);
	int[][] g = new int[][n];
	int[] degree = new int[n];
	foreach (i; 0..n-1) {
		int x, y;
		scanf("%d %d\n", &x, &y);
		--x; --y;
		g[x] ~= y;
		g[y] ~= x;
		degree[x]++;
		degree[y]++;
	}
	string c = readln().chomp;

	bool[] live = new bool[n];
	live[] = true;

	int[] queue; int cursor = 0;
	foreach (i; 0..n) {
		if (degree[i] == 1) {
			queue ~= i;
		}
	}

	int L = n;
	while (cursor < queue.length) {
		int v = queue[cursor]; cursor++;
		if (c[v] == 'W') continue;
		live[v] = false; L--;
		foreach (u; g[v]) {
			degree[u]--;
			if (degree[u] == 1) {
				queue ~= u;
			}
		}
	}
	if (L == 0) {
		writeln(0);
		return;
	}
	int base = L*2;

	int[] score = new int[n];
	foreach (v; 0..n) {
		if (!live[v]) continue;
		score[v] = (degree[v] + (c[v]=='B'?0:1)) % 2;
		base += score[v];
	}

	int best = 0;
	int dfs(int v, int parent=-1) {
		int ret = score[v];
		foreach (u; g[v]) {
			if (u == parent) continue;
			if (!live[u]) continue;
			int s = dfs(u,v);
			best = max(best, ret+s);
			ret = max(ret, s+score[v]);
		}
		return ret;
	}
	foreach (v; 0..n) {
		if (!live[v]) continue;
		dfs(v);
		break;
	}

	writeln(base-best*2-2);
}

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

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int i,j,m,s,l,n,temp;
    ll ar1[200][200],ar2[200][200],sum;
    scanf("%d%d%d",&n,&m,&l);
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            scanf("%d",&ar1[i][j]);
    for(i=0;i<m;i++)
        for(j=0;j<l;j++)
            scanf("%d",&ar2[i][j]);
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            sum=0;
            for(s=0;s<m;s++)
            {
                sum+=(ar1[i][s]*ar2[s][j]);
            }
            printf("%lld%c",sum,(j<l-1)?' ':'\n');
        }
    }
    return 0;
}




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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> a(10,vector<int>(n+1,n));
    for (int i = 0;i < n;++i) a[s[i]-'0'][i] = i;
    for (int i = 0;i < 10;++i) for (int j = n;j > 0;--j) a[i][j-1] = min(a[i][j-1],a[i][j]);
    int ans = 0;
    for (int i = 0;i < 1000;++i) {
        int x = i/100,y = (i%100)/10,z = i%10;
        if (a[x][0] < n && a[y][a[x][0]+1] < n && a[z][a[y][a[x][0]+1]+1] < n) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
prime = 10**9+7

X, Y = map(int, input().split(' '))

n = -X + 2*Y
m = 2*X - Y
if n < 0 or m < 0 or n%3 != 0 or n%3 != 0:
    print(0)
    exit(0)

n = n // 3
m = m // 3

# (n+m)!/n!m!を求める
# n >= mにする
if n < m:
    n, m = m, n

# (n+m)*...*(n+1)
a = 1
for i in range(n+1, n+m+1):
    a = a * i % prime

# m!
b = 1
for i in range(1, m+1):
    b = b * i % prime

# bの逆数cを求める c = b^p-2
ans = 1
exp = prime - 2
while exp:
    if exp & 1:
        ans = ans*b%prime
    b = b**2%prime
    exp = exp >> 1


print(a*ans%prime)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int  ,long long int> P;

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

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


int main(void)
{
	int q;
	int maxi = 0;
	int tmp;
	int before = -1;
	int count = 0;
	string n;
	string a, b;

	cin >> q;
	
	FOR(i, 1, q)
	{
		cin >> n;
		count = 0;
		while (1)
		{
			maxi = -1;
			if(n.size()==1){
				break;
			}
			FOR(j, 0, n.size() - 2)
			{
				a = n.substr(0, j + 1);
				b = n.substr(j + 1);
				if(maxi<stoi(a)*stoi(b)){
					maxi = stoi(a) * stoi(b);
				}
			}
			n = to_string(maxi);
			count++;
			if (maxi == before)
			{
				break;
			}
			before = maxi;
		}

		if(n.size()==1){
			cout << count << endl;
		}else{
			cout << -1 << endl;
		}
	}
}



Measured memory_bytes: 3260
from collections import deque
inf = 1000000000
h, w = map(int, input().split())
root = [[-1]*w for i in range(h)]
root[0][0] = 1
s = [[] for i in range(h)]

cnt = 0
for i in range(h):
    s[i] = input()
    for j in range(w):
        if s[i][j] == '#': cnt+=1
dw = [-1, 0, 1, 0]
dh = [0, 1, 0, -1]
que = deque()
que.append([0, 0])
while len(que)>0:
    x, y = que.popleft()
    for dx, dy in zip(dw, dh):
        nx, ny = x+dx, y+dy
        if 0<=nx<w and 0<=ny<h and root[ny][nx]==-1 and s[ny][nx]=='.':
                que.append([nx, ny])
                root[ny][nx] = root[y][x] + 1
if root[h-1][w-1]<0:
    print(-1)
else:
    print(h*w - cnt - root[h-1][w-1])

Measured memory_bytes: 74428
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define sgn(v) (abs((v))<eps?0:((v)<0?-1:1))
#define sqr(v) ((v)*(v))
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
#define debug 0
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<double,int> PDI;
typedef pair<double,double> PDD;
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
const double eps=1e-8;
const double pi=acos(-1);
const int maxn=1200;
const int maxe=2e6;
struct Edge
{
	int from,to,cap,next;
	Edge(){}
	Edge(int u,int v,int c,int n)
	{
		from=u;to=v;cap=c;next=n;
	}
}edge[maxe];
int ne,head[maxn];
int n,m,dis[maxn];
void add(int u,int v,int c)
{
	edge[ne]=Edge(u,v,c,head[u]);
	head[u]=ne++;
	edge[ne]=Edge(v,u,0,head[v]);
	head[v]=ne++;
}
bool bfs(int st,int tp)
{
	queue<int> q;
	int now,i,u,v;
	memset(dis,-1,sizeof(dis));
	dis[st]=0;
	q.push(st);
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		for(i=head[u];i!=-1;i=edge[i].next)
		{
			v=edge[i].to;
			if(dis[v]==-1&&edge[i].cap>0)
			{
				dis[v]=dis[u]+1;
				q.push(v);
			}
		}
	}
	return (dis[tp]!=-1);
}
int dfs(int a,int b,int tp)
{
	int res=0,v,i;
	if(a==tp)return b;
	for(i=head[a];i!=-1&&res<b;i=edge[i].next)
	{
		v=edge[i].to;
		if(edge[i].cap>0&&dis[v]==dis[a]+1)
		{
			int x=min(edge[i].cap,b-res);
			x=dfs(v,x,tp);
			res+=x;
			edge[i].cap-=x;
			edge[i^1].cap+=x;
		}
	}
	if(!res)dis[a]=-2;
	return res;
}
int MAX=1000;
int dinic(int st,int tp)
{
	int total=0,t;
	while(bfs(st,tp))
	{
		while(t=dfs(st,MAX,tp))
			total+=t;
	}
	return total;
}
int main()
{
	int n,m,k,b,i,j,flw;
	memset(head,-1,sizeof(head));
	ne=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	{
		add(0,i,1);
		scanf("%d",&k);
		for(j=0;j<k;++j)
		{
			scanf("%d",&b);
			add(i,n+b,1);
		}
	}
	for(i=1;i<=m;++i)
		add(n+i,n+m+1,1);
	flw=dinic(0,n+m+1);
	//cout <<flw<<endl;
	if(flw==m)puts("Bob");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    cin>>n;
    vector<ll>a(n), pref(n+1), suff(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pref[i+1] = pref[i] + a[i];
    }

    suff[n] = a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suff[i+1] = suff[i+2] + a[i];
    }

    ll ans = INF;
    for(int i=1;i<n;i++)
    {
        ans = min(ans, abs(pref[i]-suff[i+1]));
    }
    cout<<ans,nl;
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    
    long long i;
    for(i = 100000; i >= 1; i--){
        if(i * i <= n){
            cout << i * i << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    ps <- getIntList
    print $ sum ps + 9 * (maximum ps)

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

int main(){
	int a , b , c;
	char arr[10000]={0};
	int i,j=0;
	cin >> a >> b >> c;
	for(i=a ; i<=b ; i++ ){
		if(c%i==0) arr[j++]='o';
	}
	cout << strlen(arr) << endl;
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  ll N,cnt=0;
  cin>>N;
  vector<ll> A(N);
  rep0(i,N){cin>>A[i];}
  for(ll i=0;i<N;i++){
      ll Min=i;
      for(ll j=i;j<N;j++){
          if(A[j]<A[Min]){Min=j;}
      }
      if(i!=Min){cnt++;}
      ll s=A[i];
      A[i]=A[Min];
      A[Min]=s;
  }
  rep0(i,N){if(i!=N-1){cout<<A[i]<<" ";} else{cout<<A[i]<<endl;}}
  cout<<cnt<<endl;
}


Measured memory_bytes: 3108
#!/usr/bin/env python3
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N, P = map(int, input().split())

F = factorization(P)
numbers = []
ans = 1
for i in range(len(F)):
    if F[i][1] >= N: ans *= F[i][0] ** (F[i][1]//N)


print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main ( int argc, char **argv )
{
    char buffer[100];
    int input_size = 0;
    
    while ( fgets(buffer, 100, stdin) != NULL )
    {
        sscanf(buffer, "%d", &input_size);

        int counter = 0;
        while ( counter < input_size )
        {
            int sides[3];
            int swap = 0;
            fgets(buffer, 100, stdin);
            sscanf(buffer, "%d %d %d", &sides[0], &sides[1], &sides[2]);

            int x = 0;
            for ( x = 0; x < 3; x++ )
            {
                if ( x + 1 == 3 )
                {
                    break;
                }

                if ( sides[x] > sides [x + 1] )
                {
                    swap = sides[x];
                    sides[x] = sides[x+1];
                    sides[x+1] = swap;
                }

            }

            if ( (sides[0] * sides[0]) + (sides[1] * sides[1]) == (sides[2] * sides[2]) )
            {
                printf("YES\n");
            }
            else
            {
                printf("NO\n");
            }

            counter++;
        }
    }

    return 0;
}

Measured memory_bytes: 584
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let l = read::<usize>();
    let mut dists = vec![vec![2 * l; n]; n];
    for _i in 0..m {
        let f = read::<usize>() - 1;
        let t = read::<usize>() - 1;
        let c = read::<usize>();
        dists[f][t] = c;
        dists[t][f] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dists[i][j] = std::cmp::min(dists[i][j], dists[i][k] + dists[k][j]);
            }
        }
    }
    let mut cnts = vec![vec![10000; n]; n];
    for s in 0..n {
        let mut queue = VecDeque::<(usize, usize)>::new();
        cnts[s][s] = 1;
        queue.push_back((s, 0));
        while let Some((from, cost)) = queue.pop_front() {
            for to in 0..n {
                let ncost = cost + 1;
                if dists[from][to] > l || cnts[s][to] <= ncost {
                    continue;
                }
                cnts[s][to] = ncost;
                queue.push_back((to, ncost));
            }
        }
    }
    let q = read::<usize>();
    for _iter in 0..q {
        let s = read::<usize>() - 1;
        let t = read::<usize>() - 1;
        if cnts[s][t] >= n + 1 {
            println!("-1");
        } else {
            println!("{}", cnts[s][t] - 1);
        }
    }
}


Measured memory_bytes: 3576
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int H = Integer.parseInt(sc.next());
    int W = Integer.parseInt(sc.next());
    int N = Integer.parseInt(sc.next());
    
    int[][] field = new int[H][W];
    int h = 0, w = 0;
    boolean f = true;
    for(int i = 0; i < N; i++){
      int M = Integer.parseInt(sc.next());
      for(int j = 0; j < M; j++){
        field[h][w] = i+1;
        if(f){
          if(w == W-1){
            f = false;
            h++;
          }else{
            w++;
          }
        }else{
          if(w == 0){
            h++;
            f = true;
          }else{
            w--;
          }
        }
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(j == W-1){
          System.out.println(field[i][j]);
        }else{
          System.out.print(field[i][j]+" ");
        }
      }
    }
  }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

struct bit {
	ll n;
	vl a;

	bit(ll n): n(n), a(n+2) { }
	
	void add(ll i, ll v) {
		for (i++; i <= n+1; i += i & -i) a[i] += v;
	}
	
	ll get(ll i) {
		ll res = 0;
		for (; i; i -= i & -i) res += a[i];
		return res;
	}
};

const ll MOD = 998244353;

void compress(vl &x) {
	vl i2x = x;
	sort(all(i2x));
	map<ll,ll> x2i;
	FOR(i,0,sz(x)) x2i[i2x[i]] = i;
	FOR(i,0,sz(x)) x[i] = x2i[x[i]];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl x(n), y(n);
	FOR(i,0,n) cin >> x[i] >> y[i];
	compress(x), compress(y);
	
	vl p2(n+1);
	p2[0] = 1;
	FOR(k,1,n+1) p2[k] = 2*p2[k-1] % MOD;

	ll res = n * (p2[n]-1) % MOD;
	FOR(i,0,n) res = (res - 4*(p2[i]-1)) % MOD;
	FOR(flip,0,2) {
		vl is(n);
		iota(all(is),0);
		sort(all(is),[&](ll i, ll j) { return x[i] < x[j]; });
		FOR(rot,0,2) {
			bit B(n);
			for (ll i: is) {
				ll cnt = B.get(y[i]);
				res = (res + p2[cnt]-1) % MOD;
				B.add(y[i],1);
			}
			reverse(all(is));
		}
		FOR(i,0,n) y[i] = n-1-y[i];
	}
	
	if (res < 0) res += MOD;
	cout << res << endl;
}



Measured memory_bytes: 17508
# Problem https://atcoder.jp/contests/abc113/tasks/abc113_b
# Python 2nd Try
import sys


def solver(allplace, maxtemp, targettemp, eachheight):
    answer = 0
    difftemp = 10.0**5
    for j in range(0, allplace):
        heretemp = abs(targettemp - (maxtemp - eachheight[j]*0.006))
        if heretemp < difftemp:
            answer = j
            difftemp = heretemp
    return answer+1


if __name__ == "__main__":
    N = list(map(int, sys.stdin.readline().split()))
    T, A = map(float, sys.stdin.readline().split(' '))
    HI = list(map(float, sys.stdin.readline().split(' ')))
    print(solver(N[0], T, A, HI))


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

int main(){
  int N;
  cin >> N;
  vector<long> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  long sump=0,sumn=0,p=0,n=0;
  
  for(int i=0; i<N; i++){
    sump+=a.at(i);
    if(i%2==0&&sump<=0){
      p+=1-sump;
      sump=1;
    }
    if(i%2==1&&sump>=0){
      p+=1+sump;
      sump=-1;
    }
  }
  for(int i=0; i<N; i++){
    sumn+=a.at(i);
    if(i%2==0&&sumn>=0){
      n+=1+sumn;
      sumn=-1;
    }
    if(i%2==1&&sumn<=0){
      n+=1-sumn;
      sumn=1;
    }
  }
  
  cout << min(p,n) << endl;
}

Measured memory_bytes: 1024
n, a, b = *ARGF.gets.split(/\s+/).collect{|i| i.strip.to_i}
total_sum = 0

(1..n).each do |i|
  sum_of_digits = i.to_s.each_char.inject(0){|sum, c| sum += c.to_i}
  if sum_of_digits >= a and sum_of_digits <= b
    total_sum += i
  end
end

puts total_sum


Measured memory_bytes: 14244
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll D, N;
/*==================================================*/
/*function*/

/*==================================================*/

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

    if(D==0){
        if(N < 100) cout<<N<<endl;
        else cout<<101<<endl;
    }else if(D==1LL){
        if(N < 100) cout<<100LL*N<<endl;
        else cout<<10100<<endl;
    }else{
        if(N < 100) cout<<10000LL*N<<endl;
        else cout<<1010000<<endl;   //1000000だと"100"で3回割れる
    }

    return 0;
}


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

  using namespace std;

  #define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
  #define forr(a, s, e) for (int a = s; a < (int)(e); a++)
  #define fore(e, a) for (auto& e : a)

  #ifdef LOCAL
  #define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
  #define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
  #define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
  #define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
  #define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
  #define logs(a) cerr << #a << " = " << (a) << "\n";
  #define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
  #define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
  #define cond(pred, stmt) if (pred) { stmt }
  #else
  #define logv(a)
  #define logvp(a)
  #define logvv(a)
  #define logvf(a, field)
  #define logvff(a, f1, f2)
  #define logs(a)
  #define logss(a, b)
  #define logp(a)
  #define cond(pred, stmt)
  #endif

  using i64 = long long;
  using iip = pair<i64, i64>;
  using ivec = vector<int>;
  using llvec = vector<i64>;
  using svec = vector<string>;
  template<typename T> using vec = vector<T>;

  template<typename T, typename Dim>
  auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
  template<typename T, typename Dim1, typename... Dim>
  auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

  template<typename T>
  bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
  template<typename T>
  bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

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

  // template<typename ...T>
  // istream& read(T&... args) { return (cin >> ... >> args); }

  static mt19937 rande(123123);
  template<typename T>
  T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    i64 a, b, k;
    while (cin >> a >> b >> k) {
      i64 la = a;
      a = max(0ll, a - k);
      k -= la - a;
      b = max(0ll, b - k);

      cout << a << " " << b << endl;
    }

  }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

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

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N,K;
LL sum[MAXN];

void work(){
    scanf("%d%d",&N,&K);
    LL ans=0;
    for(int i=1;i<=N;i++) sum[i]=sum[i-1]+i;
//    for(int i=1;i<=N;i++) printf("%d ",sum[i]);
//    printf("\n");
    for(int i=K;i<=N+1;i++){
        ans=((ans+sum[N]+MOD-sum[N-i])+(MOD-sum[i-1])+1)%MOD;
    }
    printf("%lld\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 5320
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#define swap(type, x, y) do { type t=x; x=y; y=t; } while(0)

int main(void) {
    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if (r <= y && y <= h-r && r <= x && x <= h-r)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans = a[0];
    n -= 2;
    ll cnt = n / 2;
    ll res;
    for(int i=1; cnt>0; ++i) {
        ans += a[i] * 2;
        cnt--;
        res = i;
        //cout << ans << endl;
    }
    if(n % 2 == 1) ans += a[res+1];
    cout << ans << endl;
}

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

ans = []

for _ in range(n):
    gx,gy = map(int,input().split())
    m = [[0 for i_ in range(gy+1)] for j_ in range(gx+1)]
    mat_num = int(input())
    mat_h = [[0 for i_ in range(gy+1)] for j_ in range(gx+1)]
    mat_v = [[0 for i_ in range(gy+1)] for j_ in range(gx+1)]
    ifm = [[0 for i_ in range(gy+1)] for j_ in range(gx+1)]
    for __ in range(mat_num):
        x1,y1,x2,y2 = map(int,input().split())
        if x1 == x2:
            mat_h[x1][max(y1,y2)] = 1
        else:
            mat_v[max(x1,x2)][y1] = 1
    queue = [(0,0)]
    while queue:
        x,y = queue.pop(0)
        if ifm[x][y] == 0:
            if x == 0:
                if y == 0:
                    m[x][y] = 1
                else:
                    if mat_h[x][y] == 0:
                        m[x][y] += m[x][y-1]
                    else:
                        pass
            else:
                if y == 0:
                    if mat_v[x][y] == 0:
                        m[x][y] += m[x-1][y]
                    else:
                        pass
                else:
                    if mat_v[x][y] == 0:
                        m[x][y] += m[x-1][y]
                    if mat_h[x][y] == 0:
                        m[x][y] += m[x][y-1]
            ifm[x][y] = 1
            if x < gx:
                queue.append((x+1,y))
            if y < gy:
                queue.append((x,y+1))
        else:
            pass
    ans.append(m[gx][gy])

for x in ans:
    if x == 0:
        print('Miserable Hokusai!')
    else:
        print(x)


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int l;
int main(){
    cin >> l;
    double ans=l/3.0;
    cout << fixed << setprecision(7) << pow(ans,3.0) << endl;
    return 0;
}

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

using namespace std;

int main(){
        string a, b, c;
        cin>>a>>b>>c;
        if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
                cout<<"YES"<<endl;
        }
        else{
                cout<<"NO"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> to(n);
    rep(i,n){
        cin >> to[i];
        to[i]--;
    }
    vector<bool> been(n,false);// n番目の街に行ったことがあるか
    been[0] = true;
    ll now = 0,step = 0;
    vector<ll> ever;
    ever.push_back(0);
    ll re = 0;
    while(true){
        step++;
        now = to[now];
        if(!been[now]){
            been[now] = true;
            ever.push_back(now);
        }
        else{
            rep(i,ever.size()){
                if(ever[i] == now){
                    re = i;
                    break;
                }
            }
            break;
        }
    }
    ll a = (k-re)%(step-re)+re;
    if(k < re) dunk(ever[k] + 1);
    else dunk(ever[a]+1);
    return 0;
}


Measured memory_bytes: 6936
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 500001
using namespace std;
ll mi(ll n,ll m){ll pw=n;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
ll n,k;
cin>>n>>k;
vl vec(n);
rep(i,0,n) cin>>vec[i];
Sort(vec);
ll ans=0;
for(int i=0;i<n-k;i++) ans+=vec[i];
cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		scan.close();
		
		System.out.print(N % K == 0 ? "0" : "1"); 
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int H, J, I;
    int n = scan.nextInt();
    
    H = n/100;
    J = (n - (H*100))/10;
    I = (n - (H*100) - (J*10));
         
    if(H == 7||J == 7||I == 7){
      System.out.print("Yes");
    } else {
      System.out.print("No");
    }
  }
}



Measured memory_bytes: 35760
class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]

def dec(n):
    return n-1


n,m,k = map(int, input().split())
block = [[] for i in range(n)]
candidate = [[] for i in range(n)]

u = UnionFind(n)


for i in range(m):
    a,b = map(dec,map(int, input().split()))
    u.unite(a,b)
    block[a].append(b)
    block[b].append(a)

for i in range(k):
    a,b = map(dec,map(int, input().split()))
    block[a].append(b)
    block[b].append(a)

ans_all = []
for i in range(n):
    ans = u.size(i)-1
    for x in block[i]:
        if u.same(i,x):
            ans-=1
    ans_all.append(ans)

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




Measured memory_bytes: 129696
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<double> mt;
	double m;
	int cont = -1;

	while(cin >> m){
		mt.push_back(m);
		cont++;
	}

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

	cout << mt[cont] - mt[0] << endl;

	return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
	string s;
	cin >> s;
	s.at(5) = ' ';
	s.at(13) = ' ';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N, M, X;
    cin >> N >> M >> X;
    ll cnt1 = 0;
    ll cnt2 = 0;
    rep(i, M) {
        ll A;
        cin >> A;
        if (A < X) cnt1++;
        else if (X < A) cnt2++;
    }
    print(min(cnt1, cnt2));
    return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

vector<int> zalgorithm(const string &s) {
    vector<int> z(s.size(), 0);
    z[0] = s.size();

    int i = 1;
    int j = 0;
    for(;i < s.size();) {
        for(;i + j < s.size() && s[i + j] == s[j];j++);
        z[i] = j;
        if(j == 0) {
            i++;
            continue;
        }
        int k = 1;
        for(;i + k < s.size() && k + z[k] < j;) {
            z[i + k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return z;
}

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    vector<vector<int>> v(N);
    REP(i, N) {
        v[i].resize(N);
    }
    REP(i, N) {
        vector<int> z = zalgorithm(s.substr(i, N - i));
        FOR(j, i, N) {
            v[i][j] = z[j - i];
        }
    }

    int res = 0;
    REP(i, N) {
        FOR(j, i, N) {
            int z = v[i][j];
            if(j < i + z)continue;
            res = max(res, z);
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 98176
#include<iostream>
#include<stdio.h>
using namespace std;

void p(int A[], int N) {
    int i = 0;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void sort(int A[], int N) {
    int i, j, v;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        p(A, N);
    }
}

int main() {
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    p(a, n);
    sort(a, n);
}


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

int main(void)
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = K; i < N; i++){
        if(A[i] > A[i-K]){
            cout << "Yes" << endl;
        } else {
            cout << "No"<< endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4836
input()
a = list(map(int,input().split()))

n=0
odd=False

while not(odd):
    for i in range(len(a)):
        if a[i]%2 == 1:
            odd=True
        else:
            a[i] /= 2
    if not(odd):
        n += 1

print(n)


Measured memory_bytes: 2940
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(a: usize, b: usize);
    let ans = if a > 12 {
        b
    } else if 6 <= a && a <= 12 {
        b / 2
    } else {
        0
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int i=0;
    while(i<n) {
        if(s.substr(i, n-i) == t.substr(0, n-i)) {
            break;
        }
        i++;
    }
    cout << n + i << endl;
    return 0;
}


Measured memory_bytes: 256
import collections

n, a = map(int, input().split())
ls = sorted([x - a for x in map(int, input().split())])
counter = collections.Counter()
for x in ls:
    for k, v in list(counter.items()):
        counter[k + x] = counter[k + x] + v
    counter[x] += 1
print(counter[0])

Measured memory_bytes: 3564
#include<iostream>
#define N 1000
using namespace std;

int main(){
  while(1){
    int n,q,e[N],w[N],que,f;
    string str[N];
    cin>>n>>q;
    if(n+q==0) break;
    for(int i=0;i<n;i++)cin>>str[i]>>e[i]>>w[i];
    for(int i=0;i<q;i++){
      cin>>que,f=0;
      for(int j=0;j<n;j++)if(e[j]-(w[j]-que)>0 && e[j]-(w[j]-que)<=e[j]) cout<<str[j]<<" "<<e[j]-(w[j]-que)<<endl,f=1;
      if(f==0) cout<<"Unknown"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1276
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
   ll n,k,q; cin >>n>>k>>q;
  vector<ll> a(q);
  rep(i,q) cin >>a[i];
  map<ll,ll> mp;
  rep2(i,1,n+1) mp[i]=0;
  rep(i,q) mp[a[i]]++;
  rep2(i,1,n+1){
    if(q-mp[i]<k)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
  }
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define debug(args...) fprintf(stderr,args)
using namespace std;
const int maxn = 5e3 , INF = 1e9;
int dp[maxn][maxn];
char s1[maxn],s2[maxn];
vector<char> resp;

int build( int i , int j )
{
	
	if( dp[i][j] != -INF )
		return dp[i][j];
	
	if( i  ==  0 || j  ==  0 )
		return 0;
	
	if( s1[i]  ==  s2[j] )
		dp[i][j] = build( i - 1 , j - 1 ) + 1;
	else
		dp[i][j] = max( build( i - 1 , j ) , build( i , j - 1 ) );
	
	return dp[i][j];
	
}

void buildResp( int i , int j )
{
	
	if( i  ==  0 || j  ==  0 )
		return;
	
	if( s1[i]  ==  s2[j] )
		resp.push_back(s1[i]) , buildResp( i - 1 , j - 1 );
	else if( dp[i-1][j]  >  dp[i][j-1] )
		buildResp( i - 1 , j );
	else
		buildResp( i , j - 1 );
}

int main(){
	scanf(" %s",s1+1);
	scanf(" %s",s2+1);
	
	int tam1 = strlen(s1+1);
	int tam2 = strlen(s2+1);
	
	for( int x = 1 ; x <= tam1 ; x++ )
		for( int y = 1 ; y <= tam2 ; y++ )
			dp[x][y] = -INF;
	
	build( tam1 , tam2 );
	buildResp( tam1 , tam2 );
	
	
	int tam = resp.size();
	for( int x = tam - 1 ; x >= 0 ; x-- )
		printf("%c",resp[x]);
	
}

Measured memory_bytes: 59520
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x = min(a, min(b, min(c, min(d, e))));
    cout << (n + x - 1) / x + 4 << endl; 
    return 0;
}


Measured memory_bytes: 3596