akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n;
  scanf("%d",&n);
  for(int i = 0; i < 26; ++i){
    for(int j = 0; j < 16; ++j){
      if( i*4 + 7*j == n ){
        printf("Yes");
        return 0;
      }
    }
  }

  printf("No");

  return 0;
}


Measured memory_bytes: 1700
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    
def bfs(u):
    queue = deque([u])
    d = [None]*n
    
    d[u] = 0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v]+1
                p[i] = v
                queue.append(i)
    return d

p = [None]*n
d = bfs(0)
if None in p[1:]:
    print('No')
else:
    print('Yes')
        
for q in range(1,n):
    print(int(p[q])+1)

Measured memory_bytes: 99600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i;
  scanf("%d",&n);
  scanf("%d",&k);
  double x = 0;
  for(i=1;i<=n;i++) {
    double p = 1.0/n;
    int y = i;
    while(y<k) {
      y = y*2;
      p = p/2;
    }
    x += p;
  }
  printf("%.12f\n", x);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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; }



//TLE
// int main() {
//     int K,S;
//     cin >> K >> S;
//     int ans = 0;
//     for(int i = 0; i <= K; i++) {
//         for(int j = 0; j<=K;j++) {
//             for(int k = 0;k<=K;k++) {
//                 int sum = i+j+k;
//                 if(sum == S) ans++;
//             }
//         }
//     }
//     cout << ans << endl;
// }
int main() {
    int K,S;
    cin >> K >> S;
    int ans = 0;
    
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j<=K;j++) {
            int k = S-i-j;
            if(k>=0 && k<=K) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, C, K, D, E, max = 0, ans;
		A = sc.nextInt();
		B = sc.nextInt();
		D = Math.max(A, B);
		C = sc.nextInt();
		E = Math.max(D, C);
		K = sc.nextInt();
		ans = A + B + C - E;
		ans += E * Math.pow(2.0, (double) K);
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

inline long long check(long long a, long long N){
    if(!a) return 0;
    return (N/a == N%a) ? a : 0;
}

int main(){
    long long N, ans(0); std::cin >> N;
    for(long long i(1); i*i <= N; ++i){
        if(!(N % i)){
            ans += check(i-1, N);
            if(i*i < N) ans += check(N/i - 1, N);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
ll fast_pow( ll a , ll b , ll m )
{
 
    ll res=1;
    while(b>0)
    {
        if(b&1) res =  (res*a)%m;
        a=(a*a)%m;
        b=b/2;
    }
    return res;
}
 
template <typename T,typename U>                                                   
std::pair<T,U> operator-(const std::pair<T,U> & l,const std::pair<T,U> & r) {   
    return {l.first-r.first,l.second-r.second};                                    
} 
 
template <typename T,typename U>                                                   
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {   
    return {l.first+r.first,l.second+r.second};                                    
} 
 
const ll maxn = 105;
const int inf = 0x3f3f3f;
const ll MOD = 1e9+7LL;


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



int main()
{
    // freopen( "input.txt" , "w" , stdout );
    
    
 
    //------- INPUT GENERATION ------
 
    // cout<<200000<<endl;
 
    //------- /INPUT GENERATION ------

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    unordered_map<int , int> f;
    unordered_map<int, int> f2;


    int n , m;
    cin>>n>>m;
    int ac=0;
    int wa=0;
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        string ans;
        cin>>ans;
        
        if(ans == "AC")
        {
            if(f[x]==0)
            {
                ac++;
                wa+=f2[x];
            }
            f[x]++;
        }
        else
        {
            f2[x]++;  
        }
    }
    
    cout<<ac<<" "<<wa<<endl;

   
    // cout<<endl;
    // end = std::chrono::system_clock::now(); 
  
    // std::chrono::duration<double> elapsed_seconds = end - start; 
    // std::time_t end_time = std::chrono::system_clock::to_time_t(end); 
  
    // std::cout << "finished computation at " << std::ctime(&end_time) 
    //           << "elapsed time: " << elapsed_seconds.count() << "s\n"; 
 
 
 
 
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    vector<int> col(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    col[0] = 1;
    function<void(int, int)> dfs = [&](int v, int p) {
        for (int to : g[v]) {
            if (to == p) continue;
            col[to] = col[v] ^ 3;
            dfs(to, v);
        }
    };
    dfs(0, -1);
    int sc = 0, tc = 0;
    for (int i = 0; i < n; i++) {
        if (col[i] == 1)
            sc++;
        else
            tc++;
    }
    if (tc > sc) {
        swap(sc, tc);
        for (int i = 0; i < n; i++) col[i] ^= 3;
    }
    ///////-------------- sc >= tc
    if (n / 3 >= tc) {
        int zcnt = 0;
        for (int i = 0; i < n; i++) {
            if (col[i] == 2)
                col[i] = 0, zcnt++;
        }
        zcnt = n / 3 - zcnt;
        for (int i = 0; i < n; i++) {
            if (col[i] && zcnt) {
                zcnt--;
                col[i] = 0;
            }
        }
        zcnt = 0;
        for (int i = 0; i < n; i++) {
            if (col[i] && zcnt < n / 3 + (n % 3 == 2)) {
                zcnt++;
                col[i] = 2;
            }
        }
        int amx = 1, bmx = 2, cmx = 3;
        for (int i = 0; i < n; i++) {
            if (col[i] == 0) {
                cout << cmx << " ";
                cmx += 3;
            } else if (col[i] == 1) {
                cout << amx << " ";
                amx += 3;
            } else {
                cout << bmx << " ";
                bmx += 3;
            }
        }
        cout << endl;
        return 0;
    }
    int amx = 1, bmx = 2, cmx = 3;
    for (int i = 0; i < n; i++) {
        if (col[i] == 1) {
            if (amx <= n) {
                cout << amx << " ";
                amx += 3;
            } else {
                cout << cmx << " ";
                cmx += 3;
            }
        } else {
            if (bmx <= n) {
                cout << bmx << " ";
                bmx += 3;
            } else {
                cout << cmx << " ";
                cmx += 3;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll p(n);
    rep(i, n){
        cin >> p[i];
    }
    string ans = "NO";
    if(is_sorted(ALL(p))) ans = "YES";
    rep(i, n-1){
        repr(j, i, n){
            swap(p[i], p[j]);
            if(is_sorted(ALL(p))){
                ans = "YES";
            }
            swap(p[i], p[j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String[] args){
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
       in.lines()
           .map(Integer::valueOf)
           .sorted(Comparator.reverseOrder())
           .limit(3)
           .forEach(System.out::println);
    }
}

Measured memory_bytes: 30980
#include <stdio.h>

char roll[8][11] = {"null","null","one pair","two pair","three card","straight","full house","four card"};

int main(){
	int ans;
	int emp;
	int a[5];
	int hand[15];
	while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]) != EOF){
		for(int i = 0; i < 15; i++){
			hand[i] = 0;
		}
		for(int i = 0; i < 5; i++){
			hand[a[i]]++;
		}
		emp = 0;
		for(int i = 0; i < 14; i++){
			if(hand[i]){
				emp++;
			}
		}
		hand[14] = hand[1];
		ans = 1;
		if(emp == 4){
			ans = 2;
		}
		if(emp == 3){
			ans = 3;
		}
		for(int i = 1; i < 14; i++){
			if(hand[i] == 3){
				ans = 4;
			}
		}
		for(int i = 1; i < 11; i++){
			if(hand[i] == 1 && hand[i + 1] == 1 && hand[i + 2] == 1 && hand[i + 3] == 1 && hand[i + 4] == 1){
				ans = 5;
			}
		}
		if(emp == 2){
			ans = 6;
		}
		for(int i = 1; i < 14; i++){
			if(hand[i] >= 4){
				ans = 7;
			}
		}
		printf("%s\n",roll[ans]);
	}
	return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#define ll long long
#define mod 1000000007
using namespace std;
ll a[100010];
ll b[100010];
int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (int i = 0; i < m; i++)
		scanf("%lld", &b[i]);
	ll dap = 0,dap1=0;
	ll ch = 0, ch1 = 0;
	for (int i = 0; i < n; i++)
	{
		dap += (a[i] - a[0]);
	}
	for (int i = 0; i < m; i++) {
		dap1 += (b[i] - b[0]);
	}
	ch = dap;
	ch1 = dap1;
	for (int i = 1; i < n; i++)
	{
		dap -= ((a[i] - a[i - 1])*(n - i));
		ch += dap;
		ch %= mod;
	}
	for (int i = 1; i < m; i++)
	{
		dap1 -= ((b[i] - b[i-1])*(m - i));
		ch1 +=dap1;
		ch1 %= mod;
	}
	printf("%lld", (ch*ch1) % mod);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, total; cin >> n >> total;
    for (ll x = 0; x <= n; x++) {
        for (ll y = 0; y <= n - x; y++) {
            ll z = n - x - y;
            if (10000 * x + 5000 * y + 1000 * z == total) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
# AOJ 0600 Baumkuchen
# Python3 2018.7.3 bal4u
  
import sys
from sys import stdin
input = stdin.readline
  
n = int(input())
a = [int(input()) for i in range(n)]
su = sum(a)
p = [0]*(n+1)
s = [0]*(n+1)
l, r = 0, su+1
while l + 1 < r:
    m = (l+r) >> 1
    for i in range(0, n):
        if i == 0: s[i] = p[i] = 0
        else:
            p[i] = p[i-1] - 1
            s[i] = s[i-1] - a[i-1]
              
        while s[i] < m:
            ii = i + p[i];
            if ii >= n: ii -= n
            s[i] += a[ii]
            p[i] += 1
  
    f = 0   
    for i in range(n):
        ii = i + p[i];
        if ii >= n: ii -= n
        if su-s[i]-s[ii] >= m:
            f = 1
            break
    if f: l = m
    else: r = m
print(l)


Measured memory_bytes: 18064
s = input()
l = len(s)

cnt = 0

for i in range(l):
	if i % 2 == 0 :
		if s[i] == "0" :
			cnt += 1

	else:
		if s[i] == "1" :
			cnt += 1

cnt_r = 0

for j in range(l):
	if j % 2 == 0 :
		if s[j] == "1" :
			cnt_r += 1

	else:
		if s[j] == "0" :
			cnt_r += 1

print(min(cnt, cnt_r))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 7;
const string res[N + 1] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
const double t[N][2] = {35.50, 71.00, 37.50, 77.00, 40.00, 83.00, 43.00, 89.00, 50.00, 105.00, 55.00, 116.00, 70.00, 148.00};

int main(void){
    for(vector<double> in(2); cin >> in[0] >> in[1];){
        int ind = N;
        for(int i = N - 1; 0 <= i; i --) rep(j, 2){
            if(t[i][j] <= in[j]) break;
            if(j) ind = i;
        }
        cout << res[ind] << endl;
    }
 
    return 0;
}

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

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

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

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

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

  cout << (x >= 30 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3544
import Foundation

let N = Int(readLine()!)!
var dp: [[[Int]]] = .init(repeating: .init(repeating: .init(repeating: -1, count: N + 1), count: N + 1), count: N + 1)
let n = Int(sqrt(Double(N)))
var count: [Int] = .init(repeating: 0, count: N)

for x in 1...n {
  for y in 1...n {
    for z in 1...n {
      dp[x][y][z] = x * x + x * y + y * y + y * z + z * z + z * x
      if 1...N ~= dp[x][y][z] {
        count[dp[x][y][z] - 1] += 1
      }
    }
  }
}

for i in 0..<N {
  print(count[i])
}

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

const int maxn = 2e5+10;

int a[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        scanf("%d", &a[i]);
    sort(a+1, a+n+1);
    int m = unique(a+1, a+n+1)-(a+1);
    if(m==n)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL countLarger(vector<LL> &pv, vector<LL> &nv, LL x, bool dec = false) {
	if (pv.size() == 0 || nv.size() == 0) {
		return 0;
	}
	int cn = nv.size() - 1;
	LL res = (LL)(0);
	for (int cp = 0; cp < pv.size(); ++cp) {
		while (cn >= 0 && nv[cn] * pv[cp] > x) {
			--cn;
		}
		res += (LL)(nv.size() - cn - 1);
	}
	if (dec) {
		for (int i = 0; i < pv.size(); ++i) {
			if (pv[i] * pv[i] > x) {
				res -= (LL)(1);
			}
		}
		res /= (LL)(2);
	}
	return res;
}

LL LLmin(LL a, LL b) {
	return (a > b) ? b : a;
}
LL LLmax(LL a, LL b) {
	return (a > b) ? a : b;
}

int main() {
	int n;
	LL k;
	vector<LL> a;
	a.clear();
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		LL t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());

	LL pn = (LL)(0), nn = (LL)(0);
	for (int i = 0; i < n; ++i) {
		if (a[i] > (LL)(0)) {
			pn += (LL)(1);
		}
		if (a[i] < (LL)(0)) {
			nn += (LL)(1);
		}
	}
	LL ppn = (pn * (pn - (LL)(1)) + nn * (nn - (LL)(1))) / (LL)(2);
	LL npn = pn * nn;
	LL totaln = ((LL)(n) * ((LL)(n) - (LL)(1))) / (LL)(2);
	if (k > npn && k <= totaln - ppn) {
		cout << 0 << endl;
		return 0;
	}

	vector<LL> pv, nv;
	pv.clear();
	nv.clear();
	for (int i = 0; i < n; ++i) {
		if (a[i] > (LL)(0)) {
			pv.push_back(a[i]);
		}
		if (a[i] < (LL)(0)) {
			nv.push_back(-a[i]);
		}
	}
	sort(pv.begin(), pv.end());
	sort(nv.begin(), nv.end());
	if (k <= npn) {
		int npv = pv.size(), nnv = nv.size();
		LL lft = 0;
		LL rgt = (LL)(1000000000);
		rgt *= (LL)(1000000001);
		while (lft < rgt) {
			LL mid = (lft + rgt) / (LL)(2);
			LL count = countLarger(pv, nv, mid);
			if (count > k - (LL)(1)) {
				lft = mid + (LL)(1);
			}
			else {
				rgt = mid;
			}
		}
		cout << (-lft) << endl;
		return 0;
		// one from pv, one from nv
	}
	if (k > totaln - ppn) {
		int npv = pv.size(), nnv = nv.size();
		// pv, pv && nv, nv
		k = totaln - k + (LL)(1);
		// cout << "k = " << k << endl;
		LL lft = 0;
		LL rgt = (LL)(1000000000);
		rgt *= (LL)(1000000001);
		while (lft < rgt) {
			LL mid = (lft + rgt) / (LL)(2);
			LL count = countLarger(pv, pv, mid, true) + countLarger(nv, nv, mid, true);
			// cout << "pv larger than " << mid << " = " << countLarger(pv, pv, mid) << endl;
			// cout << "nv larger than " << mid << " = " << countLarger(nv, nv, mid) << endl;
			if (count > k - (LL)(1)) {
				lft = mid + (LL)(1);
			}
			else {
				rgt = mid;
			}
		}
		cout << lft << endl;
		return 0;
		// cout << (-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
int dp[16][16]={};

int main() {
	int n;
	cin>>n;
	rep(i,16){
		rep(j,16){
			dp[i][j]=-1;
		}
	}
	rep(i,n){
		int a;
		cin>>a;
		rep(j,a){
			int x,y;
			cin>>x>>y;
			dp[i+1][x]=y;
		}
	}
	int r=0;
	rep(i,(1<<n)){
		bool flg=true;
		int n2=0;
		rep(j,n){
			if((i&(1<<j))>0){
				n2++;
				rep(k,n){
					if((dp[j+1][k+1]==0&&((i&(1<<k))>0))||(dp[j+1][k+1]>0&&((i&(1<<k))==0)))flg=false;
				}
			}
		}
		if(flg)r=max(r,n2);
	}
	printf("%d",r);

	return 0;
}


Measured memory_bytes: 2560
import java.util.*;

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

    int r = sc.nextInt();

    // 2×半径×円周率
    double circle = 2 * r * Math.PI;
    System.out.println(circle);

    sc.close();
  }
}


Measured memory_bytes: 35908
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool check(int n)
{
	int count=0;
	for(int i=1;i<=n;i++)
		if(n%i==0)
			++count;
	if(count==8)
		return true;
	else
		return false;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin>>n;
	int count=0;
	for(int i=3;i<=n;i+=2)
	{
        if(check(i))
        	++count;
	}
	cout<<count;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <limits>
#include <cfloat>
#include <functional>
using namespace std;

template <class T>
class Edge
{
public:
    int to;
    T cost;
    Edge(){};
    Edge(int to0, T cost0){to = to0; cost = cost0;}
};

template<class T>
void shortestPath(const vector<vector<Edge<T> > >& edges, int start, vector<T>& dist)
{
    const T INF = numeric_limits<T>::max();
    const T EPS = static_cast<T>(1.0e-10);

    dist.assign(edges.size(), INF);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int> >, greater<pair<T,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<T, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first - EPS)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge<T> e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to] - EPS){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

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

    vector<vector<Edge<int> > > edges(n);
    for(int i=0; i<m; ++i){
        int a, b, c, d;
        char z;
        cin >> a >> z >> b >> z >> c >> z >> d;
        edges[a-1].push_back(Edge<int>(b-1, c));
        edges[b-1].push_back(Edge<int>(a-1, d));
    }

    int x1, x2, y1, y2;
    char z;
    cin >> x1 >> z >> x2 >> z >> y1 >> z >> y2;

    vector<int> dist1, dist2;
    shortestPath(edges, x1-1, dist1);
    shortestPath(edges, x2-1, dist2);

    int ret = y1 - y2 - dist1[x2-1] - dist2[x1-1];
    cout << ret << endl;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int n;
    scanf("%d", &n);
    int k=1;
    while(k*(k-1)/2 < n)
        k++;
    if (k*(k-1)/2 == n){
        printf("Yes\n");
        printf("%d\n", k);

        vector<vector<int>> Ss(k);
        int row1 = 0, row2 = 1;
        const int m = k-1;
        for(int i=1; i<=n; i++){
            if (Ss[row1].size()==m){
                row1++;
                row2 = row1+1;
            }
            Ss[row1].push_back(i);
            Ss[row2++].push_back(i);
        }

        for(int kk=0;kk<k; kk++) {
            printf("%d ",k-1);
            for (int x : Ss[kk])
                printf("%d ", x);
            printf("\n");
        }

    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
const int S_MAX = 30;
const double inf = 1e9;

struct info{
    int curr;
    int prev;
    int v;
    double t;
    info(int c, int p, int v, double t):curr(c),prev(p),v(v),t(t){}
};
namespace std{
    bool operator < (const info &a, const info &b){
        return b.t < a.t;
    }
}

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        int s,g;
        cin >> s >> g;
        vector<vector<vector<info> > > adj(n+1, vector<vector<info> >(S_MAX+1));
        for(int i=0; i<m; i++){
            int x,y,d,c;
            cin >> x >> y >> d >> c;
            for(int v=1; v<=S_MAX; v++){
                for(int r=-1; r<=1; r++){
                    if(v+r>0 && v+r<=c){
                        adj[x][v].push_back(info(y, x, v+r, (double)d/(v+r)));
                        adj[y][v].push_back(info(x, y, v+r, (double)d/(v+r)));
                    }
                }
            }
        }

        priority_queue<info> pq;
        pq.push(info(s, 0, 1, 0));
        vector<vector<vector<double> > > mincost(n+1, vector<vector<double> >(n+1, vector<double>(S_MAX+1, inf)));
        mincost[s][0][1] = 0;
        while(!pq.empty()){
            int curr = pq.top().curr;
            int prev = pq.top().prev;
            int v = pq.top().v;
            double cost = pq.top().t;
            pq.pop();
            if(cost > mincost[curr][prev][v]) continue;
            if(curr==g && v==1) break;
            for(int i=0; i<(int)adj[curr][v].size(); i++){
                info next = adj[curr][v][i];
                if(next.curr == prev) continue;
                if(prev == 0 && next.v != 1) continue;
                if(cost + next.t < mincost[next.curr][next.prev][next.v]){
                    pq.push(info(next.curr, next.prev, next.v, cost+next.t));
                    mincost[next.curr][next.prev][next.v] = cost + next.t;
                }
            }
        }
        double ans=inf;
        for(int i=1; i<=n; i++){
            ans = min(ans, mincost[g][i][1]);
        }
        if(ans == inf){
            cout << "unreachable" << endl;
        }else{
            cout << fixed;
            cout << setprecision(12);
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6144
n = int(input())
S = [s for s in input()]
w,b = [0],[0]
for i in range(n):
    if S[i] is '#': w.append(w[i]+1)
    else:   w.append(w[i])
    if S[n-i-1] is '.': b.append(b[i]+1)
    else:   b.append(b[i])
b = b[::-1]
#print(w,b)
ans = float('inf')
for i in range(n+1):
    ans = min(ans, w[i]+b[i])
print(ans)


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

using namespace std;

int main()

{

string s;
cin >> s;
int ans =0;
for(int i = 0 ; i < (int)s.size() ; i++)
   {
    for(int j = 1 ; j <= (int)s.size() - i; j++)
    {
      string k = s.substr(i,j);
      int ok = 1;
      for(int t = 0 ; t < (int)k.size() ; t++)
       {
           if(k[t] != 'A' and k[t] != 'G' and k[t] != 'C' and k[t] != 'T')  ok = 0;
       }
       
       if(ok) ans = max(ans , (int)k.size());
    }
   }
   
   cout << ans ;

}

Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(n int, a []int) int {
        c := 0
        rise := 0 // -1: down, 1: up
        for i := 1; i < n; i++ {
                d := a[i] - a[i-1]
                switch {
                case d > 0 && rise == -1:
                        c++
                        rise = 0
                case d < 0 && rise == 1:
                        c++
                        rise = 0
                case d > 0:
                        rise = 1
                case d < 0:
                        rise = -1
                }
        }
        return c + 1
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n int
        fmt.Fscan(r, &n)
        a := make([]int, n)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    cout << ((s[2] == s[3] and s[4] == s[5]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (long long i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			long long tmp = n / i;
			if (i + 2 <= tmp) ans += tmp - 1;
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC117_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var raw_str = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            double T = raw_str[0];
            double X = raw_str[1];

            Console.WriteLine(T / X);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<string>
using namespace std;
string str;
int inp(){
	int n,x;
	cin>>str;
	if(!str.compare("-"))return 0;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>x;
		str=str.substr(x)+str.substr(0,x);
	}
	cout<<str<<endl;
	return 1;
}
int main(){
	while(inp());
	return 0;
}

Measured memory_bytes: 1216
// Aizu Vol-10 1060: No Story
// 2017.10.7 bal4u@uu

#include <stdio.h>
#include <math.h>

#define SIZE  100
int size;
int power[SIZE];

void prime_factor(long long n)
{
    long long i;
    int sw;
    
    size = 0;
    if ((n & 1LL) == 0) {
        power[size] = 0;
        do n >>= 1LL, power[size]++;
        while ((n & 1) == 0);
        size++;
    }
    if (n % 3LL == 0) {
        power[size] = 0;
        do n /= 3LL, power[size]++;
        while (n % 3LL == 0);
        size++;
    }
    if (n > 1LL) {
        long long b = (long long)sqrt((double)n);
        for (i = 5, sw = 1; n > 1; ) {
            if (i > b) { power[size++] = 1; break; }
            if (n % i == 0) {
                power[size] = 0;
                do n /= i, power[size]++;
                while (n % i == 0);
                size++;
            }
            if (sw) i += 2, sw = 0;
            else    i += 4, sw = 1;
        }
    }
}

int main()
{
	long long n, ans;
	int i;

	while (scanf("%lld", &n) && n > 0) {
        prime_factor(n);
		for (ans = 1LL, i = 0; i < size; i++) ans = ans * (1 + (power[i] << 1));
		ans = (ans + 1) / 2;
        printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1752
#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) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int 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() {
	
	ll A,B;
  cin>>A>>B;
	ll ans=0;
	if(A & 1==1){
		if(B & 1==1){
			if(((B-A)/2)%2==0){
				ans=0;
			}else{
				ans=1;
			}
		}else{
			if(((B-A)/2)%2==0){
				ans=0;
			}else{
				ans=1;
			}
			ans^=B;
		}
		ans^=A;
	}else{
		if(B & 1==1){
			if(((B-A+1)/2)%2==0){
				ans=0;
			}else{
				ans=1;
			}

		}else{
			if(((B-A)/2)%2==0){
				ans=0;
			}else{
				ans=1;
			}
          			ans^=B;
		}
	}
	ce(ans)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
const int Maxn = 52;
 
string S, T;
string res;
 
bool Restore(int pos, string &tmp)
{
	tmp = S;
	for (int i = 0; i < T.length(); i++)
		if (S[pos + i] != '?' && S[pos + i] != T[i]) return false;
		else tmp[pos + i] = T[i];
	for (int i = 0; i < tmp.length(); i++)
		if (tmp[i] == '?') tmp[i] = 'a';
	return true;
}
 
int main()
{
	cin >> S >> T;
	string tmp;
	for (int i = 0; i + T.length() <= S.length(); i++)
		if (Restore(i, tmp))
			if (res == "" || tmp < res) res = tmp;
	if (res == "") printf("UNRESTORABLE\n");
	else printf("%s\n", res.c_str());
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

ll dp[2005];

ll go(ll s)
{
	if (s == 0)return 1;
	if (s < 3)return 0;
	ll &ans = dp[s];
	if (ans != -1)return ans;
	ans = 0;
	for (int i = 3; i <= s; ++i)
	{
		ans += go(s - i);
		ans %= M;
	}
	return ans;
}

void solve()
{
	ll s;
	cin >> s;
	memset(dp, -1, sizeof dp);
	cout << go(s) << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999

int main() {
	int a,b,c,d = 0;
	cin >> a >> b >> c;
	if (c > 1000) {
		d = c / 1000 * min(a, b * 2);
		c = c % 1000;
	}
	if (c > 500) d += min(a, b * 2);
	else if (c > 0) d += min(a, b);
	cout << d << endl;
}


Measured memory_bytes: 3124
struct MyIo{

}

impl MyIo{
    fn readline()->Vec<String>{
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let ret:Vec<String> = buf.split_whitespace().map(|c|c.to_string()).collect();
        ret
    }
}



fn main() {

    let mut input = MyIo::readline().into_iter();

    let v1 = input.next().unwrap().parse::<i32>().unwrap();
    let v2 = input.next().unwrap().parse::<i32>().unwrap();

    let mut n:i32=0;
    let dif = v2-v1;

    n = (1..1000).scan(0,|total,v|{*total=*total+v;Some(*total)}).nth((dif-1) as usize).unwrap();
    println!("{}",n - v2);
}

Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

//Color the Map
public class Main{

	class R{
		List<L> l;
		boolean u;
		int color, id;
		public R(int id) {
			this.id = id;
			l = new ArrayList<L>();
			u = false;
			color = 0;
		}
		boolean adj(R r){
			for(L a:l)for(L b:r.l){
				double x1 = a.t.x-a.s.x, y1 = a.t.y-a.s.y, x2 = b.t.x-b.s.x, y2 = b.t.y-b.s.y;
				if(x1*y2-x2*y1!=0)continue;
				if(x1==0){
					if(a.s.x!=b.s.x)continue;
					P[] p = new P[4];
					a.s.id = a.t.id = 0; b.s.id = b.t.id = 1;
					p[0] = a.s; p[1] = a.t;
					p[2] = b.s; p[3] = b.t;
					Arrays.sort(p);
					if(p[0].id==p[1].id)continue;
					if(!p[1].eq(p[2]))return true;
				}
				else{
					double alpha = y1/x1;
					double beta = a.s.y-alpha*a.s.x;
					double y = b.s.y, x = alpha*b.s.x+beta;
					if(Math.abs(y-x)<1e-7){
						P[] p = new P[4];
						a.s.id = a.t.id = 0; b.s.id = b.t.id = 1;
						p[0] = a.s; p[1] = a.t;
						p[2] = b.s; p[3] = b.t;
						Arrays.sort(p);
						if(p[0].id==p[1].id)continue;
						if(!p[1].eq(p[2]))return true;
					}
				}
			}
			return false;
		}
	}
	class P implements Comparable<P>{
		int id;
		double x, y;
		public P(double x, double y, int d) {
			this.x = x;
			this.y = y;
			id = d;
		}
		public int compareTo(P o) {
			if(x<o.x)return -1;
			if(o.x<x)return 1;
			return (int) Math.signum(y-o.y);
		}
		boolean eq(P p){
			return Math.abs(x-p.x)<1e-7 && Math.abs(y-p.y)<1e-7;
		}
	}
	class L{
		P s, t;
		public L(P s, P t) {
			this.s = s;
			this.t = t;
			if(t.compareTo(s)<0){
				P tmp = s;
				s = t;
				t = tmp;
			}
		}
		
	}

	R[] c;
	int N, min;
	boolean[][] adj;
	
	void dfs(int k, int maxcolor){
		boolean[] u = new boolean[11];
		for(int i=0;i<N;i++){
			if(adj[k][i])u[c[i].color] = true;
		}
		if(k==N-1){
			for(int i=1;i<=maxcolor+1;i++){
				if(!u[i]){
					min = Math.min(min, Math.max(i, maxcolor));
					return;
				}
			}
		}
		for(int i=1;i<=maxcolor+1;i++){
			if(!u[i]){
				c[k].color = i;
				dfs(k+1, Math.max(i, maxcolor));
				c[k].color = 0;
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int id = 0;
			Map<String, Integer> ref = new HashMap<String, Integer>();
			c = new R[10];
			while(n--!=0){
				String name = sc.next();
				R r;
				if(ref.containsKey(name))r = c[ref.get(name)];
				else{
					r = new R(id);
					c[id] = r;
					ref.put(name, id++);
				}
				int sx = sc.nextInt(), sy = sc.nextInt();
				int px = sx, py = sy;
				for(;;){
					int x = sc.nextInt();
					if(x==-1){
						r.l.add(new L(new P(px, py, 0), new P(sx, sy, 0)));
						break;
					}
					int y = sc.nextInt();
					r.l.add(new L(new P(px, py, 0), new P(x, y, 0)));
					px = x; py = y;
				}
			}
			adj = new boolean[id][id];
			for(int i=0;i<id;i++)for(int j=i+1;j<id;j++){
				if(adj[i][j])continue;
				if(c[i].adj(c[j])){
					adj[i][j] = true;
					adj[j][i] = true;
				}
			}
			N = id;
			min = 10;
			dfs(0, 0);
			System.out.println(min);
		}
	}

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    vl v[100005];
    bool visited[100005]={0};
    ll cnt=0;
    ll dist[100005]={0};
    ll in_degree[100005];
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            dist[f]=max(dist[f],dist[u]+1);
            --in_degree[f];
            if(in_degree[f]==0)dfs(f);
        }
    }
    void solve()
    {
        in2(n,m);
        f(i,0,m)
        {
            in2(x,y);
            v[x].pb(y);
            ++in_degree[y];
        }
        f(i,1,n+1)
        {
            if(!visited[i] && in_degree[i]==0)
                dfs(i);
        }
        cout<<*max_element(dist,dist+n+1);

    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll ans;
    REP(i,5){
        ll x;
        cin >> x;
        if(x == 0){
            ans = i+1;
        }
    }

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


Measured memory_bytes: 3596
#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 ops cout<<"ops"<<endl;
#define freopens freopen("dishes.in", "r", stdin);freopen("dishes.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 107
#define DIMM 10000007
#define INF 10000000000000000007.0
#define X 200000
#define epc 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> myset;

ll n;
ll res;
ll v[DIM],c[DIM];

int main()
{
    //ops
    //freopens
    fast

    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    for(int i=1;i<=n;i++){
     cin>>c[i];
     if((v[i]-c[i])>0)res+=(v[i]-c[i]);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
M = sum(A)

for i in range(N):
    if A[i] <= B[i]:
        B[i] -= A[i]
        A[i] = 0

ne = M
for i in range(N):
    if A[i] != 0 and B[i] < ne:
        ne = B[i]
print(M - ne)
# Correct

Measured memory_bytes: 4852
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        String  s  = stdIn.next();
        String  t  = stdIn.next();
        
        String[] ss = s.split("");
        String[] tt = t.split("");

        int count = 0;
        for(int i = 0;i < 3; i++) {
            if(ss[i].equals(tt[i])){
                count++;
            }
        }

        
        System.out.println(count);

        
    }

}

Measured memory_bytes: 22996
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		N int
	)

	fmt.Scan(&N)

	VArray := make([]float64, 0, N)
	for i := 0; i < N; i++ {
		var V float64
		fmt.Scan(&V)
		VArray = append(VArray, V)
	}

	sort.Float64s(VArray)
	sum := VArray[0]
	var second float64 = 2
	for i, v := range VArray {
		if i == 0 {
			continue
		}

		sum = (sum + v) / second
	}

	fmt.Println(sum)
}


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


void solve(long long N, long long X, std::vector<long long> m){
    auto rem = X - accumulate(m.begin(), m.end(), 0l);
    auto min = *min_element(m.begin(), m.end());
    cout << N + (rem / min) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> m(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&m[i]);
    }
    solve(N, X, std::move(m));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    int len = s.size();

    if (len <= k){
        cout << s;
    } else {
        string t = s.substr(0, k) + "...";
        cout << t;
    }

    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  bool first = true;
  while (k) {
    if (first) {
      b += a / 2;
      a /= 2;
    }
    else {
      a += b / 2;
      b /= 2;
    }
    first = !first;
    k--;
  }
  cout << a << " " << b << endl;
}


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

int main(){

    int n;
    cin >> n;

    int A_count = 0;
    int Uh_count = 0;
    string ans = "YES";

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

        if(s == "A"){
            A_count++;
        }
        else{
            Uh_count++;
        }

        if(A_count < Uh_count){
            ans = "NO";
            break;
        }
    }

    if(A_count != Uh_count){
        ans = "NO";
    }

    cout << ans << endl;

}


Measured memory_bytes: 3212