akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//x???????????????
		int x = sc.nextInt();
		//x???3???
		int X = x * x * x;
		//??¨???
		System.out.println(X);
	}
}

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

int main() {
  char a,b;
  cin >> a>>b;

  if(a=='H'){
    if(b=='H'){
      cout<<"H"<<endl;
    }
    else{
      cout<<"D"<<endl;
    }
  }
  else{
    if(b=='D'){
      cout<<"H"<<endl;
    }
    else{
      cout<<"D"<<endl;
    }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

bool compare_second(const pair<int,int>& p1, const pair<int,int>& p2){ return p1.second < p2.second; }

int main()
{
    int n;
    cin >> n;
    map<int,int> counts[2];
    for(int i = 0; i < n; ++i)
    {
        int v; cin >> v;
        counts[i%2][v]++;
    }
    
    auto e_max = max_element(begin(counts[0]), end(counts[0]), compare_second);
    auto o_max = max_element(begin(counts[1]), end(counts[1]), compare_second);

    auto answer = n - e_max->second - o_max->second;
    if(answer == 0 && e_max->first == o_max->first)
    {
        cout << (n/2) << endl;
    }
    else if(e_max->first == o_max->first)
    {
        int a1,a2;
        const int e_max_v = e_max->second;
        const int o_max_v = o_max->second;
        e_max->second = 0;
        auto e_max_2 = max_element(begin(counts[0]), end(counts[0]), compare_second);
        a1 = n - e_max_2->second - o_max_v;
        
        o_max->second = 0;
        auto o_max_2 = max_element(begin(counts[1]), end(counts[1]), compare_second);
        a2 = n - e_max_v - o_max_2->second;
        
        cout << min(a1,a2) << endl;
    }
    else
    {
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, ans = 0;
    cin>>n;
    ans += (n/500)*1000;
    n%=500;
    ans += (n/5)*5;
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
using namespace std;
int P[205],K[205],ans;
bool flag[205];
int n,x,y;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        P[x]=y;K[x]=0;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        P[x]=y;K[x]=1;
    }
    for(int i=0;i<=2*n-1;i++)
    {
        int Pnum=-1,nq=-1;
		if(K[i])
		{
			for(int j=i-1;j>=0;j--)
			{
				if(!flag[j]&&K[j]!=K[i]&&P[j]<P[i])
				{
					if(Pnum<P[j])
					{Pnum=P[j];nq=j;}
				}
			}
			//printf("%d %d\n",i,Pnum);//
			if(Pnum==-1)continue;
			flag[nq]=1;flag[i]=1;ans++;
		}
    }
    printf("%d",ans);
}

Measured memory_bytes: 256
import numpy as np
ans = ["<", "=", ">"]
m = np.full((6, 6), 1, np.int64)
m[np.tri(6) == 0] = 0
m[np.tri(6).T == 0] = 2
X, Y = map(lambda x: ord(x) - 65, input().split())
print(ans[m[X][Y]])


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

int main(){
    int r,c,s[101][101]={0};
    cin >> r >> c;
    for(int i=0;r>i;i++){
        for(int j=0;c>j;j++){
            cin >> s[i][j];
            s[r][j]+=s[i][j];
            s[i][c]+=s[i][j];
        }
        s[r][c]+=s[i][c];
    }
    for(int i=0;r+1>i;i++){
        for(int j=0;c+1>j;j++){
            cout << s[i][j];
            if(j!=c) cout << " ";
        }
        cout << endl;
    }
}


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

int main() {
  int input01;
  int input02;
  int input03;  

  cin >> input01 >> input02 >> input03;
  if(input01 < input02 && input02 < input03) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        a[i] *= n;
    }
    int index = 0;
    int tmp = abs(a[0] - sum);
    for(int i = 1; i < n; i++){
        if(abs(sum - a[i]) < tmp){
            tmp = abs(sum - a[i]);
            index = i;
        }
    }
    cout << index << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


class Main {
	static int x ;
	static int y ;
	static int road[][];
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] ss = in.readLine().split(" ");
			x = Integer.parseInt(ss[0]);
			y = Integer.parseInt(ss[1]);
			if(x == 0&&y ==0){
				break;
			}
			road = new int[x][y];
			for(int i = 0;i<x ;i++){
				Arrays.fill(road[i],-1);
			}
			int n = Integer.parseInt(in.readLine());
			for(int i= 0; i < n;i++){
				String[] s = in.readLine().split(" ");
				int a = Integer.parseInt(s[0]);
				int b = Integer.parseInt(s[1]);
				road[a-1][b-1] = 0;
			}
			road[0][0] = 1;
			for(int i = 0;i<road.length;i++){
				for(int j = 0;j< road[i].length;j++){
					if(road[i][j] != 0){
						if(i != 0){
							if(road[i][j] == -1) road[i][j]++;
							road[i][j] = road[i][j]+road[i-1][j];
						}
						if(j != 0){
							if(road[i][j] == -1) road[i][j]++;
							road[i][j] = road[i][j]+road[i][j-1];
						}
					}
				}
			}
			System.out.println(road[x-1][y-1]);
		}	

	}
}

Measured memory_bytes: 16984
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

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

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int T, n, m;
int a[N], b[N];
char s[N];

int main()
{
	//File("");
	int h1 = gi(), m1 = gi(), h2 = gi(), m2 = gi();
	int now = h2 * 60 + m2 - h1 * 60 - m1;
	int k = gi();
	cout << now - k << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1000000007;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 2e5 + 5;

ll n, m, k;
ll a[N], b[N];

void Solve(){
    cin >> n;
    int cnt = 1;
    ll x = 0;
    for(int i = 1; i <= n; i++){
        cin >> k;
        if(k == cnt) cnt++;
        if(k == 1) x = 1;
    }
    if(x == 0) {
        cout << -1;
        return;
    }
    cout << n - cnt + 1;
}

int main(){
    Speed;
    int query = 1; //cin >> query;
    while(query--){
        Solve();
    }
}












Measured memory_bytes: 256
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	a := scanInt(sc)
	b := scanInt(sc)
	t := scanInt(sc)

	var i int
	for ; (i+1)*a <= t; i++ {
	}

	fmt.Printf("%d\n", i*b)
	return

}

func main() {
	check()
}


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

int accepted(vector<int> &h, int k) {
    int count = 0;
    for (auto x : h) {
        if (x >= k) {
            count++;
        }
    }

    return count;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &h.at(i));
    }

    cout << accepted(h, k) << endl;
}

Measured memory_bytes: 640
Option Explicit On

Module Module1

    Sub Main()

        Dim S As String = Console.ReadLine()
        Dim T As String = Console.ReadLine()

        If Len(S) + 1 = Len(T) Then
            If S = Left(T, Len(T) - 1) Then
                Console.WriteLine("Yes")
                End
            End If
        End If
        Console.WriteLine("No")

    End Sub
End Module


Measured memory_bytes: 27396
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

// -1 4 3 2 -5 4
// -1 4 -4 2 -5 5

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

	ll ans = INF_LL;

	//+-+-+...
	{
		ll tmp = 0;
		ll sum = a[0];
		if (sum <= 0) {
			tmp += abs(sum) + 1;
			sum = 1;
		}
		for (int i = 1; i < N; i++) {
			sum += a[i];
			if (i % 2 == 0) {
				if (sum <= 0) {
					tmp += abs(sum) + 1;
					sum = 1;
				}
			}
			else {
				if (sum >= 0) {
					tmp += abs(sum) + 1;
					sum = -1;
				}
			}
		}
		ans = min(ans, tmp);
	}

	//-+-+-+-...
	{
		ll tmp = 0;
		ll sum = a[0];
		if (sum >= 0) {
			tmp += abs(sum) + 1;
			sum = -1;
		}
		for (int i = 1; i < N; i++) {
			sum += a[i];
			if (i % 2 == 0) {
				if (sum >= 0) {
					tmp += abs(sum) + 1;
					sum = -1;
				}
			}
			else {
				if (sum <= 0) {
					tmp += abs(sum) + 1;
					sum = 1;
				}
			}
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int n,c[17],p[300]={0},i,j;
  for(i=1;i<18;i++)c[i-1]=i*i;
  p[0]=1;
  for(i=0;i<17;i++)
    for(j=0;j<300;j++)
      if(j-c[i]>=0)p[j]+=p[j-c[i]];
  while(cin>>n,n)cout<<p[n]<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
    }

    rep(i,n) {
        int r = n-i-1;
        int l = i;
        int x = abs(l-r);
        mp[x]--;
    }

    bool ok = true;
    for(auto x : mp){
        if(x.second!=0) ok = false;
    }
    if(!ok) {cout << 0 << endl; return 0;}
    else{
        int ans = 1;
        rep(i, n/2) {ans *= 2, ans%=mod;}
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7348
/**
 * Title: C - All Green
 * Url: https://atcoder.jp/contests/abc104/tasks/abc104_c
 * 
 * <解法のポイント>
 * 全探索は無理。
 * じゃあどうするか？
 * そもそも全部見る必要がない
 * シミュレート後の問題の状態は以下の2つしかない
 * - 全問解いてボーナス点を貰ったか
 * - 全問は解かなかった（0問以上N-1問以下）
 * 全問解かなかった問題リストからある点数以上を解答する問題数を最小にするには、
 * 配点の高い問題から解けばいい。
 * ということで、
 * 全bit探索で、まず全問解いた問題のシミュレートをした後、
 * 余った得点を配点の高い問題順に処理していく。
 * これだと O(D*2^D) で計算可能.  
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long
#define INF 1000000000

int main() {
    int D, G; cin >> D >> G;
    vector<int> p(D+1), c(D+1);
    for(int i=1; i<D+1; i++) cin >> p[i] >> c[i];
    int ans = INF;
    for(int bit=0; bit<(1<<D); bit++) {
        int t_ans = 0;
        int g = G;
        // 全問解いたパターンを先に処理
        for(int i=0; i<D; i++) {
            if(bit&(1<<i)) {
                g = g - p[D-i]*100*(D-i) - c[D-i];
                t_ans += p[D-i]; 
            }
        }
        // 0問以上N-1問以下解いた場合
        for(int i=0; i<D; i++) {
            if(g<=0) break;
            if((bit&(1<<i))==0) {
                int q;
                if(g%(100*(D-i))==0) {
                    q = g/(100*(D-i));
                } else {
                    q = g/(100*(D-i))+1;
                }
                if(q > p[D-i]-1) {
                    g = g - (p[D-i]-1)*100*(D-i);
                    t_ans += p[D-i]-1;
                } else {
                    g = 0;
                    t_ans += q;
                }
            }
        }
        if(g<=0) ans = min(ans, t_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  vector<int> x(5);
  rep(i, 5) {
    int num;
    cin >> num;
    x.at(i) = num;
  }
  rep(i, 5) {
    if (x.at(i) == 0) {
      cout << i+1 << endl;
    }
  }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> vc(n);
    for(int i=0; i<n; i++){
        cin >> vc.at(i);
    }
    int cnt = 0;
    int k=1, tf=0;
    for(int i=0; i<n; i++){
        if(vc.at(i) == k){
           k++;
           tf = 1;
           continue;
        }
        cnt++;
    }
    if(tf == 0){
        cout << -1 << endl;
        return 0;
    }

    cout << cnt <<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <iostream>

int n, k;

struct point {
	int x, y;
	void read() {
		scanf("%d%d", &x, &y);
	}
	bool operator < (const point &that) const {
		return x < that.x || (x == that.x && y < that.y);
	}
} p[55];

int x[55], y[55];

int posx(int X) { return std::lower_bound(x+1, x+n+1, X)-x; }

int posy(int Y) { return std::lower_bound(y+1, y+n+1, Y)-y; }


/*
struct node {
	int cnt;
	node *ls, *rs;
} t[500010], *root[55], *et = t;

void build(node *&rt, int l, int r) {
	rt = ++et;
	if(l == r) return;
	int mid = l+r>>1;
	build(rt->ls, l, mid);
	build(rt->rs, mid+1, r);
}

void insert(node *la, node *&rt, int l, int r, int x) {
	rt = ++et; *rt = *la;
	if(l == r) {
		rt->cnt++;
		return;
	}
	int mid = l+r>>1;
	if(x <= mid) insert(la->ls, rt->ls, l, mid, x);
	else insert(la->rs, rt->rs, mid+1, r, x);
}

int query(node *rt, int l, int r, int L, int R) {
	if(r < L || R < l) return 0;
	if(L <= l && r <= R) return rt->cnt;
	int mid = l+r>>1;
	return query(rt->ls, l, mid, L, R)+query(rt->rs, mid+1, r, L, R);
}
*/

int map[55][55];

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++)
		p[i].read(), x[i] = p[i].x, y[i] = p[i].y;
	std::sort(x+1, x+n+1), std::sort(y+1, y+n+1);
	std::sort(p+1, p+n+1);
	//build(root[0], 1, n);
	//for(int i = 1; i <= n; i++)
		//insert(root[i-1], root[i], 1, n, posy(p[i].y));
	for(int i = 1; i <= n; i++)
		map[posx(p[i].x)][posy(p[i].y)]++;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			map[i][j] += map[i-1][j]+map[i][j-1]-map[i-1][j-1];
	unsigned long long ans = -1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) {
			for(int u = i; u <= n; u++) {
				for(int v = j; v <= n; v++) {
					int res = map[u][v]-map[u][j-1]-map[i-1][v]+map[i-1][j-1];
					//printf("%d, %d, %d, %d = %d\n", x[i], y[j], x[u], y[v], res);
					if(res >= k)
						if(ans > 1ll*(x[u]-x[i])*(y[v]-y[j]))
							ans = 1ll*(x[u]-x[i])*(y[v]-y[j]);
				}
			}
		}
	std::cout << ans << std::endl;
	return 0;
}


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

int main()
{
    int n,q;
    cin >> n >> q;
    vector<vector<int>> tree(n);
    vector<int> ans(n);
    for(int i = 0; i < n-1; ++i)
    {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    for(int i = 0; i < q; ++i)
    {
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }

    queue<int> que;
    vector<bool> checker(n);
    que.push(0);
    checker[0] = true;
    while(!que.empty())
    {
        int t = que.front();
        que.pop();
        for(int child : tree[t])
        {
            if(checker[child])
            {
                continue;
            }
            ans[child] += ans[t];
            que.push(child);
            checker[child] = true;
        }
    }

    for(int i = 0; i < n; ++i)
    {
        if(i != 0)
        {
            cout << " ";
        }
        cout << ans[i];
    }
    cout << endl;
}

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

int main()
{
  int N;
  cin >> N;
  set<string> S;
  for (int i = 0; i < N; i++)
  {
    string tmp;
    cin >> tmp;
    S.insert(tmp);
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 19180
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

Ans_raw = []
count = 0
for i in range(len(A)):
    num = i+1
    for _ in range(A[i]):
        Ans_raw.append(str(num))

for i in range(h):
    Now = Ans_raw[i*w:(i+1)*w]
    if i % 2 == 1:
        Now = Now[::-1]
    print(' '.join(Now))

Measured memory_bytes: 3700
import Control.Arrow
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.B.lines=<<B.getContents
solve[s,ks]=V.sum(V.map((`div`2).snd)vs)*k+f((V.head&&&V.last)vs)where
  k=fst.fromJust.B.readInt$ks
  vs=V.fromList$map(B.head&&&B.length).B.group$s
  f((c1,k1),(c2,k2))
    |c1/=c2 || even k1 || even k2=0
    |V.length vs==1=k`div`2
    |otherwise=k-1

Measured memory_bytes: 4308
#include <iostream>

using namespace std;

int main() {
	long long x;
	long long ans;
	int q;

	cin >> x;

	q = x % 11;
	ans = x / 11;
	ans *= 2;

	if (q == 0)	{}
	else if (q < 7)	ans++;
	else	ans += 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
ll kaijo[200010] = { 0 };

void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 100010;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n] % N;
	ll c = kaijo[n - k] % N;
	ll d = kaijo[k] % N;
	ll cd = (c*d) % N;
	return ((b%N)*((inv(c) % N)*(inv(d) % N) % N)) % N;
}
int main(void) {
	ll n, input;
	cin >> n;
	ll first = 1, last = n + 1;
	map<ll, ll>mp;
	init();
	for (ll i = 1;i <= n + 1;i++) {
		cin >> input;
		if (mp.count(input)) {
			first = mp[input];
			last = i;
			break;
		}
		else {
			mp[input] = i;
		}
	}
	for (ll i = 1;i <= n + 1;i++) {
		cout << (Comb(n + 1, i) - Comb(first + n - last, i - 1) + N) % N << endl;
	}
	return 0;
}

Measured memory_bytes: 8192
using System;


namespace SLDS1_1_MaximumProfit
{
    class MaximumProfit2
    {
        public static void Main()
        {
            Scanner cin = new Scanner();

            // Input
            int n = cin.myInputInt();
            int[] r = new int[n];
            for (int i = 0; i < n; i++) r[i] = cin.myInputInt();

            // Solve
            int max = -2000000000;
            int min = r[0];
            for (int i = 1; i < n; i++)
            {
                max = Math.Max(max, r[i] - min);
                min = Math.Min(min, r[i]);
            }

            // Output
            Console.WriteLine("{0}", max);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string myInput()
        {
            if (i < s.Length)
                return s[i++];
            string st = Console.ReadLine();
            while (st == "")
                st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }

        public int myInputInt()
        {
            return int.Parse(myInput());
        }

        public long myInputLong()
        {
            return long.Parse(myInput());
        }

        public double myInputDouble()
        {
            return double.Parse(myInput());
        }
    }
}

Measured memory_bytes: 21724
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  vector<vector<int>> field(3,vector<int>(3));
  for (int i = 0; i < 3; ++i)
  {
    for (int j = 0; j < 3; ++j)
    {
      cin>>field[i][j];
    }
  }
  int n;
  cin>>n;
  for (int k = 0; k < n; ++k)
  {
    int tmp;
    cin>>tmp;
    for (int i = 0; i < 3; ++i)
    {
      for (int j = 0; j < 3; ++j)
      {
        if(field[i][j]==tmp) field[i][j]=-1;
      }
    }
  }
    for (int i = 0; i < 3; ++i)
    {
      bool flag=true;
      for (int j = 0; j < 3; ++j)
      {
        if(field[i][j]!=-1) flag=false;
      }
      if(flag)
      {
        cout<<"Yes"<<endl;
        return 0;
      }
      flag=true;
      for (int j = 0; j < 3; ++j)
      {
        if(field[j][i]!=-1) flag=false;
      }
      if(flag)
      {
        cout<<"Yes";
        return 0;
      }
      flag=true;
      for (int j = 0; j < 3; ++j)
      {
        if(field[j][j]!=-1) flag=false;
      }
      if(flag)
      {
        cout<<"Yes";
        return 0;
      }
      flag=true;
      if(field[0][2]!=-1) flag=false;
      if(field[1][1]!=-1) flag=false;
      if(field[2][0]!=-1) flag=false;
      if(flag)
      {
        cout<<"Yes";
        return 0;
      }
    }
    cout<<"No"<<endl;
}

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

using namespace std;

int main(){
  vector<char> c1;
  vector<char> c2;
  vector<char> c3;
  for(int i = 0;i < 3;i++){
    char a;
    cin >> a;
    c1.push_back(a);
  }
  for(int i = 0;i < 3;i++){
    char b;
    cin >> b;
    c2.push_back(b);
  }
  for(int i = 0;i < 3;i++){
    char c;
    cin >> c;
    c3.push_back(c);
  }
  cout << c1[0] << c2[1] << c3[2] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
int N; ll A[100001], B[100001];
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N; ++i) scanf("%ld", &A[i]);
  for(int i = 1; i <= N; ++i) scanf("%ld", &B[i]);
  ll sumlack = 0LL; vector<ll> surplus; int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(A[i] < B[i]) sumlack += B[i]-A[i], ++ans;
    else surplus.push_back(A[i]-B[i]);
  }
  sort(surplus.begin(), surplus.end(), greater<>());
  for(int i = 0; sumlack > 0 && i < surplus.size(); ++i) {
    sumlack -= surplus[i], ++ans;
  }
  if(sumlack > 0) ans = -1;
  printf("%d\n", ans);
}

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

using namespace std;

int main()
{
	int n, r = 0;
	vector<int> a;
	cin >> n;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		a.push_back(x-1);
	}
	for (int i = 0; i < n; ++i) {
		if (i < a[i] && a[a[i]] == i) ++r;
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 892
# coding: utf-8
from math import ceil
N = int(input())
A = list(map(int, input().split()))
A.sort()
top = A[-1]
half = ceil(top / 2)
ans = float("inf")
for i in range(N):
    if abs(half - ans) > abs(half - A[i]):
        ans = A[i]
    # print(A[i], abs(half - A[i]))
print(top, ans)

Measured memory_bytes: 14180
#include <cstdio>

bool used[10];
int num[10][10000];
int sum, ans, n, s, Min, Max;

inline void A(int t, int x){
	if(x == 11) return;
	int	tmp = -x;
	for(int i = 9; i >= 0; i--){
		tmp += x;
		if(used[i]) continue;
		used[i] = true;
		sum += tmp;
		num[t][sum]++;
		A(t+1, x+1);
		sum -= tmp;
		used[i] = false;
	}
}

int main(){
	A(0,1);
	while(scanf("%hd%hd", &n, &s) != EOF){
		if(s >= 10000 || s < 0){
			printf("0\n");
		} else{
			printf("%d\n", num[n-1][s]);
		}
	}
}

Measured memory_bytes: 1080
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n;
    cin >> n;
    vll a(n);
    ll zero = 0;
    rep(i, 0, n)
    {
        cin >> a[i];
        if (!a[i])
            zero++;
    }
    if (zero == n)
        return print(1), 0;
    if (n % 3 != 0)
        return print(0), 0;
    sort_v(a);
    if (a[0] == a[n / 3 - 1] && a[n / 3] == a[n - 1] && a[0] == 0)
        return print(1), 0;
    if (a[0] == a[n / 3 - 1] && a[n / 3] == a[2 * n / 3 - 1] && a[2 * n / 3] == a[n - 1] && ((a[0] ^ a[n / 3]) ^ a[2 * n / 3]) == 0)
        return print(1), 0;
    print(0);
}

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

int n,bag;
const int N = 100005;
ll dp[105][100005];
int W[N], C[N];
int main() {
	cin >> n>>bag;
	for (int i = 1; i <= n; i++)cin >> W[i] >> C[i];
	for (int i = 0; i <= bag; i++)dp[0][i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= bag; j++) {
			if (j < W[i])dp[i][j] = dp[i - 1][j];
			else dp[i][j] = max(C[i] + dp[i - 1][j - W[i]], dp[i - 1][j]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= bag; i++)ans = max(ans, dp[n][i]);
	cout << ans;
	
}

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

int main() {
	int H, W;

	cin >> H >> W;

	while(!(H == 0 && W == 0)) {
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if ((h + 1) % 2 == 1 && (w + 1) % 2 == 1 || (h + 1) % 2 == 0 && (w + 1) % 2 == 0){//奇数行奇数列または偶数業偶数列
					cout << '#';
				}
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

ll exp(ll a, ll b) {
  ll ans = 1;
  while(b) {
    if(b & 1) ans *= a;
    a *= a, b >>= 1, ans %= mod, a %= mod;
  }
  return ans;
}

int main(void) {
  ll i, j, k, n, ans = 0, a;
  scanf("%lld", &n);
  ll rev[n + 10], fact = 1;
  rev[0] = 0;
  for(i = 1; i <= n; ++i) {
    rev[i] = exp(i, mod - 2), rev[i] += rev[i - 1], rev[i] %= mod;
    fact *= i, fact %= mod;
  }
  for(i = 1; i <= n; ++i) {
    scanf("%lld", &a);
    ans += (a * (rev[i] + rev[n - i + 1] - 1)) % mod * fact;
    ans %= mod;
  }
  printf("%lld", ans);
  return  0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, K;
ll V[2005][2005];

void comb(){
    rep(i, N+1){
        V[i][0]=1;
        V[i][i]=1;
        rep(j,i){
            ll a=(V[i-1][j-1]+V[i-1][j]);
            V[i][j]=a%MOD;
        }
    }
}

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

    cin >> N >> K;

    comb();
    rep(i,K) cout << (V[N-K+1][i+1]*V[K-1][i])%MOD << endl;
    return 0;
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  string s;
  cin >> s;
  ll tmp1 = 0, tmp2 = 0;
  rep(i, 3) {
    if (s.at(i) == 'A') {
      tmp1++;
    } else {
      tmp2++;
    }
  }
  if (tmp1>0 && tmp2>0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	if k > a && k-a >= b {
		fmt.Println(0, 0)
		return
	}
	if k >= a {
		fmt.Println(0, b-(k-a))
		return
	}
	fmt.Println(a-k, b)
}


Measured memory_bytes: 512
import numpy as np
import sys
from numba import njit, i8

input = sys.stdin.readline

R, C, K = map(int, input().split())
table = [[0] * (C + 1) for _ in range(R + 1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    table[r][c] = v
table = np.array(table, dtype=np.int64)


@njit((i8, i8, i8[:, :]), cache=True)
def solve(R, C, table):
    dp0 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp1 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp2 = np.zeros((R + 1, C + 1), dtype=np.int64)
    dp3 = np.zeros((R + 1, C + 1), dtype=np.int64)

    for r in range(1, R + 1):
        for c in range(1, C + 1):
            m = max(dp0[r - 1, c], dp1[r - 1, c], dp2[r - 1, c], dp3[r - 1, c])
            dp0[r, c] = max(m, dp0[r, c - 1])
            dp1[r, c] = max(m, dp1[r, c - 1])
            dp2[r, c] = max(m, dp2[r, c - 1])
            dp3[r, c] = max(m, dp3[r, c - 1])
            if table[r, c]:
                dp1[r, c] = max(dp1[r, c], m + table[r, c], dp0[r, c - 1] + table[r, c])
                dp2[r, c] = max(dp2[r, c], m + table[r, c], dp1[r, c - 1] + table[r, c])
                dp3[r, c] = max(dp3[r, c], m + table[r, c], dp2[r, c - 1] + table[r, c])
    return max(dp0[-1, -1], dp1[-1, -1], dp2[-1, -1], dp3[-1, -1])


print(solve(R, C, table))


Measured memory_bytes: 466308
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll i[3]={0},j,N=0;
  string s="A";
  vector<string> v(3);
  rep(j,3)cin>>v[j];
  while(1){
    if(i[N]==v[N].size()){
      s[0]+=N;
      cout<<s<<endl;
      return 0;
    }else{
      N=v[N][i[N]++]-'a';
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<set>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
    int k,a, b;
    cin >> k >> a >> b;
    int m = 0;
    while (m < a) {
        m += k;
    }
    if(m<=b) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3596
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int a[N],ans;
void solve(){
	int n;cin>>n;
	rep(i,0,n-1)cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);ans=a[0];
	rep(i,0,n-3)ans+=a[(i/2)+1];
	cout<<ans;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  string s;
  cin >> s;
  int x = 0;
  for (char c: s) {
    x += c-'0';
  }
  cout << (x%9?"No":"Yes");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3772
def binarySearch(A,n,key):
    
    left = 0
    right = n
    while(left < right):
        mid = (left + right)//2
        if(key == A[mid]):
            return 1
        if(key > A[mid]):
            left = mid + 1
        elif(key < A[mid]):
            right = mid
            
    return 0
    
if __name__ == '__main__':
    
    n = int(input())
    L = list(map(int,input().split()))
    q = int(input())
    key = list(map(int,input().split()))
    
    count = 0
    for i in range(q):
        if(binarySearch(L,n,key[i])):
            count += 1
            
    print(count)



Measured memory_bytes: 16712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 3e5 + 10;
int x[MAXN], y[MAXN];






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, m, k; cin >> n >> m >> k;
  set<pii> table;
  for (int i = 0; i < k; i++) {
    int a, b; cin >> a >> b;
    x[a]++;
    y[b]++;
    table.emplace(a, b);
  }
  vector<pii> numx, numy;
  for (int i = 1; i <= n; i++) {
    numx.emplace_back(x[i], i);
  }
  for (int i = 1; i <= m; i++) {
    numy.emplace_back(y[i], i);
  }
  sort(numx.begin(), numx.end(), greater<pii>());
  sort(numy.begin(), numy.end(), greater<pii>());
  int ret = 0;
  for (const auto itemx : numx) {
    for (const auto itemy : numy) {
      if (itemx.first + itemy.first <= ret) break;
      if (table.find(make_pair(itemx.second, itemy.second)) == table.end()) {
        ret = max(ret, itemx.first + itemy.first);
      } else {
        ret = max(ret, itemx.first + itemy.first-1);
      }
    }
  }
  cout << ret << '\n';








/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 27592
#![allow(non_snake_case)]

use std::io;

fn main() {
    let sin = io::stdin();
    loop {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();

        let mut s = 0;
        for c in buf.chars() {
            if c.is_digit(10) {
                s += c.to_digit(10).unwrap();
            } else {
                break;
            }
        }
        if s == 0 {
            break;
        }
        println!("{}", s);
    }
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int M = 2000;

bool match(char c1, char c2){
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

bool ab[100000], ac[100000], bc[100000];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string a,b,c;cin >> a >> b >> c;

  int A = a.length();
  int B = b.length();
  int C = c.length();

  rep(i,A) rep(j,B) if(!match(a[i],b[j])) ab[i-j+50000] = true;
  rep(i,A) rep(j,C) if(!match(a[i],c[j])) ac[i-j+50000] = true;
  rep(i,B) rep(j,C) if(!match(b[i],c[j])) bc[i-j+50000] = true;

  int ans = 3*M;
  repp(i,-2*M,2*M+1) repp(j,-2*M,2*M+1){
    if(!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]){
      int L = min(0,min(i,j));
      int R = max(A, max( B+i, C+j));
      ans = min(ans,R-L);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            int T = 0;
            int out1 = -1;
            for (int i = 0; i < N; i++)
            {
                if (A[T] == 2)
                {
                    out1 = i + 1;
                    break;
                }
                T = A[T]-1;                
            }
            Console.Write(out1);
        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int n;
    int sum= 0;
    cin >> n;
    vector<int> A(n),B(n),C(n-1);
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    for(int i=0; i<n; i++){
        cin >> B[i];
    }
    for(int i=0; i<n-1; i++){
        cin >> C[i];
    }
    for(int i=1; i<n; i++){
        if(A[i]-A[i-1]==1){
            sum+= C[A[i-1]-1]; 
        }
    }
    sum+= accumulate(B.begin(), B.end(), 0);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin>>N;
  pair<int,int> itv[N];
  for(int i=0;i<N;i++){
    int x,l;
    cin>>x>>l;
    itv[i].first=x+l;
    itv[i].second=x-l;
  }
  sort(itv, itv+N);
  int ans=0,t=-12345678;

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

    if(t<=itv[i].second){
      //cout<<itv[i].first<<itv[i].second<<endl;
      ans++;
      t=itv[i].first;
    }
  }

cout<<ans<<endl;
}


Measured memory_bytes: 1024
A = []
for i in range(3):
    A.append(list(map(int,input().split())))

N = int(input())

flag = [[False]*3 for i in range(3)]

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b==A[j][k]:
                flag[j][k]=True

for i in range(3):
    ans = True
    for j in range(3):
        if not flag[i][j]:
            ans=False
            break
    if ans:
        print("Yes")
        break

if not ans:
    for i in range(3):
        ans = True
        for j in range(3):
            if not flag[j][i]:
                ans=False
                break
        if ans:
            print("Yes")
            break

if not ans:
    ans = True
    for i in range(3):
        if not flag[i][i]:
            ans = False
            break
    if ans:
        print("Yes")

if not ans:
    ans = True
    for i in range(3):
        if not flag[i][2-i]:
            ans = False
            break
    if ans:
        print("Yes")

if not ans:
    print("No")

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

int h,w,k;
vector<string> grid;

bool search_row(int y, int from, int to){
  for(int i = from;i < to;++i){
    if(grid[y][i] == '#')
      return true;
  }
  return false;
}

bool search_col(int x, int from, int to){
  for(int i = from;i < to;++i){
    if(grid[i][x] == '#')
      return true;
  }
  return false;
}

int main(void){
  cin >> h >> w >> k;
  grid = vector<string>(h);
  for(int i = 0;i < h;++i){
    cin >> grid[i];
  }

  vector<int> hol;
  hol.push_back(0);
  for(int i = 0;i < h;++i){
    if(search_row(i,0,w)){
      hol.push_back(i+1);
    }
  }

  hol.pop_back();
  hol.push_back(h);
  int hol_size = hol.size() - 1;
  auto ver = vector<vector<int>>(hol_size);
  for(int i = 0;i < hol_size;++i){
    ver[i].push_back(0);
    for(int j = 0;j < w;++j){
      if(search_col(j,hol[i],hol[i+1])){
        ver[i].push_back(j+1);
      }
    }
    ver[i].pop_back();
    ver[i].push_back(w);
  }

  int mark = 1;
  int res[310][310];
  for(int i = 0;i < hol_size;++i){
    int ver_size = ver[i].size() - 1;
    for(int j = 0;j < ver_size;++j){
      for(int a = hol[i];a < hol[i+1]; ++a){
        for(int b = ver[i][j];b < ver[i][j+1]; ++b){
          res[a][b] = mark;
        }
      }
      ++mark;
    }
  }
  for(int i = 0;i < h;++i){
    for(int j = 0;j < w;++j){
      if(j != 0)printf(" ");
      printf("%d",res[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 1920