akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#define MAXN 100010

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN<<1];

int n,lim;
int pre[MAXN];
int g[MAXN],nume;
int dep[MAXN],maxd[MAXN];
bool f[MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

void dfs(int x){
	maxd[x]=dep[x];
	for(int i=g[x];~i;i=e[i].next){
		dep[e[i].to]=dep[x]+1;
		dfs(e[i].to);
		if(f[e[i].to]) continue;
		if(maxd[e[i].to]>maxd[x])
			maxd[x]=maxd[e[i].to];
	}
	if(maxd[x]-dep[x]+1>=lim && pre[x]!=1) f[x]=1;
}

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	memset(g,-1,sizeof g);
	scanf("%d%d",&n,&lim);
	for(int i=1;i<=n;i++) scanf("%d",pre+i);
	if(pre[1]!=1) f[1]=1;
	pre[1]=1;
	for(int i=2;i<=n;i++) addEdge(pre[i],i);
	dfs(1);
	int ans=0;
	for(int i=1;i<=n;i++) if(f[i]) ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;

int main(){
  ll a,b;
  cin>>a>>b;
  ll ans = a*b/2;
  if(a==1 || b==1) cout << 1;
  else if(a%2==1 && b%2==1) cout << ans+1;
  else cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

string s[51];
map<char,int> cnt,cnt2;
int main(){
    int n;
    cin>>n;
    rep(i,26){
        cnt2[(char)(i+'a')]=2555;
    }
    FOR(i,0,n){
        cin>>s[i];
        rep(i,26){
            cnt[(char)(i+'a')]=0;
        }
        rep(j,s[i].size()){
            ++cnt[s[i][j]];
        }
        for(auto it:cnt){
            cnt2[it.first]=min(cnt2[it.first],it.second);
        }
    }
    string ans;
    for(auto it:cnt2){
        if(it.second>0&&it.second!=2555){
            int c=it.second;
            while(c--) ans+=it.first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#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() {
    string s;
    cin >> s;
    deque<char> ans;
    rep(i,s.size()) {
        if (s[i] == '1' || s[i] == '0') ans.push_back(s[i]);
        else if (ans.size() > 0) ans.pop_back();
    }
    while (ans.size() > 0) {
        char c = ans.front();
        ans.pop_front();
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>

struct Vector {
	int64_t x, y;
	Vector(int64_t x = 0, int64_t y = 0): x(x), y(y) {}
	int64_t mag_sq() const {
		return x * x + y * y;
	}

	friend Vector operator+ (const Vector &a, const Vector &b) {
		return Vector(a.x + b.x, a.y + b.y);
	}
	friend int64_t operator^ (const Vector &a, const Vector &b) {
		return a.x * b.y - a.y * b.x;
	}
	bool hspace() const {
		if (x == 0) {
			return y > 0;
		} else {
			return x < 0;
		}
	}

	static bool angle_cmp(const Vector &a, const Vector &b) {
		//return std::atan2(a.y, a.x) < std::atan2(b.y, b.x);
		bool ha = a.hspace();
		bool hb = b.hspace();

		if (ha != hb) {
			return ha < hb;
		} else {
			return (a ^ b) > 0;
		}
	}
};

std::vector<Vector> vList;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	uint32_t n;
	std::cin >> n;

	for (uint32_t i = 0;i < n;i++) {
		Vector v;
		std::cin >> v.x >> v.y;
		if ((v.x != 0) || (v.y != 0)) {
			vList.push_back(v);
		}
	}
}

long double solve() {
	int64_t best = 0;
	std::sort(vList.begin(), vList.end(), Vector::angle_cmp);
	//for (uint32_t i = 0;i < vList.size();i++) {
	//	std::cerr << vList[i].x << " " << vList[i].y << "\n";
	//}
	for (uint32_t i = 0;i < vList.size();i++) {
		Vector cur(0, 0);
		uint32_t j = i;
		for (uint32_t k = 0;k < vList.size();k++) {
			cur = cur + vList[j];
			best = std::max(best, cur.mag_sq());
			j = (j + 1) % vList.size();
		}
	}
	return sqrtl((long double) (best));
}


int main() {
	input();
	std::cout << std::fixed << std::setprecision(50) << solve() << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int A[10000];
int count=0;

void iszhi(int A[],int n)
{
	int flag=1,i,j;
	for(i=0;i<n;i++)
	{
		for(j=2;j<=(int)sqrt(A[i]);j++)
		//for(j=2;j<A[i];j++)
			if(A[i]%j==0)
			{
				flag=0;
				break;
			}
		if(flag)
		{
			count++;
			//printf("a=%d\n",A[i]); 
		}	
		flag=1;	
	}
}

int main(void)
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	iszhi(A,n);
	printf("%d\n",count);
	return 0;
} 


Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long a = 1;
            long x = 0;
            while (a * a <= N)
            {
                if (N % a == 0)
                {
                    x = a;
                }
                a += 1;
            }
            long y = N / x;
            Console.WriteLine(x + y - 2);
        }
    }
}


Measured memory_bytes: 27512
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n)

	if n == 1 {
		fmt.Println("Hello World")
		return
	}
	if n == 2 {
		fmt.Scan(&a, &b)
		fmt.Println(a + b)
	}

}


Measured memory_bytes: 1768
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n < 105 {
		fmt.Println(0)
	} else if n < 135 {
		fmt.Println(1)
	} else if n < 165 {
		fmt.Println(2)
	} else if n < 189 {
		fmt.Println(3)
	} else if n < 195 {
		fmt.Println(4)
	} else {
		fmt.Println(5)
	}
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int bubblesort(int a[],int n)
{
    int flag=1,times=0,i=0;
    while(flag)
    {
        flag=0;
        for(int j=n-1;j>=i+1;j--)
            if(a[j]<a[j-1])
            {
                swap(a[j],a[j-1]);
                times++;
                flag=1;
            }
        i++;
    }
    return times;
}
int main()
{
    int a[100],times;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    times=bubblesort(a,n);
    for(int i=0;i<n-1;i++)
        cout<<a[i]<<' ';
    cout<<a[n-1];
    cout<<endl;
    cout<<times<<endl;
    return 0;
}

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

int main() {
  long long n; cin >> n;
  long long cnt = n;
  for (int i = 1; i <= 1000000; ++i) {
    if (n % i == 0) {
      long long tmp = i + n / i - 2;
      if (tmp < cnt) cnt = tmp;
    }
  }
  cout << cnt << endl;
}


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


int main() 
{
    int N;
    cin>>N;
    vector<int>L(N,0);

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

    auto end=L.end();

    int ans = 0;
    for (auto it1 = L.begin(); it1 != end; ++it1)
    {
        for (auto it2 = it1+1; it2 !=end; ++it2)
        {
            if((*it1)==(*it2))
            {
                continue;
            }
            for(auto it3=it2+1;it3!=end;++it3)
            {
                if((*it2)==(*it3)||(*it1)==(*it3))
                {
                    continue;
                }
                if((*it1)+(*it2)>(*it3)&&(*it2)+(*it3)>(*it1)&&(*it3)+(*it1)>(*it2))
                {
                    ++ans;
                }
            }
        }
        
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3580
s = [0 for i in range(13)]
h = [0 for i in range(13)]
c = [0 for i in range(13)]
d = [0 for i in range(13)]
n = int(input())
for i in range(n):
    m,num = [i for i in input().split()]
    if(m == 'S'):
        s[int(num) - 1] += 1
    if(m == 'H'):
        h[int(num) - 1] += 1
    if(m == 'C'):
        c[int(num) - 1] += 1
    if(m == 'D'):
        d[int(num) - 1] += 1
for i in range(13):
    x1 = s[i]
    if(x1 == 0):
        print('S',i + 1)
for i in range(13):
    x2 = h[i]
    if(x2 == 0):
        print('H',i + 1)
for i in range(13):
    x3 = c[i]
    if(x3 == 0):
        print('C',i + 1)
for i in range(13):
    x4 = d[i]
    if(x4 == 0):
        print('D',i + 1)

Measured memory_bytes: 7720
/*author : Yashvardhan
Saturday, May 30, 2020
5:32 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

int diff(int h1, int m1, int h2, int m2){
	if(h1 == h2 && m1 == m2) return 0;
	int ans = 0;
	while(1){
		m1 += 1;
		ans++;
		if(m1 == 60){
			h1 += 1;
			m1 %= 60;
		}
		h1 %= 24;

		if(h1 == h2 && m1 == m2) return ans;
	}
}
signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int tot_diff = diff(h1, m1, h2, m2);

	cout << tot_diff - k << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3640
/**
*	created: 10.09.2020 00:25:37
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T &b) {if (b < a) {a = b; return 1;} return 0;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

struct graph {
    vector<vector<int>> to;
    vector<P> bri;
    vector<int> art, ord, low;
    vector<bool> vis;
    graph(int n) : ord(n,0), low(n,0), vis(n,false), to(n) {}

    void lowlink(int v, int p, int &t) { 
        vis[v] = true;
        ord[v] = t++;
        low[v] = ord[v]; // initialize
        bool isart = false; int cnt = 0;
        for (auto i : to[v]) {
            if(!vis[i]) {
                cnt++; lowlink(i,v,t); chmin(low[v],low[i]);
                if (!p && ord[v] <= low[i]) isart = true;
                if (ord[v] < low[i]) bri.push_back(P(min(v,i),max(v,i)));
            }
            else if (i != p) chmin(low[v],ord[i]);
        }
        if (p == -1 && cnt > 1) isart = true;
        if(isart) art.push_back(v);
    }
};

signed main() {
    int n, m; cin >> n >> m;
    graph G(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        G.to[a].push_back(b);
        G.to[b].push_back(a);
    }
    int t = 0;
    rep(i,n) G.lowlink(i,-1,t);
    cout << G.bri.size() << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	cin>>n;
	long long sum=0;
	int mini=INT_MAX;
	int ma=-INT_MAX;
	for(int i=0;i<n;i++){
		cin>>a;
		sum+=a;
		if(mini>a)mini=a;
		if(ma<a)ma=a;
	}
	cout<<mini<<" "<<ma<<" "<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3108
N, K = map(int, input().split())
P = int(1e9+7)

# 再利用する時あらかじめN以下の計算しとく
kaizyo = [0]
kaizyo_inv = [0]
tmp = 1
for i in range(1, N+2):
    tmp = (tmp*i) % P
    kaizyo.append(tmp)
    kaizyo_inv.append(pow(tmp, P - 2, P))


def comb(n, r):
    if n < r or n < 0:
        return 0
    elif n == r or r == 0:
        return 1
    else:
        return kaizyo[n] * kaizyo_inv[r] * kaizyo_inv[n - r]

for i in range(1, K + 1):
    print((comb(K - 1, i - 1) * comb(N - K + 1, i)) % P)


Measured memory_bytes: 74520
n=int(input())
a = list(map(int,input().split()))
b= list(map(int,input().split()))
c= list(map(int,input().split()))
score=0
m=-1
for i in a:
  if(i-m==1):
    score+=c[i-2]
  score+=b[i-1]
  m=i
print(score)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A;
    int S[N];
    for(int i=1; i<=N; i++){
        cin >> A;
        S[A-1] = i;
    }
    for(int i=0; i<N; i++){
        cout << S[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factrial(int n){
  if(n == 0) return 1;
  return n*factrial(n-1);
}

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

vector<pair<int,pair<int,int>>> v;

int main(){
  int a,b;
  cin >> a >> b;
  a--;b--;
  cout << a*b << endl;
}
  




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

int a[2001];
int main() {
    int N,Z,W;
    cin >> N >> Z >> W;
    for(int i=0; i<N; ++i) {
        cin >> a[i];
    }

    int ans = 0;
    if (N==1) {
        ans = abs(a[0]-W);
    } else {
        ans = max(abs(a[N-1]-W),abs(a[N-2]-a[N-1]));
    }

    cout << ans << endl;
}



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

int main()
{
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        string s[102];
        int ans = 0;
        bool y = true;
        bool ly = true;
        bool ry = true;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            if(s[i] == "lu" || s[i] == "ld") ly = !ly;
            else ry = !ry;
            if(ly == ry && y != ly){
                ans++;
                y = !y;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3148
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,sum=0;
  cin>>a>>b>>c;
  if(a+b==c || a+c==b || b+c==a){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 512
import sys

N = int(sys.stdin.readline())
S = input()
K = int(sys.stdin.readline())

#print(N,K)
#print(type(S))

sk = S[K-1]
out = ""
for s in S:
    if sk==s:
        out += s
#        print("onaji",s)
    else:
        out += "*"
#        print("tigau",s)
print(out)
        

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

int main() {
  string S;
  cin >> S;
  int ssize = S.size();
  string ans = "Yes";
  rep(i, (ssize - 1)/2){
    if(S.at(i) != S.at(ssize - i -1)){
      ans = "No";
    }
  }
  if(ans == "Yes"){
    rep(i, (ssize - 1)/2){
    	if(S.at(i) != S.at((ssize - 1)/2 + 1 + i)){
          ans = "No";
        }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 112;
int w[mx], v[mx];
int dp[112345];
int main() {
  int n, W;
  cin >> n >> W;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  int ans = 0;
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 112344; j >= 0; j--) {
      if (j-v[i] >= 0) dp[j] = min(dp[j], w[i] + dp[j-v[i]]);
      if(dp[j] <= W) ans = max(ans, j);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    vector<vector<int>> a(n, vector<int>(m));

    for ( int i = 0; i < n; i++ ) {
        int k;
        cin >> k;
        for ( int j = 0; j < k; j++ ) {
            int tmp_num;
            cin >> tmp_num;
            a[i][tmp_num-1] = 1;
        }
    }

//    for ( int i = 0; i < n; i++ ) {
//        for ( int j = 0; j < m; j++ ) {
//            cout << a[i][j] ;
//        }
//        cout << endl;
//    }

//    cout << endl;

    int sum = 0;
    int dishes = 0;
    for ( int i = 0; i < m; i++ ) {
        sum = 0;
        for ( int j = 0; j < n; j++ ) {
            sum += a[j][i];
        }
//        cout << sum << endl;
        if ( sum == n ) {
            dishes++;
        }
    }

    cout << dishes << endl;

    return 0;
}

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

int main()
{
  string s;
  bool C_flag = false, flag = true;

  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (i == 0)
    {
      if (s[i] != 'A')
        flag = false;
    }
    else if (s[i] == 'C')
    {
      if (!C_flag && 1 < i && i < s.size() - 1)
        C_flag = true;
      else
        flag = false;
    }
    else if (s[i] < 'a' || 'z' < s[i])
      flag = false;
    if (!flag)
      break;
  }
  cout << (flag && C_flag ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>

int main(void) {
	// your code goes here
	char s[105];
	int flag = 0;
	
	fgets(s,sizeof(s),stdin);
	for(int i = 0; i < strlen(s) - 1;i++){
		if(s[i] == 'C'){
			for(int j = i + 1; j < strlen(s) ; j++){
				if(s[j] =='F'){
					printf("Yes\n");
					flag = 1;
					break;
				}
			}
			if(flag == 1){
				break;
			}
		}
		if(i == strlen(s) - 2){
			printf("No\n");
			break;
		}
	}
	

	return 0;
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    let [N, K] = lines[0].split(' ').map(Number)
    const A = lines[1].split(' ').map(Number)

    const s = Array(N).fill(0)
    for (let i = 0; i < K; i++) {
        s[K - 1] += A[i]
    }

    for (let i = K; i < N; i++) {
        s[i] = s[i - 1] - A[i - K] + A[i]
    }

    for (let i = K; i < N; i++) {
        console.log(s[i - 1] < s[i] ? 'Yes' : 'No')
    }    

})(input)


Measured memory_bytes: 62372
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

typedef pair<long long,string> p;

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		vector< p > vec(n);
		rep(i,n){
			long long timeh[4],timem[4],time=0;
			string num;
			cin>>num;
			rep(j,4){
				cin>>timeh[j]>>timem[j];
				time+=(timeh[j]*60+timem[j]);
			}
			vec[i].first=time;
			vec[i].second=num;
		}
		sort(vec.begin(),vec.end());
		cout<<vec[0].second<<endl;
		cout<<vec[1].second<<endl;
		cout<<vec[n-2].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
n = int(input())
xyh = [list(map(int,input().split())) for _ in [0]*n]
xyh.sort(key=lambda x:x[2])
x0,y0,h0 = xyh[-1][0],xyh[-1][1],xyh[-1][2]

#全探索で良さそう
for Cx in range(101):
  for Cy in range(101):
    # H-|x-Cx|-|y-Cy| = h
    H = h0 + abs(x0-Cx) + abs(y0-Cy)
    tf = True
    for k in range(n-1):
      x,y,h = xyh[k][0], xyh[k][1], xyh[k][2]
      if h != max(H - abs(x-Cx) - abs(y-Cy), 0):
        tf = False
        break
    if tf == True and H >=1:
      print(Cx,Cy,H)
      exit()


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

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

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

ll to5(ll i) { return i * i * i * i * i; }

int main() {
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;

    const int mm = 1001;
    vector<ll> m(mm);

    for (int i = 0; i < mm; i++) {
        m[i] = to5(i);
    }

    for (int i = 0; i < mm; i++) {
        ll a5 = m[i];
        ll a5idx = i;
        ll b5 = a5 - x;

        auto it = lower_bound(m.begin(), m.end(), b5);
        if (it != m.end() && *it == b5) {
            ll b5idx = it - m.begin();
            // printf("x:%lld, a5:%lld, b5:%lld\n", x, a5idx, b5idx);
            cout << a5idx << " " << b5idx << endl;
            return 0;
        }

        b5 = x - a5;
        it = lower_bound(m.begin(), m.end(), b5);
        if (it != m.end() && *it == b5) {
            ll b5idx = it - m.begin();
            b5idx = -b5idx;
            // printf("x:%lld, a5:%lld, b5:%lld\n", x, a5idx, b5idx);
            cout << a5idx << " " << b5idx << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
  string st;
  int a,aa,b,bb;
  char c;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>st;
      if(st=="snuke"){
	aa=i;
	bb=j;
      }
    }
  }
  c=bb+'A';
  cout<<c<<aa+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll x[110000],y[110000];
int main(){
    ll n,m;cin>>n>>m;
    rrep(i,n)cin>>x[i];
    rrep(i,m)cin>>y[i];
    mint ax=0,ay=0;
    ll t=0,s=0;
    rrep(i,n){
        ax+=t*x[i]-s;
        t++;
        s+=x[i];
    }
    t=s=0;
    rrep(i,m){
        ay+=t*y[i]-s;
        t++;
        s+=y[i];
    }
    mint ans=ax*ay;
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 1792
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List

main :: IO ()
main = do
  n <- getl read
  solve <$> replicateM n (getl read) >>= print

solve :: [Int] -> Int
solve = length . nub . sort

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 1020
n, W = map(int, input().split())
inf = 10 ** 10
V = 10 ** 5
dp = [inf for _ in range(V + 1)]
dp[0] = 0
ans = 0
for _ in range(n):
    w, v = map(int, input().split())
    for i in range(V, v - 1, -1):
        dp[i] = min(dp[i], dp[i - v] + w)
        if dp[i] <= W:
            ans = max(ans, i)
print(ans)

Measured memory_bytes: 77140
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Scanner in = new Scanner(System.in);
    static long h,w,n;
    static Hashtable<Long, Long> hashtable = new Hashtable<Long, Long>();
    static long dx[] = new long[]{-2, -2, -2, -1, -1, -1, 0, 0, 0};
    static long dy[] = new long[]{-2, -1, 0, -2, -1, 0, -2, -1, 0};

    static void add(long x, long y) {
        long a, b;
        long tmp;
        for (int i = 0; i < 9; ++i) {
            a = x + dx[i];
            b = y + dy[i];
            if(a<1||b<1||a>h-2||b>w-2) {
                continue;
            }
            tmp = (h-2) * ( b - 1) + a;
            Object ans = hashtable.get(tmp);
            if(ans == null) {
                hashtable.put(tmp, 1L);
            }
            else {
                hashtable.put(tmp,((long)ans)+1);
            }
        }
    }

    public static void main(String args[]){
        h = in.nextLong();
        w = in.nextLong();
        n = in.nextLong();
        for (long i = 0; i < n; ++i) {
            long x, y;
            x = in.nextLong();
            y = in.nextLong();
            add(x,y);
        }
        long ans[] = new long[10];
        Arrays.fill(ans,0);
        ans[0] = (h-3)*(w-2)+w-2;
        Set<Long>s = hashtable.keySet();
        for (Long nxt : s) {
            long second = hashtable.get(nxt);
            ans[(int) second]++;
            ans[0]--;
        }
        for(int i = 0;i<10;++i) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 161224
import sys
input_lines = sys.stdin.readlines()[:-1]
num = 1
for input_ in input_lines:
    h, w = [int(i) for i in input_.split()]
    if w % 2 == 0:
        base = '#.' * (w//2) + '#'
    else:
        base = '#.' * ((w+1)//2)
    for i in range(h):
        if i % 2 == 0:
            print(base[:-1])
        else:
            print(base[1:])
    print()



Measured memory_bytes: 5640
s = input()
possible_answers = [0]
possible_answer = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in acgt:
        possible_answer += 1
    else:
        possible_answers.append(possible_answer)
        possible_answer = 0

possible_answers.append(possible_answer)
print(max(possible_answers))

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

struct minimum_spanning_arborescence_runner {
	typedef ll weight;
	typedef vector<vector<ll>> matrix;

	void backward_traverse(int v, int s, int r, matrix& g,
		vector<int>& no, vector< vector<int> >& comp,
		vector<int>& prev, vector<weight>& mcost,
		vector<int>& mark, weight& cost, bool& found) {
		const int n = g.size();
		if (mark[v]) {
			vector<int> temp = no;
			found = true;
			do {
				cost += mcost[v];
				v = prev[v];
				if (v != s) {
					while (comp[v].size() > 0) {
						no[comp[v].back()] = s;
						comp[s].push_back(comp[v].back());
						comp[v].pop_back();
					}
				}
			} while (v != s);
			for (int j = 0; j < n; ++j)
				if (j != r && no[j] == s)
					for (int i = 0; i < n; ++i)
						if (no[i] != s && g[i][j] < INF)
							g[i][j] -= mcost[temp[j]];
		}
		mark[v] = true;
		for (int i = 0; i < n; ++i)
			if (no[i] != no[v] && prev[no[i]] == v)
				if (!mark[no[i]] || i == s)
					backward_traverse(i, s, r, g,
						no, comp, prev, mcost, mark, cost, found);
	}

	weight minimum_spanning_arborescence(int r, matrix& g) {
		const int n = g.size();

		vector<int> no(n);
		vector< vector<int> > comp(n);
		for (int i = 0; i < n; ++i) {
			no[i] = i;
			comp[i].push_back(i);
		}
		weight cost = 0;
		while (1) {
			vector<int> prev(n, -1);
			vector<weight> mcost(n, INF);
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					if (j == r) continue;
					if (no[i] != no[j] && g[i][j] < INF) {
						if (g[i][j] < mcost[no[j]]) {
							mcost[no[j]] = g[i][j];
							prev[no[j]] = no[i];
						}
					}
				}
			}
			bool stop = true;
			vector<int> mark(n);
			for (int i = 0; i < n; ++i) {
				if (i == r || mark[i] || comp[i].size() == 0) continue;
				bool found = false;
				backward_traverse(i, i, r, g,
					no, comp, prev, mcost, mark, cost, found);
				if (found) stop = false;
			}
			if (stop) {
				for (int i = 0; i < n; ++i)
					if (prev[i] >= 0)
						cost += mcost[i];
				return cost;
			}
		}
	}

};


int main(void)
{
	int v, e, r;
	cin >> v >> e >> r;

	vector<vector<ll>> g(v,vector<ll>(v, INF));
	rep(i, e) {
		ll s, t, c;
		cin >> s >> t >> c;
		g[s][t] = c;
	}
	minimum_spanning_arborescence_runner runner;
	auto w = runner.minimum_spanning_arborescence(r, g);
	cout << w << endl;
	return 0;
}



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

int main() {
  vector <int> a(10);
  int x;
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 9; i > 6; i--) { 
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): #高速素因数分解 m[n]=nを割ることの出来る最小の素数
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): #b[n]=nを割ることの出来る最小の素数　の配列を生成　エラトステネスの篩
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    a,b,c,d=map(int,input().split())
    aa=a*c
    bb=a*d
    cc=b*d
    dd=b*c
    print(max(aa,bb,cc,dd))








if __name__ == "__main__":

    main()


Measured memory_bytes: 77408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace PaizaSkillCheck
{
    public class Program
    {
        public static int[] flower;

        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] line = Console.ReadLine().Split(' ');
            int[] flower = new int[n];

            int minHeight = int.MaxValue;

            for (int i = 0; i < flower.Length; i++)
            {
                int v = int.Parse(line[i]);
                flower[i] = v;

                minHeight = Math.Min(minHeight, v);
            }

            int needCount = minHeight;
            int nowHeight = minHeight;
            int endCount = 0;

            while (endCount != flower.Length)
            {
                endCount = 0;
                for (int i = 0; i < flower.Length; i++)
                {
                    if (flower[i] > nowHeight)
                    {
                        //  左端
                        if (i == 0 || flower[i - 1] <= nowHeight)
                        {
                            needCount++;
                        }
                    }
                    else
                    {
                        endCount++;
                    }
                }
                nowHeight++;
            }

            Console.WriteLine(needCount);
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

const double pi = acos(-1);

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double theta = ((60 * h + m) / 720 * 2 * pi - m / 60 * 2 * pi);

	cout << fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(theta)) << endl;
}

Measured memory_bytes: 4184
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    bool f1 = s.size() % 2 == 0;
    bool f2 = s[0] == s.back();

    cout << (f1 ^ f2? "Second" : "First") << endl;
}
/*
 * aba -> 先手が負け
 * acba -> 後手
 * abcda -> 先手
 * abcba -> 先手
 * abc -> 後手
 * abcd -> 先手
 *
 * 偶数 かつ 前後が同じ   -> 後手
 * 偶数 かつ 前後が異なる -> 先手
 * 奇数 かつ 前後が同じ  -> 後手
 * 奇数 かつ 前後が異なる -> 先手
 */

Measured memory_bytes: 640
#include<cstdio>
using namespace std;
long long a,b,c,d;
int main()
{
//	freopen("B.in","r",stdin);
	int n;
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n--;
	long long l1,l2,r1,r2;
	for(int i=0;i<=n;i++)
	{
		l1=i*c,r1=i*d;
		l2=(n-i)*c,r2=(n-i)*d;
		if(b-a>=l2-r1&&b-a<=r2-l1)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<string, pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 19;
ll i,j,n,m,a,b,ans;
vi v[N];
ll p[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,m){
        cin>>a;
        rep(j,0,a){
            cin>>b;
            v[i].pb(b - 1);
        }
    }
    rep(i,0,m) cin>>p[i];
    for(i = 0;i < (1 << n);i += 1){
        b = 1;
        for(j = 0;j < m;j += 1){
            a = 0;
            for(auto x: v[j]) if((i >> x) & 1)
                a += 1;
            if(a % 2 != p[j]){
                b = 0;
                break;
            }
        }
        ans += b;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
using ll = long long;

const int MN = 2003;

int n;
int l[MN];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0; i<n; ++i){
		cin>>l[i];
	}
	sort(l,l+n);
	ll res=0;
	for(int i=0; i<n; ++i){
		for(int j=i+1; j<n; ++j){
			int lb=j,ub=n;
			while(lb<ub-1){
				int m=(lb+ub)/2;
				if(l[m]<l[i]+l[j])lb=m;
				else ub=m;
			}
			res+=lb-j;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	const lines = input.split("\n");
	const firstLineWords = lines[0].split(" ");  

	const N = parseInt(firstLineWords[0], 10);
    const A = parseInt(firstLineWords[1], 10);
    const B = parseInt(firstLineWords[2], 10);
  
    const costByTrain = A * N;
    const costByTaxi = B;
  
	//出力
	console.log(Math.min(costByTrain, costByTaxi));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#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 reprange(i, a) for(int i : vector<int>a)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL << 60;
const ll mod=1e9+7;

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

  int n;
  cin >> n;
  vi d(2*n);
  rep(i, n){
    cin >> d[2*i] >> d[2*i+1];
  }

  int cnt=0;
  string ans="No";
  rep(i, n){
    if(d[2*i]==d[2*i+1])cnt++;
    else cnt=0;
    if(cnt==3){
      ans="Yes";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;
    ll ans = 0;

    ans += min(A, K);
    K -= A;
    if (K > 0) K -= B;
    if (K > 0) ans -= min(C, K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto &i:a)
#define rvl(a,n) vl a;FOR(i,0,n){IN(in); a.pb(in);}
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll dp[2010];
void solve()
{
	IN(s);
	dp[0]= 1;
	FOR(i, 3, s + 1)
	{
		FOR(j, 3, i + 1)
		{
			dp[i] = (dp[i] + dp[i - j])%MOD;
		}
	}
	cout << dp[s];
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

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

int main() {
  long A, B, a, b, i, r, G, L;
  cin >> A >> B;
  
  if (A < B){
    a = B;
    b = A;
  }
  else{
    a = A;
    b = B;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  G = b;
  L = A * B / G;
  cout << L;
}
 

Measured memory_bytes: 764
#include <iostream>
using namespace std;
 
int main() {

    string X, Y;
    int x, y;
    cin >> X >> Y;

    if (X == "A"){
      x = 10;
    } else if (X == "B") {
      x = 11;
    } else if (X == "C") {
      x = 12;
    } else if (X == "D") {
      x = 13;
    } else if (X == "E") {
      x = 14;
    } else {
      x = 15;
    }

    if (Y == "A"){
      y = 10;
    } else if (Y == "B") {
      y = 11;
    } else if (Y == "C") {
      y = 12;
    } else if (Y == "D") {
      y = 13;
    } else if (Y == "E") {
      y = 14;
    } else {
      y = 15;
    }

    if (x == y){
      cout << "=" << endl;
    } else if (x > y) {
      cout << ">" << endl;
    } else {
      cout << "<" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication40
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string A = Console.ReadLine();
                if (A == null) break;
                Decimal[] B = A.Split(',').Select(decimal.Parse).ToArray();
                decimal C = B[0] + B[1] + B[2] + B[3] + B[4] + B[5] + B[6] + B[7] + B[8] + B[9];
                decimal D = C * (B[10] / (B[10] + B[11]));
                decimal E = 0;
                for (int W = 1; W < 11; W++)
                {
                    E += B[W - 1];
                    if (E>= D) { Console.WriteLine(W);break; }
                }
            }
        }
    }
}

Measured memory_bytes: 9676
import math
a, b, h, m = map(int, input().split())
msita = 6*m
hsita = 30*h + 30*m/60
sita = abs(msita - hsita)
sita = min(sita, 360-sita)
c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(sita)))
print(c)

Measured memory_bytes: 9496
#include <iostream>

using namespace std;

int main(){
    int s, hh, mm , ss;

    cin >> s;

    mm = s / 60;
    hh = mm / 60;
    ss = s % 60;
    mm = mm % 60;

    cout << hh << ":" << mm << ":" << ss << endl;
    return 0;
}


Measured memory_bytes: 3088
import java.util.*;
// Good catch
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		System.out.println((Math.abs(a-c)<=d||(Math.abs(a-b)<=d && Math.abs(b-c)<=d)) ? "Yes" : "No");
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35716
#define MAX 10000005
p[MAX],four[1000],j,f;
main(i)
{
  for(i=2;i<MAX;i++)
    if(!p[i])
      for(j=i*2;j<MAX;j+=i)
	p[j]=1;
  for(i=3;i<MAX-7;i+=2)
    if(p[i]==0 && p[i+2]==0&& p[i+6]==0 && p[i+8]==0)
      four[f++]=i+8;
  
  for(four[f]=MAX;scanf("%d",&j),j;printf("%d\n",four[i-1]))
    {
      for(i=0 ;four[i]<=j; i++);

    }
	exit(0);  
}

Measured memory_bytes: 0
using System;
public class Hello{
    public static void Main(){
        int cnt = 0;
        string input = Console.ReadLine();
        for(int n = 0;n < input.Length;n++){
            if(input.Substring(n,1) == "1"){
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{

    int strips;     cin >> strips;
    int required;   cin >> required;
    int tot = strips, answer = 1;

    while (tot < required){
        tot = (tot+strips) - 1;
        answer++;
    }
    
    if (required == 1){
        cout << 0 << endl;
        return 0;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256