akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


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


int main(void)
{

    long long n;
    cin >>n;

    vector< long long > dis = divisor(n);

    long long minMove = n - 1;
    for(int i = 0; i < dis.size(); i++){
        minMove = min(minMove, dis[i] + n / dis[i] -2);
    }

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

    return 0;
}

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

struct	UnionFind {
	int		size;
	int		*par;
	int		*rank;
	int		num_group;
	UnionFind(int size): size(size), par(NULL), rank(NULL), num_group(size) {
		assert(size > 0);
		par = new int[size];
		rank = new int[size];
		assert(par != NULL && rank != NULL);
		for (int i = 0; i < size; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	~UnionFind() {
		delete [] par;
		delete [] rank;
		par = NULL;
		rank = NULL;
	}
	int		find(int idx) {
		if (par[idx] == idx)
			return idx;
		return (par[idx] = find(par[idx]));
	}
	bool	same(int lhs, int rhs) {
		if (find(lhs) == find(rhs))
			return true;
		return false;
	}
	void	unite(int lhs, int rhs) {
		int	par_l = find(lhs), par_r = find(rhs);
		if (par_l == par_r)
			return;
		if (rank[par_l] < rank[par_r]) {
			par[par_l] = par_r;
		} else {
			par[par_r] = par_l;
			if (rank[par_l] == rank[par_r])
				++rank[par_l];
		}
		--num_group;
	}
};

int	main()
{
	int	N, M;
	cin >> N >> M;
	int	a, b;
	vector<pair<int, int>>	edge_vec(M);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		--a; --b;
		edge_vec.at(i) = {a, b};
	}
	int	cnt = 0;
	for (int i = 0; i < M; ++i) {
		UnionFind	uf(N);
		for (int j = 0; j < M; ++j) {
			if (i == j) continue;
			uf.unite(edge_vec.at(j).first, edge_vec.at(j).second);
		}
		if (uf.num_group > 1)
			++cnt;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin>>n;
map<string,int>fr;
for(int i=0;i<n;i++){
	string s;
	cin>>s;
	if(fr.count(s)==0)
	fr.insert({s,1});
	else
	fr[s]++;
}
cout<<fr.size();




}


Measured memory_bytes: 19232
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  vector<int> A(5);
  int mn = 10;
  int ans = 0;
  for(int i = 0; 5 > i; i++){
    cin>>A[i];
    ans += A[i]/10*10 + 10*(A[i]%10?1:0);
    if(A[i]%10){
      mn = min(mn,A[i]%10);
    }
  }
  cout << ans-10+mn << endl;

}


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

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

  int t = 0;
  int d = 0;
  while (d < X) {
    t++;
    d += t;
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
 
/**
 * @author kawakami
  
*/
class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner as = new Scanner(System.in);
            
        int x;
        int y;
 
        
            
          
            
            
            
 
        while(true){
            
            
           x = as.nextInt();
           y = as.nextInt();
           if(x==0 && y==0){
               break;
  }
            
            
           if(x<y){
                
              System.out.println(x+" "+y);
 
             }
           else{
              System.out.println(y+" "+x);
 
             } 
       }
 
    }
 
}

Measured memory_bytes: 36228
L,R = map(int, input().split())
if R - L >= 2018:
    print(0)
    exit()
else:
    ans = 2019**2
    for i in range(L, R):
        for j in range(i+1, R+1):
            i %= 2019
            j %= 2019
            k = (i*j) % 2019
            ans = min(ans, k)
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int x, n;
    cin >> x >> n;
    vector<Int> p(n);
    for (Int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    vector<Int> s;
    vector<Int> b;
    bool x_exist = false;
    for (Int i = 0; i < n; ++i) {
        if (p[i] < x) {
            s.push_back(x - p[i]);
        } else if (p[i] > x) {
            b.push_back(p[i] - x);
        } else {
            x_exist = true;
        }
    }
    sort(s.begin(), s.end());
    sort(b.begin(), b.end());
    Int small_diff = -1;
    Int big_diff = -1;;
    for (Int i = 0; i < (Int)s.size(); ++i) {
        if (s[i] != i + 1) {
            small_diff = i + 1;
            break;
        }
    }
    if (small_diff == -1) {
        small_diff = (Int)s.size() + 1;
    }
    for (Int i = 0; i < (Int)b.size(); ++i) {
        if (b[i] != i + 1) {
            big_diff = i + 1;
            break;
        }
    }
    if (big_diff == -1) {
        big_diff = (Int)b.size() + 1;
    }
    //cout << small_diff << " " << big_diff << endl;

    if (!x_exist) {
        cout << x << endl;
    } else if (small_diff <= big_diff) {
        cout << x - small_diff << endl;
    } else {
        cout << x + big_diff << endl;
    }

    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

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

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    repp(i,0,N) cin >> A[i] >> B[i];

    priority_queue<pair<ll, int>> pq;
    repp(i,0,N) pq.push(make_pair(A[i] + B[i], i));

    ll score_t = 0;
    ll score_a = 0;

    repp(i,0,N) {
        if (i%2 == 0) {score_t += A[pq.top().second]; pq.pop();}
        else {score_a += B[pq.top().second]; pq.pop();}
    }
    cout << score_t - score_a << endl;
}


Measured memory_bytes: 3956
#include <cstdio>
#include <cstring>
const int BASE = 10;
const int DIVD = 13;
const int MAXS = 1e5+5;
const int MOD = 1e9+7;
const int REM = 5;
char buff[MAXS];
int dp[MAXS][DIVD];
int S;

void place(int i, int val, int b) {
    int msb = val * b % DIVD;
    for (int k = 0; k < DIVD; ++k) {
        int pos = (msb + k) % DIVD;
        dp[i][pos] = (1LL * dp[i+1][k] + dp[i][pos]) % MOD;
    }
}

int main() {
    scanf(" %s", buff);
    S = strlen(buff);
    for (int i = 0; i <= S; ++i) {
        for (int j = 0; j < DIVD; ++j) {
            dp[i][j] = 0;
        }
    }
    dp[S][0] = 1;
    int b = 1;
    for (int i = S-1; i >= 0; --i) {
        if (buff[i] == '?') {
            for (int j = 0; j < BASE; ++j) {
                place(i, j, b);
            }
        } else {
            place(i, buff[i]-'0', b);
        }
        b = b * BASE % DIVD;
    }
    printf("%d\n", dp[0][REM]);
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int fa[2*maxn];
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y){
	x=find(x),y=find(y);
	fa[x]=fa[y];
}
bool same(int x,int y){
	return find(x)==find(y);
}
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n*2;++i) fa[i]=i;
	for(int i=1;i<=m;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		merge(u,v+n);
		merge(v,u+n);
	}
	for(int i=1;i<=n;++i){
		if(same(i,i+n)){
			printf("%lld",1ll*n*(n-1)/2-m);
			return 0;
		}
	}
	int ls=1,rs=0;
	for(int i=2;i<=n;++i){
		if(same(i,1)) ++ls;
		else ++rs;
	}
	printf("%lld\n",1ll*ls*rs-m);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  } else if (N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)

typedef long long ll;

using namespace std;


int main()
{
  ll dp[11][1001]={};
  dp[0][0] = 1;
  FOR(k,0,100) DOWN(i,10,1) FOR(j,k,1000)
    dp[i][j] += dp[i-1][j-k];
  int n, s;
  while(cin>>n>>s,n) cout << dp[n][s] << endl;
  return 0;
}

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

vector<int> v;

int main(){
while(1){//start
	int b;
	cin >> b;
	if(b == 1) break;
	for(int i = 2; i <= b; i++){
		bool flag = true;
		if((i % 7 == 1 or i % 7 == 6) and b % i == 0){
			for(int j = 2; j < i; j++){
				if((j % 7 == 1 or j % 7 == 6) and i % j == 0) flag = false;
			}
			if(flag) v.push_back(i);
		}
	}

	cout << b << ":";
	for(int i = 0; i < (int)v.size(); i++) cout << " " << v[i];
	cout << endl;
	v.clear();
}//end
	return 0;
}



Measured memory_bytes: 3048
h, w = map(int, raw_input().split())
grid = [raw_input() for y in range(h)]
dist = [[-1]*w for y in range(h)]
que = [(0,0)]
dist[0][0] = 0
while que != []:
    cx, cy = que.pop(0)
    for dx, dy in [(1,0), (0,1), (-1,0), (0,-1)]:
        nx, ny = cx+dx, cy+dy
        if (0 <= nx < w) and (0 <= ny < h) and (grid[ny][nx] == '.') and (dist[ny][nx] == -1):
            que.append((nx, ny))
            dist[ny][nx] = dist[cy][cx] + 1
d = dist[h-1][w-1]
if d == -1:
    print -1
else:
    print (h*w - d - 1 - sum([len(filter(lambda c: c=="#", line)) for line in grid]))

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N), S(N+1);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    ll ans = 0;
    for(ll i = 40; i >= 0; i--){
        ll t = (1LL << i) + ans;
        ll cnt = 0;
        rep(j,N+1){
            REP(k,j+1,N+1){
                if(((S[k] - S[j]) & t) == t)cnt++;
            }
        }
        if(cnt >= K){
            ans = t;
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}

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

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

    vector<string> V = { "SUN","MON","TUE","WED","THU","FRI","SAT"};
    string S;
    cin >> S;
    cout << V.end() - find(V.begin(), V.end(), S) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[200010];
  long long i,r=0,a=0,b=0;
  scanf("%s",s);
  for(i=0;s[i];i++){
    s[i-r]=s[i];
    if(s[i]=='B'&&s[i+1]=='C'){
      s[i-r]='D';
      r++;
      i++;
    }
  }
  s[i-r]=0;
  for(i=0;s[i];i++){
    if(s[i]=='A')a++;
    else if(s[i]=='D')b+=a;
    else a=0;
  }
  printf("%lld\n",b);
  return 0;
}


Measured memory_bytes: 384
// M - Candies  https://atcoder.jp/contests/dp/tasks/dp_m
/* 入力例
3 4
1 2 3
// →出力 5 
// 横軸子供、縦軸アメのナップザック的２次元DP
// 各セルには左のセルの個数と上からのセルの個数の和から上からのセルから満杯になってものを引いた値が入る。
// 左からのセル(i, j-1)の個数は、そのセル j列の子供が０個持つことを意味し
// 上からのセル(i-1, j)の個数は、そのセル j列の子供が(i-1, j)に一つ加えたアメを持つことを意味する。そのためj列の子が持ちきれなくたった分を引かないといけないが
// その個数は、DP表を考えると、dp[i - 1 - a[j]][j - 1]であらわされる。
//
// WAがひどかった。（理由）1000000007で割るとえらく小さい値なる可能性があり、それから値を引いたとき、負の数になってしまって想定外のことがおこってしまう。
//                         引き算がある場合は、この解答のように割る前に1000000007を足しておかないといけない。
*/
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    unsigned int a[N], dp[K + 1][N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int j = 0; j < N; j++) {
        dp[0][j] = 1;
    }
    for(int i = 1; i <= K; i++) {
        if(i <= a[0]) {
            dp[i][0] = 1;
        } else {
            dp[i][0] = 0;
        }
        for(int j = 1; j < N; j++) {
            if(a[j] == 0) {
                dp[i][j] = dp[i][j - 1];
            } else {
                if(i <= a[j]) {
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + 1000000007) % (1000000007);
                } else {
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1 - a[j]][j - 1] + 1000000007) % (1000000007);
                }
            }
        }
    }
    cout << dp[K][N - 1] << endl;
    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int l = s.length(), i = l / 2; i--;) {
    ans += s[i] != s[l - 1 - i];
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long LL;

const int N=6908733,M=200000;

int n,m,cq;
char s[M+9];

void into(){
  scanf("%d%s",&n,s+1);
  cq=strlen(s+1);
}

struct tree{
  int s[3],id,rev;
}tr[N+9];
int cn;

void Build(){tr[cn=1].id=-1;}

void Update_rev(int k){swap(tr[k].s[1],tr[k].s[2]);tr[k].rev^=1;}

void Pushdown(int k){
  if (!tr[k].rev) return;
  for (int i=0;i<3;++i) Update_rev(tr[k].s[i]);
  tr[k].rev=0;
}

void Insert(int x){
  int k=1;
  for (int i=0,now=x;i<n;++i,now/=3){
	int &t=tr[k].s[now%3];
	tr[k=t=t?t:++cn].id=-1;
  }
  tr[k].id=x;
}

void Change_add(int k){
  if (tr[k].id>=0) return;
  int t=tr[k].s[2];
  Pushdown(k);
  for (int i=2;i>=1;--i) tr[k].s[i]=tr[k].s[i-1];
  Change_add(tr[k].s[0]=t);
}

int ans[N+9];

void Dfs_ans(int k,int v,int pw){
  if (tr[k].id>=0) {ans[tr[k].id]=v;return;}
  Pushdown(k);
  for (int i=0;i<3;++i) Dfs_ans(tr[k].s[i],v+i*pw,pw*3);
}

void Get_ans(){
  m=1;
  for (int i=1;i<=n;++i) m*=3;
  Build();
  for (int i=0;i<m;++i) Insert(i);
  for (int i=1;i<=cq;++i) s[i]=='S'?Update_rev(1):Change_add(1);
  Dfs_ans(1,0,1);
}

void work(){
  Get_ans();
}

void outo(){
  for (int i=0;i<m;++i)
	printf("%d ",ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 21972
def partition(array, p, r):
    x = array[r]
    i = p-1
    for j in range(p, r):
        if array[j] <= x:
            i += 1
            array[i], array[j] = array[j], array[i]
    array[i+1], array[r] = array[r], array[i+1]
    a1 = array[:i+1]
    a2 = "[" + str(array[i+1]) +  "]"
    a3 = array[i+2:]
    array = a1[:]
    array.append(a2)
    array += a3
    print(*array)
    return i+1

n = int(input())
array = [int(a) for a in input().split()]
p = partition(array, 0, n-1)


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

int main(){
	long long N,T;
	cin >> N >> T;
	vector<long long> t(N,0);
	long long sum=0;
	for(long long i=0;i<N;i++){
		cin >> t[i];
		
		if(i==0){
			sum+=0;
		}
		
		if(i>=1){
			if((t[i]-t[i-1])<T){
				sum+=t[i]-t[i-1];
			}else{
				sum+=T;
			}
		}
		
	}
	sum+=T;
	cout << sum << endl;
	return 0;
}


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

int main(){
	int N;
	cin >> N;
	int count_ans = 0;

	for (int i=0; i<= N; ++i ){
		if (i % 2 == 0){continue;}

		int count_yakusu = 1; // init: 1
		int num = i;

		for (int j=1; j<i; ++j){
			if (j % 2 == 0){continue;}
			int num_t = j;
			if (num % num_t == 0){
				++count_yakusu;
// 				cout << "num, num_t: " << num << ", " << num_t << 
// 					"count_yakusu: "<< count_yakusu << endl;	
			}
		}
		if (count_yakusu==8) 
		{
			++count_ans;
		}
	}
	cout << count_ans << endl;

	return 0;
}


Measured memory_bytes: 256
k, n = gets.split(" ").map { |s| s.to_i }
a = gets.split(" ").map { |s| s.to_i }

dis = []
(n-1).times do |i|
	dis.push(a[i+1] - a[i])
end
dis.push(a[0] + k - a[-1])

puts dis.inject(:+) - dis.max

Measured memory_bytes: 18948
count = gets.to_i
arr = gets.split(" ").map(&:to_i)
bool = true
counter = 0
while bool
    bool = false
    (arr.length - 1).downto(1) do |index|
        if arr[index] < arr[index - 1]
            tmp = arr[index]
            arr[index] = arr[index - 1]
            arr[index - 1] = tmp
            counter += 1
            bool = true
        end
    end
end
puts arr.join(" ")
puts counter



Measured memory_bytes: 6860
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
LL Q,H,S,D,n;
int main()
{
	scanf("%lld%lld%lld%lld",&Q,&H,&S,&D);
	if(Q*2<H) H=Q*2;
	if(H*2<S) S=H*2;
	if(S*2<D) D=S*2;
	cin>>n;
	cout<<(n/2)*D+(n%2)*S<<endl;
	return 0;
}
/*
12345678 87654321 12345678 87654321
123456789
*/

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

struct T{
	int start, end;
};

T getT(){
	int a, b, c, d;
	scanf("%d:%d-%d:%d", &a, &b, &c, &d);
	T ret;
	ret.start = a * 60 + b;
	ret.end = c * 60 + d;
	return ret;
}

vector<T> getTs(){
	int n;
	scanf("%d", &n);
	vector<T> v;
	FOR(i, n) v.push_back(getT());
	return v;
}

int main(){
	auto f = getTs();
	vector<int> teacher(sz(f)), student(sz(f));
	int n; scanf("%d", &n);
	FOR(i, n){
		vector<int> cur;
		auto a = getTs();
		for (auto t : a) {
			FOR(i, sz(f)){
				if (t.start <= f[i].start && f[i].end <= t.end) teacher[i]++;
			}
		}
	}

	int m; scanf("%d", &m);
	FOR(i, m){
		vector<int> cur;
		auto a = getTs();
		for (auto t : a) {
			FOR(i, sz(f)){
				if (t.start <= f[i].start && f[i].end <= t.end) student[i]++;
			}
		}
	}

	int ans = 0;
	FOR(i, sz(f)){
		ans += min(teacher[i], student[i]);
	}
	cout << ans << endl;

}

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

template <class T> class CumulativeSum2D {
private:
  vector<vector<T>> D;

public:
  CumulativeSum2D(int W, int H) : D(W + 1, vector<T>(H + 1, 0)) {}
  void add(int x, int y, T z) {
    x++, y++;
    if (x >= (int) D.size() || y >= (int) D.at(0).size()) return;
    D.at(x).at(y) += z;
  }
  void build() {
    for (int i = 1; i < (int) D.size(); i++) {
      for (int j = 1; j < (int) D.at(i).size(); j++) {
        D.at(i).at(j) += D.at(i).at(j - 1) + D.at(i - 1).at(j) - D.at(i - 1).at(j - 1);
      }
    }
  }
  T query(int sx, int sy, int gx, int gy) const { return (D.at(gx + 1).at(gy + 1) - D.at(sx).at(gy + 1) - D.at(gx + 1).at(sy) + D.at(sx).at(sy)); }
};

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, M, Q;
  cin >> N >> M >> Q;
  CumulativeSum2D<int> CS2(N, N);
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R, L--, R--;
    CS2.add(L, R, 1);
  }
  
  CS2.build();
  
  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q, p--, q--;
    cout <<  CS2.query(p, p, q, q) << "\n";
  }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n), aa;
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<P> p;
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    p.emplace_back(c, b);
  }
  sort(p.rbegin(), p.rend());
  for (auto x : p) {
    rep(i, x.second) aa.push_back(x.first);
    if (n <= aa.size()) break;
  }
  // rep(i, n) fprintf(stderr, "%d%c", a[i], (i == n - 1 ? '\n' : ' '));
  // rep(i, n) fprintf(stderr, "%d%c", aa[i], (i == n - 1 ? '\n' : ' '));

  ll ans = 0;
  rep(i, n) {
    if (aa.size() <= i) {
      ans += a[i];
    } else {
      ans += max(a[i], aa[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6812
N = int(input())
ans = 0

for num in range(1, N+1, 2):
    divisor = 0
    for devide in range(1, N+1, 2):
        if num % devide == 0:
            divisor += 1
        if divisor > 8:
            break
    if divisor == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{	
  char a[4];
  cin>>a;
  int temp = 0 ;
  for(int i = 0 ;i<3;i++)
  {
  		if(a[i]==a[i+1])
        {temp = 1 ;break;}
    }
  if(temp)
    cout<<"Bad"<<"\n";
  else 
    cout<<"Good"<<"\n";
}

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

using namespace std;
typedef long long int lint;

void answer()
{
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main()
{
	answer();
	return 0;
}

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

int cnt[101];

int main(){
	int n,k;
	cin>>n>>k;
	for (int i=0;i<k;i++){
		int d;
		cin>>d;
		for (int j=0;j<d;j++){
			int a;
			cin>>a;
			cnt[a-1]++;
		}
	}
	long long sum=0;
	for (int i=0;i<n;i++){
		if (cnt[i]==0){
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  string s;
  cin >> N >> s;
  vector<char> S(N);
  for (int i = 0; i < N; i++) S.at(i) = s.at(i);
  
  bool fin = false;
  while (!fin)
  {
    fin = true;
    for (int i = 0; i < S.size() - 1; i++)
    {
      if (S.at(i) == '(' && S.at(i + 1) == ')')
      {
        S.erase(S.begin() + (i + 1));
        S.erase(S.begin() + i);
        if (S.size() > 0) fin = false;
        break;
      }
    }
  }
  
  string L, R;
  
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == ')') L += '(';
    else if (S.at(i) == '(') R += ')';
  }
  
  cout << L << s << R << endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    adj_max = [0 for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        if adj_max[a-1] < H[b-1]:
            adj_max[a-1] = H[b-1]
        if adj_max[b-1] < H[a-1]:
            adj_max[b-1] = H[a-1]
    num = 0
    for i in range(N):
        if H[i] > adj_max[i]:
            num += 1
    print(num)




Measured memory_bytes: 20128
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	unsigned long long depo = 100, x, year = 0;
	cin >> x;
	while(depo < x) {
		depo = floor((double)depo * 1.01);
		year++;
	}
	cout << year << "\n";
	return 0;

}

Measured memory_bytes: 3656
function main(arg) {
	var header = arg.split("\n")[0].split(" ")

	var N = header[0]
	var H = Number(header[1])
	var W = Number(header[2])
	var count = 0
	arg = arg.split("\n")
	arg.shift()

	arg = arg.map(e => e.split(" ").map(ee => Number(ee)))

	for (var i = 0; i < arg.length; i++) {
		var row = arg[i]
		if (row[0] >= H && row[1] >= W) {
			count++
		}
	}

	console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <iostream>
#include<string>
#include <set>

using namespace std;

int N, M;
string S;

int dp[200005], NEXT[100005];

int INF = 999999;

set<pair<int, int> > G;

int main(void) {

	cin >> N >> M;
	cin >> S;

	for (int i = 0; i <= N+M+1; i++) {
		dp[i] = INF;
	}

	dp[N] = 0;

	G.insert(make_pair(0, N));

	for (int i = N - 1; i >= 0; i--) {
		G.erase(make_pair(dp[i + M + 1], i + M + 1));
		if (S[i] == '0') {
			auto it = G.begin();
			dp[i] = (*it).first + 1;
			NEXT[i] = (*it).second;
		}
		G.insert(make_pair(dp[i], i));
	}

	if (dp[0] >= INF) {
		cout << -1 << endl; return 0;
	}
	else {

		int cur = 0;

		while (cur < N) {
			if (cur != 0) { cout << " "; }
			cout << NEXT[cur] - cur;
			cur = NEXT[cur];
		}
		cout << endl;

	}

	return 0;
}


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

using namespace std;
#define ll long long
int timer=0;
int l;
const int N=3e5+5;
int up[N][30];
vector<int> adj[N],Want[N];
int in[N],out[N],a[N],b[N],u[N],v[N],c[N],x[N];
ll curcost[N],curcnt[N],y[N],dis[N],d[N];
ll ans[N];
map< pair<int,int> , ll >cnt,cost;
void dfs(int u,int par,ll D)
{
    in[u]=++timer;
    up[u][0]=par;
    dis[u]=D;
    for(int i=1;i<=l;i++)
        up[u][i]=up[up[u][i-1]][i-1];
    for(auto idx:adj[u]){
        int v;
        if(a[idx]==u)
            v=b[idx];
        else v=a[idx];
        if(v!=par)
            dfs(v,u,D+d[idx]);
    }
    out[u]=timer;
}
bool is_ancestor(int u,int v)
{
    return in[u]<=in[v]&&out[u]>=out[v];
}
int LCA(int u,int v)
{
    if(is_ancestor(u,v))
        return u;
    if(is_ancestor(v,u))
        return v;
    for(int i=l;i>=0;i--)
    {
        if(!is_ancestor(up[u][i],v))
            u=up[u][i];
    }
    return up[u][0];
}
void solve(int u,int par)
{
    for(auto v:Want[u])
    {
        cnt[{u,v}]=curcnt[v];
        cost[{u,v}]=curcost[v];
    }
    for(auto idx:adj[u])
    {
        int v;
        if(a[idx]==u)
            v=b[idx];
        else v=a[idx];
        if(v!=par)
        {
            curcnt[c[idx]]++;
            curcost[c[idx]]+=d[idx];
            solve(v,u);
            curcnt[c[idx]]--;
            curcost[c[idx]]-=d[idx];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,q;
    l=ceil(log2(n));
    cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        adj[a[i]].push_back(i);
        adj[b[i]].push_back(i);
    }
    dfs(1,1,0);
    for(int i=0;i<q;i++)
    {
        cin>>x[i]>>y[i]>>u[i]>>v[i];
        ans[i]=dis[u[i]]+dis[v[i]]-2*dis[LCA(u[i],v[i])];
        Want[u[i]].push_back(x[i]);
        Want[v[i]].push_back(x[i]);
        Want[LCA(u[i],v[i])].push_back(x[i]);
    }
    solve(1,1);
    for(int i=0;i<q;i++)
    {
        ans[i]-=(cost[{u[i],x[i]}]+cost[{v[i],x[i]}]-2*cost[{LCA(u[i],v[i]),x[i]}]);
        ans[i]+=(cnt[{u[i],x[i]}]+cnt[{v[i],x[i]}]-2*cnt[{LCA(u[i],v[i]),x[i]}])*y[i];
        cout<<ans[i]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 91512
M=0
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
B=[]
D=[0 for i in range(N+1)]
for i in range(N):
  i=N-i
  su=0
  for j in range(i+i,N+1,i):
    su=su^D[j]
  if su!=A[i]:
    B.append(str(i))
    M=M+1
    D[i]=1
  

C=[]
for i in range(len(B)):
  i=len(B)-i-1
  C.append(B[i])
print(M)
print(" ".join(C))


Measured memory_bytes: 18612
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    avg = sum(A)/N
    ans = 0
    mi = abs(A[0] - avg)
    for i, a in enumerate(A[1:], start=1):
        if abs(a - avg) < mi:
            ans = i
            mi = abs(a - avg)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "stdio.h"

int main()
{
    int input = 0;
    int nCnt = 0;
    int a[4];
    int output[4][3][10];
    int buff = 0;
    int loop = 0;
    int i = 0;
    int j = 0;
    int k = 0;

    //++++++++++
    // Init
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 3; j++)
        {
            for(k = 0; k < 10; k++) output[i][j][k] = 0;
        }
    }

    scanf("%d", &nCnt);
    if(nCnt < 0)
    {
        return 0;
    }

    for(loop = 0; loop < nCnt; loop++)
    {
        //++++++++++++++++++++++++
        //a[0]:A/B/C/D
        //a[1]:Floor
        //a[2]:Row
        //a[3]:Value
	for(i = 0; i < 4; i++)
	{
            scanf("%d", &input);
            a[i] = input;
        }

        output[ a[0]-1 ][ a[1]-1 ][ a[2]-1 ] = output[ a[0]-1 ][ a[1]-1 ][ a[2]-1 ] + a[3];
    }


    //++++++++++
    // Output
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 3; j++)
        {
            for(k = 0; k < 10; k++)
            {
                if(k == 0)		printf(" %d", output[i][j][k]);
                else if(k == 9)		printf(" %d\n", output[i][j][k]);
                else		printf(" %d", output[i][j][k]);
            }
        }

        if(i != 3)
        {
            printf("####################\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int n,i;
	cin >> n >> i;
	dump(n - i + 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N; cin >> N;
	int num1, num2;
	int t_num = (N /10) / 10;
	for (int i = 0; i < 3; ++i) {
		num1 = (num1) * 10 + t_num;
	}
	t_num++;
	for (int i = 0; i < 3; ++i) {
		num2 = (num2) * 10 + t_num;
	}
	if (N <= num1) {
		cout << num1 << endl;
	} else {
		cout << num2 << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n;
  n = s.length();
  bool ok = 0;
  for(int i = 0;i<n;i++){
   if(s[i]=='7'){ 
     ok = 1;
     break;}
  }
  if(ok) cout << "Yes";
  else cout <<"No";
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct d{
  struct d *prev;
  struct d *next;
  int x;
}Data;

void init(void);
void printer(void);
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

Data head, end;

void init(){
  head.prev = NULL;
  head.next = &end;
  head.x = -1;
  end.prev = &head;
  end.next = NULL;
  head.x = -1;
}

int main(){
  int i, n, x;
  char command[12];

  init();

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s %d",command ,&x);

    if(!strcmp(command, "insert")){
      //printf("%d  insert\n",i);
      insert(x);
    } else if(!strcmp(command, "delete")){
      //printf("%d  delete\n",i);
      delete(x);
    } else if(!strcmp(command, "deleteFirst")){
      //printf("%d  deleteFirst\n"i);
      deleteFirst();
    } else if(!strcmp(command, "deleteLast")){
      //printf("%d  deleteLast\n"i);
      deleteLast();
    }
  }

  printer();

  return 0;
}

void printer(void){
  Data *nowdata ;
  for(nowdata = head.next; nowdata != &end; nowdata = nowdata->next){
    printf("%d",nowdata->x);
    if(nowdata->next != &end){
      printf(" ");
    }
  }
  printf("\n");
}

void insert(int x){
  Data *newlist;

  newlist = (Data *)malloc(sizeof(Data));
  newlist->next = head.next;
  head.next->prev = newlist;
  head.next = newlist;
  newlist->prev = &head;

  newlist->x = x;
}

void delete(int x){
  Data *nowdata;

  for(nowdata=head.next; nowdata != &end; nowdata = nowdata->next){
    if(nowdata->x == x){
      nowdata->prev->next = nowdata->next;
      nowdata->next->prev = nowdata->prev;
      free(nowdata);
      break;
    }
  }
}

void deleteFirst(void){
  head.next->next->prev = &head;
  head.next = head.next->next;
}

void deleteLast(void){
  end.prev->prev->next = &end;
  end.prev = end.prev->prev;
}



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

int main(){
    ll n,y;
    cin >> n >> y;
    ll s = y/1000;
    ll m=0,l=0;

    rep(i,2001){
        rep(j,2001){
            if(s-(i*9+j*4) == n && (n-i-j)>=0){
                m = (ll)i;
                l = (ll)j;
                break;
            }
        } 
    }
    if((n-m-l)*1000+5000*l+10000*m == y){
        cout<<m<<" "<<l<<" "<<(n-m-l)<<endl;
    }
    else{
        puts("-1 -1 -1");
    }
    return 0;
}

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

int main() {
    ll N, M, V, P; cin >> N >> M >> V >> P;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    int ok = 0, ng = N;
    while (ng - ok != 1) {
        int med = (ng + ok) / 2;
        ll x = A[med] + M;
        ll MV = 0, count = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] > x) {
                MV += M;
                count++;
            } else if (count < P-1) {
                MV += M;
                count++;
            } else {
                MV += min(M, x - A[i]);
            }
        }
        if (count >= P || MV < M * V) {
            ng = med;
        } else {
            ok = med;
        }
    }
    cout << ok + 1 << endl;
}


Measured memory_bytes: 1024
import math

def C(n, r):
    if (n == r or r == 0):
        return 1
    if (r > n):
        return 0
    f = math.factorial

    ret = f(n) / (f(r) * f(n - r))
    return int(ret)


n,p = map(int, input().split())
x = list(map(int, input().split()))

odd = even = ans = 0

for i in range(n):
    if (x[i] % 2 == 0):
        even+=1
    else:
        odd+=1

print("")

for i in range(n + 1):
    for j in range(i + 1):
        if (p == 1 and j % 2 == 1) or (p == 0 and j % 2 == 0):
            ans += C(even, i - j) * C(odd, j)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(){

  int a,b;
  double c,C,cc;
  
  scanf("%d %d %lf",&a,&b,&C);

  C=C*M_PI/180;
  
  printf("%.5lf\n",a*b*sin(C)/2);

  cc=a*a+b*b-2*a*b*cos(C);

  c=sqrt(cc);

  printf("%.5lf\n",a+b+c);

  printf("%.5lf\n ",b*sin(C));

  return 0;

}

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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return b < a ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return b > a ? (a = b, true) : false; }

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    long double n, m, d;
    cin >> n >> m >> d;
    long double num = (fabs(d) < 1e-9 ? n : 2 * (n - d));
    cout << (m - 1) * num / n / n << '\n';

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define VMAX 1e05 + 3

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

int main(void) {
    VI total(VMAX, 0);
    VI start(VMAX, 0);
    VI goal(VMAX, 0);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int s;
        int g;
        cin >> s >> g;
        start[s]++;
        goal[g + 1]++;
    }
    total[0] = 0;
    for (int i = 1; i <= n + 1; i++) {
        total[i] = total[i-1] + start[i] - goal[i];
    }
    int rmax = 0;
    for (int i = n + 1; i >= 1; i--) {
        if (total[i] + 1 >= i) {
            cout << i - 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

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

    cout << (A + B) % 24 << endl;
}

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

string S;

int main(){
    cin>>S;

    for (char s = 'a'; s <= 'z'; s++)
    {
        bool found = false;
        for (int i = 0; i < S.size(); i++)
        {
            if(s == S[i]) found = true;
        }

        if(!found){
            cout << s << endl;
            return 0;
        } 
    }
    cout << "None" << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int c=0;
	rep(i,3) {
		if(s[i]=='o') c++;
	}
	c*=100;
	cout << 700+c << endl;
}

Measured memory_bytes: 3536
A=[]
for i in range(0,3):
    k=list(map(int,input().split(' ')))
    A.append(k)
n=int(input())
b=[]
for i in range(0,n):
    b.append(int(input()))
for i in range(0,3):
    if (A[1][i] in b and A[2][i] in b and A[0][i] in b):
        print('Yes')
        quit()
    if (A[i][1] in b and A[i][2] in b and A[i][0] in b):
        print('Yes')
        quit()
if (A[0][0] in b and A[2][2] in b and A[1][1] in b):
    print('Yes')
    quit()
if (A[0][2] in b and A[2][0] in b and A[1][1] in b):
    print('Yes')
    quit()
print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,mod=1e9+7,dp[100005][2];
vector<ll> g[100005];
void dfs(int x,int f){
	dp[x][0]=dp[x][1]=1;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(u==f)continue;
		dfs(u,x);
		(dp[x][0]*=(dp[u][0]+dp[u][1])%mod)%=mod;
		(dp[x][1]*=dp[u][0])%=mod;
	}
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,-1);
	print((dp[1][0]+dp[1][1])%mod);
    return 0;
}

Measured memory_bytes: 14208
from collections import defaultdict
import math
N = int(input())
P = defaultdict(int)
def rev(A):
    if A == 0:
        return 0
    elif A in P:
        return P[A]
    else:
        a = int(math.log(A, 9)+10**(-10))
        b = int(math.log(A, 6)+10**(-10))
        if A > 9:
            k = min([rev(A - 9 ** a) + 1, rev(A - 6 ** b) + 1])
            P[A] = k
            return k
        else:
            k = min([rev(A - 9 ** a) + 1, rev(A - 6 ** b) + 1, rev(A - 1) + 1])
            P[A] = k
            return k

print(rev(N))

Measured memory_bytes: 65980
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,t;
    cin >> x >> t;
    cout << max(x-t,0) << endl;
    return 0;
}

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; a; a = edge[a].nxt)

const int SIZE = 100005;

int n, m;

int ans;
struct Node {
    int a, b;
} x[SIZE];
struct cmp {
    bool operator () (const Node& x1, const Node& x2) const {
        return x1.b > x2.b;
    }
};

int fa[100005];
int Find (int x) {
    if (x == fa[x]) return x;
    return fa[x] = Find(fa[x]);
}

void _main () {
    scanf ("%d%d", &n, &m);

    REP (i, 1, m) fa[i] = i;

    REP (i, 1, n) {
        scanf ("%d%d", &x[i].a, &x[i].b);
    }
    sort(x + 1, x + n + 1, cmp());

    REP (i, 1, n) if (m >= x[i].a) {
        int fx = Find(m - x[i].a + 1);
        if (fx) {
            ans += x[i].b;
            fa[fx] = Find(fx - 1);
        }
    }

    printf ("%d\n", ans);
}

int main () {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    _main();   
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>

char G[1000][1000];
int N;

int next(int i){ return ((N-i-1)+N)%N;}

int getState(int i, int j){
  return  G[i][j] == G[i][next(j)] &&
    G[i][j] == G[next(i)][j] &&
    G[i][j] == G[next(i)][next(j)];
}

int getInit(){
  int i, j, dcnt = 0;
  for ( i = 0; i < N/2; i++ ){
    for ( j = 0; j < N/2; j++ ){
      if (!getState(i, j)) dcnt++;
    }
  }
  return dcnt;
}

int main(){
  int i, j, k, r, c, C, dcnt, ans = 0, pre, post;
  char str[1001];
  scanf("%d %d", &C, &N);

  for ( i = 0; i < N; i++ ){
    scanf("%s", str);
    for ( j = 0; j < N; j++ ){
      G[i][j] = str[j];
    }
  }
  
  dcnt = getInit();
  if (dcnt == 0 ) ans++;
  for ( i = 0; i < C-1; i++ ){
    scanf("%d", &k);
    for (  j = 0; j < k; j++ ){
      scanf("%d %d", &r, &c); r--; c--;
      pre = getState(r, c);
      G[r][c] = G[r][c]=='1'?'0':'1';
      post = getState(r, c);
      if ( !pre && post ) dcnt--;
      else if ( pre && !post ) dcnt++;
    }
    if ( dcnt == 0 ) ans++;
  }

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



Measured memory_bytes: 2828