akhauriyash/Code-Regression huggingface dataset:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N = i2n()
    A = i2nn()
    X = [0] * N
    Y = [0] * N
    for i in range(N, 0, -1):
        t = (A[i-1] + X[i-1]) % 2
        if t > 0:
            Y[i-1] = 1
            divisors = make_divisors(i)
            for d in divisors:
                X[d-1] += t
    B = []
    for i, y in enumerate(Y):
        if y > 0:
            B.append(i+1)
    M = len(B)
    print(M)
    if M > 0:
        print(' '.join([str(b) for b in B]))

main()


Measured memory_bytes: 73572
#include <stdio.h>
#include <math.h>
#define N 100001
#define M 1000000007
typedef long long LL;

int n, m, a[33];
LL f[N], invf[N], ans = 0;

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

LL C(int x, int y)
{
	return f[x] * invf[y] % M * invf[x - y] % M;
}

void solve(int x, int y, int d)
{
	if(d > n) return;
	a[d] = x;
	int i, k, td = d + 1, j, ta, tn = n, tb;
	LL tp = 1;
	for(i = 1; i <= d; i = j){
		for(j = i + 1, ta = a[i]; j <= d && a[j] == ta; j++);
		tp = tp * C(tn, tb = j - i) % M;
		tn -= tb;
	}
	ans = ans + tp;
	if(ans >= M) ans -= M;
	
	for(i = y, k = sqrt(x); i <= k; i++){
		if(x % i == 0) a[d] = i, solve(x / i, i, td);
	}
}

int main()
{		
	int i, j;
	
	scanf("%d%d", &n, &m);
	if(m == 1 || n == 1){
		puts("1");
		return 0;
	}
	for(f[j = 0] = 1, i = 1; i <= n; j = i++){
		f[i] = f[j] * (LL)i % M;
	}
	invf[j = n] = qpow(f[n], M - 2);
	for(i = j - 1; i >= 0; j = i--){
		invf[i] = invf[j] * (LL)j % M;
	}
	solve(m, 2, 1);
	printf("%lld\n", ans);
			
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(abs(c-b)%2==0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  string str;
  cin >> str;

  if(str[0] == str[1] && str[1] == str[2]){
    cout << "Yes" << endl;
  } else if(str[1] == str[2] && str[2] == str[3]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import fractions
n, m = map(int, input().split())
s = input()
t = input()
gcd = fractions.gcd(n, m)
lcm = n * m // gcd
o = lcm // gcd
for i in range(gcd):
    if s[i * lcm // m] != t[i * lcm // n]:
        print(-1)
        exit()
print(lcm)


Measured memory_bytes: 5432
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

void tol(string& str){
  const int len = str.length();

  for(int i = 0; i < len; i++){
    if(islower(str[i])){
      str[i] = toupper(str[i]);
    }
  }
}

int main(void){
  string w, sw;
  const string end = "END_OF_TEXT";
  int cnt;
  
  cin >> w;

  tol(w);

  cnt = 0;

  while(true){
    cin >> sw;

    if(sw == end){
      break;
    }

    tol(sw);
    
    if (sw == w){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

typedef long long ll;
vector<vector<int> >  g,gv;
vector<int>t;
vector<bool>flag;
vector<int>cmp;
int cnt = 0;
int p = 0;
void dfs(int i){
    if(flag[i])return;
    flag[i] = true;
    for(auto x:g[i]){
        dfs(x);
    }
    t[i] = cnt;
    cnt++;
}
void redfs(int i){
    if(flag[i])return;
    flag[i] = true;
    for(auto x:gv[i]){
        redfs(x);
    }
    cmp[i] = p;
}


int main(){
    int n,m;
    cin >> n >> m;
    g.resize(n);
    gv.resize(n);
    t.resize(n);
    flag.resize(n);
    cmp.resize(n);
    for(int i=0;i<m;i++){
        int s,t;
        cin >> s >> t;
        g[s].push_back(t);
        gv[t].push_back(s);
    }
    for(int i=0;i<n;i++){
        dfs(i);
    }
    vector<pair<int,int> >v;
    for(int i=0;i<n;i++){
        v.push_back(make_pair(t[i],i));
        flag[i] = 0;
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<n;i++){
        redfs(v[i].second);
        p++;
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int a,b;
        cin >> a >> b;
        if(cmp[a]==cmp[b]){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define inf 1e9
int main(){
    string A,B;
    cin >> A >> B;
    if(A == B) cout << "EQUAL" << endl;
    else if(A.length() > B.length()) cout << "GREATER" << endl;
    else if(A.length() < B.length()) cout << "LESS" << endl;
    else{
        REP(i,A.length()){
            if(A[i] == B[i]) continue;
            if(A[i] > B[i]) cout << "GREATER" << endl;
            else cout << "LESS" << endl;
            break;
        }
    }
    return 0;
}


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

typedef long long ll;
ll N,W,V=0, w[100],v[100], dp[100][100001];

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

    cin>>N>>W;
    for (ll i=0; i<N; i++) cin>>w[i]>>v[i];
    for (ll i : v) V += i;

    for (ll i=0; i<N; i++) {
        for (ll j=0; j<=V; j++)
            dp[i][j] = 1e12;
        dp[i][0] = 0;
    }

    dp[0][v[0]] = w[0];
    for (ll idx=1; idx<N; idx++) {
    for (ll val=1; val<=V; val++) {
        if (dp[idx-1][val] != -1) {
            dp[idx][val] = dp[idx-1][val];
        }
        if (val-v[idx] >= 0) {
            if (dp[idx-1][val-v[idx]] != -1) {
                dp[idx][val] = min(dp[idx][val], w[idx] + dp[idx-1][val-v[idx]]);
            }
        }
    }}

    ll ans;
    for (ll val=V; val>=0; val--) {
        if (dp[N-1][val] <= W) {
            ans = val;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

vector<ll> nibu(1e5, -1);
vector<vector<ll>> edge(1e5, vector<ll>(0));
vector<bool> used(1e5, 0);

bool dfs(ll now, bool f){
    used[now] = 1;
    if(nibu[now] == -1) nibu[now] = (ll)f;
    else if(nibu[now] != (ll)f) return false;
    bool ret = true;
    for(ll next : edge[now]){
        if(!used[next]) ret &= dfs(next, !f);
        else if(nibu[next] == (ll)f) return false;
    }
    return ret;
}

int main(){
    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < M; i++){
        ll a, b;
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
        edge[b - 1].push_back(a - 1);
    }
    bool ret = dfs(0, 0);
    if(ret){
        ll po = 0, yo = 0;
        for(ll i = 0; i < N; i++) (nibu[i] ? po : yo)++;
        cout << po * yo - M;
    }else{
        cout << N * (N - 1) / 2 - M;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 8320
import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m+1];
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            for(int j=0; j<num; j++){
                int t = sc.nextInt();
                a[t]++;
            }
        }
        int ans = 0;
        for(int i=0; i<=m; i++){
            if(a[i] == n){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25300
n = int(input())
g = list([-1] * n for _ in range(n))
ans = 0


#gをいじる
for i in range(n):
    m = int(input())
    for j in range(m):
        a,x = map(int,input().split())
        a -= 1
        g[i][a] = x
    #
#print(g)
for i in range(2**n):
    d = [0]*n
    for j in range(n):     #n人が正直者、不親切どちらになるかのパターンを作成
        if((i>>j)&1):
            d[n-1-j] = 1
            #d[j] = 1

    #判定
    ok = True
    for j in range(n):
        if d[j]:
            for k in range (n):
                if g[j][k] == -1: continue
                if g[j][k] != d[k]: ok = False
    if ok: ans = max(ans,bin(i).count("1"))
print(ans)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

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

    int ma = 200000;
    int n, m;
    long long a[ma];
    int l[ma], r[ma];
    int pre[ma+1];
    long long dp[ma+1];

    cin>>n>>m;
    rep(i, n){
        cin>>a[i];
    }
    rep(i, m){
        cin>>l[i]>>r[i];
    }
    for(int i = 1; i <= n; i++){
        pre[i] = i-1;
    }
	for(int i = 0; i < m; i++){
		pre[r[i]] = min(pre[r[i]], l[i]-1);
	}
	for (int i = n-1; i >= 1; i--){
		pre[i] = min(pre[i], pre[i+1]);
	}

	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		dp[i] = max(dp[i-1], dp[pre[i]] + a[i-1]);
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << 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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string n;
	cin >> n;
	if(n.size() == 1){
		cout << stoi(n) << endl;
		return 0;
	}
	bool wee = true;
	For(i,1,n.size()){
		if(n[i] != '9'){
			wee = false;
			break;
		}
	}
	int ans = n.size() * 9 - 9;
	string b = "";
	b +=  n[0];
	int a = stoi(b);
	if(wee){
		cout << ans + a << endl;
		return 0;
	}
	cout << ans + a - 1 << endl;
}


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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveC(args);
        }
        static void SolveA(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int a = int.Parse(szArr[0]);
            int b = int.Parse(szArr[1]);

            int dif = a - b;
            if( dif < 0 ) { dif = -dif; }
            if (dif > 6)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }

        static void SolveB(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            int d = int.Parse(szArr[0]);
            int n = int.Parse(szArr[1]);

            int answer = 0;
            if( d == 0)
            {
                answer = n;
            }else if( d == 1)
            {
                answer = 100 * n;
            }else // d == 2
            {
                if (n == 100)
                {
                    answer = 100 * 100 * 101;
                }
                else
                {
                    answer = 10000 * n;
                }
            }
            Console.WriteLine(answer);
        }

        static void SolveC(string[] args)
        {
            string szLine = Console.ReadLine();
            int n = int.Parse(szLine);
            szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            long[] a = new long[szArr.Length];


            // 各数に対し、2^ki の倍数かを求め　ki を足し合わせるイメージ？
            int total = 0;
            for(int i=0;i<a.Length;++i)
            {
                long tmp = long.Parse(szArr[i]);
                a[i] = tmp;

                while ( tmp % 2 == 0)
                {
                    tmp /= 2;
                    total++;
                }
            }

            


            Console.WriteLine(total);
        }
    }

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;

    cout << max(0, min(b, d) - max(a, c)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli a, b;
int main() {
  cin >> a >> b;
  if (b%a==0) cout << a+b << endl;
  else cout << b-a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x = a*c;
	ll y = a*d;
	ll z = b*c;
	ll t = b*d;
	ll f = max(x,max(y,max(z,t)));
	cout<<f;
	return 0;
}

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

int main()
{
	int N, V, P;
	long long M;
	cin >> N >> M >> V >> P;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	sort( A.begin(), A.end(), greater<long long>() );
	auto f = [&]( int x ) -> bool
	{
		if( x < P ) return true;
		long long now = A[x] + M;
		if( now < A[P - 1] ) return false;
		long long score = 0;
		score = (P - 1) * M + (N - x) * M;
		for( int i = P - 1; i < x; i++ ) {
			score += min( M, max( 0LL, now - A[i] ) );
		}
		return score >= M * V;
	};
	int l = -1;
	int r = N;
	while( r - l > 1 ) {
		int m = (l + r) / 2;
		if( f( m ) ) l = m;
		else r = m;
	}
	int ans = l + 1;

	cout << ans << endl;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	string s;
	cin >> s;
	int legth = s.size();
	vector<vector<long long>> dp(legth + 2, vector<long long>(14, 0));
	int terget;
	terget = s[legth-1] - '0';
	if (s[legth-1] == '?')
	{
		terget = -1;
	}
                        //	cout<<terget<<"  ";
	for (int n = 0; n < 10; n++)
	{
		if (terget == -1 or terget == n)
		{
			dp[legth-1][n]=1;
		}
	                	//cout<<dp[legth-1][n]<<" ";
	}

	int C[7] = {1, 10, 9, 12, 3, 4};
		/*
	dp::(at)(mod13)->mod13 == 5
	dp(legth-1)(s[tegth-1])=1, otherwise:0;

	{
		if(s[i]==?){
			dp(i)(t+nC(i%7))+=dp(i-1)(t) (for t in 0 to 12), (for n in 0 to 9)
		}else{
			dp(i)(t+s[i]*C(i%7))=dp(i-1)(t)  (for t in 0 to 12)
		}

	}
	find::dp[0][5]
	*/
                                    //cout<<endl;
		int to;
		int count = 1;
		for (int at = legth - 2; at >= 0; at--)
		{
		                            //cout<<C[count]<<"-  ";
			terget = s[at] - '0';
			if (s[at] == '?')
			{
				terget = -1;
			}
			for (int t = 0; t < 13; t++)
			{

				for (int n = 0; n < 10; n++)
				{
					if (terget == -1 or terget == n)
					{
						to = (t + n * C[count]) % 13;
					                    	//cout<< to <<" ";
						dp[at][to] += dp[at + 1][t];
					}
					dp[at][to] %= MOD;
				}
			}
			//cout<< dp[at][5]<<endl;
			count = (count + 1) % 6;
		}
	cout << dp[0][5] % MOD;

}

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

using namespace std;

int N,R;
vector<vector<pair<int, int> > > MapData;
vector<pair<int, int> > CourseInfo;
int ShortDistOfEachNode[1501][1501];
bool Used[1501];
set<int> Result;

const int INF = 1e9;

void findShortDistOfEachNode(int StartNode, int *dist) {
	int curNode, cost, sizeOfTo, nextNode, costTo;
	priority_queue<pair<int, int> > NodeList;
	//priority_queue<pair<int, int>,vector<pair<int, int> >,greater<pair<int, int> > > NodeList;
	pair<int, int> tmp;

	for (int i = 1; i <= N; ++i) {
		fill(dist, dist + N + 1, INF);
	}
	dist[StartNode] = 0;
	NodeList.push({ StartNode,0 });
	while (!NodeList.empty()) {
		tmp = NodeList.top();
		NodeList.pop();

		curNode = tmp.first;
		cost = tmp.second;
		if (cost > dist[curNode]) {
			continue;
		}
		sizeOfTo = MapData[curNode].size();
		for (int i = 0; i < sizeOfTo; ++i) {
			nextNode = MapData[curNode][i].first;
			costTo = MapData[curNode][i].second;
			if (cost + costTo < dist[nextNode]) {
				dist[nextNode] = cost + costTo;
				NodeList.push({ nextNode,dist[nextNode] });
			}
		}

	}
}

void findNode(int startNode, int curNode, int *dist) {
	int sizeOfTo, preNode, cost;

	if (Used[curNode]) {
		return;
	}
	Used[curNode] = true;
	Result.insert(curNode);
	if (startNode == curNode) {
		return;
	}

	sizeOfTo = MapData[curNode].size();
	for (int i = 0; i < sizeOfTo; ++i) {
		preNode = MapData[curNode][i].first;
		cost = MapData[curNode][i].second;
		if (dist[curNode] == dist[preNode] + cost) {
			findNode(startNode, preNode, dist);
		}
	}
}

int main() {
	int s, t, d, maxShortLen;

	cin >> N >> R;
	MapData.resize(N + 1);
	for (int i = 0; i < R; ++i) {
		cin >> s >> t >> d;
		MapData[s].push_back({ t,d });
		MapData[t].push_back({ s,d });
	}
	for (int i = 1; i <= N; ++i) {
		findShortDistOfEachNode(i,ShortDistOfEachNode[i]);
	}
	
	maxShortLen = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			if (ShortDistOfEachNode[i][j] == INF) {
				continue;
			}
			maxShortLen = max(maxShortLen, ShortDistOfEachNode[i][j]);
		}
	}

	for (int i = 1; i <= N; ++i) {
		memset(Used, false, sizeof(Used));
		for (int j = 1; j <= N; ++j) {
			if (ShortDistOfEachNode[i][j] == maxShortLen) {
				findNode(i, j, ShortDistOfEachNode[i]);
			}
		}
	}

	cout << N - Result.size() << endl;
	for (int i = 1; i <= N; ++i) {
		if (Result.find(i) == Result.end()) {
			cout << i << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 12108
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << H * W - h * W - H * w + h * w << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
    cout<<a-1<<" "<<b<<endl;
    else
    cout<<a<<" "<<b-1<<endl;

} 



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

#define int long long
#define f first

#define s second
using namespace std;

template<typename T> using vc = vector<T>;
using pii=pair<int, int>;

void xmax(int & a, int b){
    a=max(a, b);
}
void xmin(int& a, int b){
    a=min(a, b);
}

void print(vc <int> & a, string s){
    cerr << s << " : ";
    for (int i=0; i<a.size(); i++){
        cerr <<a[i] << " ";
    }
    cerr << endl;
}
int mod = 1e9+7;
int poww (int a, int exp){
    if (exp == 0) return 1;
    if (exp%2 == 0) return poww(a*a%mod, exp/2);
    return a*poww(a, exp-1)%mod;
}
int inv (int a){
    return poww(a, mod -2);
}

int fac (int a, int b){
    int res = 1;
    for (int i=a; i<=b; i++){
        res=(res*i)%mod;
    }
    return res;
}
int binom (int n, int k){
    return fac(n-k+1, n)*inv(fac(1, k))%mod;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL_RUN
    freopen("input.txt", "r", stdin);
    int ttt;
    cin >> ttt;
    while(ttt--){
    #endif // LOCAL_RUN
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    /*for (int i=0; i<40; i++){
        cout << pow(2, i) << " ";
    }
    cout << endl;*/
    //cout << poww(2, n) << " " << binom(n, a) <<  " " << binom(n, b) << endl;
    int sol = poww(2, n) - 1 - binom(n, a) - binom(n, b);
   // cout << "presol " << sol << endl;
    sol = sol%mod;
   // cout << "presol2 " << sol << endl;
    sol = (mod+sol)%mod;
    cout << sol << "\n";

   /* for (int i=0; i<10; i++){
        for (int j=0; j<=i; j++){
            cout << binom(i, j) << " ";
        }
        cout << endl;
    }*/
    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  unordered_map<char, long> mp;
  mp['N'] = 0;
  mp['W'] = 0;
  mp['S'] = 0;
  mp['E'] = 0;
  for (char c: S) mp[c]++;

  if ((mp['N'] == 0) ^ (mp['S'] == 0)) cout << "No" << endl;
  else if ((mp['W'] == 0) ^ (mp['E'] == 0)) cout << "No" << endl;
  else cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;

ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}


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

    ll a,n;
    cin >> a >> n;
    cout << binary_power(a,n) << endl; 

    return 0;   
}



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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    int A;
    cin >> A;
    for(int i=1;i<10;i++){
        if(A%i==0){
            if(A/i<10){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
def sort_num(x, y):
  list_num = []
  for i in range(y):
    list_num.append(x[i])

  return list_num

def main():
  x,y,a,b,c = (int(i) for i in input().split())
  p_list = sorted(list(map(int, input().split())),reverse=True)
  q_list = sorted(list(map(int, input().split())),reverse=True)
  r_list = sorted(list(map(int, input().split())),reverse=True)
  
  sum_list = sorted(list(sort_num(p_list, x) + sort_num(q_list, y) + r_list), reverse=True)
  sum_num = x + y
  
  print(sum(sum_list[:sum_num]))

if __name__ == '__main__':
  main()


Measured memory_bytes: 23200
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Atime = [0]
Btime = [0]

idxA = 0
for a in A:
    Atime.append(a+Atime[idxA])
    idxA += 1

idxB = 0
for b in B:
    Btime.append(b+Btime[idxB])
    idxB += 1

ans,j = 0,M
for i in range(N+1):
    if Atime[i] > K:
        break
    while Btime[j] > K - Atime[i]:
        j -= 1
    
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47324
from collections import deque
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key = lambda x:x[0]+x[1],reverse=True)
ans=0
for i in range(n):
  if i%2==0:
    ans+=l[i][0]
  else:
    ans-=l[i][1]
print(ans)


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

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

    set<int>a{1,3,5,7,8,10,12};
    set<int>b{4,6,9,11};
    set<int>c{2};

    const bool x_is_in_a = a.find(x) != a.end();
    const bool x_is_in_b = b.find(x) != b.end();
    const bool x_is_in_c = c.find(x) != c.end();
    const bool y_is_in_a = a.find(y) != a.end();
    const bool y_is_in_b = b.find(y) != b.end();
    const bool y_is_in_c = c.find(y) != c.end();

    if( x_is_in_a == y_is_in_a && x_is_in_a == 1 ){
        cout << "Yes" << endl;
        return 0;
    } else if( x_is_in_b == y_is_in_b && x_is_in_b == 1 ) {
        cout << "Yes" << endl;
        return 0;
    } else if( x_is_in_c == y_is_in_c && x_is_in_c == 1 ) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }
    
}

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

int n,pi;
int nid[100002];
int main(){
    cin>>n;
    rep(i,n){
        cin>>pi;
        nid[pi]=i;
    }
    ll ans=0;
    multiset<int> s;
    s.insert(-1),s.insert(n);s.insert(-1),s.insert(n);
    for(int i=n;i>0;--i){
        auto it=s.insert(nid[i]);
        int c=*it;
        ++it;
        ll r1=*it;++it;
        ll r2=*it;--it,--it,--it;
        ll l1=*it;--it;
        ll l2=*it;
        ans+=(ll)i*((r2-r1)*(c-l1)+(l1-l2)*(r1-c));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5376
n,m=map(int,input().split())
a=[]
z=(10**9)+7
for _ in range(n):
    s=input()
    b=[str(x) for x in s]
    a.append(b)
dp=[[0 for i in range(m)]for j in range(n)]
dp[0][0]=1
for i in range(1,m):
    if dp[0][i-1]==1 and a[0][i]!='#':
        dp[0][i]=1
for i in range(1,n):
    if dp[i-1][0]==1 and a[i][0]!='#':
        dp[i][0]=1
for i in range(1,n):
    for j in range(1,m):
        if a[i][j]!='#':
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
print(dp[n-1][m-1]%z)

Measured memory_bytes: 166100
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	boolean f(long L,long K,long[] A) {
		long cnt=0;
		for (long a:A) {
			cnt+=(a+L-1)/L-1;
		}
		return cnt<=K;
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		long K=sc.nextLong();
		long[] A=new long[N];
		for (int i=0;i<N;++i) {
			A[i]=sc.nextLong();
		}
		Arrays.sort(A);
		long ng=0;
		long ok=A[N-1];
		while (ok-ng>1) {
			long middle=(ok+ng)/2;
			if (f(middle,K,A)) {
				ok=middle;
			} else {
				ng=middle;
			}
		}
		System.out.println(ok);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
	
	class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	    	return (int)nextLong();
	    }
	}
}



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

using namespace std;

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

    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> l(n+2);
    vector<int> r(n+2);
    int last = -1e9;
    for (int i = 1; i <= n; i++) {
        l[i] = l[i-1];
        if (s[i-1] == 'o' && i - last > c) {
            last = i;
            l[i]++;
        }
    }
    last = 1e9;
    for (int i = n; i >= 1; i--) {
        r[i] = r[i+1];
        if (s[i-1] == 'o' && last - i > c) {
            last = i;
            r[i]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (l[i-1] + r[i+1] < k) {
            cout << i << "\n";
        }
    }

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define MOD (ll)1000000007
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

ll n, k, arr[110], dp[110][100100], prefix[110][100100];

int main(){
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	
	for(int i = 0; i <= n; i++){
		dp[i][0] = prefix[i][0] = 1;
	}
	for(int i = 0; i <= k; i++){
		prefix[0][i] = 1;//why
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= k; j++){
			ll first = (j-arr[i]-1 >= 0) ? prefix[i-1][j-arr[i]-1] : 0;
			ll last = prefix[i-1][j];
			dp[i][j] = (dp[i][j] + (last-first)+MOD)%MOD;
			prefix[i][j] = (prefix[i][j-1]+dp[i][j])%MOD;
		}
	}
	cout << dp[n][k];
}

Measured memory_bytes: 160000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,K,ans=0,ck[2000],i,j;
vector <int> G[2000];
void f(int a,int dis){
    ans++;
    ck[a]=1;
    dis++;
    if(dis>K/2)return ;
    for(int k:G[a]){
        if(k==j||k==i)continue;
        if(ck[k])continue;
        f(k,dis);
    }
}
int main(){
    cin>>N>>K;
    for(int i=0,a,b ; i<N-1 ; i++){
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    int t=0;
    j=-100;
    if(K%2==0){
        for(i=0 ; i<N ; i++){
            ans=0;
            for(int j=0 ; j<N ; j++)ck[j]=0;
            f(i,0);
            t=max(t,ans);
        }
    }
    else{
        for(i=0 ; i<N ; i++){
            for(j1:G[i]){
                    j=j1;
                ans=0;
                for(int k=0 ; k<N ; k++)ck[k]=0;
                f(i,0);
                f(j,0);
                t=max(t,ans);
            }
        }
    }
    cout<<N-t;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1)) {
    if (S.at(1) == S.at(2)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
W1 = []
W2 = []
H1 = []
H2 = []
W1.append(0)
W2.append(W)
H1.append(0)
H2.append(H)
for i in range(N) :
    x,y,a = map(int,input().split())
    if a == 1 :
        W1.append(x)
    if a == 2 :
        W2.append(x)
    if a == 3 :
        H1.append(y)
    if a == 4 :
        H2.append(y)
width = max(0,min(W2)-max(W1))
height = max(0,min(H2)-max(H1))
print(width*height)


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

using namespace std;

int main() {

  int r , g , b ;

  cin >> r  >> g >>  b  ;

  int x=100*r+10*g+b ;

  if (x%100%4==0){
    cout << "YES"  << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500005
#define int long long
using namespace std;
int n,m,xx,b[N],x[N],tmp[N],ans[N],sum[N],tmpp[N];long long K;
inline void change1(){
	for (int i=1;i<=n;i++) tmpp[i]=ans[i];
	for (int i=1;i<=n;i++) ans[i]=tmp[tmpp[i]];
}
inline void change2(){
	for (int i=1;i<=n;i++) tmpp[i]=tmp[i];
	for (int i=1;i<=n;i++) tmp[i]=tmpp[tmpp[i]];
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&x[i]),b[i]=x[i]-x[i-1];
	scanf("%lld%lld",&m,&K);
	for (int i=1;i<=n;i++) tmp[i]=i;
	for (int i=1;i<=m;i++){
		scanf("%lld",&xx);
		swap(tmp[xx],tmp[xx+1]);
	}
	for (int i=1;i<=n;i++) ans[i]=i;
	while (K){
		if (K&(int)1) change1();
		K=K/(int)2;change2();
	}
	for (int i=1;i<=n;i++) sum[i]=b[ans[i]];
	for (int i=1;i<=n;i++) sum[i]+=sum[i-1];
	for (int i=1;i<=n;i++) printf("%lld\n",sum[i]);
	return 0;
}

Measured memory_bytes: 20480
import java.util.Arrays;
import java.util.Random;

//The Closest Circle
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
	
	class R implements Comparable<R>{
		double x, y, r;
		public R(double x, double y, double r) {
			this.x = x;
			this.y = y;
			this.r = r;
		}
		public int compareTo(R o) {
			if(Math.abs(x-o.x)<EPS)return (int)Math.signum(y-o.y);
			return (int)Math.signum(x-o.x);
		}
	}
	
	double EPS = 1e-8;
	
	void run(){
		Scanner sc = new Scanner();
		Random rand = new Random(System.currentTimeMillis());
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int rot = rand.nextInt(44)+1;
			double sin = Math.sin(rot*Math.PI/180), cos = Math.cos(rot*Math.PI/180);
			R[] rs = new R[n];
			for(int i=0;i<n;i++){
				double r = sc.nextDouble(), x = sc.nextDouble(), y = sc.nextDouble();
				rs[i] = new R(cos*x-sin*y, sin*x+cos*y, r);
			}
			Arrays.sort(rs);
			double res = 1L<<60;
			for(int i=0;i<n;i++){
				int t = Math.min(n, i+50);
				for(int j=i+1;j<t;j++){
					res = Math.min(res, Math.sqrt((rs[i].x-rs[j].x)*(rs[i].x-rs[j].x) + (rs[i].y-rs[j].y)*(rs[i].y-rs[j].y))-rs[i].r-rs[j].r);
				}
			}
			System.out.printf("%.9f\n", res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int color[9]; REP(i,9) color[i] = 0;
    int N; cin >> N;
    int a[N]; REP(i,N){cin >> a[i]; color[min(a[i]/400, 8)]++;}

    int mn=0, mx=0;
    REP(i,8){
        if(color[i]){
            mn++; mx++;
        }
    }
    mx += color[8];
    if(mn == 0) mn++;
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
Alist = [0]+list(map(int, input().split()))+[0]
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(1,N+1)]))


Measured memory_bytes: 16124
#include <iostream>

using namespace std;

int main()
{
    double l,r;
    int rn[4]={0},ln[4]={0};
    while(cin>>l>>r)
    {
        int ls=0;
        if(l>=0.2)ls++;
        if(l>=0.6)ls++;
        if(l>=1.1)ls++;
        ln[ls]++;
        int rs=0;
        if(r>=0.2)rs++;
        if(r>=0.6)rs++;
        if(r>=1.1)rs++;
        rn[rs]++;
    }
    for(int i=3;i>=0;--i){
        cout<<ln[i]<<" "<<rn[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

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

int main() {
    int a = ri();
    int b = ri();
    int x = ri();
    cout << ((a<=x && a+b>=x)?"YES":"NO") << endl;
    
 return 0;
}


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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<bool> dp(k+1);
  rep(i, k+1) rep(j, n) {
    if (i-a[j] >= 0 && !dp[i-a[j]])
      dp[i] = 1;
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys,heapq
input = sys.stdin.buffer.readline


n,m = map(int,input().split())
edge = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

#True:訪問済み False:未訪問
flag = [False]*n

res = 0

for i in range(n):
    if flag[i]:
        continue

    size = 0
    #tank element : 行く候補
    tank = [i]
    while len(tank) > 0:
        now = tank.pop()
        if flag[now]:
            continue
        flag[now] = True
        size += 1

        #今見てる点と繋がっているかつ未訪問の点を候補に追加
        for nxt in edge[now]:
            if not flag[nxt]:
                tank.append(nxt)
    
    res = max(res,size)

print(res)

Measured memory_bytes: 105228
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
const int maxm = 2e4+10;
int wei[maxn], val[maxn],dp[maxm], n, m,max_wei = -0x3f3f3f3f;
void CompletePack ( int val[], int wei[], int n, int m )
{
    for( int i = 1; i <= n; ++i )
    {
        int thisM = m+max_wei;
        for( int j = wei[i]; j <= thisM; ++j )
        {
            dp[j] = min( dp[j], dp[j-wei[i]]+val[i] );
        }
    }
}
int main ( )
{

    scanf( "%d%d", &m, &n );

    memset( dp, 0x3f, sizeof(dp) );
    dp[0] = 0;
    for(int i = 1; i <= n; ++i )
    {
        scanf( "%d%d", &wei[i], &val[i] );
        max_wei = max( max_wei, wei[i] );
    }
    CompletePack( val, wei, n, m );

    long long minVal = 0x3f3f3f3f,
              minVal_CurWeight,
              thisM = m+max_wei;
    for ( int i = m; i <= thisM; ++i )
    {
        if ( dp[i]<=minVal )
        {
            minVal = dp[i];
            minVal_CurWeight = i;
        }
    }
    printf( "%lld\n", minVal);
    return 0;
}

Measured memory_bytes: 384
A, B, C, X, Y = map(int,input().split())
if(A + B >= 2 * C):
  if(X >= Y):
    print(C * 2 * Y + (X - Y) * min(A, 2 * C))
  else :
    print(C * 2 * X + (Y - X) * min(B, 2 * C))
else:
  print(A * X + B * Y)

Measured memory_bytes: 3060