akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2461;
ll BIT[50][bm];
int zero[50];
priority_queue<ll> PQ;
inline ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return kotae;
}
inline void query2(int A, int gin, ll ti) {
	int tmp = gin;
	while (gin < bm) {
		if (BIT[A][gin] >= ti) return;
		gin += gin & -gin;
	}
	gin = tmp;
	while (gin > 0) {
		if (BIT[A][gin] >= ti) break;
		BIT[A][gin] = ti;
		gin -= gin & -gin;
	}
	PQ.push(ti << 18 | A << 12 | tmp);
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[50];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[50], D[50];
	rep(i, N) {
		cin >> C[i] >> D[i];
	}

	query2(0, S + 1, 4e12);
	ll zenbu = 0;
	ll owari = (1ll << N) - 1;

	while (zenbu != owari) {
		auto p = PQ.top();
		PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;
		if (ti < query(i, gin)) continue;

		ll ti2 = ti - D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		query2(i, gin2, ti2);

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti - (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) query2(to, gin2, ti2);
		}
		zenbu |= 1ll << i;
	}

	for (int i = 1; i < N; i++) {
		co(ll(4e12 - query(i, 1)));
	}



	Would you please return 0;
}

Measured memory_bytes: 4564
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int&i:v)cin>>i;
    
    int n2=*max_element(v.begin(), v.end());
    
    int goal=n2/2+n2%2;
    int best=-1;
    
    for(int i=0; i<n; i++){
        if(v[i]<n2 && abs(v[i]-goal)<abs(best-goal)) best=v[i];
    }
    
    cout<<n2<<" "<<best;
   
    
    return 0;
}

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

using namespace std;

int main()
{


    string s;
    cin >> s;
    int counter = 0;


    if (s == "RSR") {
        cout <<  1 << endl;
    }

    else {

    for (int i = 0; i < s.size(); i++) {

        if (s[i] == 'R')
        counter++;
    }
      cout << counter << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <stdio.h>

using namespace std;

int main() {
 
	int a, b, c;
	cin >> a >> b >> c;
	b = b + c;
	a = a - c;
	a = a / b;
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e18;

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

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

  rep(i,N){
    if(A[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }

  ll ans=1;
  for(int i=0;i<N;i++){
    if(ans>2*INF/A[i]){
      cout<<-1<<endl;
      return 0;
    }
    ans*=A[i];
    if(ans>INF){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3996
#include <stdio.h>

int grouping(int);

int main(void)
{
	int x,y;
	scanf("%d %d",&x,&y);
 	
 	x = grouping(x);
 	y = grouping(y);

 	if(x == y) printf("Yes");
 	else printf("No");

   	return 0;
}

int grouping(int x)
{
	switch(x)
	{
		case 1: case 3: case 5: case 7:
		case 8: case 10: case 12:
			return 1;
			break;
		case 4: case 6: case 9: case 11:
			return 2;
			break;
		case 2:
			return 3;
			break;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int sumOfAlice = 0;
    int sumOfbob = 0;
    
    sort(a.rbegin(), a.rend());
    
    for (int i = 0; i < n; i++){
        if (i % 2 == 0) sumOfAlice += a[i];
        else sumOfbob += a[i];
    }
    
    int ans = sumOfAlice - sumOfbob;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);
        
        String x=stdIn.next();
        
        if(x.indexOf("7")>=0){
            System.out.println("Yes");
            
        }
        else{
            System.out.print("No");
            
        }
    }

}
        
    



Measured memory_bytes: 35516
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  vector<bool> isPrime(n+1,1);
  isPrime[0]=0;
  isPrime[1]=0;
  REP(i,n+1){
    if(isPrime[i]){
      for(int j=2;i*j<=n;j++){
        isPrime[i*j]=0;
      }
    }
  }
  map<int,int> mp;
  REP2(i,2,n+1){
    int x=i,j=2;
    while(x>1){
      if(isPrime[j] && x%j==0){
        x/=j;
        mp[j]++;
        continue;
      }
      j++;
    }
  }
  ll ans=1;
  REP2(i,2,n+1){
    ans=ans*(mp[i]+1)%1000000007;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int ax[n],ay[n],bx[m],by[m];
	for(int i=0; i<n;i++){
		scanf("%d %d", &ax[i],&ay[i]);}
	for(int i=0;i<m;i++){
		scanf("%d %d",&bx[i],&by[i]);}
	for(int i=0;i<n;i++){
	int menor=1000000000;
	int pos;
		for(int j=0;j<m;j++){
			if(abs(ax[i]-bx[j])+abs(ay[i]-by[j]) < menor){
				menor = abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
				pos = j;}
		}
	printf("%d\n",pos+1);	
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD = 1000000007LL;
const int MAX_N = 700;
const int MAX_SUM = 2020;

int s;
ll dp[MAX_N][MAX_SUM];

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> s;
	dp[0][0] = 1;
	for (int i = 0; i < MAX_N - 1; i++)
		for (int j = 0; j < s; j++)
			if (dp[i][j] != 0)
				for (int d = 3; j + d <= s; d++)
				{
					dp[i + 1][j + d] += dp[i][j];
					while (dp[i + 1][j + d] >= MOD)
						dp[i + 1][j + d] -= MOD;
				}
	
	ll result = 0;
	for (int i = 1; i < MAX_N; i++)
	{
		result += dp[i][s];
		while (result >= MOD)
			result -= MOD;
	}
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 11168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] c = S.toCharArray();
		sc.close();

		for (int i = 1; i < 3; i++) {
			if (c[i - 1] != c[i]) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


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

using ll= unsigned long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif


void solve(){
	ll n,x,m;
	cin>>n>>x>>m;
	vector<ll> p;
	p.push_back(0);
	map<int,int> t;
	ll last = x;
	ll k=n;
	n--;
	t[last] =1;
	p.push_back(x);
	ll now;
	while(n){
		now= (last*last)%m;
		if(t.count(now)){
			break;
		}
		t[now]=1;
		p.push_back(now);
		last = now;
		n--;
	}
	if(n==0){
		for(int i=1;i<p.size();i++){
				p[i] += p[i-1];
		}
		cout<<p.back()<<"\n";
	}else{
		ll pt;
		n= k;
		bool f=1;
		ll len=(p.size()-1);
		for(int i=1;i<p.size();i++){
			// if(i)cout<<p[i]<<endl;
			if(p[i]==now){ 
				pt= i;
				f=0;
			}
			if(f){
				n--;
				len--;
			}
			p[i] += p[i-1];
		}
		ll ans = p[pt-1]+(n/len)*(p.back()-p[pt-1]) + (p[pt+(n%len)-1]-p[pt-1]);
		cout<<ans<<"\n";
	}
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 5936
# -*- coding: utf-8 -*-

class Node_Class():
    def __init__(self, left, right):
        self.left = left
        self.right = right

n = int(raw_input())
node_dic = {}
par_list = [0]*n
sib_list = [0]*n
deg_list = [0]*n
dep_list = [0]*n
hei_list = [0]*n
typ_list = ['']*n
root = 0
for i in range(n):
    root += i
for i in range(n):
    id, left, right = map(int, raw_input().split())
    node_dic[id] = Node_Class(left, right)
#parent
for i in range(n):
    left = node_dic[i].left
    right = node_dic[i].right
    if left > -1:
        par_list[left] = i
        root -= left
    if right > -1:
        par_list[right] = i
        root -= right
par_list[root] = -1
#sibling
for i in range(n):
    left = node_dic[i].left
    right = node_dic[i].right
    if left > -1:
        sib_list[left] = right
    if right > -1:
        sib_list[right] = left
sib_list[root] = -1
#degree
for i in range(n):
    if node_dic[i].left > -1:
        deg_list[i] += 1
    if node_dic[i].right > -1:
        deg_list[i] += 1
#depth
for i in range(n):
    j = i
    while par_list[j] > -1:
        j = par_list[j]
        dep_list[i] += 1
#height
for i in range(n):
    if node_dic[i].left != -1 or node_dic[i].right != -1:
        continue
    j = i
    height = 0
    while par_list[j] > -1:
        j = par_list[j]
        height += 1
        hei_list[j] = max(hei_list[j], height)

#type
for i in range(n):
    if par_list[i] == -1:
        typ_list[i] = typ_list[i] + "root"
    else:
        if node_dic[i].left > -1 or node_dic[i].right > -1:
            typ_list[i] = typ_list[i] + "internal node"
        else:
            typ_list[i] = typ_list[i] + "leaf"
#print
for i in range(n):
    s = "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s" %(i, par_list[i], sib_list[i], deg_list[i], dep_list[i], hei_list[i], typ_list[i])
    print s

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
#define MAX 5000000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % MOD;
    inverse[i] = MOD - (inverse[MOD % i] * (MOD / i)) % MOD;
    finverse[i] = finverse[i - 1] * inverse[i] % MOD;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % MOD *
         finverse[n - k] % MOD;
}

long long x, y;

long long solve();

int main() {
  cin >> x >> y;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  if((x + y) % 3 != 0) return 0;
  smodfact();
  long long ans = 0, cnt = (x + y) / 3;
  for(int i = 0; i <= x; ++i)
    if(cnt + i == x && cnt + (cnt - i) == y) {
      (ans += calccomb(cnt, i)) %= MOD;
    }
  return ans;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  char a[n];
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    a[i]=c;
  }
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1])ans++;
  }
  if(ans+2*k>n-1)cout<<n-1<<endl;
  else cout<<ans+2*k<<endl;
}


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

def count(s):
    m=0
    e=0
    for t in s:
        if t=='(':
            e+=1
        else:
            e-=1
            m=min(m,e)
    return (e,m)
def count_reverse(s):
    m=0
    e=0
    for t in s[::-1]:
        if t==')':
            e+=1
        else:
            e-=1
            m=min(m,e)
    return (e,m)

def main():
    n=int(input())
    S=[input().strip() for _ in range(n)]
    P,M=[],[]
    Z=[0]
    for s in S:
        e,m=count(s)
        if e>0:
            P.append((m,e))
        elif e<0:
            e,m=count_reverse(s)
            M.append((m,e))
        else:
            Z.append(m)
    P.sort(reverse=True); M.sort(reverse=True)
    s_p,s_m=0,0
    for m,e in P:
        if s_p+m<0:
            return 'No'
        s_p+=e
    for m,e in M:
        if s_m+m<0:
            return 'No'
        s_m+=e
    if s_p==s_m and s_p+min(Z)>=0:
        return 'Yes'
    return 'No'

if __name__=='__main__':
    print(main())

Measured memory_bytes: 198984
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

string S_, T;
vector<string> S;

bool match(string s)
{
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] != '?' && s[i] != T[i]) {
            return false;
        }
    }
    return true;
}

int main()
{
    cin >> S_ >> T;
    if (S_.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (size_t i = 0; i <= S_.size() - T.size(); i++) {
        string S_sub = S_.substr(i, T.size());
        if (match(S_sub)) {

            string S_ans(S_.size(), 'a');
            for (size_t j = 0; j < S_ans.size(); j++) {
                if (j >= i && j < i + T.size()) {
                    S_ans[j] = T[j - i];
                } else {
                    if (S_[j] != '?') {
                        S_ans[j] = S_[j];
                    }
                }
            }
            S.push_back(S_ans);
        }
    }

    if (S.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(S.begin(), S.end());
        cout << S.front() << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int l;
char s[1000];
int main(){
	scanf("%d",&l);
	scanf("%s",s+1);
	if (l&1){
		puts("No");
		return 0;
	}
	for (int i=1;i<=l/2;i++){
		if (s[i]!=s[l/2+i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
} 

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

  int H, W;
  cin >> H >> W;
  string S[55];

  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

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

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {

      if (S[i][j] == '#') continue;

      int count = 0;
      for (int k = 0; k < 8; k++) {
        if (i + dy[k] >= 0 && i + dy[k] < H &&
          j + dx[k] >= 0 && j + dx[k] < W) {
          if (S[i + dy[k]][j + dx[k]] == '#') {
            count++;
          }
        }
      }
      S[i][j] = '0' + count;
    }
  }
  for (int i = 0; i < H; i++) {
    cout << S[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

std::vector<std::pair<int64_t, int64_t>> FactorizeIntoPrimeFactors(const int64_t N) {
  std::vector<std::pair<int64_t, int64_t>> result;
  if (N <= 0LL || N == 1LL) {
    return result;
  }
  int64_t remaining = N;
  for (int64_t i = 2LL; i * i <= remaining; ++i) {
    int64_t count = 0LL;
    while (remaining % i == 0LL) {
      ++count;
      remaining /= i;
    }
    if (count > 0LL) {
      result.push_back(std::pair<int64_t, int64_t>(i, count));
    }
  }
  if (remaining > 1) {
    result.push_back(std::pair<int64_t, int64_t>(remaining, 1));
  }
  return result;
}

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t N;
  cin >> N;
  map<int64_t, int64_t> mp;
  // const int64_t L = static_cast<int64_t>(T.length());
  for (int64_t i = 2; i <= N; ++i) {
    vector<Pair> fs = FactorizeIntoPrimeFactors(i);
    for (const auto &f : fs) {
      if (mp.find(f.first) == mp.end()) {
        mp[f.first] = f.second;
      } else {
        mp[f.first] += f.second;
      }
    }
  }
  Mint result = 1;
  for (const auto a : mp) {
    result *= (a.second + 1);
  }
  cout << result.value << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long (int)1e18+1
#define MAX 200001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;
	
int main() {
	int n;
	cin >> n;
	int ans = 0;
	bool flag = false;
	rep(i, 0, n) {
		int x, y;
		cin >> x >> y;
		if (x == y)ans++;
		else ans = 0;
		if (ans == 3)flag = true;
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3596
def abc():
    n, m, c = map(int, input().rstrip().split())
    bmap = list(map(int, input().rstrip().split()))
    cnt = 0
    for i in range(n):
        amap = list(map(int, input().rstrip().split()))
        if sum([a * b for a, b in zip(amap, bmap)]) + c > 0:
            cnt += 1
    print(cnt)


abc()


Measured memory_bytes: 3060
N, M = map(int, input().split())

food = [0] * M
ans = 0

for i in range(N):
    KA = list(map(int, input().split()))
    for j in KA[1:]:
        food[j-1] += 1

for i in range(M):
    if food[i] == N:
        ans += 1
print(ans)


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

using namespace std;
using ll = long long;

int main() {
    int k = 0;
    cin >> k;
    string s = "";
    cin >> s;
    int i = 0;
    int j = k - 1;
    int cnt = 0;
    while(1){
        if(i >= j){
            break;
        }
        while(s[i] != 'W' && i < k){
            i++;
        }
        while(s[j] != 'R' && j > 0){
            j--;
        }
        //cout << i << " " << j << endl;
        if(i < j){
            i++;
            j--;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main()
{
  int n, x, t;
  cin >> n >> x >> t;

  int ans = 0;
  while (n > 0)
  {
    n -= x;
    ans += t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) {
        cin >> ans[i];
        ans[i]--;
        //ans[i] = i % 26;
    }
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
            cout << ret << endl;
        }
        return ret;
    };
    
    ll x = calc_score();
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,c,d,i,x[100000],y=0;
     //char s[100000],z[100000];
     string s,z;
     cin>>s>>z;
     for(i=0;s[i];i++)
     {
         if(s[i]!=z[i])
         {
             y++;
         }
     }
     cout<<y<<endl;




}


Measured memory_bytes: 3856
N = int(input().rstrip())
t = [0 for _ in range(N+1)]
x = [0 for _ in range(N+1)]
y = [0 for _ in range(N+1)]

for i in range(1, N+1):
    t[i], x[i], y[i] = [int(s) for s in input().rstrip().split()]

judge = []
for i in range(N):
    diff_t = t[i+1] - t[i]
    diff_x = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if diff_t >= diff_x and (diff_t - diff_x ) % 2 == 0:
        judge.append(True)
    else:
        judge.append(False)

if all(judge):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12704
#include <cstdio>

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (m * i + j * n - 2 * i * j == k) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int A[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		if(x%2==0 && (x%3&&x%5)) {
			cout<<"DENIED"<<endl;
			return;
		}
	}
	cout<<"APPROVED"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, u, k, n, v, A[101][101] = {};

  scanf("%d", &n);

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

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j != 1)printf(" ");
      printf("%d", A[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 652
n = gets.to_i
aun = 0
flag = true
n.times{
    if gets.chomp == "A"
        aun += 1
    else
        aun -= 1
        if aun < 0
            flag = false
            break
        end
    end
}
puts (aun == 0 && flag) ? "YES" : "NO"


Measured memory_bytes: 8860
#include <cstdio>
#include <vector>
#define pb push_back
int arr[3005];
std::vector<int> adj[3005];
bool dfs(int u, int fa = -1)
{
	for (int v : adj[u])
	{
		if (v != fa && arr[v] < arr[u] && !dfs(v))
			return true;
	}
	return false;
}
int main()
{
	// freopen("AGC010-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	for (int i = 0; i < n; i++)
	{
		if (dfs(i))
			printf("%d ", i + 1);
	}
	puts("");
	return 0;
}


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

int factorial(int n)
{
  int i = n;
  while(i > 1)
  {
  	n *= i - 1;
    i--;
  }
  return n;
}

int main()
{
  int n;
  double sum = 0.0;
  cin >> n;
  vector<pair<double, double>> p(n);
  int count = 0;
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  do{
    for(int i = 0; i < n - 1; i++)
    {
      sum += sqrt(pow((p[i].first - p[i + 1].first), 2.0) + pow((p[i].second - p[i + 1].second),2.0));
    }    
  }while(next_permutation(p.begin(), p.end()));

  cout << fixed << setprecision(10);
  cout << sum / factorial(n) << endl;
}


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

int main(int argc, char const *argv[])
{
	int n,t;
	cin>>n>>t;
	int c,s,ans=10000000;
	for (int i = 0; i < n; ++i)
	{
		cin>>c>>s;
		if (s<=t)
		{
			ans=min(ans,c);
		}
	}
	if (ans==10000000)
	{
		cout<<"TLE\n";
	}
	else
	{
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;


int main(){
    ll c=0,d=0,k=0,n,m,h,w,p,q,ans=0;
    string s,s1,s2;
    cin >> n;
    VI a(n);
    VI b(n);
    rep(i,n){
        cin >> a[i];
    }
    int j=1;
    rep(i,n){
        b[a[i]-1] = j;
        j++;
    }
    rep(i,n){
        cout << b[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
const int maxN = 1e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

inline void NIE() { puts("-1"); exit(0); }

int n, m, res;
int U, V, Kd;
int dep[maxN], sz[maxN], cnt[2];
bool vis[maxN];
int q[maxN], tt;

struct Vec {
	static const int maxE = maxN;
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}e;

struct Rec {
	int x, c;
	inline void operator += (const Rec &v) { x += v.x, c += v.c; }
}a[maxN];

void calc(Rec v) {
	if (v.x == 0) res += abs(v.c);
	else q[++tt] = -v.x * v.c;	
}

int calcdis() {
	q[++tt] = 0;
	sort(q+1, q+tt+1); 
	int p = tt >> 1, res = 0;
	rep (i, 1, tt) res += abs(q[p] - q[i]);
	return res;
}

void dfs(int x, int fa) {
	vis[x] = 1; ++ cnt[dep[x] & 1];
	a[x] = (Rec){0, (dep[x] & 1) ? 1 : -1};
	fore (e, x, y) if (y != fa) {
		if (vis[y]) {
			U = y, V = x, Kd = (dep[U] & 1) == (dep[V] & 1);
		}
		else {
			dep[y] = dep[x] + 1;
			dfs(y, x);
		}
	}
}

void gao(int x, int fa) {
	vis[x] = 1;
	fore (e, x, y) if (y != fa && !vis[y]) {
		gao(y, x);
		a[x] += a[y];
	}
	if (x != 1) calc(a[x]);
}

int main() {

	n = ri(), m = ri();
	rep (i, 1, m) e.link(ri(), ri());

	memset(vis, 0, sizeof vis);
	dfs(1, 0);

	if (((!U && !V) || Kd == 0) && cnt[0] != cnt[1]) NIE(); 
	if ((Kd == 1) && (cnt[0] & 1) != (cnt[1] & 1)) NIE(); 

	if (Kd == 1) { // odd
		int del = (cnt[0] - cnt[1]) >> 1;
		a[U].c += del, a[V].c += del, res += abs(del);
	}
	else if (U) { // even
		a[U].x = -1;
		a[V].x = 1;
	}

	memset(vis, 0, sizeof vis);
	gao(1, 0);

	printf("%d\n", res + calcdis());

	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> v(101);
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        ++v[a];
    }
    int ans = accumulate(v.begin()+ x, v.end(), 0);
    int ans2 = accumulate(v.begin(), v.begin()+ x, 0);
    cout << min(ans, ans2) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){

	long long tan,suu;
	char ch;
	long long sum,ave;
	long long num;
	long long cnt;

	num=0,sum=0,cnt=0;
	while(cin>>tan>>ch>>suu){
		sum+=tan*suu;
		num+=suu;
		cnt++;
		ave=(int)(((double)num/cnt)+0.5);
	}

	cout<<sum<<"\n"<<ave<<endl;

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int a[6];

int solve(){
	for(int i = 0; i < 6; i++){
		scanf("%d",&a[i]);
	}
	int t1 = a[0]*3600+a[1]*60+a[2];
	int t2 = a[3]*3600+a[4]*60+a[5];
	int n = t2 - t1;
	printf("%d %d %d\n",n/3600,(n%3600)/60,n%60);
	return 0;
}

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

Measured memory_bytes: 2596
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    ll now=i;
    double cost=1;
    double plus=0;
    while(now>=1&&now<=k-1){
      cost*=0.5;
      plus+=cost;
      now*=2;
    }
    ans+=(1-plus)/((double)n);
  }
  printf("%.20f\n",ans);
  return 0;
}


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

    int a,b;
    cin >> a >> b;

    int n = a*b;
    rep(i,10000){
        int ta = i * 0.08;
        int tb = i * 0.10;
        if(ta == a && tb == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
#define INF (1<<28)
inline void cmin(int &a, int b) { if(a>b) a = b; }

typedef pair<int, int> P;
int diff(const P& a, const P& b) {
    return abs(a.first-b.first)+abs(a.second-b.second);
}

int w, h, f[128][128];
char buf[128];

int main() {
    for(;;) {
        scanf("%d%d", &w, &h);
        if(w==0 && h==0) return 0;
        memset(f, 0, sizeof(f));
        P g;
        rep(i, h) rep(j, w) {
            scanf("%s", buf);
            if(buf[0]=='S') f[i][j] = 1;
            else if(buf[0]=='G') g = mp(i, j);
            else if(isdigit(buf[0])) f[i][j] = atoi(buf)+1;
        }
        int m = 0;
        rep(i, h) rep(j, w) m = max(m, f[i][j]);
        vector<vector<P> > loc(m);
        vector<vector<int> > dp(m);
        rep(i, h) rep(j, w) if(f[i][j]) {
            loc[f[i][j]-1].push_back(mp(i, j));
            dp[f[i][j]-1].push_back(INF);
        }
        dp[0][0] = 0;
        rep(k, m-1) rep(i, dp[k].size()) rep(j, dp[k+1].size()) {
            cmin(dp[k+1][j], dp[k][i]+diff(loc[k+1][j], loc[k][i]));
        }
        int ans = INF;
        rep(i, dp[m-1].size()) cmin(ans, dp[m-1][i]+diff(loc[m-1][i], g));
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 0
from itertools import product

H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]

move = [(-1, 0), (0, -1), (0, 1), (1, 0)]

cord = []
# cord_prime = []
N = 0

# print(A)

for i, j in product(range(H), range(W)):
    # print(A[i][j])
    if A[i][j] % 2 == 0:
        continue
    else:
        # for di, dj in move:
        #     if j + dj < 0 or i + di < 0 or j + dj >= W or i + di >= H:
        #         continue

        #     if A[i + di][j + dj] % 2:  # 探索が奇数だったら
        #         N += 1
        #         cord.append((i + 1, j + 1, i + di + 1, j + dj + 1))
        #         A[i + di][j + dj] += 1
        #         A[i][j] -= 1
        #         continue

        # なかったら押し付ける
        A[i][j] -= 1
        if i == H - 1:
            # 最終行では隣に押し付ける
            if j != W - 1:
                A[i][j + 1] += 1
                N += 1
                cord.append((i + 1, j + 1, i + 1, j + 2))
            else:
                # 最終マスではなにもしない
                A[i][j] += 1
        else:
            # 基本的に下に押し付ける
            A[i + 1][j] += 1
            N += 1
            cord.append((i + 1, j + 1, i + 2, j + 1))

print(N)
for c in cord:
    print(*c)

# print(A)
# print(A)


Measured memory_bytes: 75004
n=int(input())
A=list(map(int,input().split()))
s=sum(A)
if s%((n*(n+1))//2):
    print('NO')
else:
    k=s//(n*(n+1)//2)
    D=[]
    for i in range(n-1):
        D.append(A[i+1]-A[i]-k)
    D.append(A[0]-A[n-1]-k)
    ans='YES'
    for i in range(n):
        if D[i]>0 or D[i]%n!=0:
            ans='NO'
    print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
int N, K;
int main() {
    cin >> N >> K;
    vector<int> A(N, 0);
    for(int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    int first = K-1;
    int sum = 1;

    if((N-1-first) % (K-1) == 0) {
        sum += (N-1-first) / (K-1);
    }else {
        sum += (N-1-first) / (K-1) + 1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 640
from sys import stdin

n, *a = (int(x) for x in stdin.read().split())

each_count = {n: 0 for n in set(a)}


for n in a:
    each_count[n] += 1

count = 0
for v in each_count.values():
    if v % 2 == 1: count += 1

print(count)

Measured memory_bytes: 23776
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<int> dp(n, 1e9 + 5);
    dp[0] = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j <= i + k; ++j)
        {
            if (j < n)
            {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
  long long int n,x,y,a;
  int k;
 scanf("%lld%d",&n,&k);
 for(;k--;)
   {
     scanf("%lld%lld",&x,&y);
      a=x;
     if(y<n-y)
       {
	 if(y<a && y<n-a)
	   a=y;
       }
     else
       {
	 if(n-y<a && n-y<n-a)
	   a=y;
       }
     
     if(a<n/2)
       printf("%d\n",(int)(a-1)%3+1);
     else
       printf("%d\n",(int)(n-a)%3+1);
   }

  exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n;
	cin >> n;
	int v[n];
	int c[n];
	rep(i,n){
		cin >> v[i];
	}
	rep(i,n){
		cin >> c[i];
	}
	ll ans=0;
	rep(i,n){
		if(v[i]-c[i]>=0){
			ans+=v[i]-c[i];
		}
	}
	cout << ans << endl;
	return 0;
}

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int gcd(int a,int b){
	if(b>a){
		int temp=a;
		a=b;
		b=temp;
	}
	if(b==0){
		return a;
	}
	return (b,b%a);
}


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

#define dcm(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string a, b, c; cin >> a >> b >> c;
    string s = a+b+c;
    if (s=="557" || s=="575" || s=="755") {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n, 0)
k.times do
    gets
    a = gets.chomp.split(" ").map(&:to_i)
    a.each do |e|
        ans[e-1] += 1
    end
end

puts ans.count(0)

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0 ; i<N ; i++){
        cin >> A[i];
        if(i!=N-1){
            cout << A[i] << " ";
        }else{
            cout << A[i] << endl;
        }
    }
    for(int j=1 ; j<=N-1 ; j++){
        int v, k;
        v = A[j];
        k = j-1;
        while(k>=0 && A[k]>v){
            A[k+1] = A[k];
            k--;
        }
        A[k+1] = v;
        int l=0;
        while(l<N-1){
            cout << A[l] << " ";
            l++;
        }
        cout << A[l] << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
# -*- coding:utf-8 -*-

n = int(input())
num = []
town = [0, 0, 0, 0, 0, 0]
time = 0
for i in range(5):
    num.append([int(input()),i])
town[0] = n
#print(num)
#print(type(min(num)))
#print(type(min(num)[1]))
time = (n-1) // min(num)[0] + 5  #1 + (5-min(num)[1])
print(time)

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

int main (void){
  int k = 0,a = 0,b = 0,c = 0;

  cin >> k >> a >> b;

  for(int i = a;i <= b;i++){
  if(i % k == 0){
    cout << "OK\n";
    return 0;
    }
  }
  cout << "NG\n";
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	char tenki[20];
	scanf("%s", tenki);
	
	if(tenki[0]=='S') printf("Cloudy");
	else if(tenki[0]=='C') printf("Rainy");
	else printf("Sunny");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] = sc.nextInt();
        }
        
        int[] c = new int[n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                c[i] += a[i][j] * b[j];
            }
        }
        
        for(int i = 0; i < c.length; i++){
			System.out.println(c[i]);
		}
    }
}


Measured memory_bytes: 40432
// https://atcoder.jp/contests/abc086/tasks/arc089_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int K_MAX = 1000;
const int X_I_MAX = 1e9;
const int Y_I_MAX = 1e9;

int N, K;
int x[N_MAX];
int y[N_MAX];
char c[N_MAX][1 + 1];

int b[K_MAX*2][K_MAX*2];
int w[K_MAX*2][K_MAX*2];
int bacc[K_MAX*4][K_MAX*3];
int wacc[K_MAX*4][K_MAX*3];

void solve() {
  int K2 = K * 2;
  int K3 = K * 3;
  int K4 = K * 4;
  REP(i, N) {
    if (c[i][0] == 'B') {
      b[x[i] % K2][y[i] % K2]++;
    } else {
      w[x[i] % K2][y[i] % K2]++;
    }
  }
  // DUMP2D(b, K2, K2);
  // DUMP2D(w, K2, K2);
  REP(i, K4 - 1) REP(j, K3 - 1) {
    bacc[i + 1][j + 1] = bacc[i][j + 1] + bacc[i + 1][j] - bacc[i][j] + b[i % K2][j % K2];
    wacc[i + 1][j + 1] = wacc[i][j + 1] + wacc[i + 1][j] - wacc[i][j] + w[i % K2][j % K2];
  }
  // DUMP2D(bacc, K4, K4);
  // DUMP2D(wacc, K4, K4);
  int ans = 0;
  REP(i, K2) REP(j, K) {
    int ok = 0;
    ok += bacc[i + K][j + K] - bacc[i][j + K] - bacc[i + K][j] + bacc[i][j];
    ok += bacc[i + K2][j + K2] - bacc[i + K][j + K2] - bacc[i + K2][j + K] + bacc[i + K][j + K];
    ok += wacc[i + K][j + K2] - wacc[i][j + K2] - wacc[i + K][j + K] + wacc[i][j + K];
    ok += wacc[i + K2][j + K] - wacc[i + K][j + K] - wacc[i + K2][j] + wacc[i + K][j];
    // printf("i:%d j:%d ok:%d\n", i, j, ok);
    ans = max(ans, ok);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d%d%s", x + i, y + i, c[i]);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(){
    int n, x, y, m, d;
    char l;
    int field[21][21];
    int rx, ry;
    cin >> n;
    while(n){
        for(int i=0;i<21;++i){
            for(int j=0;j<21;++j){
                field[i][j] = 0;
            }
        }
        rx = 10, ry = 10;
        for(int i=0;i<n;++i){
            cin >> x >> y;
            field[x][y] = 1;
        }
        cin >> m;
        for(int i=0;i<m;++i){
            cin >> l >> d;
            for(int j=0;j<d;++j){
                switch(l){
                    case 'N':
                        ++ry;
                        break;
                    case 'S':
                        --ry;
                        break;
                    case 'E':
                        ++rx;
                        break;
                    case 'W':
                        --rx;
                        break;
                }
                if(field[rx][ry] == 1){
                    field[rx][ry] = 0;
                    --n;
                }
            }
        }
        if(n) cout << "No" << endl;
        else cout << "Yes" << endl;
        cin >> n;
    }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int q;cin>>q;
  rep(i,q){
    ll a,b;cin>>a>>b;
    if(a>b)swap(a,b);

    ll result = 2*(a-1);
    ll l=0, r=1<<30, num;
    while(r-l>1){
      num=(l+r)/2;
      if(a+num>b){
        r=num;
        num=(l+r)/2;
        continue;
      }
      bool ng=false;
      for(ll x = num/2-2; x<=num/2+2 ;x++){
        if(x>num || x<=0)continue;
        if((a+x)*(a+num-x)>=a*b){
          ng=true;
        }
      }
      if(ng)r=num;
      else l=num;
      num=(l+r)/2;
//cout<<num<<' '<<l<<' '<<r<<endl;
    }
    cout<<result + num<<endl;
//    cout<<result<<' '<<num<<' '<<result + num<<endl<<endl;

  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;
    string str;
    cin>>str;
    int n=str.size(),cnt=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]=='?')
        {
            str[i]='D';
            ++cnt;
        }
    }
    cout<<str;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=2e3+7;
const int mod=1e9+7;
ll quick(ll a,ll b)
{
	if(b<0) return 1;
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll dp[maxn][maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	dp[0][n+1]=1;
	for(int i=1;i<=k;i++)
	{
		vc<ll> suf(n+3);
		for(int j=n-i+1+(i==1);j>=1;j--)
			suf[j]=(suf[j+1]+dp[i-1][j])%mod;
		for(int j=1;j<=n-i+1;j++)
		{
			//dp[i][j]=suf[j+1];
			dp[i][j]=(suf[j+1]+dp[i-1][j])%mod;
	//		dbg(i,j,dp[i][j]);
		}
	}
	cout<<dp[k][1]*quick(2,n-k-1)%mod<<endl;
}


Measured memory_bytes: 31104
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = scan.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scan.nextInt();
        }
        long ans = 0;
        for (int j = 0; j < n; j++) {
            int x = Math.min(a[j], b[j]);
            ans += x;
            b[j] -= x;
            int y = Math.min(a[j + 1], b[j]);
            ans += y;
            a[j + 1] -= y;
        }
        System.out.println(ans);
    }
}

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

int main(){
    int n;
    while(cin >> n){
        if(n == -1) break;
        
        if(n == 0){
            cout << 0 << endl;
            continue;
        }

        vector<int> res;
        while(n != 0){
            res.push_back(n%4);
            n /= 4;
        }

        reverse(res.begin(), res.end());
        for(int i : res)    cout << i;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3060