akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int k, a, b;

void solve()
{
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i)
    {
        if(i%k==0)
            return puts("OK"), void();
    }
    puts("NG");
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

using ll = long long;

using namespace std;

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

  double routen = sqrt((double)n);

  //n平方根から、割り切れる最小を見つける

  ll a, b;
  for (ll i = (ll)(routen + 1); i > 0; i--){
    if(n % i == 0){
      a = n / i;
      b = i;
      break;
    }
  }

  ll ans = (a - 1) + (b - 1);
  cout << ans << endl;
  return 0;
}
  
    


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int o=0;
		int t=0;
		int tt=0;
		int f=0;
		for(int i = 0; i<3; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==1 || b==1){
				o++;
			}
			if(a==2 || b==2){
				t++;
			}
			if(a==3 || b==3){
				tt++;
			}
			if(a==4 || b==4){
				f++;
			}
		}
		if(o==0 || t==0 || tt==0 || f==0 || o>=3 || t>=3 || tt>=3 || f>=3){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
#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)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define fi first
#define se second
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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;}
int const INF = 1001001001;


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

ll N; cin >> N;
ll ans = 0;
rrep(i,N) {
    if(i % 3 != 0 && i % 5 != 0) ans += i;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3660
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int pre[4005][4005][2];//0white,1black
//pos x color
//before or at pos howmany below or equal to x
int dp[4005][2005]; //whitenum,blacknum
int n;int arr[4005];char color[4005];;
int pos[4005][2];
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin>>n;
	for(int i=1;i<=n*2;i++)
	{
		char c;cin>>c;if(c=='W') color[i]=0;else color[i]=1;cin>>arr[i];
		pos[arr[i]][color[i]]=i;
	}
	 for(int i=1;i<=n*2;i++)
	 {
	 	for(int j=1;j<=n;j++)
	 	{
	 		pre[i][j][0]=pre[i-1][j][0];pre[i][j][1]=pre[i-1][j][1];
	 	}
	 	for(int j=arr[i];j<=n;j++)
	 	{
	 		pre[i][j][color[i]]++;
	 	}
	 }
	 
	 for(int i=0;i<2002;i++) for(int j=0;j<2002;j++) dp[i][j]=1e9;
	 dp[0][0]=0;
	 for(int i=1;i<=n*2;i++)
	 {
	 	for(int j=0;j<=n;j++)
	 	{
	 		int x=j,y=i-j;
	 		if(y<0) continue;
	 		
	 		int there=pos[x][0];
	 		int bef=x-1-pre[there][x-1][0]+y-pre[there][y][1];
	 		if(x!=0)dp[x][y]=min(dp[x-1][y]+abs(there+bef-i),dp[x][y]);
	 		if(y==0) continue;
	 		there=pos[y][1];
	 		bef=x-pre[there][x][0]+y-1-pre[there][y-1][1];
	 		dp[x][y]=min(dp[x][y-1]+abs(there+bef-i),dp[x][y]);
	 	}
	 }
	 cout<<dp[n][n];
	return 0;
}

Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int a,k,b;cin>>k>>a>>b;
   bool ans=false;
   for(int i=a;i<=b;i++){
     if(i%k==0){
       ans=true;
       break;
     }
   }
   if(ans)cout<<"OK"<<endl;
   else cout<<"NG"<<endl;
 }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  REP(i,h){
    cin>>s[i];
  }
  vector<vector<int>> num(h, vector<int>(w, -1));
  int index = 1;
  REP(i,h){
    REP(j,w){
      if(s[i][j] == '#'){
        num[i][j] = index;
        index++;
      }
    }
  }
  REP(i,h){
    int temp = -1;
    int last_ = -1;
    for(int j = w-1; j>= 0; j--){
      if(num[i][j] < 0){
        num[i][j] = temp;
      }else{
        if(temp < 0){
          last_ = num[i][j];
        }
        temp = num[i][j];
      }
    }
    REP(j,w){
      if(num[i][j] < 0){
        num[i][j] = last_;
      }
    }
  }
  bool rowex[h] = {};
  vector<int> rows;
  int rowed = -1;
  REP(i,h){
    if(num[i][0] < 0)continue;
    rowex[i] = true;
    rows.push_back(i);
  }
  for(int i = h-1; i>=0; i--){
    if(rowex[i]){
      rowed = i;
      break;
    }
  }
  int m = rows.size();
  REP(i,m){
    if(i == 0){
      if(rows[i] == 0)continue;
      for(int i2 = rows[i]-1; i2>=0; i2--){
        REP(j,w){
          num[i2][j] = num[i2+1][j];
        }
      }
    }else{
      for(int i2 = rows[i]-1; i2>=rows[i-1]+1; i2--){
        REP(j,w){
          num[i2][j] = num[i2+1][j];
        }
      }
    }
  }
  if(rowed != h-1){
    for(int i = rowed + 1; i<h; i++){
      REP(j,w){
        num[i][j] = num[i-1][j];
      }
    }
  }
  
  REP(i,h){
    REP(j,w){
      cout<<num[i][j]<<' ';
    }
    cout<<endl;
  }
      
  return 0; 
}


Measured memory_bytes: 1280
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from collections import deque
def solve(N, A):
    # A as deques of values in [0, N)

    now = range(N)
    todo = N * (N - 1)
    for ans in range(1, N * N):
        later = set()
        for i in now:
            if A[i] and i not in later:
                j = A[i][0]
                if j not in later and A[j] and A[j][0] == i:
                    later.add(A[i].popleft())
                    later.add(A[j].popleft())
                    todo -= 2

        if not todo:
            return ans
        now = later
    return -1


N = rri()
A = []
for _ in xrange(N):
    row = rrm()
    A.append(deque(x-1 for x in row))
print solve(N, A)


Measured memory_bytes: 60444
N,M=map(int,input().split())
A=list(map(int,input().split()))
s=sum(A)
A.sort(reverse=True)
t=0
for x in range(M):
  if A[x]*4*M<s:
    t=1
    break
if t==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9116
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, d;
  double ans = 0;
  scanf("%lld%lld%lld", &n, &m, &d);
  if(d) ans = (double)(n * 2 - 2 * d) / (double)(n * n);
  else ans = 1.0 / (double)n;
  ans *= (double)(m - 1);
  printf("%.12lf", ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int a, b, d, r;
  double f;

  scanf("%d%d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double) a / b;

  printf("%d %d %f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll C;
    C = A + B;
    ll ans;
    ans = A*(N/C);
    ans += min(N%C,A);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import sys
import numpy as np
mod=10**9+7
n=int(sys.stdin.buffer.readline())
a=np.fromstring(sys.stdin.buffer.readline(),dtype=np.int64,sep=' ')
ans=0
b=1
for i in range(60):
    s=int((a&1).sum())
    ans=(ans+s*(n-s)*b)%mod
    a>>=1
    b=b*2%mod
print(ans)

Measured memory_bytes: 38172
#include <string>
#include <iostream>

int main()
{
	std::string s;
	std::cin >> s;
	std::string result;
	int a, b;
	a = stoi(s.substr(0, 2));
	b = stoi(s.substr(2, 2));
	if ((b > 12 || b == 0)&&(a>0&&a<=12)) {
		result = "MMYY";
	}
	else if((a>12||a==0)&&(b>0&&b<=12)){
		result = "YYMM";
	}
	else if ((a == 0 || b == 0) || (a > 12 || b > 12)) {
		result = "NA";
	}
	else { result = "AMBIGUOUS"; }
	
	std::cout<<result;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b; char op; cin >> a >> op >> b;
    cout << ((op == '+') ? a+b : a-b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string S; cin >> S;
	int idx = S.size() - 1;
	while (idx >= 0) {
		if (idx - 4 >= 0 && S.substr(idx - 4, 5) == "dream") {
			idx -= 5;
		} else if (idx - 4 >= 0 && S.substr(idx - 4, 5) == "erase") {
			idx -= 5;
		} else if (idx - 6 >= 0 && S.substr(idx - 6, 7) == "dreamer") {
			idx -= 7;
		} else if (idx - 5 >= 0 && S.substr(idx - 5, 6) == "eraser") {
			idx -= 6;
		} else {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 100; i; i--)
		if (a%i == 0 && b%i == 0 && !--k) {
			cout << i << endl;
			break;
		}
	return 0;
}


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

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	for(int x = 0; x<S.length(); x++){
		if(S[x] + N > 'Z'){
			S[x] = S[x] - 26 + N;
		}else{
			S[x] = S[x] + N ;
		}
	}	
	cout << S;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const double eps = 1e-12;
struct Point {
	double x, y;
} a[N], O;
double R;
double sqr(double x) {
	return x * x;
}
double dis(Point a, Point b) {
	return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
void work(Point p1, Point p2, Point p3) {
	double a, b, c, d, e, f;
	a = p2.y - p1.y;
	b = p3.y - p1.y;
	c = p2.x - p1.x;
	d = p3.x - p1.x;
	f = p3.x * p3.x + p3.y * p3.y - p1.x * p1.x - p1.y * p1.y;
	e = p2.x * p2.x + p2.y * p2.y - p1.x * p1.x - p1.y * p1.y;
	O.x = (a * f - b * e) / (2 * a * d - 2 * b * c);
	O.y = (d * e - c * f) / (2 * a * d - 2 * b * c);
	R = dis(O, p1);
}
int main() {
	int n, i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
	random_shuffle(a + 1, a + n + 1);
	O = a[1];
	R = 0;
	for (i = 2; i <= n; ++i)
		if (dis(a[i], O) > R + eps) {
			O = a[i];
			R = 0;
			for (j = 1; j < i; ++j)
				if (dis(a[j], O) > R + eps) {
					O.x = (a[i].x + a[j].x) / 2;
					O.y = (a[i].y + a[j].y) / 2;
					R = dis(a[j], O);
					for (k = 1; k < j; ++k) if (dis(a[k], O) > R + eps) work(a[i], a[j], a[k]);
				}
		}
	printf("%.10lf", R);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list()
for i in range(n):
    x = input()
    w.append(x)

ans = 'Yes'
used_w = []
for i, word in enumerate(w):
    if i == 0:
        used_w.append(word)
        prev = word[-1]
        continue
    if word[0] == prev and word not in used_w:
        prev = word[-1]
        used_w.append(word)
    else:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    vector<ll> B(m);
    REP(i, 0, m) {
        cin >> B[i];
    }
    int ans = 0;
    REP(i, 0, n) {
        ll t = 0;
        REP(j, 0, m) {
            ll a;
            cin >> a;
            t += a * B[j];
        }
        ans += (t + c > 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,i,j,cnt;
	string s;
	cin>>n;
	cin>>s;
	int mx=0;
	loop(i,n){
		cnt=0;
		for(char c='a';c<='z';c++){
			int l=0,r=0;
			for(j=0;j<=i;j++){
				if(s[j]==c){
				l=1;
				break;}
			}
				for(j=i+1;j<n;j++){
				if(s[j]==c){
				r=1;
				break;}
			}
			if(l&&r)
			cnt++;
		}
		if(mx<cnt)
		mx=cnt;
	}
	cout<<mx<<'\n';
	// your code goes here
	return 0;
}

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

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if(N<=K){
        cout << N*X << endl;
    }else{
        cout << K*X + (N-K)*Y << endl;
    }
    return 0;
}


Measured memory_bytes: 256
t1,t2,r1,r2 = [ int(s) for s in input().split() ]
  
if r1 == -1 or r2 == -1:
    if t1 < t2:
        print('Alice')
    elif t1 > t2:
        print('Bob')
    else:
        print('Draw')
else:
    if r1 > r2:
        print('Alice')
    elif r1 < r2:
        print('Bob')
    else:
        print('Draw')




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

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

  if (n[0]=='7' || n[1]=='7' || n[2]=='7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// Constant variables
const long double PI = (acos(-1));
const long long MOD = 1000000007;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int x, y;
    cin >> x >> y;
    ll ans = 0;
    if(x == y && x == 1) ans += 400000;
    switch (x)
    {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    default:
        break;
    }
    switch (y)
    {
    case 1:
        ans += 300000;
        break;
    case 2:
        ans += 200000;
        break;
    case 3:
        ans += 100000;
        break;
    default:
        break;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin >> n >> a >> b;
  int aa = 0, bb = 0, cc = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    if (p <= a) aa++;
    if (a + 1 <= p && p <= b) bb++;
    if (p >= b + 1) cc++;
  }
  cout << min(aa, min(bb,cc)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    string ans;
    if(s == "Sunny")ans = "Cloudy";
    else if(s == "Cloudy")ans = "Rainy";
    else ans = "Sunny";

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

Measured memory_bytes: 256
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
A = array[1].split(" ").map(&:to_i)

all_possiblity = 1
odd_possibiity = 1

for a in A
  cand = (a-1).upto(a+1).to_a
  odd  = cand.select{|e| e % 2 != 0}
  all_possiblity = all_possiblity * cand.length
  odd_possibiity = odd_possibiity * odd.length
end

# all possibility
puts all_possiblity - odd_possibiity

Measured memory_bytes: 1788
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main()
{
	int pos[] = {111,222,333,444,555,666,777,888,999};
	int n;
	cin >> n;
	int ans = 0;
	for (auto x : pos)
	{
		if(n<=x)
		{
			ans = x;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define NL endl
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ull i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

int main(){
    fastIO;
    //cout<<(5>>1)<<endl;
    ll n;
    cin>>n;
    ll factor = 1;
    ll ans = 0;
    while(n){
        n = (n>>1);
        ans += factor;
        factor *= 2;
    }
    cout<<ans<<endl;
}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, m, fr, to, dega[maxn], degb[maxn];
string s;
queue <ll> q;
bool vis[maxn];
vector <ll> adj[maxn];

int main() {
	fio();
	cin >> n >> m;
	cin >> s;
	for (int i = 0; i < m; i++) {
		cin >> fr >> to;
		adj[--fr].pb(--to);
		adj[to].pb(fr);	
		if (s[fr] == 'A')
			dega[to]++;
		else
			degb[to]++;
		if (s[to] == 'A')
			dega[fr]++;
		else
			degb[fr]++;
	}
	for (int i = 0; i < n; i++) {
		if (dega[i] == 0 or degb[i] == 0) 
			q.push(i);
	}
	while (q.size() != 0) {
		ll ind = q.front();
		//cout << ind << " ";
		q.pop();
		if (vis[ind] == 1)
			continue;
		vis[ind] = 1;
		for (auto u : adj[ind]) {
			if (s[ind] == 'A') {
				dega[u]--;
				if (dega[u] == 0)
					q.push(u);
			} else {
				degb[u]--;
				if (degb[u] == 0)
					q.push(u);
			}
		}
	}
	for (int i = 0; i < n; i++)
		if (vis[i] == 0) {
			cout << "Yes\n";
			return 0;	
		}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 15952
# Calculate count of combination
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b


mod = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(1, k + 1):
    ans = combination(n - k + 1, i) * combination(k - 1, i - 1) % mod
    print(ans)


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

int main()
{
  int N, K;
  cin >> N >> K;
  int D[100] = {};
  for (int i = 0; i < K; ++i)
  {
    int d;
    cin >> d;
    for (int j = 0; j < 10; ++j)
      D[d + 10*j] = 1;
    if (0 != d)
      for (int j = 0; j < 10; ++j)
        D[j + 10*d] = 1;
  }
  for (; ; ++N)
  {
    bool head = true;
    auto _N = N;
    int den = 1000;
    for (; 0 != den; den /= 10)
    {
      int n = _N/den;
      if (head && 0 == n)
        continue;
      head = false;
      if (1 == D[n])
        break;
      _N -= n*den;
    }
    if (0 == den)
    {
      cout << N;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
""" 局所探索の例 """
import numpy as np
import sys
import random

input = sys.stdin.readline


contest_types = 26
days = int(input())
cs = list(map(int, input().strip().split()))
ss = [list(map(int, input().strip().split())) for _ in range(days)]
# ts = [int(input()) - 1 for _ in range(days)] # 0 始まりにする

# m = int(input())
# queries = [list(map(int, input().strip().split())) for _ in range(m)]
# queries = np.array(queries, dtype=np.int32)
# queries -= 1  # 0始まりにする


# コンテストごとの開催日
def calc_contest_dict(ts):
    contest_dict = [[-1, days] for _ in range(contest_types)]
    for d, t in enumerate(ts):
        contest_dict[t].append(d)

    for contest_days in contest_dict:
        contest_days.sort()

    return contest_dict


def count_block(contest_days):
    block = 0
    for i in range(len(contest_days) - 1):
        period = contest_days[i + 1] - contest_days[i]
        block += period * (period - 1) // 2
    return block


def calc_score(cs, ss, ts):
    contest_dict = calc_contest_dict(ts)
    # 満足度
    satisfaction = 0
    # 開催されることによる増加分
    for d, t in enumerate(ts):
        satisfaction += ss[d][t]

    # 減少分
    for t, contest_days in enumerate(contest_dict):
        decrease = cs[t] * count_block(contest_days)
        satisfaction -= decrease

    return satisfaction


def greedy():
    last_days = np.array([-1] * contest_types, dtype=np.int32)
    results = [0] * days

    for d in range(days):
        max_diff = - 1e9
        max_c_type = None
        for t in range(contest_types):
            diff = ss[d][t] - np.sum(cs * (d - last_days)) \
                   + cs[t] * (d - last_days[t])

            if diff > max_diff:
                max_diff = diff
                max_c_type = t

        results[d] = max_c_type

    return results


ts = greedy()
best_score = calc_score(cs, ss, ts)
contest_dict = calc_contest_dict(ts)
best_ts = ts

for i in range(10000):
    d, q = random.randint(0, days - 1), random.randint(0, contest_types - 1)
    old_t = ts[d]
    new_t = q
    old_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])
    ts[d] = new_t
    contest_dict = calc_contest_dict(ts)
    open_diff = ss[d][new_t] - ss[d][old_t]

    new_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])

    diff = open_diff + old_decrease - new_decrease

    if best_score + diff > best_score:
        best_score = best_score + diff
        # print(best_score)
    else:
        # 戻す
        ts[d] = old_t

for t in ts:
    print(t + 1)


Measured memory_bytes: 27788
import sys
input = sys.stdin.readline
import random
import time
import copy
time0=time.time()

D=int(input())
C=[0]+list(map(int,input().split()))
S=[0]+[[0]+list(map(int,input().split())) for i in range(D)]

ANS=0
T=[0]
LAST=[0]*27
for day in range(1,D+1):
    SCORE=[-1<<30]*27
    for j in range(1,27):
        SC=0
        SC+=S[day][j]

        for k in range(26):
            if j==k:
                continue
            SC-=C[k]*(day-LAST[k])
        SCORE[j]=SC

    choose=SCORE.index(max(SCORE))
    T.append(choose)
    LAST[choose]=day

ANS=0
LAST=[[0]*27 for i in range(D+1)]
for day in range(1,D+1):
    for j in range(1,27):
        LAST[day][j]=LAST[day-1][j]
    t=T[day]
    ANS+=S[day][t]
    LAST[day][t]=day

    for j in range(1,27):
        ANS-=C[j]*(day-LAST[day][j])

while time.time()-time0<1.77:
    BT=copy.deepcopy(T)
    BLAST=copy.deepcopy(LAST)
    BANS=ANS
    
    d=random.randint(1,D)
    after_t=random.randint(1,26)

    before_t=T[d]

    ANS+=S[d][after_t]-S[d][before_t]

    T[d]=after_t

    for day in range(d,D+1):
        if T[day]!=before_t:
            ANS+=C[before_t]*(day-LAST[day][before_t])
            LAST[day][before_t]=LAST[day-1][before_t]
            ANS-=C[before_t]*(day-LAST[day][before_t])
        else:
            break

    ANS+=C[after_t]*(d-LAST[d][after_t])
    LAST[d][after_t]=d

    for day in range(d+1,D+1):    
        if T[day]!=after_t:
            ANS+=C[after_t]*(day-LAST[day][after_t])
            LAST[day][after_t]=LAST[day-1][after_t]
            ANS-=C[after_t]*(day-LAST[day][after_t])

    if ANS<BANS:
        T=BT
        LAST=BLAST
        ANS=BANS

print(*T[1:])


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D)
    cout << "Left" << endl;
  if (A + B == C + D)
    cout << "Balanced" << endl;
  if (A + B < C + D)
    cout << "Right" << endl;
}

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

int main() {
	long long N, N_ = 1;
	cin >> N;
	while (1) {
		if (N_ * 2 > N) {
			cout << N_ << endl;
			return 0;
		}
		N_ *= 2;
	}
}


Measured memory_bytes: 3100
import math

def pow_k(x, n, mod):
  if n == 0:
    return 1

  K = 1
  while n > 1:
    if n % 2 != 0:
      K = (x * K) % mod
        
    x = (x * x) % mod

    n //= 2

  return (x * K) % mod

def prime_fuctorization(n):
  result = {}
  count = 0
  while n % 2 == 0:
    n //= 2
    count += 1
    
  if count != 0:
    result[2] = count
  
  for i in range(3, n, 2):
    count = 0
    while n % i == 0:
      n //= i
      count += 1
    
    if count != 0:
      result[i] = count
      
    if math.sqrt(n) <= i:
      break
      
  if n != 1:
    result[n] = 1
    
  return result
    
MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))

soinsu = []
result = {}
for i in range(n):
  dic = prime_fuctorization(a[i])
  soinsu.append(dic)
  
  for k in dic.keys():
    item = dic[k]
    if item >= result.get(k, 0):
      result[k] = item
      
m = 1
tmp = 1
for k, v in result.items():
  m *= pow_k(k, v, MOD)
  tmp *= k ** v
  m %= MOD
  
ans = 0
for i in range(n):
  ans += m * pow_k(a[i], MOD-2, MOD)
  ans %= MOD
  
print(ans)

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

using namespace std;

int main(){

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

	int N,M;

	cin >> N >> M;
	
	vector<pair<int,int>> v(M);

	for(int i=0;i<M;++i){
		cin >> v[i].first >> v[i].second;
	}

	int li = v[0].first,ri = v[0].second;

	for(int i=1;i<M;++i){
		li = max(li,v[i].first);
		ri = min(ri,v[i].second);
	}

	cout << (ri < li ? 0 : (ri-li+1)) << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    string s;
    cin>>s;
    for (int i=0;i<x;i++){
        string t=s.substr(0,i+1);
        t=t+t;
        if (s==t){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


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

int main() {
    vector<vector<int>> A(3, vector<int>(3, 0));
    rep(i, 3) cin >> A[i][0] >> A[i][1] >> A[i][2];
    int N;
    cin >> N;
    rep(i, N) {
        int b;
        cin >> b;
        rep(h, 3) rep(w, 3) {
            if (A[h][w] == b) A[h][w] = 0;
        }
    }

    bool flag = false;
    if (A[0][0] + A[0][1] + A[0][2] == 0) flag = true;
    if (A[1][0] + A[1][1] + A[1][2] == 0) flag = true;
    if (A[2][0] + A[2][1] + A[2][2] == 0) flag = true;
    if (A[0][0] + A[1][0] + A[2][0] == 0) flag = true;
    if (A[0][1] + A[1][1] + A[2][1] == 0) flag = true;
    if (A[0][2] + A[1][2] + A[2][2] == 0) flag = true;
    if (A[0][0] + A[1][1] + A[2][2] == 0) flag = true;
    if (A[0][2] + A[1][1] + A[2][0] == 0) flag = true;

		if(flag){
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
銀貨の枚数と時間

DP[1][0] = 0
DP[1][2600] = 

50*2600*2

1のまち、交換効率がわるい。
2のまち、運賃高いけど交換効率よい。
[1][100]
[1][101]

*/

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N,M,S,oo=1e15; cin>>N>>M>>S;
  S=min(S,2600LL);
  vector<vector<ll>> T(N+1, vector<ll> (0, 0));
  vector<vector<pair<ll,ll>>> root(N+1, vector<pair<ll,ll>>(N+1, {0,0}));
  vector<ll> C(N+1,0), D(N+1,0);
  vector<vector<ll>> DP(55, vector<ll>(2650, oo));

  rep(i, M){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    T[u].push_back(v);
    T[v].push_back(u);
    root[u][v] = {a,b};
    root[v][u] = {a,b};
  }
  rep(i, N){
    ll c, d; cin>>c >> d;
    C[i+1] = c;
    D[i+1] = d;
  }
  queue<ll> Q;
  Q.push(1);
  DP[1][S] = 0;
  while (!Q.empty()){
    ll now = Q.front(); Q.pop();
    //今の町で交換
    bool change = false;
    for (ll i=0; i<=2600; i++){
      ll j=min(i+C[now], 2600LL);
      if (chmin(DP[now][j], DP[now][i] + D[now]))
        change = true;
    }
    //次の町へ
    for(auto v: T[now]){
      ll a = root[now][v].first;
      ll b = root[now][v].second;
      for(ll i=0; i<=2600-a; i++){
        if (chmin(DP[v][i], DP[now][i+a] + b))
          change = true;
      }
      if (change)
        Q.push(v);
    }
  }
  for(ll i=2; i<=N; i++){
  ll ans = oo;
    for(ll j=0; j<=2600; j++)
      chmin(ans, DP[i][j]);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 4468
import copy
import math
import time
import statistics
import math
import itertools

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()
    n = get_int()
    a = []
    ans = 0
    for i in range(n):
        a.append(get_int_list())

    count = 0
    for keiro in itertools.permutations(a):
        count += 1
        nagasa = 0
        for i in range(1,n):
            nagasa += math.sqrt((keiro[i][0] - keiro[i-1][0]) ** 2 + (keiro[i][1] - keiro[i-1][1]) **2)
        ans += nagasa
    print(ans / count)


if __name__ == '__main__':
    main()




Measured memory_bytes: 10948
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll h,w;cin>>h>>w;
  rep(i,h){
    rep(j,w){
      string s;cin>>s;
      if(s=="snuke"){
        cout<<ABC[j]<<i+1<<endl;
        return 0;
      }
    }
  }
}
  

Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val memo = Array.tabulate(1000){_ ⇒ 0}
  val num = readLine.trim.split(' ').map(_.toInt)
  num.find{it ⇒
    if (memo(it % (n - 1)) == 0) {
      memo(it % (n - 1)) = it
      false
    }else {
      true
    }
  } match{
    case Some(a) ⇒ println(s"${memo(a % (n - 1))} $a")
    case _ ⇒
  }
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;

int ansW=0,ansS=0;
  for(int i=0;i<=30;i++){
    for(int j=0;j<=30;j++){
      int w = 100*a*i + 100*b*j;
      if(w==0)continue;
      for(int k=0;k<=3000;k++){
        int s = c*k;
        int sm = w/100*e;
        if(w+s<=f && sm>=s){
          ll t1 = s * (ansW + ansS);
          ll t2 = ansS * (w + s);
          if(t1>=t2){
            ansW=w;
            ansS=s;
          }
          int dcnt=(sm-s)/d;
          int dcnt2=(f-w-s)/d;
          s += d * min(dcnt, dcnt2);
          t1 = s * (ansW + ansS);
          t2 = ansS * (w + s);
          if(t1>=t2){
            ansW=w;
            ansS=s;
          }
        }
      }
    }
  }
  cout<< (ansW+ansS) <<' '<<ansS<<endl;
  
  return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string w;
  cin >> w;
  for (char c = 'a'; c <= 'z'; ++c) {
    if (count(w.begin(), w.end(), c) % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

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

  if(A - B >= 0) { cout << "delicious"; return 0; }

  if(B - A <= X) cout << "safe";
  else cout << "dangerous"; 
 return 0;
}



Measured memory_bytes: 3572
s = input()

key = 'keyence'
yes = False

if key in s:
    idx = s.index('key')
    if idx == 0:
        yes = True
    elif len(s) - idx == 7:
        yes = True
else:
    for i in range(1,8):
        pre = key[:i]
        post = key[i:]
        #print(pre, post)
        if pre == s[:len(pre)]:
            #print('end', s[len(s)-(7-i):])
            if s[len(s)-(7-i):] == post:
                yes = True
                break
        
if yes == True:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int S(int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

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

    cout << (n % S(n) == 0 ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 // freopen("data.in", "r", stdin);
  int n, a, c = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a%2 != 0 && i%2 != 0) c++;
  }
  cout << c << endl;
  return 0;
}




















Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int ans=INT_MIN;
void bfs(const vector<vector<int>>&mp, const string& bin, const int& n){
	queue<int>q;
	int cnt=0;
	for(int i=0;i<n;i++)
		if(bin[i]=='1') q.push(i+1), cnt++;
	while(!q.empty()){
		int cur=q.front(); q.pop();
		for(int i=1;i<=n;i++)
			if(bin[cur-1]=='1'){
				if(mp[cur][i]==0 && bin[i-1]=='1') return;
				if(mp[cur][i]==1 && bin[i-1]=='0') return;
			}
	}
	ans=max(cnt,ans);
	return;
}
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<vector<int>>mp(n+1, vector<int>(n+1,-1));
	for(int i=1;i<=n;i++){
		int a; cin>>a;
		for(int j=1;j<=a;j++){
			int x,y; cin>>x>>y;
			mp[i][x]=y;
		}
	}
	string bin;
	for(int i=0;i<n;i++) bin+='0';
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if((1<<j)&i)bin[n-1-j]='1';
			else bin[n-1-j]='0';
		}
		bfs(mp,bin,n);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
//ABC106C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s.at(0) == s.at(1) && s.at(1) == s.at(2)){
		cout << "Yes" << endl;
		return 0;
	}else if(s.at(1) == s.at(2) && s.at(2) == s.at(3)){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
n, y = gets.split.map(&:to_i)

result = 0
(0..n).each do |i|
  (0..(n - i)).each do |j|
    k = n - i - j
    result = i.to_i * 10000 + j.to_i * 5000 + k.to_i * 1000
    if result == y
      puts "#{i} #{j} #{k}"
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 1788
import sys
fin = sys.stdin.readline
sys.setrecursionlimit(200000)

def factorial(n, mod):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1, mod) % mod


MOD = 10**9 + 7
N = int(fin())
A_list = [int(elem) for elem in fin().split()]

fac_N = factorial(N, MOD)
inv_nums = [fac_N * pow(i, MOD - 2, MOD) % MOD for i in range(1, N + 1)]
cuml_inv_nums = [inv_nums[0]]
for inv_num in inv_nums[1:]:
    cuml_inv_nums.append((cuml_inv_nums[-1] + inv_num) % MOD)

ans = 0
for i, A in enumerate(A_list):
    ans += A * (cuml_inv_nums[i] + cuml_inv_nums[N - 1 - i] - cuml_inv_nums[0]) % MOD
    ans %= MOD

print(ans)



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

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int num = r * 100 + g * 10 + b;
  string ans;
  if (num % 4 == 0) {
    ans = "YES";
  } else {
    ans = "NO";
  }

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

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll H[100010];
vector<int> path[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m;cin>>n>>m;

	for(int i=1; i<=n; i++){
		cin>>H[i];
	}

	for(int i=0; i<m; i++){
		int from ,to;cin>>from>>to;

		path[from].push_back(to);
		path[to].push_back(from);
	}
	ll ans=0;
	for(int i=1; i<=n; i++){
		 bool judge =true;
			for(auto e : path[i]){
				if(H[i]<=H[e] ){
					judge =false;
				}
			}
			if(judge)ans++;

	}
	writeln(ans);



}




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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		List<Integer> list = new ArrayList<>();
		
		for (int i = 0; i < m; i++) {
			list.add(sc.nextInt());
			list.add(sc.nextInt());
		}
		
		int[] road = new int[n];
		for (int i = 0; i < road.length; i++) {
			for (int r : list) {
				if (r == i + 1) {
					road[i]++;
				}
			}
			System.out.println(road[i]);
		}
	}
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
int a[333333];
int s[333333];
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)a[i]=io::F();
	if(n&1)
	{
		int c[2]={0};
		for(register int i=1;i<=n;++i)c[i&1]+=a[i];
		int ans=c[1];
		for(register int i=1;i<=n;++i)
			s[i]=s[i-1]+(i&1?a[i]:-a[i]);
		for(int l=dmax(0,c[1]-c[0]),r=c[1]+c[0],mid=l+r>>1;l<=r;mid=l+r>>1)
		{
			int a=0;
			for(int i=1;i<n;i+=2)
				 if(s[i]-a>=mid)cmin(a,s[i+1]);
			if(s[n]-a>=mid)cmax(ans,c[0]+mid),l=mid+1;
				else r=mid-1;
		}
		printf("%d %d\n",ans,c[0]+c[1]-ans);
	}
	else
	{
		int c[2]={0};
		for(register int i=1;i<=n;++i)c[i&1]+=a[i];
		printf("%d %d\n",dmax(c[0],c[1]),dmin(c[0],c[1]));
		return 0;
	}
	return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] s = new char[H][];
		for ( int h = 0 ; h < H ; h++ ) {
			s[h] = sc.next().toCharArray();
		}
		sc.close();

		int[][] map = new int[H][W];
		if ( s[0][0] == '.' ) {
			map[0][0] = 0;
		} else {
			map[0][0] = 1;
		}
		for ( int w = 1 ; w < W ; w++ ) {
			if ( s[0][w] == '.' ) {
				map[0][w] = map[0][w-1];
			} else {
				if ( s[0][w-1] == '.' ) {
					map[0][w] = map[0][w-1] + 1;
				} else {
					map[0][w] = map[0][w-1];
				}
			}
		}
		for ( int h = 1 ; h < H ; h++ ) {
			if ( s[h][0] == '.' ) {
				map[h][0] = map[h-1][0];
			} else {
				if ( s[h-1][0] == '.' ) {
					map[h][0] = map[h-1][0] + 1;
				} else {
					map[h][0] = map[h-1][0];
				}
			}
			for ( int w = 1 ; w < W ; w++ ) {
				if ( s[h][w] == '.' ) {
					map[h][w] = Math.min(map[h-1][w], map[h][w-1]);
				} else {
					int down = s[h-1][w] == '.' ? map[h-1][w] + 1 : map[h-1][w];
					int right = s[h][w-1] == '.' ? map[h][w-1] + 1 : map[h][w-1];
					map[h][w] = Math.min(down, right);
				}
			}
		}

		System.out.println(map[H-1][W-1]);
	}
}


Measured memory_bytes: 23440
import sys
from itertools import accumulate
input = sys.stdin.readline

def acm(x):
    ary = [ i for i in range(x) ]
    return sum(ary)

n = int(input())
strings = {}
for _ in range(n):
    obj = ('').join(sorted(input()))
    if obj in strings:
        strings[obj] += 1
    else:
        strings[obj] = 1

res = 0
for obj in strings:
    res += acm(strings[obj])
print(res)

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

int main() {
  int N;
    cin >> N;
  int i = 0;
  string S;
  
  while(i < N){
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    
    else{
      i++;
    }
    
    if(S != "Y" && i == N){
      cout << "Three" << endl;
    }
  }
  
}


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

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

int main() {
  int N, M;
  cin >> N >> M;
  int A[1001];
  for(int i = 0; i < N; i++) cin >> A[i];
  int LCM = lcm(N, M);
  int mn = 0, mx = 0, sum = 0;
  for(int i = 0; i < LCM; i++) {
    if(i%M == 0) {
      sum += mx - mn;
      mn = 10000;
      mx = 0;
    }
    mn = min(mn, A[i%N]);
    mx = max(mx, A[i%N]);
  }
  cout << sum + (mx != 10000 ? mx - mn : 0) << endl;
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int N = scanner.nextInt();
		int R = scanner.nextInt();
		
      //10以上はそのまま表示、10以下は計算して表示
		if (N >= 10) {
			System.out.println(R);
		} else {
			System.out.println(R + 100 * (10 - N));
		}
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919

using namespace std;

int main(void){
  string S,S1,S2;
  int i=0,ans=0,p=0,swi=1,check=0;
  cin >> S;
  int L=S.length();
  if(L==1){
    ans=1;
  }
  if(L==2){
    if(S[0]!=S[1]){
      ans=2;
    }
    else{
      ans=1;
    }
  }
  if(L>=3){
    S1=S[0],S2=S[1];
    while(i<L){
      if(S1==S2){
        S1=S[i+1]+S[i+2];
        S2=S[i+3];
        i=i+2;
      }
      else{
        S1=S2;
        S2=S[i+2];
        i++;
      }
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640