akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <queue>

const int INT_INF = 1e9;

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> range(n + 1, INT_INF);
    range[1] = 0;
    int a, b;
    vector<queue<int>> rin(n + 1);
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        rin[a].push(b);
        rin[b].push(a);
    }

    queue<int> q;
    vector<int> parent(n + 1);
    vector<bool> used(n + 1, false);
    used[1] = true;
    q.push(1);
    while (!q.empty())
    {
        int temp = q.front();
        q.pop();
        while (!rin[temp].empty())
        {
            int i = rin[temp].front();
            rin[temp].pop();
            if (used[i] == false)
            {
                q.push(i);
                used[i] = true;
                parent[i] = temp;
                range[i] = min(range[i], range[temp] + 1);
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)
    {
        cout << parent[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 71640
#include <stdio.h>
#include <ctype.h>

int main(void){

	char ch;

	do{
		scanf("%c", &ch);

		if(islower(ch)){
			ch = toupper(ch);	//?°???????????????§???????????????
		}
		else if(isupper(ch)){
			ch = tolower(ch);	//??§?????????????°????????????????
		}

		printf("%c" ,ch);

	}while(ch != '\n');

	return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<pair<long, long>> vec;
  rep (i, N) {
    long a, b;
    cin >> a >> b;
    vec.push_back(make_pair(b, a));
  }
  sort(vec.begin(), vec.end());

  long current = 0;
  for (auto it: vec) {
    current += it.second;
    if (current > it.first) {
      cout << "No" << endl;
      return;
    }
  }

  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 6512
#include<cstdio>
using namespace std;

long long n, k;

int main(void) {
	scanf("%lld%lld", &n, &k);
	if (k % 2 == 0) {
		long long cur1 = 0, cur2 = 0;
		for (long long i = 1; i <= n; ++ i) {
			if (i % k == 0) ++ cur1;
		}
		for (long long i = 1; i <= n; ++ i) {
			if (i % k == (k/2)) ++ cur2;
		}
		printf("%lld\n", cur1 * cur1 * cur1 + cur2 * cur2 * cur2);
	} else {
		long long cur = 0;
		for (long long i = 1; i <= n; ++ i) {
			if (i % k == 0) ++ cur;
		}
		printf("%lld\n", cur * cur * cur);
	}
	return 0;
}

Measured memory_bytes: 128
X, N = map(int, input().split())

if N==0:
  print(X)
  exit(0)
  
p = [int(i) for i in input().split()]

for i in range(X+1):
  for s in [-1,1]:
    a = X + i*s
    if a not in p:
      print(a)
      exit(0)
  

Measured memory_bytes: 9168
#include<iostream>

using namespace std;

int main(){
    int bingo[3][3];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> bingo[i][j];
        }
    }

    int n;

    cin >> n;

    for(int i=0;i<n;i++){
        int v; cin >> v;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(bingo[j][k]==v)bingo[j][k]=-1;
            }
        }
    }

    bool ans  = false;
    for(int i=0;i<3;i++){
        if(bingo[i][0]==-1 && bingo[i][1]==-1 && bingo[i][2]==-1){
            ans = true;
        }
        if(bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i]==-1){
            ans = true;
        }
    }

    if(bingo[0][0] == -1 && bingo[1][1]==-1 && bingo[2][2]==-1)ans=true;
    if(bingo[0][2] == -1 && bingo[1][1]==-1 && bingo[2][0]==-1)ans=true;

    if(ans)cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
using System;

namespace Free_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int X = int.Parse(str[1]);
            int T = int.Parse(str[2]);
            int output;
            int amari;

            output = N / X;
            amari = N % X;
            if (amari > 0)
            {
                output += 1;
            }
            output = output * T;
            Console.WriteLine(output);
        }
    }
}


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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}

#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>







int main()
{
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n=Int,m=Int;
    cout<<max(0,n-(m*2))<<endl;
    
    return 0;
}




Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r * g * b

for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            continue
        k = 2*j - i
        if k >= n or s[k] == s[i] or s[k] == s[j]:
            continue
        ans -= 1
        
print(ans)

Measured memory_bytes: 73532
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const int INF = 1e18L+5;
/*
int power(int x,int y)
{
	int res=1;
	while(y>0)
	{
		if(y%2==1)
			res=(res*x)%mod;
		x=(x*x)%mod;
		y=y/2;
	}
	return res;
}
*/
int32_t main()
{
	//cout.precision(10);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				if(i*j==n)
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
		cout<<"No"<<endl;
		return 0;
		
	}
}


Measured memory_bytes: 256
s=input()
ans="WA"
if s[0]=="A":
    if s[2:-1].count("C")==1:
        s=list(s)
        s.remove("A")
        s.remove("C")
        for j in range(len(s)):
            if ord(s[j])<ord("a"):
                break
        else:
            ans="AC"
print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	int n;cin>>n;
	vector<string> s(2);
	rep(i,2) cin>>s[i];
	deque<int> vertical;
	rep(i,n) if(s[0][i]==s[1][i]) vertical.push_back(i);
	vertical.push_back(n);
	vector<int> dp(n+1);
	dp[0]=1;
	bool flag = false;
	rep(i,n){
		if(i==vertical.front()){
			if(i==0) dp[i+1]=3;
			else if(flag) dp[i+1]=dp[i]*2%mod;
			else dp[i+1]=dp[i];
			vertical.pop_front();
			flag=true;
		}
		else{
			if(i==0) dp[i+2]=6;
			else if(flag)dp[i+2]=dp[i]*2%mod;
			else dp[i+2]=dp[i]*3%mod;
			flag=false;
			i++;
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum2(int n, int total, int stage)
{
  int count = 0;

  if (stage == 4) {
    if (total == n) return 1;
    return 0;
  }

  if (total > n) return 0;

  for (int i = 0; i < 10; i++) {
    count += sum2(n, total + i, stage + 1);
  }

  return count;
}

int sum(int n)
{
  int count = 0;

  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++)
        for (int l = 0; l < 10; l++)
          if (i + j + k + l == n) count++;

  return count;
}

int main(void)
{
  int n;

  while (cin >> n) cout << sum2(n, 0, 0) << endl;

  return 0;
}

Measured memory_bytes: 3092
class Sieve: 
    
    def __init__(self, n=1):
        self.f = [0 for _ in range(n+1)]
        self.f[0] = -1
        self.f[1] = -1
        self.primes = []
        for i in range(2, n+1):
            if self.f[i]:
                continue
            self.primes.append(i)
            self.f[i] = i
            for j in range(i*i, n+1, i):
                if not self.f[j]:
                    self.f[j] = i
    
    def isPrime(self, x):
        return self.f[x] == x
    
    def factorList(self, x):
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res
    
    def factor(self, x):
        fl = self.factorList(x)
        if not len(fl):
            return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res



n = int(input())

s = Sieve(10**6+10)

prime_list = []
for i in range(2, 10**6+10):
    if s.isPrime(i):
        prime_list.append(i)

e = 1
pos = 0
ans = 0
while pos < len(prime_list) and n >= prime_list[pos]:
    p = prime_list[pos]
    if n%(p**e) == 0:
        ans += 1
        n //= p**e
        e += 1
    else:
        while n%p == 0:
            n //= p
        pos += 1
        e = 1

if n > 1:
    ans += 1
print(ans)


Measured memory_bytes: 142048
n,l = map(int, input().split())
L = []
for i in range(n):
    L.append(i+l)
S = sum(L)
e = 10**9+7
ans = 0
for i in range(n):
    A = L.copy()
    A.pop(i)
    s = sum(A)
    d = abs(S-s)
    if d < e:
        e = d
        ans = s
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long

#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

int MIN(int a, int b)
{
    return (a > b) ? b : a;
}



void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    int q; cin >> q;
    vector<int> B(q);
    vector<int> C(q);
    rep(i, q) cin >> B[i] >> C[i];

    map<int, int> mp ={};
    for (int i = 0; i < n; i++) mp[A[i]]++;

    int sum = 0;
    for (int i = 0; i< n;i++) sum += A[i];
    vector<int> ans;

    for (int i = 0; i< q; i++) {
        int b = mp[B[i]];
        sum = sum - B[i]*b + C[i]*b;
        mp[B[i]] = 0;
        mp[C[i]] += b;

        ans.push_back(sum);

    }

    for (auto a:ans) cout << a << endl;




}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 12228
#include <iostream>

using namespace std;
const int N = 2e5 + 1;
int a[N] , n;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long ans = 0;
    for (int i = 2; i <= n; i++)
        if (a[i - 1] > a[i]) ans = ans + (a[i - 1] - a[i]) , a[i] = a[i - 1];
    cout << ans;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int clamp(ll a, ll low, ll high)
{
	if(a<low)return low;
	else if(a>high)return high;
	else return a;
}

int main()
{
	int a,b,q;cin>>a>>b>>q;
	vector<ll> s(a);
	vector<ll> t(b);
	vector<ll> x(q);
	int i;
	rep(i,a)cin>>s[i];
	rep(i,b)cin>>t[i];
	rep(i,q)cin>>x[i];
	rep(i,q)
	{
		ll ans=123456789012;
		int inds=lower_bound(all(s),x[i])-s.begin();
		int indt=lower_bound(all(t),x[i])-t.begin();
		int j,k;
		rep(j,2)rep(k,2)
		{
			int is=clamp(inds-j,0,a-1);
			int it=clamp(indt-k,0,b-1);
			ll kans=0;
			if(x[i]>max(s[is],t[it])||x[i]<min(s[is],t[it]))
			{
				kans+=max(abs(x[i]-s[is]),abs(x[i]-t[it]));
			}
			else
			{
				kans+=max(abs(x[i]-s[is]),abs(x[i]-t[it]));
				kans+=min(abs(x[i]-s[is]),abs(x[i]-t[it]))*2;
			}
			ans=min(ans,kans);
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    if(T1*A1+T2*A2 < T1*B1+T2*B2){
        swap(A1, B1);
        swap(A2, B2);
    }
    if(T1*A1+T2*A2 == T1*B1+T2*B2){
        cout << "infinity" << endl;
        return 0;
    }
    if(T1*A1 > T1*B1){
        cout << 0 << endl;
        return 0;
    }
    ll d = T1*A1+T2*A2 - (T1*B1+T2*B2);
    ll m = (T1*B1 - T1*A1);
    ll c = m/d;
    ll ans = c*2+1;
    if(m%d == 0){
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    one_set = set([])
    two_set = set([])
    three_set = set([])

    count = 0
    for i in range(n):
        if i==0:
            one_set.add(s[0])
            continue

        if 2<=i:
            for two in two_set:
                if two + s[i] not in three_set:
                    three_set.add(two + s[i])
                    count+=1

        for one in one_set:
            two_set.add(one + s[i])
        one_set.add(s[i])

    print(count)

if __name__=="__main__":
    main()


Measured memory_bytes: 9224
n=int(input())
A=list(map(int, input().split(" ")))
B=list(map(int, input().split(" ")))

#足りない合計
short=0
arr=[]
count=0
for i,j in zip(A,B):
    if i<j:
        short+=j-i
        count+=1
    else:
        arr.append(i-j)

arr.sort()

if short==0:
    print(0)
else:
    for i in arr[::-1]:
        short-=i
        count+=1
        if short<=0:
            break
    if short>0:
        print(-1)
    else:
        print(count)

Measured memory_bytes: 18164
#include <iostream>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    
    int route[2 * m]; 
    int sum[n];
    for (int i = 0; i < 2 * m; i++) {
        cin >> route[i];
    }   

    for (int i = 0; i < n; i++) {
        sum[i] = 0;
        for (int j = 0; j < 2 * m; j++) {
            if (i + 1 == route[j]) {
                sum[i] += 1;
            }   
        }   
    }   

    for (int i = 0; i < n; i++) {
        cout << sum[i] << endl;
    }   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b,c;
bool ab[100000],ac[100000],bc[100000];
bool judge(char a,char b){return (a=='?'||b=='?'||a==b);}
int main()
{
    cin>>a>>b>>c;
    int l1=a.size(),l2=b.size(),l3=c.size(),ans=6000;
    for(int i=0;i<l1;i++) for(int j=0;j<l2;j++) if(!judge(a[i],b[j])) ab[i-j+50000]=1;
    for(int i=0;i<l1;i++) for(int j=0;j<l3;j++) if(!judge(a[i],c[j])) ac[i-j+50000]=1;
    for(int i=0;i<l2;i++) for(int j=0;j<l3;j++) if(!judge(b[i],c[j])) bc[i-j+50000]=1;
    for(int i=-4000;i<=4000;i++){
        for(int j=-4000;j<=4000;j++){
            if(!(ab[i+50000]||ac[j+50000]||bc[j-i+50000])) ans=min(ans,max(l1,max(l2+i,l3+j))-min(0,min(i,j)));
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;
typedef unsigned long long ull;

const ull B1 = (ull)1e9 + 7;
const ull B2 = (ull)1e9 + 9;
int H, W, R, C;
vector<string> s, p;
vector< vector<ull> > HASH[2];

vector< vector<ull> > compute_hash(vector<string> &s, int h, int w, int r, int c) {
  vector< vector<ull> > res(h, vector<ull>(w, 0)), tmp = res;
  ull t1 = 1, t2 = 1;
  for (int i = 0; i < c; i++) t1 *= B1;
  for (int i = 0; i < h; i++) {
    ull e = 0;
    for (int j = 0; j < c; j++) e = e * B1 + s[i][j];
    for (int j = 0; j + c <= w; j++) {
      tmp[i][j] = e;
      if (j + c >= w) continue;
      e = e * B1 + s[i][j + c] - s[i][j] * t1;
    }
  }
  for (int i = 0; i < r; i++) t2 *= B2;
  for (int j = 0; j < w; j++) {
    ull e = 0;
    for (int i = 0; i < r; i++) e = e * B2 + tmp[i][j];
    for (int i = 0; i + r <= h; i++) {
      res[i][j] = e;
      if (i + r >= h) continue;
      e = e * B2 + tmp[i + r][j] - tmp[i][j] * t2;
    }
  }
  return res;
}

int main(void) {
  cin >> H >> W;
  s.resize(H);
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }
  cin >> R >> C;
  p.resize(R);
  for (int i = 0; i < R; i++) {
    cin >> p[i];
  }

  if (R <= H && C <= W) {
    HASH[0] = compute_hash(s, H, W, R, C);
    HASH[1] = compute_hash(p, R, C, R, C);
    
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (HASH[0][i][j] != HASH[1][0][0]) continue;
        cout << i << " " << j << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 28328
#include<stdio.h>
int main(void)

{
	int a;
	int b;
	int c;
	int d;
	
	scanf("%d %d", &a, &b);
	
	c = a * b;
	d = 2 * (a + b);
	
	printf("%d %d\n", c, d);
	
	return 0;
}



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

using namespace std;

int main() {
    long long n;
    cin >> n;

    long long max = 10, z = 1;
    while (5*max < 1000000000000000000) {
        max *= 5;
        z++;
    }

    if (n % 2 == 0) {
        long long count = 0;
        while (z > 0) {
            if (n / max > 0) {
                count += z * (n / max - n / (max*5));
            }
            z--;
            max /= 5;
        }
        cout << count << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static final String BR = System.getProperty("line.separator");
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			StringBuilder sb = new StringBuilder();

			int[][] house = new int[12][10];

			for (int[] rooms : house) {
				for (int room : rooms) {
					room = 0;
				}
			}

			int n = Integer.parseInt(br.readLine());
			String[] strs;

			for (int i = 0; i < n; i++) {
				strs = br.readLine().split("\\s");
				house[(Integer.parseInt(strs[0]) - 1) * 3
						+ Integer.parseInt(strs[1]) - 1][Integer
						.parseInt(strs[2]) - 1] += Integer.parseInt(strs[3]);
			}

			for (int i = 0; i < house.length; i++) {
				for (int j = 0; j < house[i].length; j++) {
					if (j != 0 || j != house[i].length - 1)
						sb.append(" " + house[i][j]);
				}
				sb.append(BR);
				if (i != 0 && i != house.length - 1 && (i + 1) % 3 == 0)
					sb.append("####################" + BR);
			}
			System.out.print(sb);
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

Measured memory_bytes: 19256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    ll ans = 0;
    ll x,y;
    cin >> x >> y;
    ll tmp = x;
    while(tmp <= y){
        ans++;
        tmp *= 2;
    }
    cout << ans;
}

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

template <typename t>
void mi(t& a, const t& b) { a = min(a, b); }

template <typename t>
void ma(t& a, const t& b) { a = max(a, b); }

constexpr int g1 = 1000 * 1000 * 1000, si = 1024 * 1024, si_log = 10 + 10, mod = static_cast<int>(1e9) + 7;
constexpr long double eps = 1.0e-9;
int n, ar[si], br[si];
char car[si];
vector<int> gr[si];
int64_t zi[100];

int64_t sol()
{
  auto r = 0 * numeric_limits<int64_t>::max();

  if (0 == zi[0])
  {
    zi[0] = 2;
    zi[1] = 1;
    for (int i = 2; i <= 87; ++i)
    {
      zi[i] = zi[i-2] + zi[i-1];
    }
  }

  r += zi[n];
  return r;
}

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

  while (1 == scanf("%d", &n))
  {
    auto s = sol();
    //puts(s ? "Yes" : "No");
    cout << s << '\n';
#ifndef _DEBUG
    break;
#else
    for (int i = 0; i <= n + 2; i++)
    {
      gr[i].clear();
    }
    memset(car, 0, sizeof car);
    memset(ar, 0, sizeof ar);
    memset(br, 0, sizeof br);
#endif
  }
  return 0;
}


Measured memory_bytes: 26880
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
string s;
int n, q;
int temp[100003] = {};
int sum[100003] = {};
int mem[2][100005];
int ans[100005];
int a,b;
int main() {
	cin >>n>>q>> s;
	
	for (int i = 0; i < q; i++)
	{
		cin >> a >> b;
		mem[0][i] = a > 0 ? a : 1;
		mem[1][i] = b;
	}
	for (int i = 0; i < n; i++)
	{
		if (i) {
			if (s[i] == 'C'&&s[i - 1] == 'A')
			{
				sum[i]++;
			}
		}
		sum[i + 1] = sum[i];
	}
	for (int i = 0; i < q;i++)
	{
		cout << sum[mem[1][i]-1] - sum[mem[0][i]-1] << endl;
	}

}

Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;



void solve() {
  string S;
  cin>>S;
  int w = 0;
  int left = 15 - S.size();
  for (char c:S)
  	if (c == 'o') w++;
  if (w +left >= 8)
  	cout<<"YES"<<endl;
  else
  	cout<<"NO"<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
//  Created by liszt on 2019/07/31.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,i; cin>>n;
    int x[200000],y[200000];
    for(i=0;i<n;i++){
        cin>>x[i];
        y[i]=x[i];
    }
    
    sort(y,y+n);
    
    int a=y[n/2-1],b=y[n/2];
    
    for(i=0;i<n;i++){
        if(x[i]<=a)cout<<b<<endl;
        else cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    for p in P:
        # 期待値
        # 累積和
        exp += (1+p)/2
        p_e.append(exp)  
    if n == k:
        print(p_e[-1])
    else:
        # 初期値
        maxv = p_e[k-1] - p_e[0]
        for i in range(1, n-k):
            # 隣接するk個の期待値の和
            p_sum = p_e[k+i] - p_e[i]
            maxv = max(maxv, p_sum)
        print(maxv)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 32316
#include <iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b;
  b = a;
  sort(b.rbegin(),b.rend());
  rep(i,n){
    if(a[i]==b[0]){
      cout << b[1] << endl;
      continue;
    }
    cout << b[0] << endl;
  }
}


Measured memory_bytes: 3200
N,M=map(int,input().split())
cards_l=1
cards_r=N


for i in range(M):
    l,r=map(int,input().split())
    cards_l=max(cards_l,l)
    cards_r=min(cards_r,r)
    #print(r,cards_r)
print(max(0,cards_r-cards_l+1))

Measured memory_bytes: 3060
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    dist = [-1]*(n+1)
    que = deque([1])
    dist[1] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            ans[w] += ans[v]
            que.append(w)

n, q  = MAP()
g = [[] for i in range(n+1)]
ans = [0]*(n+1)
for i in range(n-1):
    a, b = MAP()
    g[a].append(b)
    g[b].append(a)
for i in range(q):
    p, x = MAP()
    ans[p] += x
#for i in range(1,n+1):
#    ans[i] += ans[g[i]]
bfs()
for i in range(1, n+1):
    print(ans[i])

Measured memory_bytes: 62340
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


def stringToList(_string, split=" "):
    str_list = []
    temp = ''
    for x in _string:
        if x == split:  # 区切り文字
            str_list.append(temp)
            temp = ''
        else:
            temp += x
    if temp != '':  # 最後に残った文字列を末尾要素としてリストに追加
        str_list.append(temp)
    return str_list


s = input()
t = input()
firstMatch = False
out = listToString(["z" for i in range(len(s))])
# tがiからスタートするとして全探索O(n^2)<=50*50
for i in range(len(s) - len(t) + 1):
    localStr = []
    match = True
    for j in range(i):  # i番目まではsの?をaで置き換えるだけ
        if s[j] == "?":
            localStr.append("a")
        else:
            localStr.append(s[j])
    for j in range(i, i+len(t)):
        # print("i:{} j:{}".format(i, j))
        # print("s[j]:{} t[j-i]:{}".format(s[j], t[j-i]))
        if s[j] != t[j - i]:
            if s[j] == "?":
                localStr.append(t[j - i])
            else:
                match = False
                break
        else:
            localStr.append(s[j])
    for j in range(i+len(t), len(s)):
        if s[j] == "?":
            localStr.append("a")
        else:
            localStr.append(s[j])
    # print("match:{}".format(match))
    if match:
        firstMatch = True
        if listToString(localStr) < out:
            # print("local:{} out:{}".format(localStr, out))
            out = listToString(localStr)
if firstMatch:
    print(out)
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        mut a: usize,
        mut b: usize,
        mut c: usize,
        s: [Chars; n],
    };
    let mut ans = vec!['_'; n];
    for (i, s_i) in s.iter().enumerate() {
        match (s_i[0], s_i[1]) {
            ('A', 'B') => {
                if a == 0 && b == 0 {
                    println!("No");
                    return;
                } else if a == 0 {
                    a += 1;
                    b -= 1;
                    ans[i] = 'A';
                } else if b == 0 {
                    a -= 1;
                    b += 1;
                    ans[i] = 'B';
                } else {
                    if i < n - 1 && (s[i + 1][0], s[i + 1][1]) == ('B', 'C') {
                        a -= 1;
                        b += 1;
                        ans[i] = 'B';
                    } else {
                        a += 1;
                        b -= 1;
                        ans[i] = 'A';
                    }
                }
            }
            ('A', 'C') => {
                if a == 0 && c == 0 {
                    println!("No");
                    return;
                } else if a == 0 {
                    a += 1;
                    c -= 1;
                    ans[i] = 'A';
                } else if c == 0 {
                    a -= 1;
                    c += 1;
                    ans[i] = 'C';
                } else {
                    if i < n - 1 && (s[i + 1][0], s[i + 1][1]) == ('B', 'C') {
                        a -= 1;
                        c += 1;
                        ans[i] = 'C';
                    } else {
                        a += 1;
                        c -= 1;
                        ans[i] = 'A';
                    }
                }
            }
            ('B', 'C') => {
                if b == 0 && c == 0 {
                    println!("No");
                    return;
                } else if c == 0 {
                    b -= 1;
                    c += 1;
                    ans[i] = 'C';
                } else if b == 0 {
                    b += 1;
                    c -= 1;
                    ans[i] = 'B';
                } else {
                    if i < n - 1 && (s[i + 1][0], s[i + 1][1]) == ('A', 'C') {
                        b -= 1;
                        c += 1;
                        ans[i] = 'C';
                    } else {
                        b += 1;
                        c -= 1;
                        ans[i] = 'B';
                    }
                }
            }
            _ => unreachable!(),
        }
    }
    println!("Yes");
    for a in ans {
        println!("{}", a);
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct coin {
  ll g; ll s; ll b;
};

auto gs = [](coin x, coin y) { return x.g-x.s<y.g-y.s; };
auto gb = [](coin x, coin y) { return x.g-x.b>y.g-y.b; };
auto sb = [](coin x, coin y) { return x.s-x.b>y.s-y.b; };

int main() {
  ll X, Y, Z; cin >> X >> Y >> Z;
  coin c[X+Y+Z];
  rep(i,X+Y+Z) {
    ll A, B, C; cin >> A >> B >> C;
    c[i] = (coin){A,B,C};
  }
  sort(c,c+X+Y+Z,gs);
  priority_queue<coin, vector<coin>, decltype(sb)> ql(sb); 
  priority_queue<coin, vector<coin>, decltype(gb)> qr(gb); 
  ll resl[Z+1]={}, resr[Z+1]={};
  rep(i,Y+Z) {
    if (i<Y) { ql.push(c[i]); resl[0]+=c[i].s; continue;}
    coin tl = ql.top();
    if (tl.s-tl.b<c[i].s-c[i].b) {
      ql.pop(); ql.push(c[i]);
      resl[i-Y+1] = resl[i-Y] - tl.s + tl.b + c[i].s;
    }
    else resl[i-Y+1] = resl[i-Y] + c[i].b;
  }
  rep(i,X+Z) {
    ll ri = (X+Y+Z-1)-i;
    if (i<X) { qr.push(c[ri]); resr[Z]+=c[ri].g; continue;}
    coin tr = qr.top();
    if (tr.g-tr.b<c[ri].g-c[ri].b) {
      qr.pop(); qr.push(c[ri]);
      resr[Z-(i-X+1)] = resr[Z-(i-X)] - tr.g + tr.b + c[ri].g;
    }
    else resr[Z-(i-X+1)] = resr[Z-(i-X)] + c[ri].b;
  }

  // rep(i,Z+1) cout << resl[i] << " " << resr[i] << endl;
  // for (auto x: c) cout << x.g << " " << x.s << " " << x.b << endl;
  ll result = 0; rep(i,Z+1) result = max(result, resl[i]+resr[i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

VVI ed;
VI ord;
vector<bool> used;

template <typename T> struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
};

void dfs(int from, int to) {
  used.at(to) = true;
  ord.push_back(to);
  for (int nex : ed.at(to)) {
    if (nex == from) {
      continue;
    }
    dfs(to, nex);
  }
  ord.push_back(to);
}

int main() {
  int N, Q;
  cin >> N >> Q;
  ed.resize(N);
  used.resize(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a;
    cin >> b;
    a--;
    b--;
    ed.at(a).push_back(b);
    ed.at(b).push_back(a);
  }
  dfs(-1, 0);
  VVI place(N);
  rep(i, (int)ord.size()) { place.at(ord.at(i)).push_back(i); }

  BIT<ll> b(ord.size());
  rep(i, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    b.add(place.at(p).at(0), x);
    b.add(place.at(p).at(1), -x);
  }
  rep(i, N) {
    cout << b.sum(place.at(i).at(0));
    if (i != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 38384
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
        int x[5];
        for(int i=0;i<5;i++)cin>>x[i];
        for(int i=0;i<5;i++)if(x[i]!=i+1){
             cout<<i+1<<endl;
             return 0;
        }

     }


 


 






    





      

        


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if ( a < b ) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if ( a > b ) { a = b; return 1; } return 0;}

const ll INF = 1LL << 60;
const int MAX = 100100;

// input 
int N;
ll W, weight[110], value[110];

// dp table
ll dp[110][MAX] = {0};

int main() {

    // input
    cin >> N >> W;
    for (int i = 0; i < N; i++)  cin >> weight[i] >> value[i];

    // loop
    for (int i = 0; i < N; i++) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {

            // choose i-th item
            if (sum_w - weight[i] >= 0) {
            chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // don't choose i-th item
            chmax(dp[i+1][sum_w], dp[i][sum_w]);

        }
    }

    // output 
    cout << dp[N][W] << '\n';
}


Measured memory_bytes: 79360
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int H = nextInt();
		int W = nextInt();
		int N = nextInt();
		int[] a = nextInts();

		int[][] x = new int[H][W];
		int w=0;
		int h=0;
		int d=1;
		int idx=0;
		while(h<H){
			while(w>=0&&w<W){
				if(a[idx]!=0){
					x[h][w]=idx+1;
					a[idx]--;
					w+=d;
				}else{
					idx++;
				}
			}
			d*=-1;
			w+=d;
			h++;;
		}

		for(h=0;h<H;h++){
			StringBuffer sb = new StringBuffer();
			for(w=0;w<W;w++){
				sb.append(x[h][w]+" ");
			}
			sb.delete(sb.length()-1, sb.length());
			System.out.println(sb.toString());
		}

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 25684
import re

s = str(input())

s = re.sub('><', '>,0,<', s)

if s[0] == '<' :
  s = '0,' + str(s)
  
if s[-1] == '>' :
  s = str(s) + ',0'
  
s = re.sub('<>', '<,>', s) 

s = s.split('0')

sum = 0

for i in s:
  i = i.split(',')
  cnt = 0
  for j in range(len(i)):
    Len = int(len(i[j]))
    cnt = cnt + 1
    sum = sum + Len * (Len + 1) / 2
    if cnt > 3:
      des = min([len(i[1]),len(i[2])])
      sum = sum - des
    
print(int(sum))

Measured memory_bytes: 14532
/* ex6_2
   seira3 */

#include <stdio.h>
#include <string.h>
#define SIZE 101

int main(void){
    int len;
    char str[SIZE]; //入力を入れる配列を宣言
    for(int i = 0; i < SIZE; i++){ //strを初期化
        str[i] = '0';
    }
    scanf("%s",str); //strに入力
    len = strlen(str); //文字列の長さを取得
    printf("%c%d%c\n",str[0],len-2,str[len-1]); //問題文の指定に沿って出力
    return 0;
}

Measured memory_bytes: 128
import sys
from statistics import median

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A, B = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    if n % 2:
        am = median(A)
        bm = median(B)
        print(int(abs(bm - am) + 1))
    else:
        A.sort()
        B.sort()
        am = (A[n // 2 - 1] + A[n // 2]) / 2
        bm = (B[n // 2 - 1] + B[n // 2]) / 2
        print(int(abs((bm - am) * 2) + 1))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 28784
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
int N, K;
std::cin >> N >> K;
string S;
std::cin >> S;

std::vector<int> moduled;
std::vector<int> dp;
int inx = 0;
// moduled.push_back(1);
if (S[0] == '0')
{
    dp.push_back(1);
    moduled.push_back(0);
    dp.push_back(0);
    moduled.push_back(1);
    ++inx;
}else{
    dp.push_back(1);
    moduled.push_back(1);
}
for (int i = 1; i < S.size(); ++i)
{
    // std::cout << i << "\n";
    if(S[i] == S[i-1]){
        moduled[inx] = moduled[inx] + 1;
    }else{
        ++inx;
        moduled.push_back(1);
        if (S[i] == '0')
        {
            dp.push_back(0);
        }else{
            dp.push_back(1);
        }
    }
}
if (S[S.size()-1] == '0')
{
    dp.push_back(1);
    moduled.push_back(0);
}
int sum;
if(moduled.size() < 2*K + 1){
    sum = accumulate(moduled.begin(), moduled.end(), 0);
}else{
    for (int i = 0; i < (moduled.size() - 2*K - 1)/2 + 1; ++i)
    {
        int new_sum = accumulate(moduled.begin() + 2*i, moduled.begin() + 2*i + 2*K + 1, 0);
        if(new_sum > sum) sum = new_sum;
    }
}
std::cout << sum << "\n";
// for (int i = 0; i < moduled.size(); ++i)
// {
//     std::cout << moduled[i];
// }
}

Measured memory_bytes: 1404
import java.util.Scanner;

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

	public static void main(String[] args) {

		String s = sc.next();

		System.out.print(s.charAt(0));
		System.out.print(s.length() - 2);
		System.out.print(s.charAt(s.length() - 1));

	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N = 3;
  vector<vector<char>> C(N, vector<char>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> C[i][j];
    }
  }
  cout << C[0][0] << C[1][1] << C[2][2] << endl;
  return 0;
}

Measured memory_bytes: 3596
/* 
Rohit645
Rohit Kumar 
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll n, d; cin >> n;
	vector <ll> vec, vec1;
	map<ll,ll> cnt;
	set <ll, greater<ll>> s;
	for (ll i = 0; i < n; i++) {
		ll a; cin >> a;
		vec.pb(a);
		vec1.pb(a);
		cnt[a]++;
		s.insert(a);
	}
	sort(vec1.begin(), vec1.end());
	ll tar = *(s.begin());
	s.erase(s.begin());
	ll tar1 = *(s.begin());
	ll tpm = cnt[tar];
	if (tpm > 1) {
		for (ll i = 0; i < n; i++) {
			cout << tar << endl;
		}
	}
	else {
		for (ll i = 0; i < n; i++) {
			if (vec[i] == tar) {
				cout << tar1 << endl;
			}
			else cout << tar << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 17632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
#define MAP_traverse_ulta(it,x) for(auto it=ED(x); it!=BN(x); it-- )
#define PI 3.14159265358979323846264338327950L

map<int,int> mp;
map<int,int>::iterator it;

int main()
{
    IOS;
    
    int n,k;
    cin>>n>>k;
    map<int,int> mp;

    for (int i = 0; i < n; i++)
    {
        mp[i]=0;
    }
    


    for (int i = 0; i < k; i++)
    {
        int m; cin>>m;
        for (int j = 0; j <m ; j++)
        {
            int x; cin>>x; x=x-1;
            mp[x]=9;
        }
        
    }

    map<int,int>::iterator it;
    int ans = 0;
    MAP_traverse(it,mp){
        if (it->second == 0)
        {
            ans++;
        }
        
    }
    
    cout<<ans;
   
    

  return 0;
     
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int MAX = 1e9;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
ll A, B;

bool enough(vector<ll> h, ll T) {
  // まずB * Tのダメージを全ての魔物に与える
  for (int i = 0; i < N; i++) {
    h[i] -= B * T;
  }

  // 残りの体力が大きい順に、魔物に追加ダメージ(A - B)を与えていく
  ll damage = A - B;
  sort(h.begin(), h.end());
  for (int i = N - 1; i >= 0; i--) {
    if (h[i] <= 0) break;

    ll c = (h[i] + damage - 1) / damage;
    T -= c;
    if (T < 0) break;
    h[i] = 0;
  }

  // 全ての魔物の体力が0以下であればtrueを返す
  bool res = true;
  for (int i = 0; i < N; i++) if (h[i] > 0) {
    res = false;
  }

  return res;
}

int main() {
  // 入力
  cin >> N >> A >> B;
  vector<ll> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];

  ll maxi = 0;
  for (int i = 0; i < N; i++) maxi = max(maxi, h[i]);

  // 何回の爆発で魔物を全滅させられるかについて二分探索
  ll ans;
  ll l = 0, r = maxi / B + 1;
  while (l <= r) {
    ll mid = (l + r) / 2;

    if (enough(h, mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		solve(scanner);
		scanner.close();
	}
	
	public static void solve(Scanner scanner) {
		int size = scanner.nextInt();
		int n = scanner.nextInt();
		int[] array = new int[size];
		for (int i = 0; i < array.length; i++) {
			array[i] = scanner.nextInt();
		}
		Arrays.sort(array);
		int sum = 0;
		for (int i = size-1; i >= size - n; i--) {
			sum += array[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
long long n,w,dp[105][10005];
struct mo{
	long long v,p; 
}a[100];
long long f(long long i,long long peso){
	//cout<<endl<<i<<" "<<peso<<endl;
	if(peso>=w or i>n)return 0;
	if(dp[i][peso]!=-1)return dp[i][peso];
	if(a[i].p+peso<=w){
		long long t=f(i,peso+a[i].p)+a[i].v;
		long long nt=f(i+1,peso);	
		return dp[i][peso]=max(nt,t);
	}
	return dp[i][peso]=f(i+1,peso);
}
int main(){
	cin>>n>>w;
	for(int i=0;i<n;i++)
		cin>>a[i].v>>a[i].p;
	for(int i=0;i<n;i++)
		for(int j=0;j<w;j++)
			dp[i][j]=-1;
	cout<<f(0,0)<<endl;
}



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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    set<int> st;
    int red = 0;
    rep(i, n) {
        if (a.at(i) < 3200)
            st.insert(a.at(i) / 400);
        else
            red++;
    }
    printf("%d %d\n", max(1, (int)st.size()), st.size() + red);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
int main() {
	int n, a, b;
	string ans;
	cin >> n;
	cin >> a;
	if (n % 500 <= a)
		ans = "Yes";
	else
		ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")
 
X,Y = array[0].split(" ").map(&:to_s)
 
hex = { 'A' => 10,
        'B' => 11,
        'C' => 12,
        'D' => 13,
        'E' => 14,
        'F' => 15}
 
if hex[X] == hex[Y]
  puts "="
elsif hex[X] > hex[Y]
  puts ">"
else
  puts "<"
end

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

using namespace std;

int sum[1010];
int main()
{
    sum[1]=1;
    for(int i=2;i<1000;i++)
        sum[i]=i+sum[i-1];
    int a,b;
    cin>>a>>b;
    cout<<sum[b-a]-b<<endl;
    return 0;
}


Measured memory_bytes: 256