akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 200100

//head

int n, m;
char s[N];
vi G[N];
int cnt[N][2];
queue<int> q;
bitset<N> check;
int able;

int main() {
	scanf("%d%d", &n, &m);
	able = n;
	scanf("%s", s);
	rep(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		cnt[b][s[a] == 'A']++;
		cnt[a][s[b] == 'A']++;
	}
	rep(i, n) if(cnt[i][0] == 0 or cnt[i][1] == 0) {
		q.push(i);
		able--;
		check.set(i);
	}
	while(!q.empty()) {
		int now = q.front();
		q.pop();
		for(int ne:G[now]) {
			if(check.test(ne)) continue;
			if(--cnt[ne][s[now] == 'A'] == 0) {
				check.set(ne);
				q.push(ne);
				able--;
			}
		}
	}
	cout << (able?"Yes\n":"No\n");
}

Measured memory_bytes: 15728
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " = " << (x) << endl
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e6+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;
int modular_exp(int base,int exp,int mod)
{
    int ans =1;
    while(exp)
    {
        if(exp%2)   ans = ans%mod*base%mod;
        base = (base%mod*base%mod)%mod;
        exp/=2;
        ans%=mod;
    }
    return ans;
}
int inverse_modulo(int base,int mod)
{
	return modular_exp(base,mod-2,mod);
}
int fact[N];
void pre_compute()
{
	fact[0] = 1;
	for(int i = 1;i<N;i++)
	{
		fact[i] = i*fact[i-1];
		fact[i]%=MOD;
	}
}
int nCr(int n, int r)
{
	if(r>=n or r==0)
		return 1;
	return ( (fact[n]%MOD * inverse_modulo(fact[r],MOD)%MOD) * inverse_modulo(fact[n-r],MOD))%MOD;
}
int32_t main()
{
	SYNC
	pre_compute();
	//  A. B. C. D. E. F. G. H.
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = sz(s);
	int bad = 0;
	int all_s = modular_exp(26,n+k,MOD);
	for(int match = 0; match < n; match++) {
		bad += nCr(n+k,match) * modular_exp(25,n+k-match,MOD);
		bad %= MOD;
	}
	cout << (all_s - bad + MOD) % MOD;
	return 0;
}

Measured memory_bytes: 19864
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main() {
    int n, a;
    int cnt = 0;
    map<int, vector<int> > w;
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a;
        if ( a != i ) {
            w[a].push_back( i );
        }
        if ( w.find(i) != w.end()) {
            for (auto x: w[i]) {
                if ( x == a ) { cnt++; }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 11136
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int n;

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		Integer[] ArrayA = new Integer[n];

		for (int i = 0; i < n; i++) {
			ArrayA[i] = sc.nextInt();
		}

		List<Integer> list = new ArrayList<Integer>(Arrays.asList(ArrayA));
		Collections.sort(list);
		int Max0 = list.get(n-1);
		int Max1 = list.get(n-2);

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

			if (ArrayA[i] == Max0) {
				System.out.println(Max1);
			} else {
				System.out.println(Max0);
			}

		}

	}
}

Measured memory_bytes: 96008
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

const int SIZE = 7368791 + 1;
int M, N;
int p[SIZE];

int main(void) {
  while(cin >> M >> N, M || N) {
    REP(i, 0, SIZE) p[i] = true;

    int cnt = N;
    int i = M;
    while(cnt > 0) {
      if(p[i]) {
        for(int j = i * 2; j < SIZE; j += i) p[j] = false;
        cnt--;
      }
      i++;
    }
    while(!p[i]) i++;
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 31856
#include<bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1e6+30;
const int inf=0x3f3f3f3f;
const int mod=998244353;

int n;
pii arr[maxn];
int val[maxn],dp[maxn],R[maxn];

struct seg{
	int l,r,dat;
}t[4*maxn];

inline bool cmp(pii a,pii b){
	return a.first<b.first;
}

inline int BinarySearch(int dat,int lbound){
	int l=lbound,r=n,mid,res=lbound-1;
	while(l<=r){
		mid=(l+r)>>1;
		if(arr[mid].first<dat){
			res=max(res,mid);
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return res;
}

inline void build(int l,int r,int x){
	t[x].l=l,t[x].r=r,t[x].dat=0;
	if(l==r) return ;
	int mid=(l+r)>>1;
	build(l,mid,x<<1);
	build(mid+1,r,x<<1|1);
	t[x].dat=max(t[x<<1].dat,t[x<<1|1].dat);
}

inline int query(int l,int r,int x){
	if(t[x].l>=l&&t[x].r<=r) return t[x].dat;
	int mid=(t[x].l+t[x].r)>>1,res=0;
	if(l<=mid) res=max(res,query(l,r,x<<1));
	if(r>mid) res=max(res,query(l,r,x<<1|1));
	return res;
}

inline void Addval(int pos,int _dat,int x){
	if(t[x].r<pos||t[x].l>pos) return ;
	if(t[x].l==t[x].r&&t[x].l==pos){
		t[x].dat+=_dat;
		return ;
	}
	int mid=(t[x].l+t[x].r)>>1;
	if(pos<=mid) Addval(pos,_dat,x<<1);
	else Addval(pos,_dat,x<<1|1);
	t[x].dat=max(t[x<<1].dat,t[x<<1|1].dat);
} 

int main(){
	cin>>n;
	for(int i=1;i<=n;++i) cin>>arr[i].first>>arr[i].second;
	for(int i=n+1;i<=n+10;++i) arr[i].first=inf;
	sort(arr+1,arr+n+1,cmp);
	for(int i=1;i<=n;++i) val[i]=BinarySearch(arr[i].first+arr[i].second,i+1);
//	for(int i=1;i<=n;++i) cout<<val[i]<<" ";
//	cout<<endl; 
	build(1,n,1);
	for(int i=n;i>=1;--i){
		R[i]=max(i,query(i,val[i],1));
		Addval(i,R[i],1);
	}
	dp[n+1]=1;
	for(int i=n;i>=1;--i){
		dp[i]=dp[i+1]+dp[R[i]+1];
		dp[i]%=mod;
	}
//	for(int i=1;i<=n;++i) cout<<dp[i]<<" ";
//	cout<<endl;
	cout<<dp[1]<<endl;
	return 0;
}

Measured memory_bytes: 24832
//Only the Creator has given me strength!🖤
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector<int>
#define vvtr vector<vctr>
int mod=1e9+7;
ll ans,g;
using namespace std;
void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main(){
fastio();
int l,r,d,a,b; 
cin>>l>>r>>d;
a=(l-1)/d;
b=r/d;
cout<<b-a<<"\n";
    return 0;
}

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

int main() {
  int n, x;

  cin >> n >> x;
  while (n != 0 || x != 0) {
    int s = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i; j <= n; ++j) {
        if (i == j) continue;
        for (int k = j; k <= n; ++k) {
          if (k == i) continue;
          if (k == j) continue;
          if (i+j+k == x) ++s;
        }
      }
    }

    cout << s << endl;
    cin >> n  >> x;
  }

  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int dp[42][2] = {};
    for(int i = 0; i < 42; i++) dp[i][1] = -1;
    for(int i = 40; i >= 0; i--){
        int c0 = 0, c1 = 0;
        for(int j = 0; j < n; j++){
            if(a[j] & (1LL << i)) c1++;
            else c0++;
        }
        if(k & (1LL << i)){
            dp[i][0] = dp[i + 1][0] + c0 * (1LL << i); // 1
            dp[i][1] = dp[i + 1][0] + c1 * (1LL << i); // 0
            if(dp[i + 1][1] >= 0) dp[i][1] = max(dp[i][1], dp[i + 1][1] + max(c0, c1) * (1LL << i)); // 1, 0
        }else{
            dp[i][0] = dp[i + 1][0] + c1 * (1LL << i); // 0
            if(dp[i + 1][1] >= 0) dp[i][1] = dp[i + 1][1] + max(c0, c1) * (1LL << i); // 1, 0
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define TRUE 3
#define FALSE 2
void initialize(void);
void printboard(void);
void recursive(int);

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int Q[N][N];


void initialize(){
  int i;
  for ( i = 0; i < N; i++ ){
    row[i] = FREE; col[i] = FREE;
  }
  for ( i = 0; i < 2*N - 1; i++ ) {
    dpos[i] = FREE; dneg[i] = FREE;
  }
}
  




void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(Q[i][j] == TRUE){
	if(row[i] != j)return;
      }
    }
  }
  for (i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%s",(row[i] == j)?"Q":".");
    }
    printf("\n");
  }

}

void recursive (int i ){
  int j;
  if ( i == N){

    printBoard();
    return ;
  }
  for (j =0 ;j <N;j++){
    if (col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] ==NOT_FREE)continue;

    row[i] =j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    recursive(i+1);
    row[i] = col[j]=dpos[i+j]=dneg[i-j+N-1] = FREE;
  }
}

  
int main(){
  int i,j,k,r,c;
  
  initialize();
   
  for (i = 0; i< N;i++)
    for (j = 0; j< N;j++)
      Q[i][j] = FALSE;

  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    Q[r][c] = TRUE;
   
  }
   
   
  recursive( 0 );
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1e9 ;
const int MAXN = 10100 ;
vector<pair<int, int> > edge[MAXN];
int n;
int d[MAXN], vis[MAXN];
priority_queue<pair<int, int> > q;
void Dij()
{
	for (int i = 0; i < n; ++i) d[i] = INF;
	d[0] = 0;
	q.push(make_pair(0, 0)) ;
	vis[0] = 1;
	while (! q.empty())
	{
		pair<int, int> cur = q.top();
		int u = cur.second;
		q.pop();
		vis[u] = 2;
		if (d[u] < cur.first * (-1)) continue ;
		for (int i = 0; i < edge[u].size(); ++i)
		{
			int to = edge[u][i].first;
			if (vis[to] == 2) continue ;
			if (d[to] > d[u] + edge[u][i].second)
			{
				d[to] = d[u] + edge[u][i].second;
				q.push(make_pair(d[to] * (-1), to));
				vis[to] = 1;
			}
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 1; j <= k; ++j)
		{
			int v, c;
			cin >> v >> c;
			edge[u].push_back(make_pair(v, c));
		}
	}
	Dij();
	for (int i = 0; i < n; ++i)
		cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	return 0;
}



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


int main() {
  int n;
  cin>>n;
  ll a[n];
  rep(i,0,n) cin>>a[n-1-i];
  ll dp[n];
  rep(i,0,n) dp[i]=2e9;
  rep(i,0,n) *upper_bound(dp,dp+n,a[i])=a[i];
  cout<<lower_bound(dp,dp+n,2e9)-dp<<endl;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{	int ans=-1e18;
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	vector<int> p(n),c(n);
	for(int i=0;i<n;i++)
		cin>>p[i],p[i]--;
	for(int i=0;i<n;i++)cin>>c[i];

	for(int i=0;i<n;i++)
	{
		int v=i;
		int csum=0,len=0;
		while(1)
		{
			len++;
			csum+=c[v];
			v=p[v];
			if(v==i)break;
		}
		int path=0,cnt=0;
		while(1)
		{
			cnt++;
			path+=c[v];
			if(cnt>k)break;
			int mul=(k-cnt)/len;
			int cur=path+max(0ll,csum)*mul;
			ans=max(ans,cur);
			v=p[v];
			if(v==i)break;
		}


	}
	cout<<ans;
}


Measured memory_bytes: 3708
S = input()
if int(S[0])+int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}+{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}+{S[3]}=7')
elif int(S[0])+int(S[1])-int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}-{S[3]}=7')
elif int(S[0])-int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}-{S[2]}+{S[3]}=7')
else:
    print(f'{S[0]}-{S[1]}-{S[2]}-{S[3]}=7')

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    rep(i, n-1){
        cin >> c[i];
    }

    int sum = 0;
    rep(i, n){
        sum += b[a[i]-1];
        if(i>=1 && a[i] == a[i-1]+1){
            sum += c[a[i-1]-1];
        }
    }

    cout << sum << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
/**
    A - Favorite Sound
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    scanf("%d %d %d",&A, &B, &C);
    if((B/A)>=C) printf("%d\n",C);
    else printf("%d\n",(B/A));
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	s = input()
	sumc = []
	sumr = 0
	sumg = 0
	sumb = 0
	for i in range(n):
		if s[i] == "R":
			sumr += 1
		if s[i] == "G":
			sumg += 1
		if s[i] == "B":
			sumb += 1
		sumc.append({
			"R" : sumr,
			"G": sumg,
			"B": sumb
			})
	a = {"R": 0, "G": 1, "B": 2}
	case = 0
	log.print(sumc)
	for i in range(n):
		for j in range(i+1, n-1):
			l = j - i
			if s[i] == s[j]:
				continue
			rgb = list("RGB")
			rgb.pop(rgb.index(s[i]))
			rgb.pop(rgb.index(s[j]))
			case += sumc[n-1][rgb[0]] - sumc[j][rgb[0]]
			if j + l < n and s[j+l] == rgb[0]:
				case -= 1
			log.print(i, j, rgb, case)
	print(case)




	


main()

Measured memory_bytes: 71528
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$odd=0;
foreach($key->X[0] as $r) {
  if (($r % 2)!=0) {
    $odd++;
  }
}
if ($key->A[0]==2) {
  switch($odd) {
    case 1:
      printf("NO\n");
      break;
    default:
      printf("YES\n");
  }
  exit;
}
$even = $key->A[0]-$odd;
if (($odd % 2)!=0) {
  printf("NO\n");
}
else {
  printf("YES\n");
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    fast;
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++)
        cin >> arr[i];
    vector<ll> res(n, INT64_MAX);
    res[n-1] = 0;
    for (ll i = n-1; i > 0; i--) {
        res[i-1] = min(res[i-1], res[i] + abs(arr[i] - arr[i-1]));
        if (i > 1)
            res[i-2] = min(res[i-2], res[i] + abs(arr[i] - arr[i-2]));
    }
    cout << res[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll ans = 0, a = 0, bc = 0;
  string task, reset;
  for (ll i = 0; i < n; i++) {
    if (s[i] == 'A') {
      if (task.size() == 0 || task.back() == 'A') {
        task.push_back(s[i]);
        a++;
      }
      else {
        ans += a * bc;
        if (task.back() == 'C') {
          task = task.substr(0, a);
          task.push_back(s[i]);
          a++;
          bc = 0;
        }
        else {
          task = reset;
          task.push_back(s[i]);
          a = 1;
          bc = 0;
        }
      }
    }
    else if (s[i] == 'B') {
      if (i == n - 1) ans += a * bc;
      else if (s[i + 1] == 'C') {
        bc++;
        task += "BC";
        i++;
      }
      else {
        ans += a * bc;
        task = reset;
        a = 0;
        bc = 0;
      }
    }
    else {
      ans += a * bc;
      task = reset;
      a = 0;
      bc = 0;
    }
  }
  if (s.size() >= 2 && s[n - 2] == 'B' && s[n - 1] == 'C') ans += a * bc;

  cout << ans << endl;
}

Measured memory_bytes: 776
def chess(h,w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(i,j), end='')
    print()
  print()


Measured memory_bytes: 7008
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

int main(){
	int n, x,ans=0;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		a.push_back(x);
	}

	for (int i = 0; i < n; i++) {
		if (a[i] == 2) {
			ans++;
			continue;
		}
		if (a[i] <= 1)continue;
		if (a[i] % 2 == 0)continue;
		int k = 3;
		while (k <= static_cast<int>(pow(a[i], 0.5))) {
			if (a[i] % k == 0) {
				ans--;
				break;
			}
			k += 2;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3432
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain < 0) break
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) return console.log(i, j, sen)
      else if (result < 1000) break
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    bool Meve;
    char s[10] = {};

    Scd(N);
    int Mmin = 0;
    int Mmax = N;

    printf ("%d\n", Mmin);
    fflush( stdout );
    Scs(s);

    Meve = s[0] == 'M';

    int Q = 0;
    int mid;
    bool Less = false;
    while( s[0] != 'V' ){
        mid = (Mmin+Mmax)/2;
        printf ("%d\n", mid);
        fflush( stdout );
        Scs(s);

        if( Meve xor mid % 2 ){
            Less = s[0] == 'M';
        }else{
            Less = s[0] == 'F';
        }
        if( Less ){
            Mmin = mid;
        }else{
            Mmax = mid;
        }
        Q++;
        if( Q == 30 ) break;
    }


    return 0;
}



Measured memory_bytes: 852
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    int n = in<int>();
    int k = in<int>();
    cout << n - k + 1 << "\n";
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let xys =  [| for _ in 1..n -> stdin.ReadLine().Split() |> fun [|x;y|] -> (int x, int y) |]

let allPatern = 
    let rec f i tmpList =
        if i > n-1 then
            tmpList
        else
            let newTmpList = 
                tmpList |> Seq.collect (fun x ->
                    [0..n-1] |> Seq.except x  
                    |> Seq.map (fun y -> y :: (x |> Seq.toList)))
            f (i+1) newTmpList
    f 1 [for i in 0..n-1 -> [i]] 

let distance (i1,i2) =
    pown (fst (xys.[i1]) - fst (xys.[i2])) 2 + pown (snd (xys.[i1]) - snd (xys.[i2])) 2 |> fun x -> sqrt <| float x 

allPatern |> Seq.map ( fun patern ->
    patern |> Seq.pairwise |> Seq.map distance |> Seq.sum)
|> Seq.average
|> stdout.WriteLine

Measured memory_bytes: 19036
import sys
from itertools import combinations, permutations

def solve():
    input = sys.stdin.readline
    N = int(input())
    for i in range(1, N+1):
        if int(i * 1.08) == N:
            print(i)
            break
    else: print(":(")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
import java.util.*;
public class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        int column = sc.nextInt();
        int blackRow = sc.nextInt();
        int blackColumn = sc.nextInt();
        int blackCount = (row*blackColumn+column*blackRow)-(blackRow*blackColumn);
        int allWhite = row*column;
        System.out.println(allWhite-blackCount);

    }
}

Measured memory_bytes: 35688
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

const int N = 100050;
int OO = 0x3f3f3f3f;

int n, W;
int v[N], w[N];
vector<ll>mem[109];
int cnt = 0;

ll solve(int idx, int wt)
{
	cnt++;
	if (idx == n)
		return 0;
	if (mem[idx][wt] != -1)
		return mem[idx][wt];
	ll op1 = 0;
	if (wt >= w[idx])
		op1 = solve(idx + 1, wt - w[idx]) + v[idx];
	ll op2 = solve(idx + 1, wt);

	mem[idx][wt] = max(op1, op2);

	return mem[idx][wt];
}

int main() {


	cin >> n >> W;
	for (int i = 0; i < 100; ++i)
	{
		mem[i].resize(W+5);
		for (int j = 0; j <= W; ++j)
			mem[i][j] = -1;
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> v[i];
	}
	solve(0, W);
	//cout << cnt << endl;
	cout << mem[0][W] << endl;
	/*int mx = 0;
	for (int i = 0; i < n; ++i)
		mx = max(mem[i][W], mx);
	cout << mx << endl;*/

	//system("pause");
	return 0;
}


Measured memory_bytes: 79488
import numpy as np
import fractions as fra


input()
s=set()
c=0
for y in input().split():
    x=int(y)//400
    if(x>=8):
        c+=1
    else:
        s.add(x)

#print(s)
ls=len(s)
print(max(1,ls),end=" ")
print(ls+c)

Measured memory_bytes: 16660
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<ll> L(N);
  for(int i=0;i<N;++i) cin >> L.at(i);

  ll ans=0;
  for(int i=0;i<N;++i){
    for(int j=i+1;j<N;++j){
      for(int k=j+1;k<N;++k){
	if(L.at(i)!=L.at(j) && L.at(j)!=L.at(k) && L.at(i)!=L.at(k)){
	  if(L.at(i)+L.at(j)>L.at(k) && L.at(j)+L.at(k)>L.at(i) &&
	     L.at(k)+L.at(i)>L.at(j)) ++ans;
	}
	else continue;
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}


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

int const N = 200000;
int x[N];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	f(i, 0, n)x[i] -= i;
	sort(x, x + n);
	int md = n >> 1;
	int z = x[md];
	ll an = 0;
	f(i, 0, n)an += abs(x[i] - z);
	printf("%lld\n", an);
}

Measured memory_bytes: 1024
#include <stdio.h>
int main() {
    char c;
    scanf("%c", &c);

    if(c >= 'A' && c <= 'Z'){
        printf("A\n");
    }
    else if(c >= 'a' && c <= 'z'){
        printf("a\n");
    }
    else{
	}

    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    freopen("input.in.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, max_weight;
    cin >> n >> max_weight;
    vector<pair<ll, ll>> val;
    ll ans = 0, total_val = 0;
    for(int i = 0; i < n; ++i) {
        int we, va;
        cin >> we >> va;
        val.push_back({we,va});
        total_val += va;
    }
    vector<ll> dp(total_val+9,1e9);
    dp[0]=0;
    for(int i = 0; i < n; ++i) {
        ll cur_value = val[i].second;
        ll cur_weight = val[i].first;
        for(int j = total_val - cur_value; j >= 0; --j) {
            dp[j + cur_value] = min(dp[j + cur_value], dp[j] + cur_weight);
        }
    }
    for(int i = 1; i <= total_val; ++i) {
        if(dp[i] <= max_weight) {
            ans = max(ans, 1ll*i);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3964
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nd = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 0;
            var points = new int[nd[0]][];
            for (var i = 0; i < nd[0]; i++)
            {
                points[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            }
            for (var i = 0; i < points.Length - 1; i++)
            {
                for (var j = i + 1; j < points.Length; j++)
                {
                    var dist = Distance(points[i], points[j]);
                    var tmp = (long)Math.Sqrt(dist);
                    for (var k = tmp - 1; k <= tmp + 1; k++)
                    {
                        if (k * k == dist) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }

        static double Distance(IEnumerable<int> a, IEnumerable<int> b)
        {
            if (a.Count() != b.Count()) throw new ArgumentException();
            var sum = 0;
            for (var i = 0; i < a.Count(); i++)
            {
                var tmp = a.ElementAt(i) - b.ElementAt(i);
                sum += (tmp * tmp);
            }
            return sum;
        }
    }
}


Measured memory_bytes: 11476
def a?(i, j, lines)
  return false if i > 6 || j > 6
  [lines[i+1][j], lines[i][j+1], lines[i+1][j+1]].all? {|e| e == 1}
end

def b?(i, j, lines)
  return false if i > 4
  [lines[i+1][j], lines[i+2][j], lines[i+3][j]].all? { |e| e == 1 }
end

def c?(i, j, lines)
  return false if j > 4
  [lines[i][j+1], lines[i][j+2], lines[i][j+3]].all? { |e| e == 1 }
end

def d?(i, j, lines)
  return false if j < 1 || i > 5
  [lines[i+1][j-1], lines[i+1][j], lines[i+2][j-1]].all? { |e| e == 1 }
end

def e?(i, j, lines)
  return false if i > 6 || j > 5
  [lines[i][j+1], lines[i+1][j+1], lines[i+1][j+2]].all? { |e| e == 1 }
end

def f?(i, j, lines)
  return false if i > 5 || j > 6
  [lines[i+1][j], lines[i+1][j+1], lines[i+2][j+1]].all? { |e| e == 1 }
end

def g?(i, j, lines)
  return false if j < 1 || j > 6 || i > 6
  [lines[i][j+1], lines[i+1][j-1], lines[i+1][j]].all? { |e| e == 1 }
end

def form?(i, j, lines)
  if a?(i, j, lines)
    'A'
  elsif b?(i, j, lines)
    'B'
  elsif c?(i, j, lines)
    'C'
  elsif d?(i, j, lines)
    'D'
  elsif e?(i, j, lines)
    'E'
  elsif f?(i, j, lines)
    'F'
  elsif g?(i, j, lines)
    'G'
  end
end

def foo
  while true
    lines = []
    while gets
      break if $_ =~ /^\n/
      lines << $_.split('').map(&:to_i)
      break if lines.size == 8
    end

    next if $_ =~ /^\n/
    break if $_.nil?

    form = nil
    lines.each.with_index do |line, i|
      line.each.with_index do |char, j|
        next if char.zero?
        form = form?(i, j, lines)
        break if !form.nil?
      end
      break if !form.nil?
    end
    puts form
  end
end

foo

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

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

    auto div = enum_divisors(m);

    rep(i, div.size()) {
        if(div[i]*n > m) {
            cout << div[i-1] << endl;
            return 0;
        }
    }

    cout << div[div.size()-1] << endl;
    return 0;
}


Measured memory_bytes: 384
//////////////////////
	        	//******************//
				//**  OM THUMMAR  **//
				//**  DA-IICT     **//
				//**  201901070   **//
				//**  I'D=Aom2608 **//
				//******************//
				/////////////////////
	
	#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace std;
	
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#define endl "\n"
	#define Max(x,y,z) max(x,max(y,z))
	#define Min(x,y,z) min(x,min(y,z))
	#define fr(i,s,e) for(i=s;i<e;i++)
	#define rf(i,s,e) for(i=s-1;i>=e;i--)
	#define pb push_back
	#define mp make_pair
	#define F first
	#define S second
	#define mod 1000000007
	typedef long long ll;
	typedef unsigned int uint;
	typedef unsigned long long ull;
	typedef pair<int, int> pii;
	typedef pair<long long, long long> pll;
	typedef vector<int> vi;
	typedef vector<long long> vll;
	typedef vector<pair<long long,long long> > vpll;
	
	
	#define PI 3.141592653589793
	#define MOD 1000000007
	
	
	
	int main()
	{
		IOS;
		ll n,i;
		cin>>n;
		ll a[10000];
		for(i=0;i<=1000;i++)
		{
			a[i]=pow(i,5);
		}
		ll j;
		for(i=0;i<=1000;i++)
		{
			for(j=i+1;j<=1000;j++)
			{
				if(n==a[j]-a[i])
				{
					cout<<j<<" "<<i;
					return 0;
				}
			}
		}
		for(i=0;i<=1000;i++)
		{
			for(ll j=1;j<=1000;j+=2)
			{
				if(a[i]+a[j]==n)
				{
					cout<<i<<" -"<<j;
					return 0;
				}
			}
		}
	}
	
	
	


Measured memory_bytes: 4056
// 「A1枚+B1枚」セットが残っているとき、
// AとBを別々で買うのと、ABを買うのとどちらが安いかを検討する
// それが終わった時、
// 残ったA or B1枚を買うのと、 AB2枚を買うのとどちらが安いかを検討する

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_L = 100000;

int main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    ll set_min = min(X, Y);

    ans += set_min * min(A + B, 2 * C);

    if (X - set_min > 0) {
        ans += (X - set_min) * min(A, 2 * C);
    }
    if (Y - set_min > 0) {
        ans += (Y - set_min) * min(B, 2 * C);
    }

    cout << ans << endl;

    return 0;
}

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

int root(int x, vector<pair<int,int>> &par){
	if(par.at(x).first == x) return x;
	else return par.at(x).first = root(par.at(x).first, par);
}

bool same(int x, int y, vector<pair<int,int>> &par)  {
	return root(x,par) == root(y,par);
}

void unite(int x, int y, vector<pair<int,int>> &par){
	x = root(x,par);
	y = root(y,par);
	if(x==y) return;
	par.at(x).first = y;
	par.at(y).second += par.at(x).second;
}

int main() {
	
	int n, m, k;
	cin >> n >> m >> k;
	vector<pair<int,int>> par(n);
	for(int i=0; i<n; i++) {
		par.at(i).first = i;
		par.at(i).second = 1;
	}
	vector<pair<int,int>>e(m);
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		unite(a, b, par);
		e.at(i).first=a;
		e.at(i).second=b;
	}
	
	for(int i=0; i<n; i++) par.at(i).second = par.at(root(i,par)).second;
	for(int i=0; i<m; i++){
		par.at(e.at(i).first).second--;
		par.at(e.at(i).second).second--;
	}
	
	for(int i=0; i<k; i++){
		int c, d;
		cin >> c >> d;
		c--;
		d--;
		if(same(c,d,par)) {
			par.at(c).second--;
			par.at(d).second--;
		}
	}

	for(int i=0; i<n; i++) cout << par.at(i).second-1 << " ";
	cout << endl;
	
	
}

Measured memory_bytes: 3072
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Brave Princess Revisited
// 2013/05/12
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;

	int n, m, bMax;
	int[] us, vs, ws, xs;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			bMax=sc.nextInt();
			if(n==0&&m==0&&bMax==0){
				break;
			}
			us=new int[m];
			vs=new int[m];
			ws=new int[m];
			xs=new int[m];
			for(int i=0; i<m; i++){
				us[i]=sc.nextInt()-1;
				vs[i]=sc.nextInt()-1;
				ws[i]=sc.nextInt();
				xs[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		@SuppressWarnings("unchecked")
		ArrayList<E>[] es=new ArrayList[n];
		for(int i=0; i<n; i++){
			es[i]=new ArrayList<E>();
		}
		for(int i=0; i<m; i++){
			es[us[i]].add(new E(vs[i], ws[i], xs[i]));
			es[vs[i]].add(new E(us[i], ws[i], xs[i]));
		}

		PriorityQueue<P> que=new PriorityQueue<P>();
		que.offer(new P(0, bMax, 0));
		int[][] d=new int[n][bMax+1];
		for(int i=0; i<n; i++){
			fill(d[i], INF);
		}

		for(; !que.isEmpty();){
			P p=que.poll();
			if(p.cost>d[p.v][p.b]){
				continue;
			}
			for(E e : es[p.v]){
				if(p.b-e.w>=0){
					P q=new P(e.to, p.b-e.w, p.cost);
					if(q.cost<d[q.v][q.b]){
						que.offer(q);
						d[q.v][q.b]=q.cost;
					}
				}
				{
					P q=new P(e.to, p.b, p.cost+e.x);
					if(q.cost<d[q.v][q.b]){
						que.offer(q);
						d[q.v][q.b]=q.cost;
					}
				}
			}
		}
		int min=INF;
		for(int i=0; i<=bMax; i++){
			min=min(min, d[n-1][i]);
		}
		println(min+"");
	}

	class E{
		int to, w, x;

		E(int to, int w, int x){
			this.to=to;
			this.w=w;
			this.x=x;
		}
	}

	class P implements Comparable<P>{
		int v, b, cost;

		P(int v, int b, int cost){
			this.v=v;
			this.b=b;
			this.cost=cost;
		}

		@Override
		public int compareTo(P p){
			return cost-p.cost;
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 64728
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int N, Q;

main(){
	while(cin >> N >> Q, N){
		vi Y(101);
		REP(i, N){
			int k;
			cin >> k;
			REP(j, k){
				int x;
				cin >> x;
				Y[x] ++;
			}
		}
		int ii = 0;
		REP(i, 101){
			if(Y[i] > Y[ii]) ii = i;
		}
		if(Y[ii] < Q) cout << 0 << endl;
		else cout << ii << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int i = 1;
		Scanner s = new Scanner(System.in);
		while(true){
			 
			 int n = s.nextInt();
			 if(n==0){
				 break;
			 }
			 
				System.out.println("Case "+ i +": "+n );
			 i++;
		}
	}

}

Measured memory_bytes: 41460
from collections import namedtuple

position = namedtuple("position","row column")
def input_queens():
    queens = []
    n = int(input())
    for _ in range(n):
        row,column = [int(x) for x in input().split()]
        queens.append(position(row,column))
    return queens

def output_board(queens):
    for r in range(8):
        for c in range(8):
            print("Q" if position(r,c) in queens else ".",end = "")
        print()

def atackable(p,queens):
    return(
        p.row in [q.row for q in queens]
        or p.column in [q.column for q in queens]
        or any([abs(p.row - q.row) == abs(p.column-q.column) for q in queens])
    )


def next_p(p):
    if p.column == 7:
        return position(p.row+1,0)
    else:
        return position(p.row,p.column+1)
def over(p):
    return p.row > 7
    
def all_queens(queens):
    def rec(p,queens):
        if len(queens) == 8:
            return queens
        elif over(p):
            return False
        elif atackable(p,queens):
            return rec(next_p(p),queens)
        else:
            result = rec(position(p.row+1,0),queens+[p])
            return result if result else rec(next_p(p),queens)
    return rec(position(0,0),queens)
    

queens = input_queens()
output_board(all_queens(queens))



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	string S; cin >> S;
	int i = 0, j = N-1;
	int cnt = 0;
	while (i < j) {
		while (i < j && S[i] == 'R') i++;
		while (i < j && S[j] == 'W') j--;
		if (i < j) {
			cnt++;
			i++, j--;
		}
	}
	cout << cnt << endl;
}

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


Measured memory_bytes: 3776
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("NYoe s"["  "in S::2])

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

int main(){
  int dig[3];
  for(int i=0; i<3; ++i) cin >> dig[i];
  int dig2[3];
  string ans = "Yes";
  for(int i=0; i<2; ++i){
    for(int j=0; j<3; ++j) cin >> dig2[j];
    if(dig2[0] -dig[0] != dig2[1] -dig[1]){
      ans = "No";
    }
    if(dig2[0] -dig[0] != dig2[2] -dig[2]){
      ans = "No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,b;
	char g;
	
	for(g='A';g!='?';){
		
		scanf("%d %c %d",&a,&g,&b);
		
		if(g=='+'){
			
			printf("%d\n",a+b);
			
		}
		else if(g=='-'){
			
			printf("%d\n",a-b);
			
		}
		else if(g=='*'){
			
			printf("%d\n",a*b);
			
		}
		else if(g=='/'){
			
			printf("%d\n",a/b);
			
		}
	}
		
	return 0;
}

Measured memory_bytes: 2744
#include<stdio.h>
#include<cstring>
 
bool isOk(char s[100]){
  int a;
  sscanf(s,"%d",&a);
  if(s[0]=='0'){
    if(s[1]=='\0')
      return true;
    else
      return false;
  }
  if( 0<=a && a<=255 )
    return true;
  else
    return false;
}
 
bool judge(char s[100],int i,int j,int k){
  char s1[4][100]={};
  int ind;
  int m[4]={};
  int n=strlen(s);
  for(ind=0; ind<n; ind++){
    if(ind<i){
      s1[0][m[0]]=s[ind];
      m[0]++;
    }
    else if(ind<j){
      s1[1][m[1]]=s[ind];
      m[1]++;
    }
    else if(ind<k){
      s1[2][m[2]]=s[ind];
      m[2]++;
    }
    else{
      s1[3][m[3]]=s[ind];
      m[3]++;
    }
  }
  if(!isOk(s1[0]))return false;
  if(!isOk(s1[1]))return false;
  if(!isOk(s1[2]))return false;
  if(!isOk(s1[3]))return false;
  return true;
}
 
int main(){
  
  char s[100];
  int i,j,k;
  int sum;
  int len;
  

    sum=0;
    scanf("%s",s);

    
    len=strlen(s);
    for(i=1;i<len-2;i++)
      for(j=i+1;j<len-1;j++)
	for(k=j+1;k<len;k++){
	  if(judge(s,i,j,k))
	    sum++;
	}
    printf("%d\n",sum);

  
}



Measured memory_bytes: 2720
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
ll MOD = 1000000007ll;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

const int MX = 20005;

int dp[1<<26];

int main()
{
	string D;
	cin >> D;
	memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;

	int cur = 0;
	for(int t = 0; t < D.size(); t++){
		if(t+1 != D.size()){
			cur ^= 1<<D[t]-'a';
			for(int i = 0; i < 26; i++){
				dp[cur] = min(dp[cur], dp[cur^1<<i] + 1);
			}
		}
		else{
			cur ^= 1<<D[t]-'a';
			int ans = dp[cur] + 1;
			for(int i = 0; i < 26; i++){
				ans = min(ans, dp[cur^1<<i] + 1);
			}
			printf("%d\n", ans);
		}
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int L = S.size();

    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    
    int cnt = 0;
    for (int i = 1; i < L; i++) {
        if (isupper(S[i])) {
            ++cnt;

            if (i == 1 || i == L - 1 || S[i] != 'C') {
                cout << "WA" << endl;
                return 0;
            }
        }
    }

    if (cnt == 1) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[1000005];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	if (n&1){
		for (int i=n;i>=1;i-=2) printf("%d ",a[i]);
		for (int i=2;i<=n;i+=2) printf("%d ",a[i]);
	}
	else {
		for (int i=n;i>=1;i-=2) printf("%d ",a[i]);
		for (int i=1;i<=n;i+=2) printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2944