akhauriyash/Code-Regression huggingface dataset:
N, K = [int(ipt) for ipt in input().split(' ')]

sunukekuns = [str(i+1) for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for kun in sunukekun:
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
lli N, digN;
int dfs(lli num, vector<bool> digflg, int count)
{
    if (count == digN)
    {
        if (num <= N && digflg[0] && digflg[1] && digflg[2])
        {
            //     cout << num << endl;
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        vector<bool> flg0{true, digflg[1], digflg[2]};
        vector<bool> flg1{digflg[0], true, digflg[2]};
        vector<bool> flg2{digflg[0], digflg[1], true};

        return dfs(num * 10 + 3, flg0, count + 1) +
               dfs(num * 10 + 5, flg1, count + 1) +
               dfs(num * 10 + 7, flg2, count + 1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    digN = ceil(log10(N + 1));
    /*  vector<lli> dp0(digN + 1, 0), dp1(digN + 1, 0);
    dp0[0] = 1;
    lli tmpN = N;
    int count[10] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3};
    REP(i, digN)
    {
        int modN = tmpN % 10;

        tmpN /= 10;
        dp0[i + 1] = dp0[i] * 3;

        dp1[i + 1] = ((modN == 3 || modN == 5 || modN == 7) ? dp1[i] : 0);

        dp1[i + 1] += dp0[i] * count[modN];
    }
    cout << dp1[digN] << "\n";
    */
    vector<bool> flg{false, false, false};
    int ans = 0;
    REP(i, digN)
    {
        ans += dfs(0, flg, i);
    }
    cout
        << ans << "\n";
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);	
	int rs=0,ls=0;
	while(sc.hasNext()){
		String []s =sc.next().split(",");
		int []e=new int[3];
		for(int i=0;i<3;i++)e[i]=Integer.parseInt(s[i]);
	   if((e[0]*e[0]+e[1]*e[1])==e[2]*e[2])rs++;
	   else if(e[0]==e[1] && e[0]+e[1]>e[2])ls++;
	}
    System.out.println(rs);
    System.out.println(ls);
    }
 }

Measured memory_bytes: 17128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int INF = 1e9 + 5;
void solve()
{
		int n;
		cin >> n;
		vector <int> dp(3, 0);
			for(int days = 0; days < n; days++)
			{
				vector <int> c(3);
						vector <int> new_dp(3, 0);

				for(int i = 0; i<3; i++)
					cin >> c[i];
					
				for(int i= 0; i<3; i++)
				{
					for(int j = 0; j <3; j++)
					{
						if(i!=j)
						{
							new_dp[j] = max(new_dp[j], dp[i]+c[j]);
						}
					}
				}
				dp = new_dp;
					
			}
			
		cout << max(dp[0], max(dp[1], dp[2]));
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}


Measured memory_bytes: 256
import sys


def parse(file):
    n = int(file.readline().strip())
    nums = map(int, file.readline().split())
    return n, nums


def main(n, nums):
    minimum_abs = 1e20
    negatives = 0
    ans = 0

    for num in nums:
        if num < 0:
            a = - num
            negatives += 1
        else:
            a = num

        if a < minimum_abs:
            minimum_abs = a
        ans += a

    if negatives % 2 == 1:
        ans -= (minimum_abs * 2)

    return ans


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;



int main() {
	int N;
	cin >> N;
	map<string, int> m;
	for (int i = 0; i < N; i++) {
		string x;
		cin >> x;
		m[x]++;
	}
	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		string x;
		cin >> x;
		m[x]--;
	}
	int ans = 0;
	for (auto val : m) {
		ans = max(ans, val.second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-S
A,B = [int(i) for i in input().split()]

X = A + B
Y = A - B
Z = A * B

if X >= Y and X >= Z:
    print(X)
elif Y >= X and Y >= Z:
    print(Y)
elif Z >= X and Z >= Y:
    print(Z)


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

int main(){
    string s; cin >>s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(i%2==0 && s[i] == 'p'){
            --ans;
        }
        else if(i%2==1&&s[i]=='g'){
            ++ans;
        }
    }
     cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    VEC(VEC(int)) Card(3, VEC(int)(3));
    FOR(i, 0, 3)
        READVEC(Card[i]);
    cin >> N;
    FOR(i, 0, N) {
        int b;
        cin >> b;
        FOR(i, 0, 3)
            FOR(j, 0, 3)
                if (b == Card[i][j])
                    Card[i][j] = -1;
    }

    bool okay = false;
    int diag1 = 0, diag2 = 0;
    FOR(i, 0, 3) {
        bool good = true;
        FOR(j, 0, 3)
            if (Card[i][j] >= 0)
                good = false;

        if (good) {
            okay = true;
            goto done;
        }

        good = true;
        FOR(j, 0, 3)
            if (Card[j][i] >= 0)
                good = false;
        if (good) {
            okay = true;
            goto done;
        }

        diag1 += Card[i][i] < 0;
        diag2 += Card[i][2 - i] < 0;
    }

    okay |= max(diag1, diag2) == 3;
done:
    if (okay)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
};

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  string op;
  cin >> a >> op >> b;
  if(op == "+") cout << a + b << endl;
  else cout << a - b << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
# self.author = Fuad Ashraful Mehmet ,CSE-UAP

from sys import stdin
input=stdin.readline

def HalfDead():
    b=sorted(a,reverse=True)
    ans=0
    for i in range(1,n):
        ans+=b[i//2]
    return ans
    
n=int(input())
a=list(map(int,input().split()))

print(HalfDead())

Measured memory_bytes: 31368
#include<iostream>
#include<vector>

class SelectionSort{
protected:
    std::vector<int> dataSet;
    int changeCount;
public:
    SelectionSort(std::vector<int> vec);
    int getChangeCount();
    void showVector();
    void startSort();
};

SelectionSort::SelectionSort(std::vector<int> vec){
    this->dataSet = vec;
    this->changeCount = 0;
}

int SelectionSort::getChangeCount(){
    return this->changeCount;
}

void SelectionSort::showVector(){
    for(int i = 0;i < dataSet.size();i++){
        std::cout << (i ? " " : "") << dataSet[i];
    }
    std::cout << std::endl;
}

void SelectionSort::startSort(){
    for(int i = 0;i < dataSet.size();i++){
        int min_index = i;
        for(int j = i;j < dataSet.size();j++){
            if(dataSet[j] < dataSet[min_index]){
                min_index = j;
            }
        }
        if(i != min_index){
            int tmp = dataSet[i];
            dataSet[i] = dataSet[min_index];
            dataSet[min_index] = tmp;
            changeCount++;
        }
    }
}

int main(){
    
    int content;
    std::cin >> content;

    int input;
    int input_count = 0;
    std::vector<int> vec;

    while(std::cin >> input){
        vec.push_back(input);

        input_count++;
        if(input_count >= content){
            break;
        }
    }

    SelectionSort ss = SelectionSort(vec);
    ss.startSort();
    ss.showVector();
    std::cout << ss.getChangeCount() << std::endl;

    return 0;
}

Measured memory_bytes: 3160
import java.util.*;
public class Main {
	int h;
	int w;
	int[][] hw;
	int q = 0;
	int qnum = 0;
	ArrayList<Integer> queue = new ArrayList<Integer>();
	int max = 0;

	Main(){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		h = sc.nextInt();
		w = sc.nextInt();
		hw = new int[h][w];

		// 文字列の入力
		for(int y=0;y<h;y++){
			String s = sc.next();
			String[] S = s.split("");
			for(int x=0;x<w;x++){
				if(S[x].equals("#")){
					hw[y][x]=0;
					queue.add(y);
					queue.add(x);
					qnum+=2;
				} else {
					hw[y][x]=2000;
				}
			}
		}

		//走査
		while(q<qnum){
			change(queue.get(q),queue.get(q+1));
			q+=2;
		}

		// 出力
		System.out.println(max);
	}

	public void change(int y,int x){
		if(y+1<h&&hw[y+1][x]>hw[y][x]+1){
			hw[y+1][x]=hw[y][x]+1;
			queue.add(y+1);
			queue.add(x);
			qnum+=2;
			if(max<hw[y][x]+1)max = hw[y][x]+1;
		}
		if(y>0&&hw[y-1][x]>hw[y][x]+1){
			hw[y-1][x]=hw[y][x]+1;
			queue.add(y-1);
			queue.add(x);
			qnum+=2;
			if(max<hw[y][x]+1)max = hw[y][x]+1;
		}
		if(x>0&&hw[y][x-1]>hw[y][x]+1){
			hw[y][x-1]=hw[y][x]+1;
			queue.add(y);
			queue.add(x-1);
			qnum+=2;
			if(max<hw[y][x]+1)max = hw[y][x]+1;
		}
		if(x+1<w&&hw[y][x+1]>hw[y][x]+1){
			hw[y][x+1]=hw[y][x]+1;
			queue.add(y);
			queue.add(x+1);
			qnum+=2;
			if(max<hw[y][x]+1)max = hw[y][x]+1;
		}
	}

	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 118984
#include<stdio.h>
#define MAX 100
#define INFTY 10000000

int n,M[MAX][MAX];


void kbtit(){
int minv,i,v,u;
int d[MAX],color[MAX];

for(i = 0;i < n;i++){
d[i] = INFTY;
color[i] = 0;
}

d[0] = 0;
color[0] = 1;
while(1){
minv = INFTY;
u = -1;
for(i = 0;i < n;i++){
if(minv > d[i] && color[i] != 2){
u =i;
minv = d[i];
}
}
if(u ==-1)break;
color[u] = 2;
for(v = 0;v < n;v++){
if(color[v] != 2 && M[u][v] != INFTY){
if(d[v] > d[u] + M[u][v]){
d[v] = d[u] + M[u][v];
color[v] = 1;
}
}
}
}
for(i = 0;i < n;i++){
printf("%d %d\n",i,(d[i] == INFTY ? -1 : d[i]));
}
}
int main(){
int i,j;
int k,c,u,v;

scanf("%d",&n);
for(i = 0;i < n;i++){
for(j=0;j<n;j++){
M[i][j] = INFTY;
}
}
for(i = 0;i < n;i++){
scanf("%d%d",&u,&k);
for(j = 0;j < k;j++){
scanf("%d%d",&v,&c);
M[u][v] = c;
}
}
kbtit();

return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int h, w;

int ans;
int maze[50][50];
bool visited[50][50];
char S[50][50];

// first が y, second が x
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];
  int ans = 0;
  REP(si, h) REP(sj, w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, inf));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != inf) return;
      dist[i][j] = x;
      q.push(P(i, j));
    };
    update(si, sj, 0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      REP(dir, 4) {
        int ni = i + dy[dir], nj = j + dx[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j] + 1);
      }
      REP(i, h) REP(j, w) {
        if (dist[i][j] == inf) continue;
        ans = max(ans, dist[i][j]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	int a[4], b[4];
	while(cin >> a[0]){
		int hit = 0, blow = 0;
		for(int i = 1;i < 4;i++)cin >> a[i];
		for(int i = 0;i < 4;i++)cin >> b[i];
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 4;j++){
				if(i==j && a[i] == b[i])hit++;
				if(i!=j && a[i] == b[j])blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0; 
}

Measured memory_bytes: 2984
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000LL
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll x[4005][4005];
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[10005],R[10005];
void make(){
	F[0] = 1;
	for(int i=1;i<10005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<10005;i++) R[i] = modpow(F[i],mod-2);
}
ll ans,hoge;
int c[200005],d[200005];
int main(){
	cin >> n; make();
	rep(i,n){
		int a,b; cin>>a>>b;
		x[2000-a][2000-b]++;
		hoge = (hoge+F[2*a+2*b]*R[2*a]%mod*R[2*b]%mod)%mod;
		c[i]=a;d[i]=b;
	}
	rep(i,4005)rep(j,4005) x[i][j]=( x[i][j] + (i?x[i-1][j]:0) + (j?x[i][j-1]:0) )%mod;
	rep(i,n) ans = (ans+x[2000+c[i]][2000+d[i]])%mod;
	cout << ((ans-hoge)%mod+mod)%mod*((mod+1)/2)%mod << endl;
}

Measured memory_bytes: 127360
H,W=map(int,input().split())
MAP=[list(input()) for i in range(H)]


ANS=0
for i in range(H):
    ANS+=MAP[i].count(".")

from collections import deque

QUE = deque()
QUE.append((0,0))
MAP[0][0]=0

while QUE:
    (x,y)=QUE.pop()

    for i,j in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
        if i<0 or j<0 or i>=H or j>=W:
            continue
        if MAP[i][j]==".":
            MAP[i][j]=MAP[x][y]+1
            QUE.appendleft((i,j))
            
        
if MAP[H-1][W-1]==".":
    print(-1)
else:
    print(ANS-MAP[H-1][W-1]-1)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 64

char A[800][801];
char B[100][101];

int AW,AH,BW,BH;
int state_len;

ll MASK[100][3][256]; //MASK[パターンの行][列/64][文字]
ll state_table[100][3]; //状態配列
ll POW[NUM];
ll AMARI,NUMBER;


void makeMask(){

	for(int row = 0; row < BH; row++){
		for(int col = 0; col < 3; col++){
			for(int i = 0; i < 256; i++)MASK[row][col][i] = 0;
		}
	}

	AMARI = (ll)(BW%NUM);

	if(AMARI == 0){
		state_len = BW/NUM;
	}else{
		state_len = BW/NUM+1;
	}

	NUMBER = (1LL << (AMARI+(NUM-1))%NUM);

  	string L = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?";

	for(int B_row = 0; B_row < BH; B_row++){ //パターンの行
		for(int col = 0; col < L.size(); col++){ //文字等
			for(int i = 0; i < state_len; i++){
				for(int k = 0; k < NUM; k++){
					if(i*NUM+k >= BW)continue;
					if(B[B_row][i*NUM+k] == L[col] || L[col] == '?' || B[B_row][i*NUM+k] == '?'){
						MASK[B_row][i][L[col]] += POW[k]; //対象文字等との一致可能性をbitで表す
					}
				}
			}
		}
	}
}


int main(){

	for(int i = 0; i < NUM; i++)POW[i] = pow(2,i);

	scanf("%d %d %d %d",&AW,&AH,&BW,&BH);

	for(int row = 0; row < AH; row++){
		scanf("%s",A[row]);
	}

	for(int row = 0; row < BH; row++){
		scanf("%s",B[row]);
	}

	makeMask();

	int ans = 0,match_num,tmp;

	for(int A_row = 0; A_row+BH <= AH; A_row++){ //検索始点行

		for(int B_row = 0; B_row < BH; B_row++){
			for(int i= 0; i < state_len; i++){
				state_table[B_row][i] = 0; //状態配列を初期化
			}
		}

		for(int A_col = 0; A_col < AW; A_col++){ //検索始点列

			match_num = 0;

			for(int B_row = 0; B_row < BH; B_row++){ //縦にBH分比較

				for(int i = state_len-1; i >= 0; i--){ //デクリメント
					if(i == 0){
						tmp = 1; //最下位ビットは1
					}else{

						if(state_table[B_row][i-1] & POW[NUM-1]){ //★左に1ビットするので、新しい最下位ビットは、state_table[B_row][i-1]の最上位ビット★
							tmp = 1;
						}else{
							tmp = 0;
						}
					}

					state_table[B_row][i] = ((state_table[B_row][i] << 1)|tmp)&MASK[B_row][i][A[A_row+B_row][A_col]];
				}
				if(state_table[B_row][state_len-1]&NUMBER)match_num++; //最上位ビットが1なら、その行は一致
			}
			if(match_num == BH)ans++; //全部の行が一致した場合
		}
	}

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

	return 0;
}



Measured memory_bytes: 4600
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#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;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int n, k;
    cin >> n >> k;
    vi v(n);
    rep(i, 0, n)cin >> v[i];
    rep(i, k, n){
        if(v[i] > v[i-k])cout << "Yes\n";
        else cout << "No\n";
    }
}
signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4724
#!/usr/bin/env python3

from itertools import combinations

def main():
    n = int(input())
    base = list(range(1, n + 2))
    if n % 2 == 0:
        numbers = [[base[i], base[n-1-i]] for i in range(n // 2)]
    else:
        numbers = [[n]]
        for i in range(n //2):
            numbers.append([base[i], base[n-2-i]])

    result = []
    for first, second in combinations(numbers, 2):
        for fv in first:
            for sv in second:
                result.append((fv, sv))
    print(len(result))
    for r in result:
        print(r[0], r[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4004
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = s[0];
            int W = s[1];
            string[,] glid = new string[H,W];
            for (int i = 0; i < H; i++)
            {
                string tmp = ReadLine();
                for (int j = 0; j < W; j++)
                {
                    glid[i, j] = tmp[j].ToString();
                }
            }

            string ans = "Yes";
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (glid[i,j] == "#")
                    {
                        bool up = false;
                        bool left = false;
                        bool down = false;
                        bool right = false;
                        //上を見れる場合
                        if (i - 1 >= 0)
                        {
                            if (glid[i - 1, j] == "#") up = true;
                        }
                        //左を見れる場合
                        if (j - 1 >= 0)
                        {
                            if (glid[i, j - 1] == "#") left = true;
                        }
                        //下
                        if (i + 1 < H)
                        {
                            if (glid[i + 1, j] == "#") down = true;
                        }
                        //右
                        if (j + 1 < W)
                        {
                            if (glid[i, j + 1] == "#") right = true;
                        }
                        if (!up && !left && !down && !right)
                        {
                            ans = "No";
                        }
                    }
                    
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13368
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int field[100][100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A,B;
    cin>>A>>B;
    rep(i,50)rep(j,100) field[i+50][j]=1;
    
    A--,B--;
    rep(k,B){
        int y=k/50, x=k%50;
        field[y*2][x*2]=1;
    }
    
    rep(k,A){
        int y=k/50, x=k%50;
        field[y*2+51][x*2]=0;
    }
    
    cout2(100,100)
    rep(i,100){
        rep(j,100) cout<<(field[i][j]?'#':'.');
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,a;
    string s,t;
    cin >> n;
    cin >> s;
    if(s.size() == 1){
        cout << "No" << endl;
        return 0;
    }
    a = s.size()/2;
    t = s.substr(0,a);
    if(s == t + t && s.size()%2 == 0){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <deque>
using namespace std;

deque<char> dq;
char s[111111];

int main(void)
{
	char src;
	int q, i, len, cmd, opt, sts = 0;

	scanf("%s %d", s, &q);
	len = strlen(s);

	for (i = 0; i < len; i++)
		dq.push_back(s[i]);

	while (q--)
	{
		scanf("%d", &cmd);

		if (cmd == 1)
		{
			sts ^= 1;
		}
		else
		{
			scanf("%d %c", &opt, &src);
			opt--;

			if (sts ^ opt)
				dq.push_back(src);
			else
				dq.push_front(src);
		}
	}

	if (sts == 0)
		for (i = 0; i < dq.size(); i++)
			printf("%c" ,dq[i]);
	else
		for (i = dq.size() - 1; i >= 0; i--)
			printf("%c" ,dq[i]);
	return 0;
}

Measured memory_bytes: 896
n = int(input())
num = list(range(2,2000))[::-1]
pri = []
while num:
  p = num.pop()
  pri.append(p)
  num = [i for i in num if i%p]
five = [i for i in pri if i%5==1]
ans = five[:n]
print(" ".join(map(str,ans)))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		char[][] map = new char[h][w];
		int[][] hmap = new int[h][w]; // 横方向
		int[][] vmap = new int[h][w]; // 縦方向

		for ( int i = 0; i < h; i++ ) {
			map[i] = in.next().toCharArray();
		}
		in.close();

		int cnt = 0;
		// 横の処理
		for ( int r = 0; r < h; r++ ) {			
			for ( int c = 0; c < w; c++ ) {
				cnt = 0;
				while ( c + cnt < w && map[r][c + cnt] == '.' ) {
					cnt++;
				}
				for ( int i = c; i < c + cnt; i++ ) {
					hmap[r][i] = cnt;
				}
				c += cnt;
			}
		}

		// 縦の処理
		for ( int c = 0; c < w; c++ ) {
			for ( int r = 0; r < h; r++ ) {
				cnt = 0;
				while ( r + cnt < h && map[r + cnt][c] == '.' ) {
					cnt++;
				}
				for ( int i = r; i < r + cnt; i++ ) {
					vmap[i][c] = cnt;
				}
				r += cnt;
			}
		}

		int ans = 0;
		for ( int r = 0; r < h; r++ ) {
			for ( int c = 0; c < w; c++ ) {
				ans = Math.max(ans, hmap[r][c] + vmap[r][c] - 1);
			}
		}
		System.out.println(ans);
	}
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,k,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> s;
       long long int size=s.size();
       rrrep(i,size-1,0){
          // s[i]='\0';
           size--;
           if(s.substr(0,size/2)==s.substr(size/2,size/2)){
               Cout(size-1);
               return 0;
           }
           
           //size--;
           }
      
       //Cout(size);
return 0;
}


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

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> v(n);
  REP(i, n) cin >> v[i];
  int sum = 0;
  REP(i, n) sum += v[i];
  if (sum >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 640
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]

MP = []
for i in range(4**N):
    Alloc = [0,0,0,0,0,0,0,0]
    for j in range(N):
        Alloc[j] = (i//(4**j))%4 
        
    Len = [0,0,0,0]
    Num = [0,0,0,0]
    mp = 0
    for j in range(N): 
        Len[Alloc[j]] += L[j]
        Num[Alloc[j]] += 1
    if Len[1]==0 or Len[2]==0 or Len[3]==0:  
        continue
    else:
        mp += abs(A-Len[1])+abs(B-Len[2])+abs(C-Len[3])+10*(sum(Num[1:])-3)
        MP.append(mp)
print(min(MP))


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k ;
    cin >> n >> k ;
    vint vec(n,0) ;
    REP(i,k){
        int d ;
        cin >> d ;
        REP(j,d){
            int l ;
            cin >> l ;
            vec[l-1]++ ;
        }
    }
    int ans = 0 ;
    REP(i,n){
        if(vec[i]==0){
            ans++ ;
        }
    }
    cout << ans <<endl ;

    

    return 0;
}


Measured memory_bytes: 3648
x,y,z,k=map(int,input().split())
a,b,c=[list(map(int,input().split())) for i in range(3)]
l=sorted([bb+cc for bb in b for cc in c],reverse=1)[:k]
t=sorted([ll+aa for aa in a for ll in l],reverse=1)
for i in range(k):
    print(t[i])

Measured memory_bytes: 144012
#include<stdio.h>

int abs(int val)
{
        if(val<0)val *= -1;
        return val;
}

int main()
{
        int x, a, b;
        int sa, sb;

        scanf("%d %d %d", &x, &a, &b);

        sa = abs(x-a);
        sb = abs(x-b);

        if(sa<sb)printf("A\n");
        else printf("B\n");

        return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=2010;
int n,a[maxn],vis[maxn],tot,in[maxn];
priority_queue<int> q1; // big
queue<int> q2;
vector<int> g[maxn],h[maxn],ans;
int gcd(int x,int y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
void dfs(int u) {
	vis[u]=1;
	for (int i=0,v;i<g[u].size();i++) {
		v=g[u][i];
		if (vis[v]) continue;
		h[u].push_back(v);
		in[v]++; dfs(v);
	}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); int u,v;
	for (int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++)
		if (gcd(a[i],a[j])>1)
			g[i].push_back(j),g[j].push_back(i);
	for (int i=1;i<=n;i++)
		if (!vis[i]) dfs(i);
	for (int i=1;i<=n;i++)
		if (in[i]==0) q1.push(i);
	while (!q1.empty()) {
		u=q1.top(); q1.pop(); ans.push_back(u);
		for (int j=0;j<h[u].size();j++) {
			v=h[u][j]; in[v]--;
			if (in[v]==0) q1.push(v);
		}
	}
	for (int i=1;i<=n;i++) printf("%d ",a[ans[i-1]]); printf("\n");
	return 0;
}

Measured memory_bytes: 17792
a=gets.to_i
array=[]
a.times{
  array << gets.to_i
  }
#p array
array=array.sort
b = array.inject{|sum,y| sum+=y}
if b%10 !=0
  puts b
else
	c=array.select{|n| n%10 !=0}
	if c.size==0
  		puts 0
	else
  		puts b - c[0]
	end
end


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

int main() {
  int N;
  cin >> N;
  int Max = 0;
  int count = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (A.at(i) > Max || A.at(i) == Max) {
      Max = A.at(i);
      count++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	if(n==1 or n==2 or n==3 or n==5 or n==6 or n== 9 or n==10 or n==13 or n==17){
		cout << "No" << endl;
	} else cout << "Yes" << endl;
	rtn 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)

int main(){
	int a,b,c,d;
	int e,f,g,h;
	cin >> a >> b >> c >> d;
	cin >> e >> f >> g >> h;
	cout << max((a+b+c+d),(e+f+g+h)) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	t=1;
	while(t--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<6-a-b;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	vector<string> C(2);
	for (int i = 0; i < 2; i++) cin >> C[i];
	if (C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3620
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let X: usize = read();
    let Y: usize = read();
    let Z: usize = read();
    let K: usize = read();
    let mut A: Vec<i64> = read_vec();
    let mut B: Vec<i64> = read_vec();
    let mut C: Vec<i64> = read_vec();
    A.sort();
    A.reverse();
    B.sort();
    B.reverse();
    C.sort();
    C.reverse();
    let mut h = BinaryHeap::new();
    let mut s = HashSet::new();
    s.insert((0, 0, 0));
    h.push((A[0]+B[0]+C[0], 0, 0, 0));
    for _ in 0..K {
        let (e, i, j, k) = h.pop().unwrap();
        println!("{}", e);
        if i+1 < X && !s.contains(&(i+1, j, k)) {
            s.insert((i+1, j, k));
            h.push((A[i+1]+B[j]+C[k], i+1, j, k));
        }
        if j+1 < Y && !s.contains(&(i, j+1, k)) {
            s.insert((i, j+1, k));
            h.push((A[i]+B[j+1]+C[k], i, j+1, k));
        }
        if k+1 < Z && !s.contains(&(i, j, k+1)) {
            s.insert((i, j, k+1));
            h.push((A[i]+B[j]+C[k+1], i, j, k+1));
        }
    }
}


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

int main(){
  long a,b,q;
  cin >> a >> b >> q;
  vector<long> s(a),t(b),x(q),result;
  for(int i = 0;i < a;i++){
    cin >> s.at(i);
  }
  for(int i = 0;i < b;i++){
    cin >> t.at(i);
  }
  for(int i = 0;i < q;i++){
    cin >> x.at(i);
  }
  for(int i = 0;i < q;i++){
    vector<long> scand,tcand;
    auto its = std::lower_bound(s.begin(),s.end(),x.at(i));
    auto itt = std::lower_bound(t.begin(),t.end(),x.at(i));
    if(its != x.end()){
      scand.push_back(*its);
    }
    //cout << 333 << endl;
    if((its - s.begin()) != 0){
      scand.push_back(*(its-1));
    }
    //cout << 666 << endl;
    if(itt != x.end()){
      tcand.push_back(*itt);
    }
    //cout << 999 << endl;
    if((itt - t.begin()) != 0){
      tcand.push_back(*(itt-1));
    }
    //cout << 111 << endl;
    long c = 100000000000000007;
    for(int j = 0;j < scand.size();j++){
      for(int k = 0;k < tcand.size();k++){
        c = min(c,abs(scand.at(j) - x.at(i)) + abs(scand.at(j) - tcand.at(k)));
        c = min(c,abs(tcand.at(k) - x.at(i)) + abs(scand.at(j) - tcand.at(k)));
      }
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define MOD 998244353
#define inv2 499122177

using namespace std;

typedef long long ll;

const int Maxn=1000000;

int prime[200000],mu[Maxn+5];
bool check[Maxn+5];

ll sum[Maxn+5];

void pre() {
  mu[1]=1;
  int tot=0;
  for(int i=2;i<=Maxn;i++) {
  	if (!check[i]) {
  		prime[++tot]=i;
  		mu[i]=MOD-1;
	  }
	for(int j=1;j<=tot&&i*prime[j]<=Maxn;j++) {
		check[i*prime[j]]=1;
		if (i%prime[j]==0) break;
		mu[i*prime[j]]=(MOD-mu[i])%MOD;
	}
  }
  for(int i=1;i<=Maxn;i++)
    for(int j=1;i*j<=Maxn;j++) sum[i*j]=(sum[i*j]+(ll)i*j%MOD*j%MOD*mu[j])%MOD;
}

int cnt[Maxn+5];

int main() {
  pre();
  int n;
  scanf("%d",&n);
  int s=0;
  for(int i=1;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	cnt[x]++;
  	s=(s+x)%MOD;
  }
  ll ans=0;
  for(int i=1;i<=Maxn;i++) {
  	ll s=0;
  	for(int j=1;i*j<=Maxn;j++) s=(s+(ll)cnt[i*j]*j)%MOD;
  	ans=(ans+sum[i]*s%MOD*s)%MOD;
  }
  printf("%lld\n",(ans-s+MOD)*inv2%MOD);
  return 0;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl;
#define _GLIBCXX_DEBUG

int main(){
  
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;

}


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

int H, W, a[1009][1009]; vector<tuple<int, int, int, int>>tup;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> a[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (a[i][j] % 2 == 0 || i + j == H + W) continue;
			if (i != H) {
				tup.push_back(make_tuple(i, j, i + 1, j));
				a[i][j]--; a[i + 1][j]++;
			}
			else {
				tup.push_back(make_tuple(i, j, i, j + 1));
				a[i][j]--; a[i][j + 1]++;
			}
		}
	}
	cout << tup.size() << endl;
	for (int i = 0; i < tup.size(); i++) {
		cout << get<0>(tup[i]) << " " << get<1>(tup[i]) << " " << get<2>(tup[i]) << " " << get<3>(tup[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll n, k;
  cin >> n >> k;
  cout << min({n-(n/k)*k, abs(n-(n/k+1)*k), n}) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] Str = new char[S.length()];

		for(int i=0; i<S.length(); i++) {
			Str[i] = S.charAt(i);
		}Arrays.sort(Str);

		int count = 0;
		for(int j=1; j<S.length(); j++) {
			if(Str[j] == Str[j-1]) {
				count++;
			}
		}

		if(count == 0) {
			System.out.println("yes");
		}else {
			System.out.println("no");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint h, w;
    cin >> h >> w;
    vector<string> grid(h);
    REP(i,h){
        cin >> grid[i];
    }
    vector<vector<llint>> dp(h, vector<llint>(w, 0));
    dp[0][0] = 1;
    REP(i,h){
        REP(j,w){
        
            if(i<h-1){
                dp[i + 1][j] += dp[i][j]*(grid[i + 1][j]!='#'?1:0);
                dp[i + 1][j]%=mod;
            
            }
            
            if(j<w-1){
                dp[i][j+1] += dp[i][j]*(grid[i ][j+1]!='#'?1:0);
                dp[i][j+1]%=mod;
            
            }
            
        }
    }
    cout << dp[h - 1][w - 1] << endl;

    return 0;
}


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

using namespace std;

int main() {
  int n, m, x, res = 1145141919;

  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));

  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  }

  for (int bit = 0; bit < (1 << n); ++bit) {
    int cost = 0;
    vector<int> deg(m, 0);
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        cost += c[i];
        for (int j = 0; j < m; ++j) deg[j] += a[i][j];
      }
    }
    if (all_of(deg.begin(), deg.end(), [&](int d) { return d >= x; })) {
      res = min(res, cost);
    }
  }
  cout << (res == 1145141919 ? -1 : res) << endl;
  return 0;
}


Measured memory_bytes: 3592
N,M,L=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
INF=10**9
DP=[[INF]*411 for i in range(411)]
DP[0][0]=0
for i in range(N):
  for j in range(400,-1,-1):
    for k in range(401):
      DP[j+X[i][0]][k+X[i][1]]=min(DP[j+X[i][0]][k+X[i][1]],DP[j][k]+X[i][2])
P=INF
for i in range(1,401):
  if i*max(M,L)>400:
    break
  P=min(P,DP[i*M][i*L])
if P==INF:
  print(-1)
else:
  print(P)

Measured memory_bytes: 74964
from math import gcd


def main():
    n, x = map(int, input().split())
    xs = list(map(int, input().split()))
    xs.append(x)
    xs.sort()
    diff = []
    for i in range(1, n+1):
        diff.append(xs[i] - xs[i-1])
    ans = diff[0]
    for i in range(1, n):
        ans = gcd(ans, diff[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20372
#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long modpow(long long a, long long n)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    long long n;
    cin >> n;
    vector< long long > d(n);
    vector< long long > num(n, 0LL);
    for (long long i = 0; i < n; i++) {
        cin >> d[i];
        if (i == 0 && d[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
        if (d[i] == 0 && i != 0) {
            cout << 0 << endl;
            return 0;
        }
        num[d[i]]++;
    }
    long long ans = 1LL;
    for (long long i = 0; i < n - 1; i++) {
        ans = (ans * modpow(num[i], num[i + 1])) % mod;
    }
    // for (long long i = 0; i < n; i++) {
    //     cout << num[i] << " ";
    // }
    // cout << endl;
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 1792