akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main () {
    
    int n;
    cin >> n;
    vector<int> vc1(100000,0); 
    vector<int> vc2(100000,0);  

    int v;
    int mx1 = 0;
    int mx2 = 0;
    REP(i, n) {
        cin >> v;
        if(i % 2 == 0) {
            mx1 = max(mx1, v);
            vc1[v-1] += 1;
        } else {
            mx2 = max(mx2, v);
            vc2[v-1] += 1;
        } 
    } 

    int v1mx = 0;
    int v2mx = 0;
    int v1mx2 = 0; 
    int v2mx2 = 0;
    int v1amx = -1; 
    int v1amx2 = -1; 
    int v2amx = -1; 
    int v2amx2 = -1;

    REP(i, mx1) {
        if(v1mx < vc1[i]) {
            v1mx2 = v1mx;
            v1mx = vc1[i];
            v1amx = i;
        } else if(v1mx2 < vc1[i]) {
            v1mx2 = vc1[i];
        } 
    }

    REP(i, mx2) {
        if(v2mx < vc2[i]) {
            v2mx2 = v2mx;
            v2mx = vc2[i];
            v2amx = i;
        } else if(v2mx2 < vc2[i]) {
            v2mx2 = vc2[i];
        } 
    } 

    // cout << v1mx << " " << v1amx << endl;
    // cout << v1mx2 << " " << v1amx2 << endl;
    // cout << v2mx << " " << v2amx << endl;
    // cout << v2mx2 << " " << v2amx2 << endl;

    if(v1amx != v2amx) {
        cout << n - v1mx - v2mx << endl;
    } else {
        cout << n - max(v1mx + v2mx2, v2mx + v1mx2)  << endl; 
    }

    return 0;
}

Measured memory_bytes: 1024
Flag =  0 
S = input()
SA = [str(c) for c in S]
#A = list(['A','A','A'])
#B = list(['B','B','B'])
S1 = SA[0]
S2 = SA[1]
S3 = SA[2]
if(S1 == S2 == S3):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a,ll b)
{
    return a / gcd(a, b) * b;
}



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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
  vector<ll> v;
  for(ll i=1; i<=N; i++)
    v.push_back(i);
  ll cnt = 0;
  ll a, b;
  do{
    cnt++;
    bool f = true;
    for(ll i=0; i<N; i++) {
      if(v[i]!=P[i])
	f = false;
    }
    if(f) {
      a = cnt;
    }
    f = true;
    for(ll i=0; i<N; i++)
      if(v[i]!=Q[i])
	f = false;
    if(f) {
      b = cnt;
    }
  }while(next_permutation(v.begin(), v.end()));
  
  std::cout << abs(a-b) << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> P(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&P[i]);
  }
  std::vector<long long> Q(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&Q[i]);
  }
  solve(N, std::move(P), std::move(Q));
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>
#include <stack>
#include <utility>
#include <cstdio>

using namespace std;

struct Water {
    int b;
    int area;
};

class PredFunctor {
  public:
    int b;
    int* area_ptr;
  public:
    PredFunctor(int b, int *area_ptr) : b(b), area_ptr(area_ptr) { }
    bool operator()(const Water& water) {
        if (water.b > this->b) {
            *area_ptr += water.area;
            return true;
        }
        return false;
    }
};

int main(void) {

    string map;
    cin >> map;

    int total_area = 0;
    list<Water> waters;
    stack<int> geo;
    for (int i = 0; i < map.size(); ++i) {
        switch (map[i]) {
            case '\\':
                geo.push(i);
                break;
            case '/':
                if ( ! geo.empty()) {
                    int b = geo.top(), this_area = i - b;
                    total_area += this_area;
                    PredFunctor pred(b, &this_area);
                    waters.remove_if(pred);
                    waters.push_back({ b, this_area });
                    geo.pop();
                }
                break;
        }
    }

    printf("%d\n", total_area);
    printf("%lld", waters.size());
    for (list<Water>::iterator it = waters.begin();
            it != waters.end(); ++it) {
        printf(" %d", it->area);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1328
import sys
n = int(input())
A = [0]*100
B = [0]*100

if n == 0:
    print(0)
    sys.exit(0)
if n == 1:
    print(1)
    sys.exit(0)
A[0] = (0, 1)
B[0] = (1, 1)
i = 1
v = -2
while(True):
    if v < 0:
        A[i] = (A[i-1][0]+v, A[i-1][1])
        B[i] = (A[i-1][0]+v, A[i-1][1]+v)
    else:
        A[i] = (A[i-1][0]  , A[i-1][1]+v)
        B[i] = (A[i-1][0]+v, A[i-1][1]+v)
    if A[i][0] <= n and n <= A[i][1]:
        break
    i += 1
    v *= -2

S = ''
for j in range(i, -1, -1):
    if B[j][0] <= n and n <= B[j][1]:
        S += '1'
        n -= v
    else:
        S += '0'
    v /= -2
print(S)


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

// 
int main() {
    int N, D;
    cin >> N >> D;
    int count = 0;
    int X,Y;
    for (int i = 0; i < N; i++) {
        cin >> X >> Y;
        if (sqrt(pow(X, 2) + pow(Y, 2)) <= D) {
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 3676
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int correct = 0;
	int penalty = 0;
	int N, M; cin >> N >> M;
	vector<int> p(M);
	vector<bool> X(100001,false);
	vector<int> ans(100001, 0);
	rep(i, 0, M) {
		int p; cin >> p;
		string S; cin >> S;
		if (S == "WA") {
			if(X[p]==false)ans[p]++;
		}
		else {
			//penalty += ans[p];
			X[p] = true;
		}

	}

	rep(i, 0, 100001) {
		if (X[i]) {
			penalty += ans[i];
			correct++;
		}
	}
	
	
	printf("%d %d\n",correct, penalty);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int h,n;
    while(~scanf("%d%d",&h,&n)){
        int sum=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        if(sum<h) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


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

int main(void){
	int k;
	string s;
	cin >> k >> s;

	if (k >= (int)s.length()) cout << s;
	else {
		for (int i = 0;i < k;i++) {
			cout << s[i];
		}
		cout << "...";
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;

    int cnt_0 = 0, cnt_1 = 0;
    for ( int i = 0 ; i < s.size(); i++ ){
        if (s[i] == '0' )cnt_0++;
        else  cnt_1++;
    }
    cout << min(cnt_0,cnt_1)*2 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
struct Block {
	int w, s, v;
	bool operator<(Block other) const {
		if (w + s == other.w + other.s) {
			return s > other.s;
		}
		return w + s > other.w + other.s;
	}
};
int n;
Block b[1000];
long long dp[1000][10001];
long long calc(int i, int s) {
	if (i == n) return 0;
	if (dp[i][s] != -1) return dp[i][s];
	long long res = calc(i + 1, s);
	if (b[i].w <= s) {
		res = max(res, calc(i + 1, min(s - b[i].w, b[i].s)) + b[i].v);
	}
	return dp[i][s] = res;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d %d %d", &b[i].w, &b[i].s, &b[i].v);
	sort(b, b + n);
	memset(dp, -1, sizeof(dp));
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, calc(i + 1, b[i].s) + b[i].v);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 78464
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (string s; getline(cin, s);) {
		string t;
		for (int j = 0; j < 26; j++) {
			t = "";
			for (int i = 0; i < s.size(); i++) {
				if (s[i] >= 'a'&&s[i] <= 'z') {
					if (s[i] + j > 'z')t += s[i] + j - 26;
					else t += s[i] + j;
				}
				else
					t += s[i];
			}
			if (t.find("the") != string::npos)break;
			if (t.find("this") != string::npos)break;
			if (t.find("that") != string::npos)break;
		}
		cout << t << endl;
	}
	return 0;
}

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

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

  if(a >= 13){
    cout << b <<endl;
  }
  if(a >= 6 && a <= 12){
    cout << b / 2 << endl;
  }
  if(a <= 5){
    cout << "0" << endl;
  }
}


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

import static java.lang.Integer.parseInt;

/**
 * Problem G: Prime Quadruplet
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		boolean[] ps = primes(10_000_000);

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			int i = n;
			while (i >= 13) {
				if (ps[i]) if (ps[i - 2] && ps[i - 6] && ps[i - 8]) break;
				i--;
			}
			System.out.println(i);

		}//end while
	}//end main

	static boolean[] primes(int limit) {

		boolean[] ps = new boolean[limit + 1];
		int _limit = (int) Math.ceil(Math.sqrt(ps.length));

		Arrays.fill(ps, 2, ps.length, true);

		for (int i = 2; i <= _limit; i++) {
			if (ps[i]) {
				for (int j = i * 2; j < ps.length; j += i) {
					if (ps[j]) ps[j] = false;
				}
			}
		}
		return ps;
	}
}

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

int main()
{	
	int a[2];
	cin >> a[0] >> a[1];
	if (a[0]>a[1])
		cout << "a > b" << endl;
	if (a[0]<a[1])
		cout << "a < b" << endl;
	if(a[0]==a[1]) cout << "a == b" << endl;
	return 0;
}

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

int main() {
  int A1, A2, A3, Amax, Amin;
  cin >> A1 >> A2 >> A3;
  
  Amax = max({A1, A2, A3});
  Amin = min({A1, A2, A3});
  
  cout << Amax - Amin << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define int long long
using namespace std;
vector<int>v[1010];
signed main() {
	int n, q; cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int a, b, c; cin >> a;
		if (a == 0) {
			cin >> b >> c;
			v[b].push_back(c);
		}
		else if (a == 1) {
			cin >> b;
			for (int j = 0; j < v[b].size(); j++) {
				if (j)cout << ' ';
				cout << v[b][j];
			}cout << endl;
		}
		else {
			cin >> b;
			v[b].clear();
		}
	}return 0;
}


Measured memory_bytes: 8764
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  for (int x = 1; x <= 50000; ++x) {
    int res = x * 1.08;
    if (n == res) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

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

int main()
{
  	int n; cin >> n;
  	map<string,int> freq;
 	freq["AC"] = 0;
  	freq["WA"] = 0;
  	freq["TLE"] = 0;
  	freq["RE"] = 0;
  	for (int i = 0; i < n; i++)
    {
    	string s;
      	cin >> s;
      	freq[s]++;
    }
  	cout << "AC x " << freq["AC"] << endl;
  	cout << "WA x " << freq["WA"] << endl;
  	cout << "TLE x " << freq["TLE"] << endl;
  	cout << "RE x " << freq["RE"] << endl;
	return 0;
}


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

using namespace std;

int main(){
  vector<int> candy(3);
  
  for(int i=0;i<candy.size();i++) cin>>candy[i];
  sort(candy.begin(),candy.end());  
  
  if(candy[0]+candy[1]==candy[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = I()
    v = LI()
    even_count = collections.defaultdict(int)
    odd_count = collections.defaultdict(int)
    for i in range(n):
        if i % 2 == 1:
            odd_count[v[i]] += 1
        else:
            even_count[v[i]] += 1
    odd_array = []
    even_array = []
    for k, v in odd_count.items():
        odd_array.append((k, v))
    for k, v in even_count.items():
        even_array.append((k, v))

    odd_array = sorted(odd_array, key=lambda x:x[1])[::-1]
    even_array = sorted(even_array, key=lambda x:x[1])[::-1]

    ans = inf
    arrLen = n // 2
    for ok, ov in odd_array[:2]:
        for ek, ev in even_array[:2]:
            if ok == ek:
                continue
            ans = min(ans, (arrLen - ov) + (arrLen - ev))
    if ans == inf:
        ans = arrLen
    print(ans)
main()



Measured memory_bytes: 23916
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define all(x)        (x).begin(),(x).end()
#define isWorking()   cout<<"Wroking"<<endl
#define FOR(i,x,y)    for(int i=x; i<y; i++)
#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl
#define SetPrint(a,x) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input

//    cin>>testCase;
    while(testCase--) {
        ll n,k; cin>>n>>k;
        ll r,s,p; cin>>r>>s>>p;

        string str; cin>>str;
        string comHand="1"; comHand+=str;
        ll ans=0;

        for(int i=1; i<=n; i++){
            if(i<=k){
                if(comHand[i]=='r') ans+=p;
                else if(comHand[i]=='p') ans+=s;
                else    ans+=r;
                continue;
            }
            if(comHand[i]==comHand[i-k]) comHand[i]='1';
            else{
                if(comHand[i]=='r') ans+=p;
                else if(comHand[i]=='p') ans+=s;
                else    ans+=r;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and wa_list[p-1] != -1:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
        wa_list[p-1] = -1
    elif wa_list[p-1] != -1:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

Measured memory_bytes: 30756
def main():
    S = input()
    K = int(input())
    ans = 0

    if len(set(S)) is 1:
        print(len(S) * K // 2)
        return

    i = 0
    cnt = [1]
    while i < len(S) - 1:
        if S[i] is S[i + 1]:
            cnt[-1] += 1
        else:
            cnt.append(1)
        i += 1

    for v in cnt:
        ans += (v // 2) * K

    if S[0] is S[-1]:
        if cnt[0] % 2 == cnt[-1] % 2 == 1:
            ans += K - 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,m,x;
 

vi bt;
void setbit(ll i){
  bt.clear();
  for(ll tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}



int main(){
  ll ans=llMAX;
  cin >> n >> m>>x;
 
  
  vi c(n);
  vvi a(n, vi(m));
 
  REP(i,n){
    cin>>c[i];
    REP(j,m){
      cin>>a[i][j];
    }
  }
 
 
 
  ll nn=1<<n;
  

  for(ll i=0;i<nn;i++){
    ll cost=0;
    vi arg(m,0);

    setbit(i);
    for (auto j : bt) {
      for(ll k=0;k<m;k++){
        arg[k]+=a[j][k];
      }
      cost+=c[j];
    }

 
    int flag=0;
    for(ll k=0;k<m;k++){
      if (arg[k]<x)flag=1;
    }
    if (flag==0){
      ans=min(ans,cost);
    }
 
    
    
  }
 
 
 
  if (ans==llMAX){
    ans=-1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

const int MAX_DIGIT = 50;
ll dp[100][2];


void chmax(ll &a,ll b) {
	if (a < b)a = b;
}



int main() {
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, 0, N)cin >> A[i];

	memset(dp, -1, sizeof(dp));

	dp[0][0] = 0;
	for (int d = 0; d < MAX_DIGIT; d++) {
		ll mask = 1LL << (MAX_DIGIT-d-1);

		int num=0;
		rep(i, 0, N)if (mask&A[i])num++;

		ll cost0 = mask * num;
		ll cost1 = mask * (N - num);

		if (dp[d][1] != -1) {
			chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));
		}
		if (dp[d][0] != -1) {
			if (K & mask) {
				chmax(dp[d + 1][1], dp[d][0] + cost0);
			}
		}
		if (dp[d][0] != -1) {
			if (K & mask) {
				chmax(dp[d + 1][0], dp[d][0] + cost1);
			}
			else {
				chmax(dp[d + 1][0], dp[d][0] + cost0);
			}
		}
	}


	cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

template <class Abel> struct BIT {
  vector<Abel> dat[2];
  Abel UNITY_SUM = 0;                     // to be set

  /* [1, n] */
  BIT(int n) { init(n); }
  void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

  /* a, b are 1-indexed, [a, b) */
  inline void sub_add(int p, int a, Abel x) {
    for (int i = a; i < (int)dat[p].size(); i += i & -i)
      dat[p][i] = dat[p][i] + x;
  }
  inline void add(int a, int b, Abel x) {
    sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
  }

  /* a is 1-indexed, [a, b) */
  inline Abel sub_sum(int p, int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
    return res;
  }
  inline Abel sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
  }
  /* get_max value */
  Abel get_max_val(int a, int b){
    ll res = 0;
    for (int i = a; i <= b; ++i){
      res = max(res, sum(i, i + 1));
    }
    return res;
  }

  /* debug */
  void print() {
    for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
    cout << endl;
  }
};

int main(){
  int N, K; cin >> N >> K;
  vector<int> A(N); rep(i, N) cin >> A[i];
  vector<int> tmp;
  BIT<ll> bit(N);
  rep(k, K){
    /*
    for (int i = 1; i <= N; ++i) bit.add(i, i + 1, -bit.sum(i, i + 1));
    for (int i = 1; i <= N; ++i) bit.add(i, i + 1, 1);
    for (int i = 1; i <= N; ++i){
      //cout << i - A[i - 1] << " " << i + A[i - 1] + 1 << endl;
      bit.add(max(1, i - A[i - 1]), min(N + 1, i + A[i - 1] + 1), 1);
      bit.add(i, i + 1, -1);
    }*/
    for (int i = 1; i <= N; ++i) bit.add(i, i + 1, -bit.sum(i, i + 1));
    for (int i = 1; i <= N; ++i){
      bit.add(max(1, i - A[i - 1]), min(N + 1, i + A[i - 1] + 1), 1);
    }
    tmp = A;
    for (int i = 1; i <= N; ++i){
      A[i - 1] = bit.sum(i, i + 1);
    }
    if (A == tmp) break;
  }
  for (int i = 1; i <= N; ++i){
    cout << bit.sum(i, i + 1) << " ";
  }
  cout << endl;

}


Measured memory_bytes: 8012
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int NIL = -1;

struct Node {
    int left, right;
    
    Node(int left, int right):left(left), right(right){}
    
};

struct Tree {
    int n; // number of nodes
    vector<int> parent; //parent
    vector<Node> nodes;
    vector<int> depth; //depth
    vector<int> height;
    
    Tree(int n): n(n) {
       parent.assign(n, -2);
       depth.assign(n, 0);
       nodes.assign(n, Node(NIL, NIL));
       height.assign(n, 0);
    }
    
    void addNode(int u, int left, int right) {
        nodes[u].left = left;
        nodes[u].right = right;
        if (left != -1) {
            parent[left] = u;
        }
        if (right != -1) {
            parent[right] = u;
        }
    }
    
    
    void preorder(int u, vector<int>& result) {
        if (u == -1) {
            return;
        }
        Node node = nodes[u];
        result.push_back(u);
        preorder(node.left, result);
        preorder(node.right, result);  
    }
    
    void inorder(int u, vector<int>& result) {
        if (u == -1) {
            return;
        }
        Node node = nodes[u];
        inorder(node.left, result);
        result.push_back(u);
        inorder(node.right, result);  
    }
    
    void postorder(int u, vector<int>& result) {
        if (u == -1) {
            return;
        }
        Node node = nodes[u];
        postorder(node.left, result);
        postorder(node.right, result);
        result.push_back(u);
    }
      
    void printResult(vector<int> result) {
        for (int i = 0; i < result.size(); i++) {
            cout << " " << result[i];
        }
        cout << endl;
    }

 
    void solve() {
        int root = -1;
        for (int i = 0; i < n; i++) {
            if (parent[i] == -2) {
                root = i;
                break;
            }
        }
        
        vector<int> result;
        
        cout << "Preorder" << endl;
        preorder(root, result);
        printResult(result);
        
        result.clear();
        cout << "Inorder" << endl;
        inorder(root, result);
        printResult(result);
        
        result.clear();
        cout << "Postorder" << endl;
        postorder(root, result);
        printResult(result);
       
    }
};

int main() {
    int n;
    cin >> n;
    Tree tree(n);
    for (int i = 0; i < n; i++) {
        int u, l, r;
        cin >> u >> l >> r;
        tree.addNode(u, l, r);   
    }
    tree.solve();
    
    return 0;
}

Measured memory_bytes: 3148
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll a[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll n, m, sum =0;
    cin>>n>>m;
    INPa(a,n);
    foo(i,1,m){
        sum += a[i];
    }
    if(sum>n){
        cout<<-1;
    }else{
        cout<<n-sum;
    }
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8364
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 15, 2018, 12:32 PM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int gcd(
    int x,
    int y
);

int main(int argc, char** argv) {
    int x, y, a;
    scanf("%d %d", &x, &y);
    a = gcd(x, y);
    printf("%d\n", a);
    return (EXIT_SUCCESS);
}

int gcd(int x, int y)
{
        while (x != y)
        {
                if (x > y)      x = x - y;
                else            y = y - x;
        }
        return x;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int l;
  scanf("%d", &l);

  double ans = (double)l * l * l / (double)27.0;

  printf("%.12lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#ifndef TEMPLATE
#define TEMPLATE
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

#endif // TEMPLATE
signed main() {
int ans;
vector<int> A(3);
REP(i,3){
cin >> A[i];
}
sort(A.begin(),A.end());
ans = A[2] - A[0];
answer(ans);
return 0;
}

Measured memory_bytes: 3536
def conb(a, b):
    nume = 1
    deno = 1
    for i in range(b):
        nume *= a - i
        deno *= i + 1

    return int(nume / deno)


n = int(input())

cnt_dict = {}
for i in range(n):
    si = input()
    si_sorted = ''.join( sorted(si) )
    if si_sorted in cnt_dict:
        cnt_dict[ si_sorted ] = cnt_dict[ si_sorted ] + 1
    else:
        cnt_dict[ si_sorted ] = 1

sum = 0
for k in cnt_dict:
    v = cnt_dict[k]
    if v > 1:
        sum += conb(v, 2)

print(sum)


Measured memory_bytes: 17892
#include<stdio.h>
 
 
int main(voi)
{
 
  int n, x, i, j, k, cnt;
 
  while(1)
  {
    scanf("%d %d", &n, &x);

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

    cnt=0;

    for(i=1;i<n;i++)
    {
       for(j=i+1;j<n;j++)
       {
          for(k=j+1;k<=n;k++)
          {
          if(i+j+k==x) cnt++;
          }
       }
    }
    
    printf("%d\n", cnt);
  }
 
  return 0;
   
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
int main()
{
ll n , t ;
cin >> n >> t ;
vector<pair<ll,ll>> v(n);
rep(i,n){
  ll a , b ;
  cin >> a >> b ;
  v[i].first=a;
  v[i].second=b;
}
sort(v.begin(),v.end());
vector<vector<ll>> dp(n+1 ,vector<ll>(t+3010) );
rep(i,n){
  rep(j,t){
    dp[i+1][j]=dp[i][j];
  }
  rep(j,t){
    dp[i+1][j+v[i].first]=max(dp[i+1][j+v[i].first],dp[i][j]+v[i].second);
  }
}
rep(i,n+1)rep(j,t+3010){
  ans=max(ans,dp[i][j]);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 141312
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ans = 0

def solve(p, L):
    #print(p, L)
    if p and len(L) == 1:
        return ((L[0][0] - p[0])**2 + (L[0][1] - p[1])**2) ** 0.5
    result = 0
    for i in range(len(L)):
        result += solve(L[i], L[:i] + L[i+1:]) 
        if p:
            result += ( ((L[i][0] - p[0])**2 + (L[i][1] - p[1])**2) ** 0.5 ) * factorial(len(L)-1)
    return result

def factorial(n):
    a = 1
    for i in range(2, n+1):
        a *= i
    return a

ans = solve(None, xy)

M = factorial(N)
print(ans / M)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
using namespace std;
int x[2][100010],n,v[2],m[2],k,t,q[2];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)	
	{
		scanf("%d",&k);	t=i%2;
		x[t][k]++;
		if (m[t]<x[t][k]) {m[t]=x[t][k];v[t]=k;}		
	}	
	if (v[0]!=v[1])	
		cout<<n-m[0]-m[1]<<endl;
	else
	{
		for (int i=1;i<=100000;i++)
		{
			if (q[0]<x[0][i]&&i!=v[0]) q[0]=x[0][i];
			if (q[1]<x[1][i]&&i!=v[1]) q[1]=x[1][i];
		}
		cout<<min(n-m[0]-q[1],n-m[1]-q[0])<<endl;
						
	}	
	return 0;
} 

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

int main() {
    string S;
    cin >> S;
    if (("01" <= S.substr(0, 2) && S.substr(0, 2) <= "12") ||
        ("01" <= S.substr(2, 2) && S.substr(2, 2) <= "12")) {
        if (("01" <= S.substr(0, 2) && S.substr(0, 2) <= "12") &&
            ("01" <= S.substr(2, 2) && S.substr(2, 2) <= "12")) {
            cout << "AMBIGUOUS" << endl;
        } else if ("01" <= S.substr(0, 2) && S.substr(0, 2) <= "12") {
            cout << "MMYY" << endl;
        } else {
            cout << "YYMM" << endl;
        }
    } else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
r1, c1, r2, c2 = map(int, input().split())
MOD = 10 ** 9 + 7

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def func(r, c):
    if c == 0:
        return r + 1
    return comb(r + c + 2, c + 1, MOD)

def comb(n, r, mod):
    return (g1[n] * g2[r] * g2[n - r]) % mod

for i in range(2, r2 + c2 + 10):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)

print((func(r2, c2) - func(r1 - 1, c2) - func(r2, c1 - 1) + func(r1 - 1, c1 - 1)) % MOD)

Measured memory_bytes: 133036
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

constexpr auto M = 998244353L;

int64_t pow2(int64_t p) {
  if (p == 0) {
    return 1;
  }
  auto pp = pow2(p / 2);
  return ((p%2)?2:1) * pp * pp % M;
}

main() {
  int64_t n;
  cin >> n;
  
  vector<int64_t> x(n), y(n);
  for (auto i : irange(0L, n)) {
    cin >> x[i] >> y[i];
  }
  
  vector<vector<unordered_set<int64_t>>> lines(n, vector<unordered_set<int64_t>>(n));
  vector<bitset<200>> used(n, bitset<200>());
  for (auto i : irange(0L, n)) {
    used[i][i] = true;
    for (auto j : irange(i + 1, n)) {
      if (used[i][j]) {
        continue;
      }
      used[i][j] = true;
      used[j][i] = true;
      lines[i][j].insert(i);
      lines[i][j].insert(j);
      bitset<200> bs;
      bs[i] = true;
      bs[j] = true;
      // y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
      // (y - y1) * (x2 - x1) = (y2 - y1) * (x - x1)
      for (auto k : irange(0L, n)) {
        if ((y[k] - y[i]) * (x[j] - x[i]) != (y[j] - y[i]) * (x[k] - x[i])) {
          continue;
        }
        lines[i][j].insert(k);
        bs[k] = true;
      }
      for (auto k : lines[i][j]) {
        used[k] |= bs;
      }
    }
  }
  
  uint64_t ans = pow2(n);
  ans += M - 1; // empty set
  ans += n * (M - 1); // one size set
  ans %= M;
  // cerr << ans << endl;
  for (auto i : irange(0L, n)) {
    for (auto j : irange(0L, n)) {
      if (lines[i][j].empty()) {
        continue;
      }
      auto m = lines[i][j].size();
      ans += (pow2(m) - 1 - m) * (M - 1);
      ans %= M;
      // cerr << i << "," << j << " " << m << " " << pow2(m) - 1 - m << " " << ans << endl;
    }
  }
  
  cout << ans << endl;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m, d;
    cin >> n >> m >> d;
    ll k = ((ll)n - (1+d) + 1);
    if (d != 0) k *= 2;
    double ans = k * (m-1);
    ans /= (ll)n * n;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int N;
ll x, A[100001];

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

  cin >> N >> x;
  ll a;
  rep(i, N) cin >> A[i];
  
  ll cnt = 0ll;
  rep(i, N-1){
    ll sm = A[i]+A[i+1];
    if (sm <= x) continue;
    
    if (A[i+1] >= sm-x){
      A[i+1]-=(sm-x);
      cnt += (sm-x);
    } else {
      A[i] -= (sm - x - A[i+1]);
      A[i+1] = 0;
      cnt += sm -x;
    }
  }

  cout << cnt << "\n";
  return 0;
}

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

ll dp[114][114514];

int main(){
	int N,W;
	cin>>N>>W;
	vector<ll>w(N),v(N);
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j>=w[i])dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i+1][j]);
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
		}
	}
	cout<<dp[N][W]<<endl;
	return 0;
}


Measured memory_bytes: 91392
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
// 	int t;
// 	cin>>t;
// 	while(t--){
// 		int n;
//         cin>>n;
// 	}
    int n;
    cin>>n;
    int cnt=0;
    bool ch=0;
    for(int i=1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        if(a==b){
            cnt++;
        }
        else{
            cnt=0;
        }
        if(cnt==3){
            ch=1;
            break;
        }
        
    }
    if(ch)cout<<"Yes";
    else cout<<"No\n";
}

Measured memory_bytes: 3636
import itertools
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

l=list([a,b,c,d,e])
sum=99999
for v in itertools.permutations(l):
    s1=0
    for i in range(0,len(v)-1):
        d=v[i]
        if d%10!=0:
            d+=10-(d%10)
        s1+=d
    s1+=v[-1]    
    sum=min(s1,sum)
print(sum)



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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> d(k);
	int a[110][110];
	int snuke[110];
	for (int i = 0; i < n; i++) {
		snuke[i] = 0;
	}
	for (int i = 0; i < k; i++) {
		cin >> d[i];
		for (int j = 0; j < d[i]; j++) {
			cin >> a[i][j];
			snuke[a[i][j]]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (snuke[i] == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}




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

int main()
{
    int N,M;
    cin >> N >> M;
    int ans = N;
    vector<int> A(M);
    rep(i,M){
        cin >> A[i];
    }
    rep(i,M){
        ans -= A[i]; 
    }
    if(ans >= 0){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int x[n],y[n],h[n];
  
  for(int i = 0; i < n; i++)
  {
    cin>>x[i]>>y[i]>>h[i];
  }
  int mh[n];
  
  for(int i = 0; i < 101; i++)
  { 
    for(int j = 0; j < 101; j++)
    {
      int H;
      int flag = 1;
      for(int k = 0; k < n; k++)
      {
        if(h[k] != 0) {
          H = h[k] + abs(i - x[k]) + abs(j - y[k]);
        }
        mh[k] = abs(i - x[k]) + abs(j - y[k]);
      }
      
      for(int l = 0; l < n; l++)
      {
        if(max(H - mh[l], 0) != h[l]) {
          flag = 0;
        }
      }
      if(flag) {
        cout<<i<<" "<<j<<" "<< H << endl;
        return 0;
      }
      
      
      

      // set<int> s;
      
      // for(int l = 0; l < n; l++)
      // {
      //   s.insert(mh[l]);
      // }
      
      // if(s.size() == 1) {
      //   set<int> t;
      //   for(int m = 0; m < n; m++)
      //   {
      //     int minv = min((abs(i - x[m]) + abs(j - y[m]) + h[m]),*s.begin());
      //     t.insert(minv);
      //   }
      //   if(t.size() == 1) {
      //     cout<<i<<" "<<j<<" "<< *s.begin()<< endl;
      //     return 0;
      //   }
        
    }
    
  }
  
  
    
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	string s;
	cin >> s;
	int N = s.size();
	int ansans = 114;
	rep(i,N) {
		char c = s[i];
		int t = 0;
		int ans = 0;
		rep(k,N) {
			if (s[k] == c) {
				t = 0;
			}
			else {
				t++;
				ans = max(ans, t);
			}
		}
		ans = max(ans, t);
		ansans = min(ansans, ans);
	}
	cout << ansans << endl;
	return 0;
}


Measured memory_bytes: 256
# 131 D - Megalomania
N = int(input())
AB = [list(map( int,input().split() )) for i in range(N)]

from operator import itemgetter
AB = sorted(AB, key=itemgetter(1))

rt = 'Yes'
X = []
val = 0
for i in range(N):
    val += AB[i][0]
    X.append( [val, AB[i][1]] )
    if val > AB[i][1] :
        rt = 'No'
        break
print(rt)

Measured memory_bytes: 71700
import scala.util.control.Breaks._

object Main extends App {
  val Array(h, n) = io.StdIn.readLine().split(' ').map(_.toInt)
  val an = io.StdIn.readLine().split(' ').map(_.toInt)
  var sum = 0
  var ans = "No"
  breakable(
    for (a <- an) {
      sum += a
      if (sum >= h) {ans = "Yes"; break()}
    }
  )
  println(ans)
}

Measured memory_bytes: 40696
#include<stdio.h>
#include<string.h>
int main()
{
    char c[1000];
    int i,j,len;
    gets(c);
    len=strlen(c);
    for(i=0; i<len; i++)
    {
        if(i==3)
            printf("8");
        else
            printf("%c",c[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
const int mod=1000000007;
char s[100010];
int n,a[100010],f[100010],nxt[3];
int main(){
	scanf("%s",s);
	while(s[n])a[n+1]=(a[n]+s[n]-'a'+1)%3,n++;
	bool fl=1;
	for(int i=1;i<n;i++)if(s[i]==s[i-1])fl=0;
	if(fl)return puts("1"),0;
	f[n]=1;
	for(int i=0;i<3;i++)nxt[i]=i==a[n]?n:n+1;
	for(int i=n;i--;){
		f[i]=i&&a[i]==a[n];
		for(int c=0;c<2;c++)(f[i]+=f[nxt[(a[i]+c+1)%3]])%=mod;
		nxt[a[i]]=i;
	}
	printf("%d\n",*f);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	void Solve() {
		ULL L; cin >> L;
		UL N; cin >> N;
		vector<ULL> X(N); rep(i, N) cin >> X[i];
		vector<ULL> SR(N + 1), SL(N + 1);
		rep(i, N) SR[i + 1] = SR[i] + X[i] * 2;
		rep(i, N) SL[i + 1] = SL[i] + (L - X[N - 1 - i]) * 2;
		ULL ans = 0;
		rep(t, 2) {
			for (UL i = 1; i < N; i++) {
				ULL tmp = 0;
				UL l = min(i, N - i), r = min(N - i, i + 1);
				tmp += SL[i] - SL[i - l];
				tmp += SR[N - i] - SR[N - i - r];
				tmp -= X[N - i - 1];
				ans = max(ans, tmp);
			}
			swap(SL, SR);
			reverse(X.begin(), X.end());
			rep(i, X.size()) X[i] = L - X[i];
		}
		ans = max(ans, X[N - 1]);
		ans = max(ans, L - X[0]);
		cout << ans << endl;
	}
	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 4992
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

#define INF 1e+9
#define MAX_N 100000

int dp[MAX_N];

int main() {

	int N;
	cin >> N;
	vector<long long> inputs;
	for (int i = 0; i < N; i++) {
		long long x;
		cin >> x;
		inputs.push_back(x);
	}


	fill(dp, dp + N, INF);
	for (int i = 0; i < N; ++i) {
		*lower_bound(dp, dp + N, inputs[i]) = inputs[i]; // 最初に見つかるa[i]以上の要素をa[i]で置き換える
	}
	cout << lower_bound(dp, dp + N, INF) - dp << endl;


	return 0;
}




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

n = int(input())
s = input().rstrip()

ans = -1

for i in range(n):
    x = s[:i]
    y = s[i:]
    z = set()
    res = 0
    for j in range(len(x)):
        if y.count(x[j]) >= 1 and x[j] not in z:
            res += 1
            z.add(x[j])
    ans = max(ans, res)
print(ans)


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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

const int N = 2e5 + 10;
const ll MOD = 1e9 + 7;

vector<int> g[N];
int n;
ll ans[N], m[N];
ll total;

ll binpow(ll a, ll b, const ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll mod_inverse(int x, const ll m = MOD) {
	return binpow(x, m - 2, m);
}

ll mul(ll a, ll b, const ll m = MOD) {
	return a * b % m;
}

int dfs1(int u, int p = -1) {
	int sz = 1;
	for (auto v : g[u]) {
		if (v != p) {
			sz += dfs1(v, u);  
		}
	}
	if (p != -1) {
		total = mul(total, mod_inverse(sz));
		m[u] = mul(m[u], sz);
		m[u] = mul(m[u], mod_inverse(n - sz));
	}
	return sz;
}

void dfs2(int u, int p = -1, ll val = 1) {
	val = mul(val, m[u]);
	ans[u] = mul(total, val);
	for (auto v : g[u]) {
		if (v != p)
			dfs2(v, u, val);
	}
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
    	int a, b; cin >> a >> b;
    	g[a].pb(b);
    	g[b].pb(a);
    }

    fill_n(m + 1, n, 1LL);
    total = 1;
    for (int i = 2; i < n; ++i)
    	total = mul(total, i);
    dfs1(1);
    dfs2(1);

    for (int i = 1; i <= n; ++i) {
    	cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 17012
n = gets.chomp.to_i
count = 0
arr = []
n.times do 
    x, y = gets.chomp.split(" ").map(&:to_i)
    if x == y
        count += 1
    else
        arr << count
        count = 0
    end
end
arr << count
arr.each do |i|
    if i >= 3
        puts "Yes"
        exit
    end
end
puts "No"

Measured memory_bytes: 14316