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

typedef struct _data {
	int val;
	int ceil;
	struct _data *next;
} data;

void push(data **p, data *d)
{
	d->next = *p;
	*p = d;
}

data *pop(data **p)
{
	if (*p == NULL) return NULL;
	data *d = *p;
	*p = (*p)->next;
	return d;
}

int main()
{
	char str[20001], ch;
	int i, val, ceil, total, count;
	data *w1, *w2, *d;

	scanf("%s", str);
	i = 0;
	w1 = w2 = NULL;
	while ((ch = str[i++]) != '\0')
	{
		if (ch == '\\')
		{
			d = (data*)malloc(sizeof(data));
			d->val = 0;
			d->ceil = 0;
			push(&w1, d);
		}
		else if (ch == '_')
		{
			d = pop(&w1);
			if (d == NULL) continue;
			d->ceil++;
			push(&w1, d);
		}
		else
		{
			val = ceil = 0;
			while ((d = pop(&w1)) != NULL)
			{
				val += d->val;
				ceil += d->ceil;
				if (d->val == 0) break;
				push(&w2,d);
			}

			if (d != NULL)
			{
				d->val = val + ceil + 1;
				d->ceil = ceil + 2;
				push(&w1, d);
				while ((d = pop(&w2)) != NULL) free(d);
			}
			else if (val > 0)
			{
				while ((d = pop(&w2)) != NULL) push(&w1, d);
			}
		}
	}

	total = count = 0;
	while ((d = pop(&w1)) != NULL)
	{
		if (d->val == 0)
		{
			free(d);
			continue;
		}

		total += d->val;
		count++;
		push(&w2, d);
	}

	printf("%d\n", total);
	printf("%d", count);
	if (count)
	{
		printf(" ");
		for (i = 0; i < count; i++)
		{
			d = pop(&w2);
			printf("%d", d->val);
			free(d);
			if (i + 1 < count) printf(" ");
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int h; cin >> h; if (h >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int N; cin >>N;
  bool flag=false;
  rep_eq(i,0,100/4) {
    rep_eq(j,0,100/7) {
      if (i*4+j*7==N) {flag=true; break;}
    }
    if (flag) break;
  }
  cout <<(flag ? "Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int max1=0,max2=0,n,p[200005]={-1};
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		if(p[i]>p[max1]) max1=i;
		else if(p[i]<=p[max1]&&p[i]>p[max2]) max2=i;
	}
	for(int i=1;i<=n;i++){
		if(i==max1) cout<<p[max2]<<endl;
		else cout<<p[max1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

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

using namespace std;

#define MAXN 100010
typedef long long LL;

int n, m, c[15][15];
int f[15][33000], g[33000], sum;

int main( int argc , char * argv[] ){
//	freopen( "input.txt" , "r" , stdin );
//	freopen( "output.txt" , "w" , stdout );
    memset(f, -0x3f, sizeof(f));
    int i, j, k, u, v, d, t;
    scanf("%d %d", &n, &m);
    for(i = 1; i <= m; ++i){
        scanf("%d %d %d", &u, &v, &d);
        --u; --v; sum += d;
        c[u][v] = c[v][u] = d;
    }
    t = 1 << n; f[0][1] = 0;
    for(i = 1; i < t; ++i)
        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            for(v = u + 1; v < n; ++v){
                if(!((i >> v) & 1)) continue;
                if(!c[u][v]) continue;
                g[i] += c[u][v];
            }
        }

    for(i = 1; i < t; ++i){
        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            if(f[u][i] < 0) continue;
            for(j = k = (t - 1) ^ i; j; j = (j - 1) & k)
                f[u][i | j] = max(f[u][i | j], f[u][i] + g[j | (1 << u)]);
        }

        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            if(f[u][i] < 0) continue;
            for(v = 0; v < n; ++v){
                if((i >> v) & 1) continue;
                if(!c[u][v]) continue;
                f[v][i | (1 << v)] = max(f[v][i | (1 << v)], f[u][i] + c[u][v]);
            }
        }
    }
    printf("%I64d\n", sum - f[n - 1][t - 1]);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int n, k;
u32 *w;

int check(u64 P)
{
    int i = 0;
    for (int j = 0; j < k; ++j)
    {
        u64 s = 0;
        while (s + w[i] <= P)
        {
            s += w[i];
            ++i;
            if (i == n) return n;
        }
    }
    return i;
}

int solve()
{
    u64 left = 0;
    u64 right = 100000 * 10000;
    u64 mid;
    while (right - left > 1)
    {
        mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n) right = mid;
        else left = mid;
    }

    return right;
}

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

    cin >> n >> k;
    w = new u32[n];

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

    u64 P = solve();

    cout << P << "\n";

    delete[] w;
    return 0;
}



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

int main(){
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for(ll i=2; i<=n; i++){
    ll num = i;
    for(ll j=2; j*j<=num; j++){
      while(num % j == 0){
        mp[j]++;
        num /= j;
      }
  	}
    if(num != 1) mp[num]++;
  }
  ll res = 1;
  for(ll i=2; i<=n; i++){
    res *= mp[i]+1;
    res %= mod;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
// bismillah .....
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 998244353
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
 void solve(){
     ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
     ll k;
     cin>>k;
     cout<<a[k-1];
 }
int main(){
    boost;
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

# aの要素すべてのXOR、sを求めます
s = a[0]
for num in a[1:]:
    s ^= num

    
# i番目は、s xor a_iです
res = [0] * n
for i, num in enumerate(a):
    res[i] = s ^ num

print(*res)

Measured memory_bytes: 31584
from itertools import accumulate
n = int(input())
s = input()
l = list(accumulate([1 if i == 'E' else 0 for i in s]))
ans = n
for i in range(n):
    a = l[-1] - l[max(i-1,0)]
    b = i - l[i]
    ans = min(ans, a+b)
print(ans)

Measured memory_bytes: 17944
import sys

[N] = [int(x) for x in sys.stdin.readline().strip().split(" ")]

result = 0

base = 1  # 1, 100, 10000, ...
upper = 10  # 10, 1000, 100000, ...

while base <= N:
    _upper = min(upper, N + 1)
    result += _upper - base
    base *= 100
    upper *= 100

print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  bitset<10000001> bit;
  ll sum = (2LL + n - 1) * n / 2;
  for (ll i = 1; i <= n;i++){
    bit.set(i);
  }
  for (ll i = n; i >= 1;i--){
    if(sum-i>=n){
      sum -= i;
      bit.reset(i);
    }
    //cout << sum << endl;
  }
  for (ll i = 1; i <= n;i++){
    if(bit[i]){
      cout << i << endl;
    }
  }
  return 0;
}

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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n, l[10000],ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> l[i]; }
	sort(l, l + n);
	for (int a = 0; a < n - 2; a++)
	{
		for (int b = a + 1; b < n - 1; b++)
		{
			for (int c = b + 1; c < n; c++)
			{
				if (l[a] < l[b] + l[c] && l[b] < l[c] + l[a] && l[c] < l[a] + l[b])
				{
					ans++;
				}
				else
				{
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

   ll i,j,t,n,a,b,c=0,mx=-1;
   
   cin>>n;
   while(n--)
   {
     cin>>a>>b;
     
     if(a==b) c++;
     if(c>mx) mx=c;
     if(c>0&&a!=b) c=0;
   }
   if(mx>=3) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   
   
}   

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

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


int main() {
	map<char, long long> mp;
	string S;
	long long N,ans=0,a,b,c;
	cin >> N >> S;
	for (auto s : S) {
		mp[s]++;
	}
	ans = mp['R'] * mp['G'] * mp['B'];
	for(int i = 0; i < N; i++) {
        for(int j = 1; j <= N; j++) {
			a = i;
			b = i + j;
			c = b + j;
			if (c < N) {
				if (S[a] != S[b] and S[b] != S[c] and S[a] != S[c]) ans--;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(ll i = 0; i < n; i++)
#define Fo(i, k, n) for(ll i = k; i < n; i++)
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
using namespace std;
using namespace __gnu_pbds;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin >> n;
	vector<int> arr(n);
	fo(i, n) cin >> arr[i];
	
	ll count = 0;
	fo(i, n) {
		if((i+1)%2 == 0)
			continue;
		
		if(arr[i]%2 != 0)
			count += 1;
	}
	
	cout << count;
	
	return 0;
}



Measured memory_bytes: 3632
n = int(input())
f = [int(input()[::2], 2) for i in range(n)]
p = [list(map(int, input().split())) for l in range(n)]
ans = -float("inf")
for h in range(1, 1024):
    ans = max(ans, sum(p[g][sum(list(map(int, bin(f[g] & h)[2:])))] for g in range(n)))
print(ans)


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

int main() {
   int n,k;
   cin >> n >> k;
   int ans = 0;
   rep(i,n){ 
     int x;
     cin >> x;
     ans += min(x,k-x)*2;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(n*a,b);
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

void test(int N) {
	vector<int>idx(N);
	iota(idx.begin(), idx.end(), 1);
	int ans = 0;
	vector<int>anss(N);
	do {
		int ret = 0;
		FOR(i, 0, N) {
			int x = i + 1;
			ret += (x%idx[i]);
		}
		if (ans < ret) {
			ans = ret;
			anss = idx;
		}

	} while (next_permutation(idx.begin(), idx.end()));

	cout << "ans;" << ans << endl;
	FOR(i, 0, N) {
		cout << anss[i] << " \n"[i + 1 == N];
	}
}

int main() {
	LL N; cin >> N;
	N--;
	LL ans = (N*(N + 1)) / 2;
	cout << ans << endl;
	//FOR(i, 1, 10) {
	//	test(i);
	//}

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

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

    if (a % 2 == 0 || b % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 768
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const int sz = 1e6+5;
int parent[sz];
bool visited[sz];
vi adj[sz];

int main() {
	memset(parent, -1, sizeof parent);
	int n, m;
	sci(n), sci(m);
	for (int i = 0; i < m; ++i) {
		int u, v;
		sci(u), sci(v);
		adj[u].pb(v); adj[v].pb(u);
	}
	queue<pi> q;
	q.push({1, -1});
	while (!q.empty()) {
		int curr, par;
		tie(curr, par) = q.front();
		q.pop();
		if (!visited[curr]) {
			visited[curr] = 1;
			parent[curr] = par;
			for (auto &nx : adj[curr]) {
				if (!visited[nx]) {
					q.push({nx, curr});
				}
			}
		}
	}
	for (int i = 2; i <= n; ++i) {
		if (parent[i] == -1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for (int i = 2; i <= n; ++i) {
		printf("%d\n", parent[i]);
	}
	return 0;
}

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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
int n, a[N];

inline void check(int x)
{
	int diff=0;
	int other=0;
	for(int i=1;i<=n;++i)
		if(a[i]==x-1)
			++diff;
		else 
			++other;
	if(diff+other/2>=x&&diff+(other>0)<=x)
	{
		cout<<"Yes";
		exit(0);
	}
 	
 	return;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	fo(i,n)
		cin>>a[i];
	sort(a+1,a+n+1);
	if(a[n]-a[1]>1)
		return cout<<"No",0;
	check(a[n]);
	check(a[n]+1);
	cout<<"No";
	return 0;
}


Measured memory_bytes: 640
N,W = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(N) ]

lic = [[],[],[],[]]
mi = li[0][0]
for w,v in li:
  lic[w-mi].append(v)

[ lis.sort() for lis in lic ]
[ lis.reverse() for lis in lic ]


for j in range(4):
  pli = lic[j]
  for i in range( len(pli) - 1 ):
    pli[i+1] += pli[i]
for i in range(4):
  tmp = [0]
  tmp.extend(lic[i])
  lic[i] = tmp 
    

sm = 0
for i in range( len(lic[0]) ):
  for j in range( len(lic[1]) ):
    for k in range( len(lic[2]) ):
      for l in range( len(lic[3]) ):
        w = (mi)*(i) + (mi+1)*(j) + (mi+2)*(k) + (mi+3)*(l)
        v = lic[0][i]+lic[1][j]+lic[2][k]+lic[3][l]
        if w <= W:
          sm = max(sm,v)
print ( sm )
  

Measured memory_bytes: 42092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long N=scan.nextInt();
		long A=scan.nextInt();
		long B=scan.nextInt();

		long ans =B*(N-1)+A - (A*(N-1)+B) +1;
		ans = Math.max(ans, 0);
		if(N==1&&A!=B){
			ans=0;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 24788
#include<stdio.h>
#define MAX 100
#define L 1000
#define INF (1<<21)

int n,N[MAX][MAX],a[MAX];
void bfs(int);
int dequeue();
void enqueue(int);
int g = 0,t = 0,q[L];

int main(){
  int k,j,i,x,y,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      N[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&k);
    x--;
    for(j=0;j<k;j++){
      scanf("%d",&y);
      y--;
      N[x][y]=1;
    }
  }
  bfs(0);
  return 0;
}
void enqueue(int z){
  q[t]=z;t=(t+1)%L;
}

int dequeue(){
  int c;
  c=q[g];
  g=(g+1)%L;
  return c;
}


void bfs(int d){
  enqueue(d);
  int i,v,u;
 for(i=0;i<n;i++){
   a[i]=INF;
 }
 a[d]=0;
   while(g != t){
     u=q[g];
     dequeue();
     for(v=0;v<n;v++){
       if(N[u][v] == 0){
         continue;
       }
       if(a[v] != INF){
         continue;
       }
       a[v] = a[u] + 1;
       enqueue(v);
     }
   }
   for(i=0;i<n;i++){
     printf("%d %d\n",i+1,(a[i] == INF ? (-1):a[i]));
   }
}




Measured memory_bytes: 2036
import sys
wx=[]
wy=[]

def readdata():
    global wx,wy
    i=1
    A="0"
    wx=[""]
    wy=[""]
    for s in sys.stdin:
        s=s[:-1]
        if i: wx.append(A+s+A)
        else: wy.append(A+s)
        i=1-i
    wx[0]=A*len(wx[1])
    z=A*len(wy[1])
    wy[0]=z
    wy.append(z)
    return

readdata()
y = 1
x = 1
d = 1
msg = ""
while 1:
    A=[3,0,1,2,3,0,1][d:d+4]
    wall=[wy[y-1][x],wx[y][x],wy[y][x],wx[y][x-1]]
    for e in A:
        if wall[e]=="1": break
    d = e
    y += [-1,0,1,0][d]
    x += [0,1,0,-1][d]
    msg += "URDL"[d]
    if [x,y]==[1,1]: break
print msg

Measured memory_bytes: 4280
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>
#include <string.h>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    char S[15] = {'\0'};

    cin >> S;
    int len = strlen(S);

    int cnt = 0;
    for (int i = 0; i < len; ++i) {
        if (S[i] == 'o') cnt++;
    }

    if (cnt + 15-len >= 8) cout << "YES";
    else cout << "NO";

    return 0;
}



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

using ll = long long int;

const int MAX = (int)1e5 + 5;
const int MOD = (ll)1e9 + 7;

ll n, m, x[MAX], y[MAX];

ll xsum, ysum, ans;

int main(void) {
  // Here your code !
	scanf("%lld %lld", &n, &m);
	for (int i = 0; i < n; ++i) scanf("%lld", &x[i]);
	for (int i = 0; i < m; ++i) scanf("%lld", &y[i]);

	for (int i = 0; i < n; ++i) {
		xsum += ((-1) * (n - 1 - i) * x[i] + (1) * (i) * x[i]);
	}

	for (int i = 0; i < m; ++i) {
		ysum += ((-1) * (m - 1 - i) * y[i] + (1) * (i) * y[i]);
	}

	xsum = xsum % MOD;
	ysum = ysum % MOD;

	ans = (xsum * ysum) % MOD;

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
eval"N,*A="+`dd`.split*?,
b=A.pop N.times{$*[A[_1]]||=_1}
c=(b+b)[(A&b).map{|x|(b.bsearch_index{_1>x}||N)-$*[x]}.max||0,N]
puts A.any?{_1==c[~-$.+=1]}?:No:[:Yes,c]

Measured memory_bytes: 89380
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

pair <long long, long long> BA[200000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        long long A;
        long long B;
        cin >> A >> B;
        BA[i] = make_pair(B, A);
    }
    sort(BA, BA + N);
    long long cur_time = 0;
    bool yes = true;
    for(int i = 0; i < N; i++){
        cur_time += BA[i].second;
        if(cur_time > BA[i].first){
            yes = false;
            break;
        }
    }
    if(yes){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
int N,M,A;
  cin>>N>>M;
  vector<int>list(M+1); // j=0から始まるためM+1にする
  for(int i=0; i<N; i++){
    int K;
    cin>>K;
   for(int j=0; j<K; j++){  // 入力されたKの数だけループをする
    cin>>A;
    list[A]++;  // 入力されたAの値の数をカウントする
   }
  }
  
  int ans=0;
  for(int i=1; i<=M; i++){
   if(list[i]==N){ans++;} // Aのカウント=Nのとき、ans++;
  }
  
  cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double x[1100];
double y[1100];
double r[1100];
double ijk[1100];
int v[1100];
int main(){
	double X1,X2,Y1,Y2;
	scanf("%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2);
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%lf%lf%lf",x+i,y+i,r+i);
	}
	int s=a;
	int t=a+1;
	int n=a+2;
	x[s]=X1;
	y[s]=Y1;
	x[t]=X2;
	y[t]=Y2;
	for(int i=0;i<n;i++)ijk[i]=99999999999999.9;
	ijk[s]=0;
	for(int i=0;i<n;i++){
		int at=0;
		double dist=999999999999999.9;
		for(int j=0;j<n;j++){
			if(!v[j]&&ijk[j]<dist){
				at=j;dist=ijk[j];
			}
		}
		v[at]=1;
		for(int j=0;j<n;j++){
			ijk[j]=min(ijk[j],ijk[at]+max(0.0,sqrt((x[j]-x[at])*(x[j]-x[at])+(y[j]-y[at])*(y[j]-y[at]))-r[j]-r[at]));
		}
	}
	printf("%.12f\n",ijk[t]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long int
ll minn(ll a,ll b)
{
    if(a>b)
        return b;
    else
        return a;
}
ll maxx(ll a,ll b)
{
    if(a<b)
        return b;
    else
        return a;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll ans=a*b;
    cout<<ans<<"\n";


}









Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i=1; i*i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i*i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> yaku = divisor(n);
    ll ans = 1000000000000;
    rep(i, yaku.size()/2+1){
        ll path = yaku[i]-1+n/yaku[i]-1;
        ans =  min(ans, path);
    }
    cout << ans;
}

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

const ll MOD=1000000007;

int main(){
    int N;
    cin>>N;
    vector<int>H(N);
    rep(i,N){
        cin>>H.at(i);
    }
    vector<int>h(N+2);
    rep(i,N){
        h.at(i+1)=H.at(i);
    }
    h.at(0)=0;
    h.at(N+1)=0;
    sort(H.begin(),H.end());
    int MAX=H.at(N-1);
    int count=0;
    bool flag=true;
    int mark=h.at(0);
    for(int j=0;j<MAX;j++){
        rep(i,N+2){
          if(h.at(i)!=0){
              if(mark==0){
                  count=count+1;
              }
              mark=h.at(i);
              h.at(i)=h.at(i)-1;
          }
          else{
              mark=h.at(i);
          }
        }
    }
    cout<<count<<endl;
}

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

int main() {
	int a;
	cin >> a;
	if (a % 2 == 1) {
		cout << a * 2 << endl;
	}
	else {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

bool asc(int a, int b, int c) {
    if(a < b && b < c) {
        return true;
    } else {
        return false;
    }
}

bool desc(int a, int b, int c) {
    if(a > b && b > c) {
        return true;
    } else {
        return false;
    }
}

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

    int p[n];
    rep(i, n) { cin >> p[i]; }

    int count = 0;
    for(int i = 1; i < n - 1; ++i) {
        bool a = asc(p[i - 1], p[i], p[i + 1]);
        bool d = desc(p[i - 1], p[i], p[i + 1]);

        if(a || d) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
   ll a,b,c;
   cin>>a>>b>>c;
   if(c>=a&&c<=b){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T, A;
  cin >> N >> T >> A;

  double minVal = INF;
  int minIndex = -1;

  REPS(i, N) {
    int x;
    cin >> x;
    double val = abs(T - x * 0.006 - A);
    if (minVal > val) {
      minVal = val;
      minIndex = i;
    }
  }
  cout << minIndex << "\n";
}

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

int main(){
	int n,m,l;
	cin >> n >> m >> l;
	
	long long int a[100][100], b[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> b[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			long long int elem=0;
			for(int k=0; k<m; k++){
				elem += a[i][k]*b[k][j];
			}
			if(j==0) cout << elem;
			else cout << " " << elem;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static int dfs(final int deep, final int N, final int node, boolean[][] adj, boolean[] visited){
		if(deep >= N){ return 1; }
		
		int ret = 0;
		
		visited[node] = true;
		for(int next = 0; next < N; next++){
			if(!adj[node][next]){ continue; }
			if(visited[next]){ continue; }
			
			ret += dfs(deep + 1, N, next, adj, visited);
		}
		visited[node] = false;
		
		return ret;
	}
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		boolean[][] adj = new boolean[N][N];
		for(int i = 0; i < M; i++){
			final int a = sc.nextInt() - 1;
			final int b = sc.nextInt() - 1;
			
			adj[a][b] = true;
			adj[b][a] = true;
		}
		
		
		System.out.println(dfs(1, N, 0, adj, new boolean[N]));
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, m;
    cin >> n >> m;
    vector<Int> ball(n + 1, 1);
    vector<bool> visited(n + 1, false);
    visited[1] = true;
    for (Int i = 0; i < m; i++) {
        Int x, y;
        cin >> x >> y;
        ball[x]--;
        ball[y]++;
        if (visited[x]) {
            visited[y] = true;
            if (ball[x] == 0) {
                visited[x] = false;
            }
        }
    }
    Int res = 0;
    for (Int i = 1; i <= n; i++) {
        if (visited[i]) res++;
    }
    dump(res);
    return 0;  
} 

Measured memory_bytes: 1024
Module Program
  Sub Main
    Dim s=GetInts()(0)
    Dim t=GetInts()(0)
    Dim u=GetInts()(0)
    Dim ans=(s-t)Mod u
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

int main()
{
    int N;
    int X;
    int Y;
    cin >> N >> X >> Y;

    queue<int> q1;

    // 1行目は、頂点1を始点とする場合
    //1,2は、1から2までいくときの最短距離、1.3は、1から3までいくときの最短距離
    vector<vector<int>> len(N + 1, vector<int>(N + 1, -1));

    vector<int> ans(N + 1, 0);

    //i行目について考える（頂点iを始点とする場合について考える）
    for (int i = 1; i <= N - 1; i++)
    {
        len[i][i] = 0;

        q1.push(i);

        while (!q1.empty())
        {
            int temp = q1.front();
            q1.pop();

            if (temp + 1 <= N)
            {
                if (len[i][temp + 1] == -1)
                {
                    len[i][temp + 1] = len[i][temp] + 1;
                    q1.push(temp + 1);
                }
            }

            if (temp - 1 >= 1)
            {
                if (len[i][temp - 1] == -1)
                {
                    len[i][temp - 1] = len[i][temp] + 1;
                    q1.push(temp - 1);
                }
            }

            //取り出した頂点が、Xかどうか確認
            if (temp == X)
            {
                if (len[i][Y] == -1)
                {
                    len[i][Y] = len[i][temp] + 1;
                    q1.push(Y);
                }
            }
        }
    }

    //ここまでで表はできている
    int temp;
    for (int i = 1; i <= N; i++)
    {
        for (int j = i; j <= N; j++)
        {
            temp = len[i][j];
            // cout << i << "--" << j << "--" << temp << "--" << endl;
            if (temp != -1)
            {
                ans[temp]++;
            }
        }
    }

    for (int i = 1; i <= N - 1; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int x;
	if(n<=1){
		x=0;
	}
	else{
		x=n*(n-1);
		x=x/2;
	}
	int y;
	if(m<=1){
		y=0;
	}
	else{
		y=m*(m-1);
		y=y/2;
	}
	cout<<x+y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#include<math.h>
 
 
int main(void)
 
 
{
 
 
double r,x;
 
 
x=M_PI;
 
 
scanf("%lf",&r);
 
 
printf("%lf %lf",r*r*x,r*2*x);
 
 
return 0;
 
 
}

Measured memory_bytes: 648
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from collections import Counter
N = int(input())
P = inpl()
ans = 0
for i in range(N-2):
    ans += (P[i] < P[i+1] < P[i+2]) | (P[i+2] < P[i+1] < P[i])
print(ans)

Measured memory_bytes: 38704
n, m = map(int, input().split())

safe = [True] * (n + 1)
for _ in range(m):
  safe[int(input())] = False
dp = [0] * (n + 1)

dp[0] = 1
if safe[1]:
  dp[1] = 1

for i in range(2, n + 1):
  if safe[i - 1]:
    dp[i] += dp[i - 1]
  if safe[i - 2]:
    dp[i] += dp[i - 2]
  dp[i] %= 1000000007
 
print(dp.pop())

Measured memory_bytes: 7772
import math
L = int(input())

n = int(math.log2(L))
w1 = pow(2,n-1)
w1n = bin(L - pow(2, n))
p = 2 * n  + w1n.count('1')
print(str(n + 1) + " " + str(p))

print("1 2 0")
print("1 2 " + str(w1))
for i in range(2, n + 1):
  print(str(i) + " " + str(i + 1) + " 0")
  print(str(i) + " " + str(i + 1) + " " + str(pow(2, n - i)))

w = L - 1
for i in range(len(w1n) - 2):
  if w1n[-1] == '1':
    print("1 " + str(n + 1 - i) + " " + str(w))
    w -= pow(2, i)
  w -= pow(2, i)
  w1n = w1n[:-1]
  if w1n.count('1') == 0:
    break

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	char str[1000][100];
	int i, n, flag;

	n=0;
	while(scanf("%s", str[n]) != EOF)
		n++;

	for(i=0; i<n; i++){
		if(str[i][strlen(str[i])-1] == '.' || str[i][strlen(str[i])-1] == ','){
			str[i][strlen(str[i])-1] = 0;
		}
	}

	flag = 0;
	for(i=0; i<n; i++){
		if(strlen(str[i]) >= 3 && strlen(str[i]) <= 6){
			if(flag == 0){
				printf("%s", str[i]);
				flag = 1;
			} else {
				printf(" %s", str[i]);
			}
		}
	}
	printf("\n");

	return 0;

}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=0;
    cin>>n;
    vector<int> h(n), high(n);
    for(int i = 0; i < n; i++)
    {
        cin>>h[i];
        if(i==0) high[i]=h[i];
        else high[i]=max(high[i-1],h[i]);
    }
    for(int i = 0; i < n; i++)
    {
        if(high[i]<=h[i]) ans++;
    }
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 384
def c(a,b)
  ans = 1
  ((a-b+1)..a).each do |d|
    ans *= d
  end
  (2..b).each do |d|
    ans /= d
  end
  return ans
end
n,p = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
a0 = 0
a1 = 0
a.each do |d|
  if(d%2 == 0)
    a0 += 1
  else
    a1 += 1
  end
end
ans = 0
if(p == 1)
  ((a1+1)/2).times do |t0|
    (0..a0).each do |t1|
      ans += c(a1,(t0*2+1)) * c(a0,t1)
    end
  end
    
else
  (0..a0).each do |t0|
    (0..(a1/2)).each do |t1|
      ans += c(a0,t0) * c(a1,t1*2)
    end
  end
end
p ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF 2000000000
#define DESPACITO2 1000000000000000
#define DESPACITO 1000000000000000000
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define msi map<string,int>
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define TRvi(c,it) for(vi::iterator it=(c).begin();it!=(c).end();it++)
#define TRvii(c,it) for(vii::iterator it=(c).begin();it!=(c).end();it++)
#define TRmsi(c,it) for(msi::iterator it=(c).begin();it!=(c).end();it++)
 
 
using namespace std;

bool compare(const pair<int,int>&a, const pair<int,int>&b)
{
	if(a.first!=b.first)
		return (a.first<b.first);
	return (a.second>b.second);
}

int main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
    int n,m;
    cin >> n >> m;
    pair<int,int>arr[m+1];
    REP(i,1,m)
    	cin >> arr[i].first >> arr[i].second;
    int ct=0;
    int maxpos=n+1;
    sort(arr+1,arr+m+1,compare);
    for(int i=m;i>=1;i--)
    {
    	if(arr[i].second<=maxpos)
    	{
    		ct++;
    		maxpos=arr[i].first;
    	}
    }
    cout << ct << "\n";
}

Measured memory_bytes: 1024
a,b,c = map(int,input().split())
f = 1
if a<b:
    pass
else:
    f = a
    a = b
    b = f
if b < c:
    pass
else:
    if a<c:
        f = b
        b = c
        c = f
    else:
        f = c
        c = b
        b = a
        a = f
print(f"{a} {b} {c}")        

    


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

int main() {
  int N;
  cin >> N;
  
  vector<int> order(N);
  
  for (int i = 0; i < N; i++) {
    cin >> order.at(i);
  }
  
  int ai;
  ai = order.at(0);
  int count;
  for (int j = 1; j < N; j++) {
    if (ai == 2) {
      count = j;
      break;
    }
    ai = order.at(ai - 1);
    count = -1;
  }    
  cout << count << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


ll gcd(ll x,ll y){
  return y==0? x:gcd(y,x%y);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  int ans = 1;
  while(N>1){
    N>>=1;
    ans<<=1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int x;

	cin >> x;

	cout << x*x*x << endl;

	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i];
    sort (arr, arr + N);

    if (arr[N-1] == 0)
    {
        cout << "Yes\n";
        return 0;
    }
    if (N % 3 != 0)
    {
        cout << "No\n";
        return 0;
    }

    int cturn = N / 3;
    if (arr[0] == arr[cturn-1] && arr[cturn] == arr[2*cturn-1] && arr[2*cturn] == arr[3*cturn-1] &&
        ((arr[0] ^ arr[cturn]) == arr[2*cturn]))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 640
/*-*-coding:utf-8-*-*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <cmath>
#include <stack>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  
  while(cin >> n, !cin.eof()) {
    int ans = 0;
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
	for(int k = 0; k < 10; k++) {
	  for(int l = 0; l < 10; l++) {
	    if(n == i + j + k + l) ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()

print("Yes" if s[2]==s[3] and s[4]==s[5] else "No")

Measured memory_bytes: 38384
//=========================================c++
/* ===========================================
// 20.04.07 AtCoder Beginner Contest 160. A - Coffee 
// 
// 
=========================================== */
/* ===========================================

1 周 KK メートルの円形の湖があり、その周りに N 軒の家があります。
i 番目の家は、湖の北端から時計回りに Ai メートルの位置にあります。
家の間の移動は、湖の周りに沿ってのみ行えます。
いずれかの家から出発して N 軒すべての家を訪ねるための最短移動距離を
求めてください。

::test input
20 3
5 10 15
=========================================== */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>

static struct GV{
    int K = 0;
    int N = 0;
    vector<int> A;
    int max_interval = 0;
}gv;

void build(){
    cin >> gv.K >> gv.N;
    rez (i, gv.N) {
        int a; cin >> a;
        gv.A.push_back(a);
        if (i > 0) {
            gv.max_interval = max(gv.max_interval, gv.A[i] - gv.A[i-1]);
        }
    }
}

void solve(){
    int ans = 0;
    ans = min(  gv.A[gv.N -1] - gv.A[0], 
                gv.K - gv.max_interval );
    cout << ans;
}

int main(){
    build();
    solve();
    
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    int X,A;

    cin >> X>>A;

    if(X<A){
        cout << '0'<<endl;
    }else{
        cout << "10"<<endl;
    }


    return 0;
}

Measured memory_bytes: 764
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B){
        cout<<C<<endl;
    }
    else if(A==C){
        cout<<B<<endl;
    }
    else if(B==C){
        cout<<A<<endl;
    }
}


Measured memory_bytes: 256
def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)
max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  P_X[k[0]] == Max_X and P_Y[k [1]] == Max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)


Measured memory_bytes: 173648