akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  int ans;
  int N, K;
  cin >> N >> K;

  if (N % K == 0) {
    ans = 0;
  } else {
    ans = 1;
  }

  cout << ans << '\n';

  return 0;
}

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

int main(){
  int n;
  cin>>n;
  int r=n%10;
  if(r==2||r==5||r==7||r==9||r==4)
  {
    cout<<"hon"<<endl;
  }
  else if(r==3)
  {
    cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int count = N /2;
    int r = N % 2;
    if(r == 1)
        count+=r;
    double result = static_cast<double>(count)  / static_cast<double>(N);
    
    cout << result << endl;
    
    return 0;
    
}


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

using namespace std;

int main(){
    int r,g,i,j;
    for(;;){
        cin>>r;
        cin>>g;
        if(0<=r&&r<=4500&&0<=g&&g<=4500){
            i=g*2;
            j=i-r;
            cout<<j<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> path(n, -1);
  q.push(0);
  dist[0] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int nv : G[v]) {
      if (dist[nv] != INF) continue;
      if (dist[nv] > dist[v] + 1) path[nv] = v;
      dist[nv] = min(dist[nv], dist[v] + 1);
      q.push(nv);
    }
  }
  bool flag = true;
  FOR(i, 1, n - 1) {
    if (path[i] == -1) {
      flag = false;
      break;
    }
  }
  if (!flag) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  FOR(i, 1, n - 1) {
    cout  << path[i] + 1 << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 10680
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    ll n, h;

    cin >> n >> h;

    ll largestA = 0;
    vector<pair<int,int>> l(n);
    for(int i = 0; i < n; i++){
        pair<ll,ll> tmp;
        cin >> tmp.first >> tmp.second;
        l[i] = tmp;
        largestA = max(largestA, tmp.first);
    }

    sort(l.begin(), l.end(), greaterSecond);
    ll ans = 0;
    bool fin = false;
    for(int i = 0; i < n; i++){
        if(l[i].second > largestA){
            h -= l[i].second;
            ans++;
            if(h <= 0){
                fin = true;
                break;
            }
        }
    }

    if(fin){
        cout << ans << endl;
        return 0;
    }


    if(h % largestA == 0){
        cout << ans + h / largestA << endl;
    } else {
        cout << ans + h / largestA + 1 << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
 
using namespace std;
 
int main (void) {
  string target;
  int n;
  string str;
  string strAppended;
 
  cin >> target; cin >> n;
 
  int lenT = target.length();
  int lenAp;
  int count = 0;
 
  for(int j=0; j < n; j++) {
    cin >> str;
     
    strAppended = str + str;// cout << "---" << strAppended << endl;;
    lenAp = strAppended.length();
     
    for(int i=0; i<lenAp; i++) {
      if (target.substr(0,1) == strAppended.substr(i,1)) {
    //cout << "pass1" << endl;
    if (target == strAppended.substr(i, lenT) ) {
      //cout << "---" << strAppended.substr(i, lenT) << endl;
      count++;
      break;
    }
      }
    }
 
  }
   
 
  cout << count << endl;
 
  return 0;
}

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

const int INF=0x3f3f3f3f;
const int N=2010;
int n,k;
int fr,to;
vector<int>ed[N];
int dist[N][N];
int ans=INF;

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&fr,&to);
		ed[--fr].push_back(--to);
		ed[to].push_back(fr);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			dist[i][j]=INF;
	for(int i=0;i<n;i++)
		dist[i][i]=0;
//	puts("Input has finished!");
//	puts("Step 1...");
	for(int x=0;x<n;x++){
		queue<int>q;
		q.push(x);
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(int i=0;i<ed[u].size();i++){
				int v=ed[u][i];
				if(dist[x][v]<INF) continue;
				dist[x][v]=dist[x][u]+1;
				q.push(v);
			}
		}
//		printf("	Point %d",x);
//		puts(" has finished!");
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=n;j++) printf("%d ",dist[i][j]);
//		puts("");
//	}
//	puts("Step 1 has finished!");
//	puts("Step 2...");
	if(k%2==1){
		for(int u=0;u<n;u++){
			for(int kk=0;kk<ed[u].size();kk++){
				int v=ed[u][kk];
				int cnt=0;
				for(int i=0;i<n;i++)
					if(dist[u][i]+dist[v][i]<=k) cnt++;
				ans=min(ans,n-cnt);
			}
		}
	} else {
		for(int i=0;i<n;i++){
			int cnt=0;
			for(int j=0;j<n;j++)
				if(dist[i][j]<=k/2) cnt++;
			ans=min(ans,n-cnt);
		}
	}
//	puts("Step 2 has finished!");
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int copy(int x){return x;}
int main(){
	int h,w,K;cin>>h>>w>>K;
	vector<string> s(h);
	for(int i = 0; i < h; i++) {
		cin>>s[i];
	}
	int res = INF;
	for(int bit = 0;bit < (1 << (h-1)); bit++) {
		int x = 0;
		vector<ll> split;
		int n = 0;
		for(int i = 0; i < h; i++) {
			if ((bit >> i) & 1){//i とi+1で分ける
				split.pb(i);
			}
		}
		split.pb(h - 1);
		vector<vector<int>> choco(w);
		int ans = split.size() - 1;
		for(int i = 0; i < split.size(); i++) {
			// cout << split[i]<< endl;
			if (i == 0){
					
					for(int k = 0; k < w; k++) {
						int cnt = 0;
				for(int j = 0; j <= split[i]; j++) {

						if (s[j][k] == '1'){
							cnt++;
						}
					}
					choco[i].pb(cnt);
				}
				
			}
			else {
					for(int k = 0; k < w; k++) {
						int cnt = 0;
						for(int j = split[i - 1] + 1; j <= split[i]; j++) {
						if (s[j][k] == '1'){
							cnt++;
						}
					}
					choco[i].pb(cnt);
				}
			}
		}

		// for(int i = 0; i < split.size(); i++) {
		// 	for(int j = 0; j < w; j++) {
		// 		cout << choco[i][j];
		// 	}
		// 	cout << endl;
		// }
		vector<int> sum(h,0);
		for(int i = 0; i < w; i++) {
			for(int j = 0; j < split.size(); j++) {
				if (choco[j][i] > K){
					ans = INF;
					break;
				}
				sum[j] += choco[j][i];
				if (sum[j] > K){
					ans ++;
					for(int k = 0; k < split.size(); k++) {
						sum[k] = choco[k][i];
					}
					break;

				}
			}
		}
		res = min(res,ans);
		// cout << "---------" << endl;
	}
	cout << res << endl;
	return 0;
}

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

int n_times(int x,int k){
    for (int i = 0; i < k;i++) {
        x = x*2;
        }
        return x;
}

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int mx;
    mx = max(a, max(b, c));
    if (mx == a){
            mx = n_times(a,k);
        cout << mx + b + c << endl;
    }
    else if (mx == b) {
            mx = n_times(b,k);
        cout << mx + a + c << endl;
    }
    else if (mx == c){
            mx = n_times(c,k);
            cout << mx + a + b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long A, B, K;
    cin >> A >> B >> K;
    if (A > K) {
        A -= K;
    }
    else {
        B -= K - A;
        A = 0;
    }
    printf("%lld %lld\n", A, max(0LL, B));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


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

	int sa = abs(a - b);

	if (sa <= w) {
		cout << 0 << endl;
	}
	else {
		
		cout << sa - w << endl;
	}
	
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
ac = collections.Counter(a)
side = []

for k,d in ac.items():
    if 2 <= d < 4:
        side.append(k)
    elif d >= 4:
        side.append(k)
        side.append(k)

side.sort(reverse=True)
if len(side) < 2:
    print(0)
else:
    print(side[0]*side[1])

Measured memory_bytes: 18600
import math 
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = [int(i) for i in input().split()]
if 1 in a:
    ans = 1
else:
    ans = gcd_list(a)
print(ans)

Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,count=0;
  string s,t;
  cin>>a>>b;
  for (int i = a; i < b+1; i++) {
    s = to_string(i);
    t = s;
    reverse(s.begin(),s.end());
    if(s.compare(t) == 0){
      count++;
    }
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int num;
	static int magic;
	static int type[] = new int[(int)200100];
	static int opponent[] = new int[(int)200100];
	static boolean isL[] = new boolean[(int)200100];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		magic = sc.nextInt();
		String oppos = sc.next();
		for(int i = 0; i < num; i ++) {
			type[i] = oppos.charAt(i) - 'A';
		}
		for(int i = 0; i < magic; i ++) {
			opponent[i] = sc.next().charAt(0) - 'A';
			isL[i] = sc.next().charAt(0) == 'L' ? true : false;
		}
		System.out.println(Math.max(bisect(true) - bisect(false) - 1, 0));
	}

	static int bisect(boolean max) {
		int ng = max ? -1 : num;
		int ok = max ? num : -1;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if(isOK(mid)) {
				ok = mid;
			}else {
				ng = mid;
			}
		}
		return ok;
	}
	static boolean isOK(int index) {//will dissapear
		for(int i = 0; i < magic; i ++) {
			if(opponent[i] == type[index]) {
				index += isL[i] ? -1 : 1;
			}
			if(index == -1 || index == num) {
				return true;
			}
		}
		return false;
	}
}

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

#define ll long long

int MAX(int a, int b){
    if(a >= b) return a;
    else return b;
}

int main(){

    int N,M;
    int i,j,k;
    int count=0;
    bool flag = false;

    cin >> N;
    vector<string> s(100);
    vector<int> s_int(100);

    for(i=0;i<N;i++){
        cin >> s.at(i);
        for(j=0;j<i;j++){
            if(s.at(i)==s.at(j) && !flag){
                s_int.at(j)++;
                flag = true;
            }
        }
        if(!flag){
            s_int.at(i)++;
        }
        flag = false;
    }

    flag = false;

    cin >> M;
    vector<string> t(100);

    for(i=0;i<M;i++){
        cin >> t.at(i);
        for(j=0;j<N;j++){
            if(t.at(i)==s.at(j) && !flag){
                s_int.at(j)--;
                flag = true;
            }
        }
        flag = false;
    }

    int max = 0;

    for(i=0;i<N;i++){
        if(max < s_int.at(i))max = s_int.at(i);
    }

    cout << max << endl;

}

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

int main(){
    int ans=0;
    string S;
    cin >> S;
    stack<char> stc;
    for(int i = 0;i < S.size();i ++){
        if(!stc.size()||stc.top()==S[i]) stc.push(S[i]);
        else {stc.pop();ans +=2;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	vec(A)
	cin>>N;
	fx(3*N){
		vecp(A)
	}
	sorts(A)
	ll ans=0;
	int i=0;
	for(int x=A.size()-2;i<N;x-=2){
		ans+=A.at(x);
		i++;
	}
	ce(ans)
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" ";
#define con(a)                  cout<<a<<endl;
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl;
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define T                       ll t=1; cin>>t; while(t--)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    ll k,x=1,n=7;
    cin>>k;
    if(k%2==0 || k%5==0) x=-1;
    else
    {
        while(n%k!=0)
        {
            n*=10;
            n+=7;
            n%=k;
            x++;
        }
    }
    cout<<x;
    
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>
#include <cmath>

#define EPS (1e-10)
#define PI (acos(-1.0))
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

using namespace std;
typedef complex<double> P;

double ccw(P& p1, P& p2, P& p3)
{
	return ((p2.real() - p1.real())*(p3.imag() - p1.imag()) 
				- (p2.imag() - p1.imag())*(p3.real() - p1.real())) > 0;
}// ccw>0 => ccw, ccw=0 => colinear, ccw<0, cw

bool complex_pred(const P& a, const P& b)
{
    if (a.real() != b.real())
		return a.real() < b.real();
	else
		return a.imag() < b.imag();
}

vector<P> solve(vector<P>& vc)
{
	sort(vc.begin(), vc.end(), complex_pred);

	int k = 0;
	vector<P> vc2(vc.size()*2);
	
	for (int i = 0; i < (int)vc.size(); i++)
	{
		while( k >= 2 && ccw(vc2[k-1], vc2[k-2], vc[i]) <= 0 )
		{
			k--;
		}
		
		vc2[k]=vc[i];
		k++;
	}

	int t = k;
	
	for (int i = vc.size()-1; i >= 0; i--)
	{
		while ( k > t && ccw(vc2[k-1], vc2[k-2], vc[i]) <= 0 )
		{
			k--;
		}
		
		vc2[k]=vc[i];
		k++;
	}
	
	vc2.resize(k-1);
	return vc2;
}

int main()
{
	int n;
	
	while(cin >> n, n)
	{
		vector<P> vc;
		vc.clear();
		
		for(int i = 0; i < n; i++)
		{
			char c;
			double a, b;
			cin >> a;
			cin >> c;
			cin >> b;
			vc.push_back(P(a, b));
		}
		
		vector<P> vc2 = solve(vc);
		cout << int(n - vc2.size()) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    cout << setprecision(10) << sqrt(pow((x2-x1),2) + pow((y2-y1),2)) << endl;
    return 0;
}


Measured memory_bytes: 3300
length = int(input())
targ = [int(n) for n in input().split(' ')]
swap = 0
for l in range(length):
    for m in range(l):
        if targ[l - m] < targ[l - m - 1]:
            disp = targ[l-m -1]
            targ[l-m-1] = targ[l-m]
            targ[l-m] = disp
            swap += 1
print(" ".join([str(n) for n in targ]))
print(swap)

Measured memory_bytes: 7728
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, k, c = 1;
	cin >> num >> k;
	vector<vector<int>> d(1, vector<int>(num + 1));
	rep(i, num)
		cin >> d[0][i];
	rep(i, k) {
		if (!c)
			break;
		c = false;
		d.push_back(vector<int>(num + 1, 0));
		rep(j, num) {
			d[i + 1][max(0, j - d[i][j])]++;
			d[i + 1][min(num, j + d[i][j] + 1)]--;
		}
		rep(j, num) {
			d[i + 1][j + 1] += d[i + 1][j];
			if (d[i][j] != d[i + 1][j])
				c = true;
		}
	}
	rep(j, num - 1)
		cout << d[i][j] << " ";
	cout << d[i][j] << "\n";
	return 0;
}

Measured memory_bytes: 36676
from collections import Counter

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ans = 0
n = 1
for i, v in Counter(prime_factorize(N)).items():
    # print(i, v)
    while True:
        # print("v", v)
        v -= n
        if v >= 0:
            ans += 1
            n += 1
        else:
            break
    n = 1
print(ans)

Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
struct Dice{
  int y,x;
  int s[6];
  Dice(){}
  void roll(char c){
    //the view from above
    // N
    //W E
    // S
    //s[0]:top
    //s[1]:south
    //s[2]:east
    //s[3]:west
    //s[4]:north
    //s[5]:bottom
    int b;
    if(c=='R'){
      x++;
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='L'){
      x--;
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='B'){
      y++;
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='F'){
      y--;
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
  int bottom(){
    return s[5];
  }
};
typedef pair<int,int> P;
int p2i(P p){
  return (p.first+1500)*3000+(p.second+1500);
}
unordered_set<int> used;
int memo[1<<16];
int n;
Dice ds[16];
string rot[16];
int dfs(int b){
  if(~memo[b]) return memo[b];
  int res=0;
  for(int i=0;i<n;i++){
    if((b>>i)&1) continue;
    unordered_map<int,int> v;
    int tmp=0;
    Dice d=ds[i];
    for(int j=0;j<(int)rot[i].size();j++){
      if(v.count(p2i(P(d.y,d.x)))||!used.count(p2i(P(d.y,d.x)))){
	//cout<<tmp<<" "<<d.bottom()<<endl;
	tmp+=d.bottom();
	if(v.count(p2i(P(d.y,d.x)))) tmp-=v[p2i(P(d.y,d.x))];
	v[p2i(P(d.y,d.x))]=d.bottom();
	used.insert(p2i(P(d.y,d.x)));
      }
      //cout<<d.y<<" "<<d.x<<":"<<tmp<<" "<<d.bottom()<<endl;
      d.roll(rot[i][j]);
    }
    res=max(res,dfs(b+(1<<i))+tmp);
    for(auto j:v) used.erase(j.first);
  }
  //cout<<b<<" "<<res<<endl;
  return memo[b]=res;
}
signed main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      cin>>ds[i].x>>ds[i].y;
      cin>>ds[i].s[3]>>ds[i].s[2]>>ds[i].s[1];
      cin>>ds[i].s[4]>>ds[i].s[5]>>ds[i].s[0];
      cin>>rot[i];
      rot[i]+="$";//guard
    }
    used.clear();
    memset(memo,-1,sizeof(memo));
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3368
A = input()
B = input()

if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
else:
    for k in range(len(A)):
        if int(A[k])>int(B[k]):
            print("GREATER")
            exit(0)
        elif int(A[k])<int(B[k]):
            print("LESS")
            exit(0)
    print("EQUAL")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("/home/dhruv/Desktop/tests/input.txt","r",stdin);
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++)
		cin>>ar[i];
	sort(ar,ar+n,greater<int>());
	int j=0,k=1;
	long long ans =0;
	for(int i=1;i<n;i++)
	{
		ans+=ar[j];
		if(k==1)
		{
			k=0;
			j++;
		}
		else
			k++;
	}
	cout<<ans;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> a(h);
  REP(i, h) { cin >> a[i]; }

  vector<vector<ll>> d(h, vector<ll>(w, -1));
  queue<P> que;
  REP(i, h) REP(j, w) {
    if (a[i][j] == '#') {
      d[i][j] = 0;
      que.push(P(i, j));
    }
  }

  while (!que.empty()) {
    P c = que.front();
    que.pop();
    REP(i, 4) {
      ll nx = c.first + dx[i], ny = c.second + dy[i];
      if (!(0 <= nx && nx < h && 0 <= ny && ny < w)) continue;
      if (d[nx][ny] == -1) {
        d[nx][ny] = d[c.first][c.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }

  ll ans = 0;
  REP(i, h) REP(j, w) { ans = max(ans, d[i][j]); }

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

Measured memory_bytes: 25524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;


// Driver code  
int main()
{
    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;
    if (a == 0) {
        cout << 1 << endl;
    }
    if (b == 0) {
        cout << 2 << endl;
    }
    if (c == 0) {
        cout << 3 << endl;
    }
    if (d == 0) {
        cout << 4 << endl;
    }
    if (e == 0) {
        cout << 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = n / 100;
        var b = n % 100;

        if (m(a))
        {
            if (m(b))
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else
            {
                Console.WriteLine("MMYY");
            }
        }
        else if (m(b))
        {
            Console.WriteLine("YYMM");
        }
        else
        {
            Console.WriteLine("NA");
        }
    }

    static bool m(int x)
    {
        return 1 <= x && x <= 12;
    }
}


Measured memory_bytes: 13140
using System;

class Program{
    public static void Main(){
        var N=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var A=new int[N];
        for(var i=0; i<N; i++){
            A[i]=int.Parse(s[i]);
        }

        var cnt=0;
        for(var i=0; i<N; i++){
            var mini=i;
            var swapped=false;
            for(var j=i; j<N; j++){
                if(A[j]<A[mini]){
                    mini=j;
                    swapped=true;
                }
            }
            if(swapped){
                cnt++;
                var tmp=A[i];
                A[i]=A[mini];
                A[mini]=tmp;
            }
        }

        for(var i=0; i<N; i++){
            if(i>=N-1){
                Console.WriteLine(A[i]);
            } else{
                Console.Write(A[i]+" ");
            }
        }
        Console.WriteLine(cnt);
    }
}

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

using namespace std;

int p,q,r;

int get(){

	int ret = 0;

	if(p <= q && p <= r){
		ret = p;
		p = 1000000;
	}
	else if(q <= p && q <= r){
		ret = q;
		q = 1000000;
	}
	else{
		ret = r;
		r = 1000000;
	}

	return ret;

}

int main(){
	
	int ans=0;

	cin >> p >> q >> r;

	for(int i=0;i<2;++i){
		ans+=get();
	}

	cout << ans << '\n';

	return 0;
}

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

int main()
{
    int N;
    int A;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A;
        if (A % 2 == 0){
            if (A % 3 == 0 || A % 5 == 0){
            } else {
                printf("%s", "DENIED");
                return 0;
            }
        };
    };
    printf("%s", "APPROVED");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> c;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int a;cin >> a;
    if(mp[a]==0){
      c.push_back(a);
    }
    mp[a]++;
  }
  sort(c.begin(),c.end());
  if(c.size()==1){
    if(c[0]==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(n%3!=0){
    cout << "No" << endl;
    return 0;
  }
  if(c.size()==2){
    if(c[0]==0&&mp[c[0]]*2==mp[c[1]]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(c.size()==3){
    if(mp[c[0]]==mp[c[1]]&&mp[c[1]]==mp[c[2]]){
      int t=c[0]^c[1];
      if(t==c[2]){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 4216
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m,a,d;
char b[33][9];

int go(){
	int c=m-1;
	rep(i,d){
		if(c>0&&b[i][c-1]=='1')c--;
		else if(c<n-1&&b[i][c]=='1')c++;
	}
	return c==a-1;
}

int main(){
	while(cin>>n&&n){
		cin>>m>>a>>d;
		rep(i,d)rep(j,n-1)cin>>b[i][j];
		if(go()){cout<<0<<endl;goto nx;}
		rep(i,d)rep(j,n-1){
			if(b[i][j]=='0'&&(j==0||b[i][j-1]=='0')
				&&(j==n-2||b[i][j+1]=='0')){
				b[i][j]='1';
				if(go()){
					cout<<i+1<<" "<<j+1<<endl;
					goto nx;
				}
				b[i][j]='0';
			}
		}
		cout<<1<<endl;
		nx:;
	}
}

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

int main(){
  int k;
  string s;
  cin>>k>>s;
  if(k>=s.size()) cout << s << endl;
  else{
    rep(i,k) cout << s[i];
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3604
// Menagerie

#include<bits/stdc++.h>

// Sheep == 0, Wolf == 1, o == 0, x == 1

int deduce(int f_2, int f_1, int s_1) {
    if ((!s_1 && !f_1) || (s_1 && f_1)) {
        return f_2;
    } else if ((!s_1 && f_1) || (s_1 && !f_1)) {
        return !f_2;
    }
}

void dfs(std::string& s, std::vector<int>& species, int index) {
    for (int i = index; i < species.size(); ++i) {
        species.at(i) = deduce(species.at(i - 2), species.at(i - 1), (s.at(i - 1) == 'o') ? 0 : 1);
    }
}

void output(std::vector<int>& species) {
    species.pop_back();
    species.pop_back();
    for (auto i : species) {
        if (i) {
            std::cout << 'W';
        } else {
            std::cout << 'S';
        }
    }
    std::cout << std::endl;
}

int check(std::vector<int>& species, int N) {
    if (species.at(0) == species.at(N) && species.at(1) == species.at(N + 1)) {
        output(species);
        return 1;
    }
    return 0;
}

int main() {
    int N = 0;
    std::string s;

    std::cin >> N >> s;
    s.push_back(s.front());
    std::vector<int> species(N + 2, 0);

    dfs(s, species, 2);
    if (check(species, N)) {
        return 0;
    }
    species.at(1) = 1;
    dfs(s, species, 2);
    if (check(species, N)) {
        return 0;
    }
    species.at(0) = 1;
    dfs(s, species, 2);
    if (check(species, N)) {
        return 0;
    }
    species.at(1) = 0;
    dfs(s, species, 2);
    if (check(species, N)) {
        return 0;
    }
    std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int D = in.nextInt();
            int[][] X = new int[N][D];
            for (int n = 0; n < N; n++) {
                for (int d = 0; d < D; d++) {
                    X[n][d] = in.nextInt();
                }
            }

            int count = 0;
            for (int n = 0; n < N; n++) {
                for (int n2 = n + 1; n2 < N; n2++) {
                    if (is(n, n2, X, D)) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }

    private static boolean is(int n, int n2, int[][] x, int D) {
        int sum = 0;
        for (int d = 0; d < D; d++) {
            int diff = x[n][d] - x[n2][d];
            sum += diff * diff;
        }

        for (int i = 0; i * i <= sum; i++) {
            if (i * i == sum) {
                return true;
            }
        }

        return false;
    }
}


Measured memory_bytes: 21972
def main():
    N = int(input())
    A = []
    B = []
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append((a, b))
    if sum(A) > max(B):
        print('No')
        return
    AB = sorted(AB, key=lambda x: x[1])
    c = 0
    for a, b in AB:
        c += a
        if c > b:
            print('No')
            return
    print('Yes')


main()


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

int main() {
  int N;
  cin >> N;
  int A = 0;
  int B = 0;
  
  vector<int> vec(N);

  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int j = 0; j < vec.size(); j++){
    if(j % 2 == 0){
      A += vec.at(j);
    }
    else{
      B += vec.at(j);
    }
  }
  cout << (A - B) << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		long a = in.nextLong();

		for (long i=(long)(Math.sqrt(a)); i>1; i--) {
			if (a%i == 0) {
				System.out.println(i + a/i - 2);
				System.exit(0);
			}
		}
		System.out.println(a - 1);
	}
}



Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <string>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string s;
  cin >> s;
  for(int i = 0; i < s.length() / 2; i++){
    if(s[i] != s[s.length() - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input()) 
insist_num = []
insists = []

for i in range(N):
    insist_num.append(int(input()))
    insists.append([list(map(int,input().split())) for _ in range(insist_num[-1])])

all_patterns = ["0","1"] # 1が正直者とする
for _ in range(N-1):
    all_patterns = [j+i for i in ["0","1"] for j in all_patterns]

ok = [True for _ in range(len(all_patterns))]

for h, pattern in enumerate(all_patterns):
    for i, honest in enumerate(list(pattern)):
        if honest == "1":
            for j in range(insist_num[i]):
                if str(insists[i][j][1]) != str(list(pattern)[insists[i][j][0]-1]):
                    ok[h] = False
                    break
            else:
                continue
            break

max_val = 0
for i, pp in enumerate(ok):
    if pp==True and all_patterns[i].count("1") > max_val:
        max_val = all_patterns[i].count("1")
print(max_val)


Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
int main(){
     int T; cin>>T;
     for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==T){
                cout<<"Yes\n"<<endl; return 0;
            }
        }
     }
     cout<<"No\n"<<endl; return 0;
}


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

using namespace std;

long gcd(long a, long b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }

  long lcm(long a, long b)
 {
    return (a*b)/gcd(a, b);
 }
int main() {
    long n1,n2;
    cin >> n1 >> n2;
    cout << lcm(n1,n2);
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int l;
  cin>>l;
  double n=(double)l/3;
  decimal(10);
  out(n*n*n);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,set<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num,int pos);
ll setbitt(ll num,ll pos);
ll resetbitt(ll num,int pos);
 //.................___Start from here___.................//
//.................._____________________................//
 
 
ll bitcount(ll n){
    int ans = 0;
    for(int i=0;i<32;i++){
        ans+=(n>>i)&1;
    }

    return ans;
}
 
 
 
 
void solve(){
    int n;
    cin>>n;
    int mask = 1<<n;
    mask--;
 
    int a[n+1],x[n+1][n+1],y[n+1][n+1];
 
    for(int u = 1 ; u <= n ; u++ ){
        cin>>a[u];
        for(int v = 1;v<=a[u];v++){
            cin>>x[u][v]>>y[u][v];
        }
    }
 
    ll ans = 0;
 
    for(int i=1;i<=mask;i++){
        bool f =true;
 
        for(int j=1;j<=n;j++){
            if(checkbitt(i,j-1)){
                for(int k=1;k<=a[j];k++){
                    if(y[j][k]^checkbitt(i,(x[j][k]-1))) f = false;
                }
            }
        }
 
        if(f) ans = max(ans,bitcount(i));
    }
 
    cout<<ans<<endl;
 
}
 
 
int main(){
    // input;
    // output;
 
    int cs=1;
    int cn=1;
    // cin>>cs;
    while(cs--){
        solve();
    }
}
 
 
 
 
 
 
bool checkbitt(ll num,int pos){
    return (num>>pos) & 1;
}
 
ll setbitt(ll num,ll pos){
    return (1<<pos) | num;
}
 
ll resetbitt(ll num,int pos){
    if(!checkbitt(num,pos)) {
        return num;
    }
    else{
        return (1<<pos)^num;
    }
}


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

int main(){
    int a, b, c, fa;
    fa = 0;
    cin >> b;


    while(fa == 0){
        a = b - 1;
        if(b == 2){
            fa = 1;
        }
        while(a >= 2){
            if(b % a ==0){
                break;
            }else{
                
                if(a == 2){
                    fa = 1;
                }
            }
            a = a - 1 ;
        }
        if(fa == 1){
            break;
        }
        b++;
        
    }
    

    cout << b << endl;
}

Measured memory_bytes: 256
import numpy as np

n,m,c = map(int,input().split())

b = list(map(int,input().split()))

ans = 0
for i in range(n):
    a = list(map(int,input().split()))
    temp =0
    for j in range(m):
        temp+=a[j]*b[j]
    if temp+c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 12396
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int64_t> a(n*2);
  REP(i,n)cin>>a[i];
  REP(i,n)a[i+n]=a[i];
  vector<int64_t> s(2*n+1);
  partial_sum(begin(a),end(a),begin(s)+1);
  int64_t mx_mn = 0;
  REP(i,n) {
    int64_t bl = 0, br = INT64_C(1000000000000000);
    while(bl + 1 < br) {
      int64_t mid = (bl + br) / 2;
      int64_t ofs = s[i];
      bool ok = true;
      REP(j,3) {
        auto itr = lower_bound(begin(s),end(s),ofs + mid);
        if (itr != end(s)) {
          ofs = *itr;
        } else {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (ofs <= s[i+n]) {
          bl = mid;
        } else {
          br = mid;
        }
      } else {
        br = mid;
      }
    }
    mx_mn = max(mx_mn, bl);
  }
  cout << mx_mn << endl;
  return 0;
}

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

const int INF = 1000000000;

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

    int A[N];
    if (S == INF) {
        for (int i=0; i<K; i++) A[i] = S;
        for (int i=K; i<N; i++) A[i] = INF -1;
    } else {
        for (int i=0; i<K; i++) A[i] = S;
        for (int i=K; i<N; i++) A[i] = INF;
    }

    rep(i, N) cout << A[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
li = [inpl()+[i] for i in range(M)]
li = sorted(li, key=lambda x: x[1])
ans = [0]*M
cnts = defaultdict(int)
for i in range(M):
    p,y,ind = li[i]
    s1 = str(p).zfill(6)
    s2 = str(cnts[p]+1).zfill(6)
    cnts[p] += 1
    ans[ind] = s1+s2

for a in ans:
    print(a)


Measured memory_bytes: 39980
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	
	ll calc(ll n, ll b,ll sum){
		if(n < b)return sum + n % b;
		else return calc(n / b, b, sum + n % b);
	}
	int d[31][31];
	int c[501][501];
	ll sum[3][31] = {};
	signed main(){
		IOS;
		ll n, C;
		cin >> n >> C;
		REP(i,C)REP(j,C)cin >> d[i + 1][j + 1];
		REP(i,n)REP(j,n)cin >> c[i + 1][j + 1];
		
		for(int co = 1;co <= C;co++){
			for(int i = 1;i <= n;i++){
				for(int j = 1;j <= n;j++){
					int k = (i + j) % 3;
					int color = c[i][j];
					sum[k][co] += d[color][co];
				}
			}
		}
		ll ans = INF;
		for(int i = 1;i <= C;i++){
			for(int j = 1;j <= C;j++){
				for(int k = 1;k <= C;k++){
					if(i == j || j == k || k == i)continue;
					ll tmp = sum[0][i] + sum[1][j] + sum[2][k];
					ans = min(ans,tmp);
				}
			}
		}
		dump(ans);
	}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  int n_player, winner;
  double P;
  while (scanf(" %d %d %lf", &n_player, &winner, &P) == 3) {
    if (n_player == 0 && winner == 0 && P == 0) break;
    winner--;
    //cout << "winner = " << winner << endl;
    int table[n_player];
    double money = 0;
    for (int i = 0; i < n_player; i++) {
      scanf(" %d", &table[i]);
      money += table[i] * 100;
    }
    if (table[winner] == 0) {
      cout << 0 << endl;
      continue;
    }
    //cout << "money = " << money << endl;
    money -= money * (double)(P/100);
    //cout << (double)(P/100) << endl;
    //cout << "money2 = "  << money << endl;
    cout << (int)(money / table[winner]) << endl;
  }
  return 0;
}

Measured memory_bytes: 0