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

class Main {

	public static void main(String[] args) {

		int n, x;
		int i = 0, j = 0, k = 0;
		int count = 0;
		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			n = stdIn.nextInt();
			x = stdIn.nextInt();

			if (n == 0 && x == 0) {
				flag = false;
				break;
			}

			count = 0;
			for (i = 1; i < n; i++) {
				for (j = i + 1; j < n; j++) {
					for (k = x - i - j; k > j; k--) {
						
						if (x == i + j + k && k <= n) {
							
							count++;
						} else {
							
						}
					}
				}

			}
			System.out.println(count);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 26584
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if N==1: print(A[0] + B[0]);exit()
AS = [0]
BS = [0]
for i in range(N):
    AS.append(AS[-1]+A[i])
    BS.append(BS[-1]+B[i])
ans = 0
for i in range(N):
    val = AS[i+1]
    val += BS[-1]-BS[i]
    ans =max(ans,val)
print(ans)

Measured memory_bytes: 61960
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

    def LII_split(): return list(map(int, input().split()))

    # 2次元リスト化
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    import string
    N = input_int()
    characters = string.ascii_letters

    def base_cvt(value, n=26):
        try:
            tmp = int(value)
        except:
            raise ValueError('Invalid value:', value)

        if n < 2 or n > len(characters):
            raise ValueError('Invalid n:', value)

        result = ''
        tmp = int(value)
        while tmp >= n:
            idx = tmp % n
            result = characters[idx] + result
            tmp = int(tmp / n)
            tmp-=1

        idx = tmp % n
        result = characters[idx] + result
        return result
    print(base_cvt(N-1))
    
resolve()

Measured memory_bytes: 9992
#include <stdio.h>
 
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF -1
  
int matrix[MAX+1][MAX+1];
int n;
int Q[MAX+1];
int d[MAX+1];
int color[MAX+1];
int head = 0, tail = 0;
 
void enq(int x){
    Q[tail] = x;
    tail++;
  
    if( tail == MAX+1 ){
        tail = 0;
    }
}
  
int deq(){
    int n;
    n = Q[head];
    head++;
  
    if( head == MAX+1 ){
        head = 0;
    }
  
    return n;
}
  
void bfs(int s){
    int i,v,u;
  
    for( i = 0 ; i <= n ; i++ ){
        color[i] = WHITE;
        d[i] = INF;
    }
  
    color[s] = GRAY;
    d[s] = 0;
    enq(s);
  
    while( tail != head ){
  
        u = deq();
  
        for( i = 1 ; i <= n ; i++ ){
  
            if( color[i] == WHITE && matrix[u][i] == 1 ){
  
                color[i] = GRAY;
                d[i] = d[u]+1;
  
                enq(i);
            }
        }
        color[u] = BLACK;
    }
}
  
int main(){
    int i,j;
    int row,col;
    int num;
  
    scanf("%d",&n);
  
  
    for( i = 0 ; i <= n ; i++ ){
        for( j = 0 ; j <= n ; j++ ){
            matrix[i][j] = WHITE;
        }
    }
  
    for( i = 1 ; i <= n ; i++ ){
  
        scanf("%d",&row);
        scanf("%d",&col);
  
        for( j = 0 ; j < col ; j++ ){
            scanf("%d",&num);
            matrix[row][num] = 1;
        }
  
    }
  
    bfs(1);
  
    for( i = 1 ; i <= n ; i++ ){
        printf("%d %d\n",i,d[i]);
    }
  
  
    return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int max_i = 0;
    for(int i = 0; i < N; i++) max_i = max(max_i, A[i]);

    int max_n = 0;
    for(int i = 0; i < N; i++){
        if(max_i == A[i]){
            A[i] = 0;
            max_n = i;
            break;
        }
    }
    int se_max = 0;
    for(int i = 0; i < N; i++) se_max = max(se_max, A[i]);
    for(int i = 0; i < N; i++){
        if(i == max_n) cout << se_max << endl;
        else cout << max_i << endl;
    }
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    if (n%2==0) {
        int ans=n/2;
        cout<<ans<<endl;
    }
    else {
        int ans=n/2+1;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import sys

input = sys.stdin.readline


def main():
    X, A, B = map(int, input().split())

    if B <= A:
        ans = "delicious"
    elif B <= A + X:
        ans = "safe"
    else:
        ans = "dangerous"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+1;

int n, pre[N], nxt[N], dp[N];
string s;
bool a[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	for(int i = 0; i < n; i++) a[i] = s[i] - '0';
	for(int i = 0, curr = -1; i < n; i++) {
		if(!a[i]) curr = i;
		pre[i] = curr;
	}
	for(int i = n-1, curr = n; i >= 0; i--) {
		if(!a[i]) curr = i;
		nxt[i] = curr;
	}
	for(int i = 0; i < n; i++) {
		dp[i+1] = max(dp[i], dp[i+1]);
		if(a[i] && pre[i] != -1 && a[pre[i]-1]) dp[i+1] = max(dp[pre[i]-1] + i - pre[i], dp[i+1]);
		if(a[i] && nxt[i] < n-1 && a[nxt[i]+1]) dp[nxt[i]+2] = max(dp[i] + nxt[i] - i, dp[nxt[i]+2]);
	}
	cout << dp[n];
}


Measured memory_bytes: 7196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    cout << char(c + 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j;
    scanf("%d%d",&n,&m);
    printf("100 100\n");
	n--;
	m--;
	for(i=0;i<50;i++)
	{
		if(i%2==1||n==0)
		{
			for(j=0;j<100;j++)
			{
				printf("#");
			}
		}
		else
		{
			for(j=0;j<100;j++)
			{
				if(n!=0&&j%2==0)
				{
					n--;
					printf(".");
				}
				else
					printf("#");
			}
		}
		printf("\n");
	}
	for(i=0;i<50;i++)
	{
		if(i%2==0||m==0)
		{
			for(j=0;j<100;j++)
			{
				printf(".");
			}
		}
		else
		{
			for(j=0;j<100;j++)
			{
				if(m!=0&&j%2==0)
				{
					m--;
					printf("#");
				}
				else
					printf(".");
			}
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int getTwos(int n){
  int res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

int main(){
  int n, a;
  scanf("%d", &n);
  int res = 0;
  for(int i=0; i < n; i++){
    scanf("%d", &a);
    res += getTwos(a);
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A[3];
    REP(i,3)cin>>A[i];
    sort(A,A+3);
    if(A[0]%2==A[1]%2&&A[0]%2==A[2]%2){
        cout<<A[2]-(A[0]+A[1])/2<<endl;
    }
    else if(A[0]%2==A[1]%2){
        A[0]++;A[1]++;
        cout<<A[2]-(A[0]+A[1])/2+1<<endl;
    }
    else if(A[1]%2==A[2]%2){
        A[1]++;A[2]++;
        cout<<A[2]-(A[0]+A[1])/2+1<<endl;
    }
    else{
        A[0]++;A[2]++;
        cout<<A[2]-(A[0]+A[1])/2+1<<endl;
    }
}


Measured memory_bytes: 256
N=int(input())
A=[0]*N
B=[0]*N

for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b

A=A[::-1]
B=B[::-1]

K=0
for i in range(N):
    if (A[i]+K)%B[i]:
        L=B[i]-((A[i]+K)%B[i])
        K+=L
print(K)


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

using namespace std;

int main () {

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    long long ans = INT_MAX;
    for (int i = 0; i <= 100000; i++) {
        long long cost = (long long)(2 * C * i + A * max(0, X - i) + B * max(0, Y - i));
        ans = min(cost, ans);
    }
    cout << ans << endl;

    return 0;
}

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

const ll X=1000000007;

ll two(ll N){
  ll num=1;
  for(ll i=0;i<N;i++){
    num*=2;
    if(num>X){
      num%=X;
    }
  }
  return num;
}

int main() {
  
  ll N;
  cin>>N;
  vector<ll> C(N),S(N);//S(N)は荷重
  for(ll i=0;i<N;i++){
    cin>>C.at(i);
  }
  
  if(N==1){cout<<C.at(0)*2%X<<endl;}
  else{
  
    sort(C.begin(),C.end());
    for(ll i=0;i<N;i++){
      S.at(i)=(N+1-i);
    }
    ll ans=0;
    for(ll i=0;i<N;i++){
      ans+=(C.at(i)*S.at(i))%X;
      ans%=X;
    }
    ans*=two(2*N-2)%X;
    cout<<ans%X<<endl;
  }
}




Measured memory_bytes: 3328
import math
a,b = map(int,input().split())
for i in range(1,1300):
  eightper = math.floor(i*0.08)
  tenper = math.floor(i*0.1)
  if eightper == a and tenper == b:
    print(i)
    break
  if i == 1299:
    print(-1)
    break

Measured memory_bytes: 3060
import itertools
n = int(input())
d = {}
for i in range(n):
  s = str(input())[0]
  if (s == 'M') or (s == 'A') or (s == 'R') or (s == 'C') or (s == 'H') :
    if s in d:
      d[s] += 1
    else:
      d[s] = 1
if len(d) <= 2:
  print(0)
else:
  d = sorted(d.values())
  ans = 0
  for team in itertools.combinations(d, 3):
    cnt = 1
    for i in team:
      cnt *= i
    ans += cnt
  print(ans)

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

int main(){
	int t,n,s[10],f[10];
	while(scanf("%d",&t),t){
		scanf("%d",&n);
		int sum=0;
		for(int i=0;i<n;i++){ scanf("%d%d",&s[i],&f[i]); sum+=f[i]-s[i]; }
		if(sum>=t) printf("OK\n");
		else printf("%d\n",t-sum);
	}	
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main(){
	int n,k;
	scanf("%d%d", &n, &k);
	for(int i=0,j;i<n;++i) scanf("%d", &j);
	printf("%d\n", (n-1+k-1-1)/(k-1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int a, b, c; cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust\n";
    else cout << "win\n";

    return 0;
}

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

string S;
int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

string S;
const int alp = 'z' - 'a' + 1;
int sizes[alp];
ll sss = 0;
int pos[2][alp];

bool isuUnbalance() {
	int buf = sss / 2;

	REP(i, alp) {
		if (sizes[i] > buf)return true;
	}

	return false;
}

void solve() {

	REP(s, S.size() - 1) {
		int len = 0;
		sss = 0;
		REP(i, alp) sizes[i] = 0;

		for (int i = s; i < S.size() && i - s < 3; ++i) {
			sizes[S[i] - 'a']++; len++; sss++;
			if (len < 2)continue;
			if (isuUnbalance()) {
				cout << (s + 1) << " " << (i + 1) << endl;
				return ;
			}
		}
	}

	cout << "-1 -1" << endl;
}

int main() {
	cin >> S;

	if (S.size() < 2) {
		cout << "-1 -1" << endl;
	}
	else {
		solve();
	}

	return 0;
}


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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

using pii = pair<int, int>;

int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    rep(i, N) {
        rep(j, N-1) {
            cin >> A[i][N-1-1-j]; A[i][N-1-1-j]--;
        }
    }
    int days = 0;
    vector<bool> done_false(N);
    vector<int> q(N);
    iota(q.begin(), q.end(), 0);
    for (;;) {
        vector<bool> done(done_false);
        bool nogame = true;
        set<int> q_next;
        for (int i : q) {
            if (done[i] || A[i].size() == 0) continue;
            int j = A[i].back();
            if (done[j]) continue;
            if (A[j].back() == i) {
                A[i].pop_back();
                A[j].pop_back();
                done[i] = true;
                done[j] = true;
                q_next.insert(i);
                q_next.insert(j);
                nogame = false;
            }
        }
        if (nogame) break;
        q.resize(q_next.size());
        copy(q_next.begin(), q_next.end(), q.begin());
        days++;
    }

    for (const auto& a : A) {
        if (a.size() != 0) {
            days = 0;
            break;
        }
    }

    cout << (days > 0 ? days : -1) << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

template<typename T>
struct Dijkstra{
    const T inf=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n;
    vector<vector<pair<int,T>>> G;
    vector<T> d;
    vector<int> prev;
    vector<long long> cnt;
    Dijkstra(int n):n(n),G(n),d(n),prev(n),cnt(n){}
    void add_edge(int u,int v,T w){
        G[u].emplace_back(v,w);
    }
    void build(int s){
        fill(d.begin(),d.end(),inf);
        fill(prev.begin(),prev.end(),-1);
        fill(cnt.begin(),cnt.end(),0);
        d[s]=0;
        cnt[s]=1;
        priority_queue<P,vector<P>,greater<P>> pq;
        pq.emplace(d[s],s);
        while(!pq.empty()){
            P p=pq.top(); pq.pop();
            int v=p.second;
            if (d[v]<p.first) continue;
            for (auto &e:G[v]){
                int u=e.first; T c=e.second;
                if (d[v]+c<d[u]){
                    d[u]=d[v]+c;
                    prev[u]=v;
                    cnt[u]=cnt[v];
                    pq.emplace(d[u],u);
                } else if (d[u]==d[v]+c){
                    cnt[u]=(cnt[u]+cnt[v])%MOD;
                }
            }
        }
    }
    vector<T> distance(int s){
        build(s);
        return d;
    }
    vector<int> get_path(int s,int t,T &dist){
        build(s);
        dist=d[t];
        vector<int> path;
        for (;t!=-1;t=prev[t]) path.emplace_back(t);
        reverse(path.begin(),path.end());
        return path;
    }
    vector<long long> cnt_path(int s){
        build(s);
        return cnt;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    while(cin >> n >> k,n){
        Dijkstra<ll> D(n);
        rep(i,k){
            int c,a,b,e; cin >> c >> a >> b; --a,--b;
            if (!c){
                vector<ll> ans=D.distance(a);
                cout << (ans[b]<IINF?ans[b]:-1) << endl;
            } else {
                cin >> e;
                D.add_edge(a,b,e); D.add_edge(b,a,e);
            }
        }
    }
}


Measured memory_bytes: 3256
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    except:
        break
    hit = 0
    blow = 0
    for i, n in enumerate(a):
        if b[i] == n:
            hit += 1
        elif n in b:
            blow += 1
    print(hit, blow)

Measured memory_bytes: 5600
import scala.io.Source.stdin

object Main {
  def countValue(i: Iterator[String], count: Map[Int, Int] = Map()): Map[Int, Int] = {
    if (i.hasNext) {
      val n = i.next.toInt
      if (count.contains(n)) countValue(i, count + (n -> (count(n) + 1)))
      else countValue(i, count + (n -> 1))
    } else count
  }

  def results(i: Iterator[String]): List[Int] = {
    val countList = countValue(i).toList.sortWith(_._2 > _._2)
    val filterMaxCount = countList.filter(_._2 == countList.head._2)
    (for ((t1,t2) <- filterMaxCount) yield t1).sortWith(_<_)
  }

  def main(args: Array[String]): Unit = {
    results(stdin.getLines).foreach(println)
  }
}

Measured memory_bytes: 43660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
bool f[4];

int main()
{
	rep(i, 4)
	{
		int a;
		cin >> a;
		if (a == 1)
			f[0] = true;
		else if (a == 9)
			f[1] = true;
		else if (a == 7)
			f[2] = true;
		else if (a == 4)
			f[3] = true;
	}
	rep(i, 4)
	{
		if (!f[i])
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#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 = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<set<int>> st(N + 1);
  REP(k, K) {
    cin >> d[k];
    int a;
    REP(dd, d[k]) {
      cin >> a;
      st[a].insert(k);
    }
  }
  int ans = 0;
  REP(i, N) {
    if (st[i + 1].size() == 0) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll X;
	cin >> X;
	int l;
	while(1)
	{
	   l = 0;
	   repd(i, 2, X/2)
	   {
	       if(X%i==0)
	       {
	           l=1;
	           break;
	       }
	   }
	   if(l==0) break;
	   X++;
	}
	cout << X << endl;
	return 0;
}


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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr(i, a, b) for (int i = (int)(a - 1); i >= b; i--)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x " = " << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX / 3

vector<int> edge[100001];
bool visited[100001];

set<int> bfs(int v) {
  set<int> ret;
  queue<int> q;
  q.push(v);
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (visited[u]) continue;
    visited[u] = true;
    ret.insert(u);
    rep(i, edge[u].size()) if (!visited[edge[u][i]]) { q.push(edge[u][i]); }
  }
  return ret;
}

int main() {
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int p[n];
  rep(i, n) cin >> p[i];
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    edge[x].pb(y), edge[y].pb(x);
  }
  int ans = 0;
  repl(i, 1, n + 1) if (!visited[i]) {
    set<int> s = bfs(i);
    each(itr, s) if (s.count(p[itr - 1])) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10880
def insertionSort(A,N):
  for i in range(N):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
 
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)


Measured memory_bytes: 5600
X, K, D = map(int ,input().split())

X = abs(X)
if K * D < X:
    ans = X - K * D
else:
    if X // D % 2 == 0:
        if K % 2 == 0:
            ans = X % D
        else:
            ans = abs(X % D - D)
    else:
        if K % 2 == 0:
            ans = abs(X % D - D)
        else:
            ans = X % D

print(ans)


Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l,r;
  l=(s[0]-'0')*10+s[1]-'0';
  r=(s[2]-'0')*10+s[3]-'0';
  if(1<=l&&l<=12) {
    if(1<=r&&r<=12) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if(1<=r&&r<=12) {
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<map>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(ll &a,ll &b){ll c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,double>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define id(i,j) ((i-1)*m+j)
#define inf (0x3f3f3f3f)
const int N=1e5+10;
int t[N],x[N],y[N];
struct node{
	int t,x,y;
	bool operator < (const node a)const{
		return t<a.t;
	}
}a[N];
inline int getdis(int x1,int y1,int x2,int y2){
    return abs(x1-x2)+abs(y1-y2);
}
int main(){
    int n=read();
    rep(i,1,n) a[i].t=read(),a[i].x=read(),a[i].y=read();
    sort(a+1,a+n+1);
    int pret=0,prex=0,prey=0;
    rep(i,1,n){
		int dis=getdis(prex,prey,a[i].x,a[i].y);
		if(dis>a[i].t-pret){puts("No");return 0;}
		if(dis&1){
			if(!(a[i].t-pret&1)){printf("No");return 0;}
		}else{
			if(a[i].t-pret&1){printf("No");return 0;}
		}
		pret=a[i].t;prex=a[i].x;prey=a[i].y;
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dist[305][305];
int dist2[305][305];

vector<vector<int>>wayConnect(100000);
vector<vector<int>>subwayConnect(100000);

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	string ans = "No";
	for (int i = 0; i <= 9;++i) {
		for (int j = 0; j <= 9;++j) {
			if (N == (i*j)) {
				ans = "Yes";
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9600
import sys
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
res = [""] * N
ab = []
ac = []
bc = []
def no():
  print("No")
  exit(0)
for i in range(N):
  s = input()[: -1]
  if s == "AB":
    ab.append(i)
    A -= 1
    B -= 1
    if A < 0:
      if len(ac):
        A += 2
        res[ac.pop()] = "A"
      elif len(ab):
        A += 2
        res[ab.pop()] = "A"
    if B < 0:
      if len(bc):
        B += 2
        res[bc.pop()] = "B"
      elif len(ab):
        B += 2
        res[ab.pop()] = "B"

  if s == "AC":
    ac.append(i)
    A -= 1
    C -= 1
    if A < 0:
      if len(ab):
        A += 2
        res[ab.pop()] = "A"
      elif len(ac):
        A += 2
        res[ac.pop()] = "A"
    if C < 0:
      if len(bc):
        C += 2
        res[bc.pop()] = "C"
      elif len(ac):
        C += 2
        res[ac.pop()] = "C"

  if s == "BC":
    bc.append(i)
    B -= 1
    C -= 1
    if B < 0:
      if len(ab):
        B += 2
        res[ab.pop()] = "B"
      elif len(bc):
        B += 2
        res[bc.pop()] = "B"
    if C < 0:
      if len(ac):
        C += 2
        res[ac.pop()] = "C"
      elif len(bc):
        C += 2
        res[bc.pop()] = "C"

  if min(A, B, C) < 0: no()

for x in ab: res[x] = "A"
for x in ac: res[x] = "A"
for x in bc: res[x] = "B"
print("Yes")
for r in res: print(r)

Measured memory_bytes: 73064
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      string s;
      cin >> s;
      lld l, i;
      l = s.length();
      foi(i, l)
      {
      	cout << "x";
      }
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, a, b, c);

  int ans = 0;
  while (true) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) break;
    ans++;
    int ha = a / 2;
    int hb = b / 2;
    int hc = c / 2;
    if (a == hb + hc && b == ha + hc && c == ha + hb) {
      cout << -1 << endl;
      return;
    }
    a = hb + hc;
    b = ha + hc;
    c = ha + hb;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n,x,y;cin >> n >> x >> y;
    --x;--y;
    vi ans(n);
    rep(i,n){
        for(int j=i+1;j<n;++j){
            int ind = min({abs(j - i), abs(i - x) + 1 + abs(y - j), abs(i - y) + 1 + abs(j - x)});
            ans[ind]++;
        }
    }
    for(int i=1;i<=n-1;++i){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 256
// #include <stdio.h>
// #include <string.h>
//#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>

using namespace std;
typedef pair<int, int> XY;// Pair型変数の宣言


    
int main()
{
  	int Nmax = 50;
    int V[Nmax];
    char String[Nmax];
    int N;
    int i,j,k;
    int len;   // 文字列の長さ
    int flag=0;
    double tmp;

    

        
    
    // 入力読込

    // 数列
   scanf("%d", &N);
   for(i=1;i<=N;i++){
        scanf("%d ",&V[i]);
  //   	 printf("%d ",V[i]);
    }
    
    //    printf("\n"); 
    sort( (int*)(V+1), (int*)(V+N+1) ); // 価値の低いじゅんにソーと

 //    for(i=1;i<=N;i++){
 //       printf("%d ",V[i]);
 //   }

    
    
    
        // 文字列
//   scanf("%s", String);   
    
    
    // 文字列の長さをチェック
    // 文字列は配列の0からlen-1に格納されてる
//    len = strlen( String );
//  	printf("%d\n",len);
    
    tmp = (double)V[1];
    for(i=2;i<=N;i++){
        tmp = (tmp + (double)V[i])/2.0;
    }
    
    printf("%f\n", tmp);
    
 
  
        
  
  return 0;
   
}

Measured memory_bytes: 888
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    if sum(lmis()) >= 22:
        print('bust')
    else:
        print('win')





main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i = a ; i <= b;i++)
using namespace std;
void debug(int x){
    cerr<<x<<endl;
}
void debug(vector<int> v){
    for(int i = 0 ; i<v.size(); i++) cerr<<v[i]<<" ";
    cerr<<"\n";
}
void debug(int *A, int N){
    for(int i = 0 ; i < N;i++) cerr<<A[i]<<" ";
    cerr<<endl;
}
void debug(int *A, int i, int j){
    for(int k = i;k<=j;k++) cerr<<A[k]<<" ";
    cerr<<endl;
}
void scan(vector<int> &h,int N){
    for(int i = 0 ; i < N;i++){
        scanf("%d",&h[i]);
    }
}
int dp[100005][3];
int main(){
            int N;
            cin>>N;
            vector<int> a(N),b(N),c(N);
            for(int i = 0 ; i < N; i++){
                cin>>a[i]>>b[i]>>c[i];
            }
           //dp[i][0] --> indicates the max happiness on the ith day(0 indexed) 
           //the last activity being 0
           //0 --> swim (a vector) , 1 --> catch bugs(b) 2-> homework
           dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
           for(int i = 1 ; i<N;i++){
                 dp[i][0] = -1; dp[i][1] = -1; dp[i][2] = -1;
                 dp[i][0] = max(dp[i][0], max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]));
                 dp[i][1] = max(dp[i][1], max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]));
                 dp[i][2] = max(dp[i][2], max(dp[i-1][1] + c[i], dp[i-1][0] + c[i]));
           }
           int ans = max(dp[N-1][0], max(dp[N-1][1],dp[N-1][2]));
           cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int n,m,k;
main()
{
	while(cin>>n>>k>>m,n)
	{
		int ans=0;
		for(int i=2;i<n;i++)ans=(ans+k)%i;
		cout<<(ans+m)%n+1<<endl;
	}
}



Measured memory_bytes: 3004
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	int sum = 6; sum -= a; sum -= b;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 764
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] v = new int[n];
		for(int i = 0;i < n;i++) {
			v[i] = sc.nextInt();
		}
		sc.close();
		Map<Integer,Integer> Odds = new HashMap<>();
		Map<Integer, Integer> Evens = new HashMap<>();
		Odds.put(0, 0);
		Evens.put(0, 0);
		for(int i = 0;i < n;i++) {
			if((i+1)%2!=0) {
				if(Odds.containsKey(v[i])) {
					Odds.put(v[i], Odds.get(v[i])+1);
				}else {
					Odds.put(v[i], 1);
				}
			}else {
				if(Evens.containsKey(v[i])) {
					Evens.put(v[i], Evens.get(v[i])+1);
				}else {
					Evens.put(v[i], 1);
				}
			}
		}

		Comparator<Entry<Integer,Integer>> comp = Entry.comparingByValue();
		Entry<Integer,Integer> O1 =Odds.entrySet().stream()
				.max(comp)
				.get();
		Entry<Integer,Integer> E1 =Evens.entrySet().stream()
				.max(comp)
				.get();
		Odds.remove(O1.getKey());
		Evens.remove(E1.getKey());
		Entry<Integer,Integer> O2 =Odds.entrySet().stream()
				.max(comp)
				.get();
		Entry<Integer,Integer> E2 =Evens.entrySet().stream()
				.max(comp)
				.get();
		n -= O1.getKey().equals(E1.getKey())
				? Math.max(O1.getValue()+E2.getValue(),
						E1.getValue()+O2.getValue())
						: O1.getValue()+E1.getValue();
		System.out.println(n);
	}
}

Measured memory_bytes: 55656
n = int(input())
l = float("inf")
r = -float("inf")
b = float("inf")
a = -float("inf")
lis = []
for i in range(n):
  j,k=map(int, input().split())
  if j>r:
    r=j
  if j<l:
    l=j
  if k>a:
    a=k
  if k<b:
    b=k
  lis.append([j, k])
  
lb = -1
lbd = float("inf")

rb = -1
rbd = float("inf")

for i in range(n):
  j, k = lis[i]
  if abs(j-l)+abs(k-b)<lbd:
    lbd =  abs(j-l)+abs(k-b)
    lb=i
  if abs(r-j)+abs(k-b)<rbd:
    rbd =  abs(r-j)+abs(k-b)
    rb=i
  
ans = 0
for i in range(n):
  a, b = lis[lb]
  j, k = lis[i]
  if abs(a-j)+abs(b-k)>ans:
    ans=abs(a-j)+abs(b-k)

for i in range(n):
  a, b = lis[rb]
  j, k = lis[i]
  if abs(a-j)+abs(b-k)>ans:
    ans=abs(a-j)+abs(b-k)
print(ans)
  

Measured memory_bytes: 103428
#include<iostream>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	int i = 3;
	if (a == b) {
		i -= 1;
	}
	if (a == c) {
		i -= 1;
	}
	if (b == c) {
		i -= 1;
	}
	if (i == 0) {
		i = 1;
	}
	std::cout << i << std::endl;
	return 0;
}

Measured memory_bytes: 256
def find(strings):
    count={}
    ans=0
    for s in strings:
        s="".join(sorted([x for x in s]))
        #print(s)
        if s in count:
            count[s]+=1
        else:
            count[s]=1
    for s in count:
        temp=count[s]
        ans+=temp*(temp-1)
    return ans//2
strings=[]
for _ in range(int(input())):
    
    strings+=[input()]
print(find(strings))
    

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
vector<ll> v;
char op[] = {'+','-','*'};
ll Rank[3];

ll number(int &i);
ll facter(int &i);
ll expr3(int &i);
ll expr2(int &i);
ll expr1(int &i);

ll number(int &i){
    ll res = 0;
    while(s[i] >= '0' && s[i] <= '9'){
        res *= 10;
        res += (s[i] - '0');
        i++;
    }
    return res;
}

ll facter(int &i){
    ll res = 0;
    if(s[i] == '('){
        i++;
        res = expr1(i);
        i++;
    }
    else if(s[i] >= '0' && s[i] <= '9'){
        res = number(i);
    }
    return res;
}

ll expr3(int &i){
    ll res = facter(i);
    while(1){
        if(s[i] == '+' && Rank[0] == 2){
            i++;
            res += facter(i);
        }
        else if(s[i] == '-' && Rank[1] == 2){
            i++;
            res -= facter(i);
        }
        else if(s[i] == '*' && Rank[2] == 2){
            i++;
            res *= facter(i);
        }
        else break;
    }
    return res;
}

ll expr2(int &i){
    ll res = expr3(i);
    while(1){
        if(s[i] == '+' && Rank[0] == 1){
            i++;
            res += expr3(i);
        }
        else if(s[i] == '-' && Rank[1] == 1){
            i++;
            res -= expr3(i);
        }
        else if(s[i] == '*' && Rank[2] == 1){
            i++;
            res *= expr3(i);
        }
        else break;
    }
    return res;
}

ll expr1(int &i){
    ll res = expr2(i);
    while(1){
        if(s[i] == '+' && Rank[0] == 0){
            i++;
            res += expr2(i);
        }
        else if(s[i] == '-' && Rank[1] == 0){
            i++;
            res -= expr2(i);
        }
        else if(s[i] == '*' && Rank[2] == 0){
            i++;
            res *= expr2(i);
        }
        else break;
    }
    return res;
}

int main(){
    cin >> s;
    rep(i,3)v.push_back(i);
    sort(ALL(v));
    ll ans = LLONG_MIN;
    rep(i,3){
        rep(j,3){
            rep(k,3){
                Rank[0] = i;
                Rank[1] = j;
                Rank[2] = k;
                int i = 0;
                ll num = expr1(i);
                ans = max(ans,num);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	char b;
	cin >> b;
	if (b == 'A')cout << 'T' << endl;
	else if (b == 'G')cout << 'C' << endl;
	else if (b == 'C')cout << 'G' << endl;
	else cout << 'A' << endl;
	return 0;
}


Measured memory_bytes: 256
//17
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  int sum=0,a=0,na=0;
  for(int t,s;(cin>>t).ignore()>>s;){
    sum+=t*s;
    a+=s*2;
    na++;
  }
  int da=a/na;
  cout<<sum<<endl<<da/2+(da&1)<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (c>a+b){
        cout<<a+2*b+1<<endl;
    }
    else if(c==a+b)
    {
        cout<<a+2*b<<endl;
    }
    else if(c<a+b){
        cout<<c+b<<endl;
    }
}

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

int a[300000];

bool complare(int a,int b){
	return a>b;
}

int main(){
	int k,n;
	cin>>n>>k;
	memset(a,0,sizeof(a));
	for (int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	sort(a,a+n,complare);
	int res=0;
	for (int i=k;i<=n;i++){
		res+=a[i];
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1408