akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main()
{
	int n,k;
	string s;
	cin >> n >> s >> k;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[k-1])
			s[i] = '*';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


bool prime(int n) {
    for (int i = n - 1; i >= 2; i--) {
        if (n%i == 0)return false;
    }
    return true;
}


int main() {
    int n;
    cin >> n;
    for (int i = 31; i <= 55555; i += 5) {
        if (prime(i)) {
            cout << i << ' ';
            n--;
        }
        if (n == 0)break;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(x: int):
    if x==0:
        print(1)
    else:
        print(0)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27140
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
#import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    A.reverse()
    sum_A = sum(A)
    M_1 = 4*M
    b = sum_A / M_1
    #b = (sum_A + (M_1) - 1) / M_1
    flag = True
    for i in range(M):
        if A[i] < b:
            print('No')
            flag = False
            break
    if flag:
        print('Yes')


if __name__ == '__main__':
    main()


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

int main(){
    FasterIO;

    int n;

    while(cin>>n){
        multiset<int>mset;
        int val;

        for(int i=0; i<n; i++){
            cin>>val;

            multiset<int>::iterator it = mset.lower_bound(val);

            if(it==mset.begin())
                mset.insert(val);

            else{
                it--;
                mset.erase(it);
                mset.insert(val);
            }
        }

        cout<<mset.size()<<endl;
    }

    return 0;
}



Measured memory_bytes: 4992
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int m = sc.nextInt();
		List<Integer>[] adj = new ArrayList[m];
		for(int i=0;i<m;++i){
			 adj[i] = new ArrayList<>();
			 int k = sc.nextInt();
			 for(int j=0;j<k;++j){
			 	int s = sc.nextInt()-1;
			 	adj[i].add(s);
			 }
		}
		int[] p = new int[m];
		for(int i=0;i<m;++i) p[i] = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < (1<<n); ++i){
			boolean light = true;
			
			for (int j=0;j<m;++j){
				int on = 0;
				
				for(int bulb : adj[j])
				if(((i>>bulb)&1) == 1) ++on;
				
				on%=2;
				if(on!=p[j]) light = false;
				
			}
			
			if(light) ++ans;
			
		}
		
		System.out.println(ans);
 	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, target;
    cin >> len >> target;
    vector<int> arr(len);
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    long long ans = INT_MAX;
    for(int i = 0; i <= len - target; i++) {
        long long small = arr[i], big = arr[i + target - 1];
        if(small < 0 && big > 0) {
            small = abs(small);
            big = abs(big);
            long long curr = (2 * min(big, small)) + max(big, small);
            ans = min(ans, curr);
        } else {
            ans = min(ans, max(abs(big), abs(small)));
        }
    }
    cout << ans;
}


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

int main() {
  vector<int> A(5);
  int k;
  for(int &i:A)
    cin>>i;
  cin>>k;
  sort(A.begin(),A.end());
  if(A.at(4)-A.at(0)>k)
    cout<<":("<<endl;
  else
    cout<<"Yay!"<<endl;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

lli mygcd(lli a, lli b){
    if(a < b) return mygcd(b, a);
    lli r;
    if(b == 0) return a;
    while(r = a%b){
        a = b;
        b = r;
    }
    return b;
}

int main(void){
    lli n;
    cin >> n;
    vector<lli> a(n);
    for(auto& i : a){
        cin >> i;
    }
    vector<lli> l(n+1, 0);
    vector<lli> r(n+1, 0);
    vector<lli> m;
    for(lli i = 0; i < n; i++){
        l[i+1] = mygcd(l[i], a.at(i));
    }
    for(lli i = n-1; i >= 0; i--){
        r[i] = mygcd(r[i+1], a.at(i));
    }
    for(lli i = 0; i < n; i++){
        m.push_back(mygcd(l[i], r[i+1]));
    }
    cout << *max_element(m.begin(), m.end()) << endl;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

   string s; cin >> s;
   ll n; n = s.size();

   f(i,0,n-1){
        if(s[i]==s[i+1]){
            cout << i+1 << " "<< i+2 << endl;
            return;
        }
   }
   f(i,0,n-2){

        if(s[i]==s[i+2]){
            cout << i+1 << " "<< i+3 << endl;
            return;
        }
   }

   cout << "-1 -1";
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        //factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define VI vector<int>

void dfs(int node, int f, vector<VI> &G, vector<VI> &C, VI &d, int val) {
    d[node] = val;
    for(int i = 0; i < int(G[node].size()); ++i) {
        int temp = G[node][i];
        if(temp == f)
            continue;
        dfs(temp, node, G, C, d, max(val, C[node][i]));
    }
}

int main() {
    //ifstream cin("testA.in");

    int n, m; cin >> n >> m;
    vector<int> a(m, 0), b(m, 0), c(m, 0);
    vector<pair<int, int>> edges;

    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    for(int i = 0; i < m; ++i) {
        edges.push_back({c[i], i});
    }

    sort(edges.begin(), edges.end());

    vector<int> dad(n, 0), sz(n, 0);
    for(int i = 0; i < n; ++i)
        dad[i] = i;

    auto f = [&] (int x) {
        int root = x;
        int steps = 0;
        while(root != dad[root]) {
            root = dad[root];
            ++steps;
        }
        while(x != root) {
            int temp = dad[x];
            dad[x] = root;
            x = temp;
        }
        return root;
    };

    auto unite = [&] (int a, int b) {
        dad[a] = b;
    };
    
    vector<vector<int>> G(n), C(n);
    long long ans = 0;

    for(auto edge : edges) {
        int x = a[edge.second];
        int y = b[edge.second];
        if(f(x) != f(y)) {
            ans += edge.first;
            unite(f(x), f(y));
            G[x].push_back(y);
            G[y].push_back(x);
            C[x].push_back(edge.first);
            C[y].push_back(edge.first);
        }
    }
        
    vector<vector<int>> d(n, vector<int> (n, 0));
    
    for(int i = 0; i < n; ++i) {
        int now = 0;
        dfs(i, -1, G, C, d[i], now);
    }

    int q; cin >> q;
    for(int i = 0; i < q; ++i) {
        int x, y; cin >> x >> y;
        x--;y--;
        cout << ans - d[x][y] << "\n";
    }
}

Measured memory_bytes: 72428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 998244353
#define inf 1000000000000000000
const int sz = 200006;
ll n,k;
vector<ll>h, dp;
ll solve(ll n1) {
	if(n1 <= 0) return 0;
	if(dp[n1] != -1) return dp[n1];
	dp[n1] = inf;
	for(int i = 1; i<=(k < n1?k:n1); i++) {
		dp[n1] = min(dp[n1], solve(n1-i) + abs(h[n1]-h[n1-i]));
	}
	return dp[n1];
}
int main() {
	io
	cin>>n>>k;
	h.resize(n);
	dp.resize(n, -1);
	for(int i = 0; i<n; i++) {
		cin>>h[i];
	}
	dp[0] = 0;
	cout<<solve(n-1);
}




Measured memory_bytes: 6528
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int s = sc.nextInt();
      	String msg = sc.next();
		
      	if(s >= 3200){
			System.out.println(msg);
        } else {
			System.out.println("red");		
        }
      	
	}
}

Measured memory_bytes: 21844
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 998244353
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
   
    
    ll n, m;
    cin >> n >> m;
    if(n > m)
    {
        for(ll i = 0; i < n; ++i)
          cout << m;     
    }  
    else
    {
        for(ll i = 0; i < m; ++i)
          cout << n;    
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	int c = 700;
	for (auto i = 0; i < 3; ++i)
	{
		if (S[i] == 'o')
		{
			c += 100;
		}
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N; cin >> N;
	set<int> S;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		set<int>::iterator where = S.find(a);
		if (where == S.end()) S.insert(a);
		else S.erase(a);
	}

	cout << S.size() << endl;

	return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    ans=10**30
    aaa=[-1,1]
    
    for j in range(2):
        pos=aaa[j]
        S=0
        temp=0
        for i in range(N):
            S+=a[i]
            if S>0:
                Sp=1
            elif S<0:
                Sp=-1
            else:
                Sp=0
            
            
            if Sp!=pos*(-1):
                target=-1*pos
                temp+=abs(target-S)
                S=target
            pos*=-1
        ans=min(ans,temp)
        
    print(ans)
        
        

main()


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

int main() {
  int n;
  std::cin >> n;
  
  std::vector<int> num;
  num.resize(n);
  std::string tmp;
 
  for (int i=0; i<n; i++) {
    std::cin >> num.at(i);
  }
  
  /*
  std::cout << "num = ";
  for (int i=0; i<n; i++) {
    std::cout << num.at(i);
  }
  std::cout << std::endl;
  */
  
  int count=1;
  int k=0;
  for (int i=0; i<n; i++) {
    if (num.at(i) == count) {
      count++;
    } else {
	  k++;
    }
  }
  
  if (n==1 && num.at(0)==1) {
    std::cout << "0" << std::endl;
  } else if (count==1) {
    std::cout << "-1" << std::endl;
  } else {
    std::cout << k << std::endl;
  }
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#define INF 1000000000000LL
using namespace std;

typedef pair<int,int> P;

long long dis[6100];
vector<P> g[6100];
long long g2[310][310];
map<string,int> id;
vector<int> gas;
int n,m,cap,d;
string a,b;

int main(){
  while(scanf("%d%d%d",&n,&m,&cap)!=EOF,n||m||cap){
    id.clear(); gas.clear();
    for(int i=0;i<6100;i++)g[i].clear();
    
    cin >> a >> b;
    id[a] = id.size(); id[b] = id.size();
    gas.push_back(1); gas.push_back(2);

    for(int i=0;i<n;i++){
      cin >> a >> b >> d;
      if(id.find(a) == id.end())id[a] = id.size();
      if(id.find(b) == id.end())id[b] = id.size();
      g[id[a]].push_back(P(d,id[b]));
      g[id[b]].push_back(P(d,id[a]));
    }
    for(int i=0;i<m;i++){
      cin >> a;
      gas.push_back(id[a]);
    }

    for(int i=0;i<gas.size();i++){
      for(int j=0;j<gas.size();j++)g2[i][j] = INF;
      g2[i][i] = 0;
    }

    for(int i=0;i<gas.size();i++){
      for(int j=0;j<=id.size();j++)dis[j] = INF;
      dis[gas[i]] = 0;
      priority_queue<P,vector<P>,greater<P> > q;
      q.push(P(0,gas[i]));
      
      while(q.size()){
	P p = q.top();q.pop();
	long long dist = p.first;
	int pos = p.second;
	
	for(int x=0;x<g[pos].size();x++){
	  int tdis = dist + g[pos][x].first;
	  int nxt = g[pos][x].second;
	  if(dis[nxt] > tdis){
	    dis[nxt] = tdis;
	    q.push(P(tdis,nxt));
	  }
	}
      }
      for(int j=0;j<gas.size();j++){
	if(cap*10<dis[gas[j]])continue;
	g2[i][j] = dis[gas[j]];	
      }
    }

    for(int k=0;k<gas.size();k++)
      for(int i=0;i<gas.size();i++)
	for(int j=0;j<gas.size();j++)
	  g2[i][j] = min(g2[i][j],g2[i][k] + g2[k][j]);

    if(g2[0][1] == INF)cout << -1 << endl;
    else cout << g2[0][1] << endl;
  }
}

Measured memory_bytes: 3260
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!
    val t = readLine()!!

    if (t.startsWith(s)) {
        "Yes"
    } else {
        "No"
    }.let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 35728
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,p;
    cin >> a >> p;
    cout << (3*a+p)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    ll w,a,b;
    cin>>w>>a>>b;
   if(a>b){
    swap(a,b);
   }
   a+w<b?cout<<b-a-w<<endl:cout<<0<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  method(input,set<int>){
    int n = in();
    set<int> s;
    rep(_,n)s.emplace(in());
    return s;
  };
  set<int> x = input();
  set<int> y = input();
  set<int> ans;
  set_intersection(all(x),
                   all(y),
                   inserter(ans,ans.end()));
  foreach(i,ans){
    cout << i << endl;
  }
}



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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
    return 0;
  }
  int a, b;
  cin >> a >> b;
  cout << a+b << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n     int
		count int
	)

	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	flag := true
	for flag {
		for i := 0; i < n; i++ {
			if a[i]%2 == 0 {
				a[i] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ss := append([]byte(s), t[len(t)-1])
	tt := []byte(t)

	if string(ss) == string(tt) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    ll k;
    cin >> s >> k;
    int n = s.length();
    for(ll i = 0; i < n; ++i){
        if(s[i] != '1'){
            cout << s[i] << "\n";
            return 0;
        }
        else{
            if(i == k-1){
                cout << 1 << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int a, b; cin >> a >> b;
  cout << (a + b) % 24 << '\n';
  return 0;
}


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

void out_put(int ans[], int d) {
  for ( int i = 0; i < d; i++ ) {
    printf("%d\n", ans[i]+1);
  }
}

double now_time(clock_t start, clock_t end) {
  return ((double)(end - start) / CLOCKS_PER_SEC);
}

int main() {
  clock_t start = clock();

  int d;
  int c[26];
  int last[26];
  scanf("%d", &d);
  for ( int i = 0; i < 26; i++ ) {
    scanf("%d", &c[i]);
    last[i] = 0;
  }
  int s[d][26];
  for ( int i = 0; i < d; i++ ) {
    for ( int j = 0; j < 26; j++ ) {
      scanf("%d", &s[i][j]);
    }
  }

  // greedy
  int now = 0;
  int val = 0;
  int t[d];
  while ( now < d ) {
    int mx = - (1e9 + 7);
    int select;
    for ( int k = 0; k < 26; k++ ) {
      int val_tmp = val;
      int now_tmp = now;
      int contest = k;
      val_tmp += s[now_tmp][contest];
      now_tmp++;
      for ( int i = 0; i < 26; i++ ) {
        if ( contest == i ) { continue; }
        val_tmp -= c[i]*(now_tmp-last[i]);
      }
      if ( val_tmp > mx ) {
        mx = val_tmp;
        select = contest;
      }
    }
    t[now] = select;
    now++;
    last[select] = now;
    val = mx;
  }

  // local search
  clock_t end;
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand_day(0, d-1);
  uniform_int_distribution<> rand_contest(0, 25);

  end = clock();
  while ( now_time(start, end) < 1.3 ) {
    int change_day = rand_day(mt);
    int after_contest = rand_contest(mt);
    int val_tmp = val;

    int bef_contest = t[change_day];
    t[change_day] = after_contest;
    val_tmp -= s[change_day][bef_contest];
    val_tmp += s[change_day][after_contest];
    
    int last_bef_front = -1;
    for ( int i = change_day-1; i >= 0; i-- ) {
      if ( t[i] == bef_contest ) { last_bef_front = i; break; }
    }
    int last_bef_back = d;
    for ( int i = change_day+1; i < d; i++ ) {
      if ( t[i] == bef_contest ) { last_bef_back = i; break; }
    }
    val_tmp += c[bef_contest]*((change_day-last_bef_front)*(2+(change_day-last_bef_front-1))/2);
    val_tmp += c[bef_contest]*((last_bef_back-change_day)*(2+(last_bef_back-change_day-1))/2);
    val_tmp -= c[bef_contest]*((last_bef_back-last_bef_front)*(2+(last_bef_back-last_bef_front-1))/2);

    int last_after_front = -1;
    for ( int i = change_day-1; i >= 0; i-- ) {
      if ( t[i] == after_contest ) { last_after_front = i; break; }
    }
    int last_after_back = d;
    for ( int i = change_day+1; i < d; i++ ) {
      if ( t[i] == after_contest ) { last_after_back = i; break; }
    }
    val_tmp -= c[after_contest]*((change_day-last_after_front)*(2+(change_day-last_after_front-1))/2);
    val_tmp -= c[after_contest]*((last_after_back-change_day)*(2+(last_after_back-change_day-1))/2);
    val_tmp += c[after_contest]*((last_after_back-last_after_front)*(2+(last_after_back-last_after_front-1))/2);

    if ( val_tmp > val ) {
      val = val_tmp;
    } else {
      t[change_day] = bef_contest;
    }

    end = clock();
  }

  // ans
  out_put(t, d);

  return 0;
}


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


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

    int t = n/100;
    t = 100*t + 10*t + t;
    if (n <= t) printf("%d\n", t);
    else printf("%d\n", t + 111);

    

    return 0;
} 



Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    const char U = 'U';
    const char D = 'D';
    const char R = 'R';
    const char L = 'L';

    int sx,sy,tx,ty;

    if (scanf("%d%d%d%d", &sx, &sy, &tx, &ty) < 4) return 0;

    const int dx = tx - sx;
    const int dy = ty - sy;

    // 内回り 行き
    printf("%s%s", string(dy, U).c_str(), string(dx, R).c_str());

    // 内回り 帰り
    printf("%s%s", string(dy, D).c_str(), string(dx, L).c_str());

    // 外回り 行き
    printf("%s%s%s%s",
        string(1, L).c_str(),
        string(dy + 1, U).c_str(), string(dx + 1, R).c_str(),
        string(1, D).c_str());

   // 外回り 帰り
    printf("%s%s%s%s\n",
        string(1, R).c_str(),
        string(dy + 1, D).c_str(), string(dx + 1, L).c_str(),
        string(1, U).c_str());

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans, n;
int a[200005];
vector<int> v1, v2;

int main(void) {

    scanf("%d", &n);
    rep(i, 1, n+1) scanf("%d", &a[i]);

    for (int i = n; i >= 1; i -= 2) v1.pb(a[i]);
    for (int i = n-1; i >= 1; i -= 2) v2.pb(a[i]);

    for (int i = 0; i < (int)v1.size(); i++) {
        if (i > 0) printf(" ");
        printf("%d", v1[i]);
    }
    for (int i = (int)v2.size()-1; i >= 0; i--) {
        printf(" ");
        printf("%d", v2[i]);
    }
    printf("\n");


	return 0;
}


Measured memory_bytes: 3832
//============================================================================
// Name        : SelectionSort.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int BubbleSort(vector<string>&, const int);
void writeVector(const vector<string>&);
int SelectionSort(vector<string>&, const int);
bool IsStable(vector<string>&, vector<string>&);

bool IsStable(vector<string>& original_v, vector<string>& sorted_v){
	bool isStable = true;
	vector<vector<string> > pairs_with_same_value;
	for(int i=0; i<sorted_v.size()-1; i++){
		if((int)sorted_v.at(i).at(1) == (int)sorted_v.at(i+1).at(1)){
			vector<string> pair;
			pair.push_back(sorted_v.at(i));
			pair.push_back(sorted_v.at(i+1));
			pairs_with_same_value.push_back(pair);
		}
	}

	for(int i=0; i<pairs_with_same_value.size(); i++){
		string former_elem = pairs_with_same_value.at(i).at(0);
		string latter_elem = pairs_with_same_value.at(i).at(1);
		for(int j=0; j<original_v.size(); j++){
			if(former_elem == original_v.at(j)){
				break;
			}
			if(latter_elem == original_v.at(j)){
				isStable = false;
				return isStable;
			}
		}
	}

	return isStable;
}


int BubbleSort(vector<string>& v, const int n_elem){
	int flag = 1;
	int n_swp = 0;
	while(flag){
		flag = 0;
		for(int i=n_elem-1; i>=1; i--){
			char str_i_1 = v[i-1][1];
			char str_i   = v[i][1];

			int num_i_1 = (int)str_i_1;
			int num_i   = (int)str_i;
			if(num_i_1 > num_i){
				string tmp = v.at(i);
				v.at(i) = v.at(i-1);
				v.at(i-1) = tmp;
				flag = 1;
				n_swp = n_swp + 1;
			}
		}
	}
	return n_swp;
}

void writeVector(const vector<string>& v){
	for(int i=0; i<v.size(); i++){
		if(i==v.size()-1){
			cout << v.at(i);
			break;
		}
		cout << v.at(i) << " ";
	}
	cout << "\n";
}

int SelectionSort(vector<string>& v, const int n_elem){
	int n_swp = 0;
	for(int i=0; i<n_elem; i++){
		int min_i = i;
		for(int j=i; j<n_elem; j++){
			if((int)v.at(j)[1] < (int)v.at(min_i)[1]){
				min_i = j;
			}
		}

		if(i != min_i){
		    string tmp = v.at(i);
		    v.at(i) = v.at(min_i);
		    v.at(min_i) = tmp;
		    n_swp = n_swp + 1;
		}
	}
	return n_swp;
}

int main() {
	int n_elem;
	vector<string> v;

	cin >> n_elem;

	for(int i=0; i<n_elem; i++){
		string input;
		cin >> input;
		v.push_back(input);
	}

	vector<string> original_v = v;

	BubbleSort(v, n_elem);
	writeVector(v);
	bool isStable = IsStable(original_v, v);
	if(isStable){
		cout << "Stable" << "\n";
	}else{
		cout << "Not Stable" << "\n";
	}

	v = original_v;
	SelectionSort(v, n_elem);
	writeVector(v);

	isStable = IsStable(original_v, v);
	if(isStable){
		cout << "Stable" << "\n";
	}else{
		cout << "Not stable" << "\n";
	}

	return 0;
}



Measured memory_bytes: 3196
#include<cstdio>
#include<algorithm>
#include<set>
#include<cmath>
#include<iostream>
using namespace std;

#define N 100001
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int, pii >
#define mp3(a, b, c) mp(a, mp(b, c))

int n;
int px[N], py[N];
int fa[N];
pii sx[N], sy[N];

int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }
bool uni(int x, int y) {
	x = get(x), y = get(y);
	if (x == y) return false;
	fa[x] = y;
	return true;
}

int dist(int i, int j) {
	return min(abs(px[i] - px[j]), abs(py[i] - py[j]));
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &px[i], &py[i]);
		fa[i] = i;
		sx[i] = mp(px[i], i);
		sy[i] = mp(py[i], i);
	}
	sort(sx + 1, sx + 1 + n);
	sort(sy + 1, sy + 1 + n);
	set<piii > st;
	for (int i = 1; i < n; i++) {
		st.insert(mp3(dist(sx[i].second, sx[i + 1].second), sx[i].second, sx[i + 1].second));
		st.insert(mp3(dist(sy[i].second, sy[i + 1].second), sy[i].second, sy[i + 1].second));
	}

	int ans = 0;
	while (st.size()) {
		piii now = *(st.begin());
		st.erase(now);
		int u = now.second.first, v = now.second.second;
		ans += uni(u, v) * now.first;
	}
	printf("%d", ans);
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; ++i){cin >> h[i];}
    int res = 0;
    while(1){ 
        int l = -1, r = -1;
        for(int i=0; i<n; ++i){
            if(h[i]!=0){l = i; break;}
        } //cout << l << ",";
        if(l==-1){break;} 
        for(int i=l; i<n; ++i){ 
            if(i==n-1){r = n-1;} //cout << "i=" << i << ", " << l << "," << r << endl;
            if(h[i]==0){r = i-1;break;}
        } //cout << r << endl;
        //for(int i=0; i<n; ++i){cout << h[i] << ",";} cout << res << endl;
        int mi =  10000000;
        for(int i=l; i<r+1; ++i){
            mi = min(mi, h[i]);
        }
        for(int i=l; i<r+1; ++i){h[i] -= mi;}
        res += mi;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3608
# Digits
N, K = map(int, input().split())
div = N // K
digits = []
while div > K:
    div = N // K
    digits.append(str(N % K))
    N   = div
digits.append(str(N % K))
if N // K != 0:
    digits.append(str(N // K))
ans = len(digits)
print(ans)

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

int main(){
    int n;
    bool flag = false;
    cin>>n;
    while(n){
        int x=n%10;
        if(x==7){
            flag=true;
        }
        n/=10;
    }
    if(flag){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

int main(){
  int n,T;
  int amin=1000;
  bool ans=false;
  cin >> n >> T;
  vector<int> c(n),t(n);
  for(int i=0;i<n;i++){
    cin >> c[i] >> t[i];
  }
  for(int i=0;i<n;i++){
    if(t[i]<=T){
      amin=min(amin,c[i]);
      ans=true;
    }
  }
   if(ans){
     cout << amin << endl;
   }else{
     cout << "TLE" << endl;
   }
}

Measured memory_bytes: 256
bingo=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
for i in range(3):
  for b in B:
    if bingo[i][0]==b:
      bingo[i][0]="!"
    if bingo[i][1]==b:
      bingo[i][1]="!"
    if bingo[i][2]==b:
      bingo[i][2]="!"
for j in range(3):
  if bingo[j][0]==bingo[j][1]==bingo[j][2]=="!":
    print("Yes")
    exit()
  if bingo[0][j]==bingo[1][j]==bingo[2][j]=="!":
    print("Yes")
    exit()
  if bingo[0][0]==bingo[1][1]==bingo[2][2]=="!":
    print("Yes")
    exit()
  if bingo[0][2]==bingo[1][1]==bingo[2][0]=="!":
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  double sum = 0;
  rep(i,n) {
    sum += a[i];
  }
  double ave = sum / n;
  int mi = 0;
  rep(i,n) {
    if(abs(a[i] - ave) < abs(a[mi] - ave)) {
      mi = i;
    }
  }
  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

typedef pair<int, string> is;
int dijkstra(map<string, vector<is> >& edge, string s, string t)
{
	map<string, int> d;
	priority_queue<is, vector<is>, greater<is> > q;
	q.push(is(0, s));
	d[s] = 0;
	while (!q.empty())
	{
		is e = q.top();
		q.pop();
		int dis = e.first;
		string from = e.second;

		if (d[from] < dis)
			continue;
		else if (from == t)
			return dis;

		for (int i = 0; i < edge[from].size(); ++i)
		{
			string to = edge[from][i].second;
			int nextDis = dis + edge[from][i].first;
			if (!d.count(to) || nextDis < d[to])
			{
				q.push(is(nextDis, to));
				d[to] = nextDis;
			}
		}
	}

	exit(1);
}
int main()
{
	int n, m;
	while (cin >> n >> m, n | m)
	{
		string s, p, g;
		map<string, vector<is> > edge;
		vector<string> st;

		cin >> s >> p >> g;
		for (int i = 0; i < m; ++i)
		{
			int d, t;
			string a, b;
			cin >> a >> b >> d >> t;

			int dis = d / 40 + t;
			edge[a].push_back(is(dis, b));
			edge[b].push_back(is(dis, a));
		}

		cout << dijkstra(edge, s, p) + dijkstra(edge, p, g) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<pair<int, int>>> testimony(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0, x, y; j < A[i]; j++) {
            cin >> x >> y;
            testimony[i].emplace_back(x, y);
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        bitset<15> bs(i);
        bool f = true;
        for (int i = 0; i < testimony.size(); i++) {
            if (!bs[i]) continue;
            for (int j = 0; j < testimony[i].size(); j++) {
                const auto& p = testimony[i][j];
                if (bs[p.first - 1] != p.second) f = false;
            }
        }
        if (f) ans = max(ans, (int)bs.count());
    }
    cout << ans << endl;
}


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

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll factorial(ll n,ll mod=mod){
  static ll dp[400000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1,mod))%mod;
}

ll powl(ll x,ll r,ll mod=mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod=mod){
  return powl(x,mod-2,mod);
}


ll n;
v1 x;

ll ans = 0;
ll r = 0;

int main(){
    cin >> n;
    x = v1(n+1);
    for(ll i = 1;i <= n;i++){
        cin >> x[i];
    }
    for(ll i = 1;i < n;i++){
        r += inverse(i);
        ans += (x[i+1]-x[i]) * r % mod;
        ans %= mod;
    }
    ans = ans * factorial(n-1) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 7968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = b * 10 + c;
	if(ans % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    ll sum = 0;
    int mod = 1000000007;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
    
    
    long ans = 0;
    for(int i = 0; i < n; i++){
        sum -= A[i];
        if(sum < 0){
            sum += mod;
        }
        ans += A[i]*sum;
        ans %= mod;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3996
a = list(input())
b = list(input())
c = list(input())
count = "a"
while(True):
  if count == "a":
    if len(a) == 0:
      break
    count = a.pop(0)
  elif count == "b":
    if len(b) == 0:
      break
    count = b.pop(0)
  elif count == "c":
    if len(c) == 0:
      break
    count = c.pop(0)
print(chr(ord(count)-32))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)

#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

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

int main()
{
    int a;
    cin >> a;
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    string ans = "NG";
    for(int i = a;i <= b;i++){
        if(i % k == 0){
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3576
import array, collections

Edge = collections.namedtuple("Edge", "start end weight")

class UnionFind(object):
    def __init__(self, number_of_nodes):
        self.par = array.array("L", range(number_of_nodes))
        self.rank = array.array("L", (0 for _ in range(number_of_nodes)))

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def in_the_same_set(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x == y:
            pass
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def compute_mst_kruskal(v_size, edges):
    edges.sort(key=lambda e: e.weight)
    uf = UnionFind(v_size)
    mst = []
    for edge in edges:
        if not uf.in_the_same_set(edge.start, edge.end):
            uf.unite(edge.start, edge.end)
            mst.append(edge)

    return mst


edges = []
v, e = map(int, input().split())
for _ in range(e):
  edges.append(Edge(*map(int, input().split())))
print(sum(e.weight for e in compute_mst_kruskal(v, edges)))



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

const int INF = 1e9;

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

  int len = s.length();
  set<string> substr;
  for (int i=0; i<len; i++) {
    for (int j=1; j<=min(len-i, k); j++) {
      string t = s.substr(i, j);
      substr.insert(t);
    }
  }
  int cnt = 0;
  for (auto t: substr) {
    ++cnt;
    if (cnt == k) {
      cout<<t<<endl;
      break;
    }
  }
}

Measured memory_bytes: 1664