akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	set<int>se;
	se.insert(-1);
	se.insert(n);
	vi in(n);
	rep(i,n)cin>>in[i];
	vi c(n);
	rep(i,n)c[in[i]-1]=i;
	ll out=0;
	rep(i,n){
		set<int>::iterator it=se.lower_bound(c[i]);
		ll a=*it-c[i];
		it--;
		ll b=c[i]-*it;
		out+=a*b*in[c[i]];
		se.insert(c[i]);
	}
	cout<<out<<endl;
}
/*int main(){
	int n,m,s;
	while(cin>>n>>m>>s,n+m+s){
		vvi in(n,vi(3));
		rep(i,n)rep(j,3)cin>>in[i][j];
		vvp area(n);
		rep(i,n)rep(j,n){
			
		}
	}
}//*/












Measured memory_bytes: 11136
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <math.h>
#include <stdio.h>
#define mp make_pair
using namespace std;
long long sum,mid,cost,h[100005];
double a,b,n;
bool check(long long x)
{
	cost=0;
	for(int i=0;i<n;i++) 
			if(h[i]-x*b>0)
				cost+=(h[i]-x*b+a-b-1)/(a-b);
	return (cost<=x and cost>=0);
}
int solve()
{
	long long lb=1,rb=1e9+1e6;
	while(lb<=rb)
	{
		mid=(rb+lb)/2;
		if(check(mid))
		{
			rb=mid-1;
		}
		else
		{
			lb=mid+1;
		}
	}
	return lb;
}
int main()
{
	
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	cout<<solve();
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char s[3];
int main()
{
	int a=700;
	for(int i=0;i<3;i++)
	{
		cin>>s[i];
		if(s[i]=='o')
		{
			a+=100;
		}
	}
	cout<<a;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	int a = accumulate(A.begin(), A.end(), 0);
	if (a % 2) {
		sort(A.begin(), A.end());
		cout << (a - *find_if(A.begin(), A.end(), [](int& a) { return a % 2; })) / 2;
	}
	else cout << a / 2;
	cout << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 10000*100000
int main(){
  int n; cin>>n;
  vector <int>h(n);
  vector <int>dp(n);
  for(int i=0; i<n; i++){
    cin>>h[i];
    dp[i]=INF;
  }

  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  if(n>2){
    for(int i=2; i<n; i++){
      dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 3896
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	
	for (int i = 1; i < n + 1; i++) {
		string s = to_string(i);
		if (s.size() % 2 == 1)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
    const int L = (1 << 20) + 1;

    char buf[L], *S , *T, c;

    char getchar() {
        if(__builtin_expect(S == T, 0)) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }

    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    unsigned inpu()
    {
        unsigned x = 0; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar());
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x;
    }

    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;

        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;

        if(x)
            *--outs = x;

        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
    if (!b) return 1;
    ll t = power(a, b/2, p);
    t = t*t%p;
    if (b&1) t = t*a%p;
    return t;
}

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

template<class T>
inline void freshmin(T &a, const T &b)
{
    if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
    if (a < b) a = b;
}

const int maxN = 100005;
const int DEG = 4;
const int BASE = 10;
const int MAXP = 10000000;
const int MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int a[maxN];
int main()
{
    int n = inp();
    int m = inp();

    for (int i = 1; i <= n; ++ i)
    {
    	int k = inp();
    	for(int j=1;j<=k;j++)
    	{
    		int x = inp();
    		a[x]++;
		}
	}
	int cnt = 0;
	for(int i=1;i<=m;i++)
	{
		if(a[i]==n)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")	
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
  
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
  
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
  
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
  
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;

  
#define FILENAME ""
  
const ll MAXN = 1000000 + 10; 


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
  	ll n, b;
  	cin >> n >> b;
  	ll sum = 0;
  	for (int i = 0; i < n; i++) {
  		ll x;
  		cin >> x;
  		sum += x;
  		//cout << sum << endl;
  		if (sum > b) {
  			re cout << i + 1, 0;
  		}
  	}
  	cout << n + 1;
    re 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

if len(B) == 1:
    print(B[0]*2)
    exit()
else:
    ans = B[0]
    for i in range(len(B)-1):
        ans += min(B[i], B[i+1])
    ans += B[-1]
print(ans)

Measured memory_bytes: 61840
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 h,a;
		cin>>h>>a;
		double d=h;
		cout<<ceil(d/a)<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8, pi = acos(-1.0);
bool eq(ld a, ld b){return (abs(b-a)<eps);}
ld dot(Point a, Point b){return real(conj(a)*b);}
ld cross(Point a, Point b){ return imag(conj(a)*b);}
int ccw(Point a, Point b, Point c){
  b-=a;c-=a;
  if(cross(b,c)>eps) return 1;//countor_crockwise
  if(cross(b,c)<-eps) return -1;//crockwise
  if(dot(b,c)<0) return 2;//c,a,b
  if(norm(b)<norm(c)) return -2;//a,b,c
  return 0;//a,c,b
}

int main(){
  Point p[4];
  ld x,y;
  while(cin>>x>>y){
    p[0]=Point(x,y);
    REP(i,3){
      cin>>x>>y;
      p[i+1]=Point(x,y);
    }
    int a=ccw(p[0],p[1],p[3]);
    int b=ccw(p[1],p[2],p[3]);
    int c=ccw(p[2],p[0],p[3]);
    if((a==1&&b==1&&c==1)||(a==-1&&b==-1&&c==-1))
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1244
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
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 d;
string s[30];



void input() {
  cin >> d;
  s[25] = "Christmas";
  s[24] = "Christmas Eve";
  s[23] = "Christmas Eve Eve";
  s[22] = "Christmas Eve Eve Eve";
}

void solve() {
  cout << s[d] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, k, m;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            if(i * m + j * n - 2 * i * j == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
}

Measured memory_bytes: 21844
from collections import deque
import sys
sys.setrecursionlimit(10000)

seen=[]
first_order =[]
last_order = []

def dfs(g, v, first_ptr, last_ptr):
    first_ptr=first_ptr+1
#    last_ptr=first_ptr
    
    first_order[v] = first_ptr
    seen[v]=True 
    for next_v in g[v]:
        if seen[next_v]:
            continue
        first_ptr, last_ptr=dfs(g, next_v, first_ptr, last_ptr)
    last_ptr=last_ptr+1
 #   first_ptr=last_ptr

    last_order[v] = last_ptr
    return first_ptr, last_ptr


while True:
    w,h=map(int,input().split())
    if w==0 and h==0:
        break
    c=[[0]*w for i in range(h)]
    for i in range(h):
        c[i]=list(map(int,input().split()))
    
    n=w*h
    g = [deque([]) for _ in range(n + 1)]
    for jh in range(h):
        for jw in range(w):
            if c[jh][jw]==0:
                continue
            i=w*jh+jw
#            print(jh,jw,i,c[jh][jw])
            if jh<h-1 :
                kh=jh+1
                kw=jw
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jh>0 :
                kh=jh-1
                kw=jw
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw<w-1 :
                kh=jh
                kw=jw+1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw>0 :
                kh=jh
                kw=jw-1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw<w-1 and jh<h-1:
                kh=jh+1
                kw=jw+1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw>0 and jh>0:
                kh=jh-1
                kw=jw-1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw<w-1 and jh>0:
                kh=jh-1
                kw=jw+1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
#                    g[ii].append(i)
            if jw>0 and jh<h-1:
                kh=jh+1
                kw=jw-1
                if c[kh][kw]==1:
                    ii=w*(kh)+kw
                    g[i].append(ii)
 #                   g[ii].append(i)

    seen=[False]*n
    first_ptr=0
    last_ptr=0
    first_order =[-1]*n
    last_order = [-1]*n

    icnt=0
    for jh in range(h):
        for jw in range(w):
            v=w*jh+jw
            if c[jh][jw]==1:
                if seen[v]:
                    continue
                else:
                    first_ptr, last_ptr=dfs(g,v,first_ptr, last_ptr)
                    icnt+=1

    print(icnt)


Measured memory_bytes: 11996
n = int(input())
w = [int(s) for s in input().split()]

i=1
while (1):
    a=sum(w[:(i+1)])
    b=sum(w[(i+1):])
    if (a > b):
        if (a-b < sum(w[i:])-sum(w[:i])):
            print(a-b)
            break
        else :
            print(sum(w[i:])-sum(w[:i]))
            break
    else :
        i+=1


Measured memory_bytes: 3060
input = list(map(str, input().split("/")))
# 文字列の入力
heisei=20190430
input_kai=int(input[0].zfill(4)+input[1].zfill(2)+input[2].zfill(2))

if input_kai<=heisei:
    print("Heisei")
else:
    print("TBD")


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

void swap(int &x, int &y){
    int temp = x;
    x = y;
    y = temp;
    return;
}

void sort(int &a, int &b, int &c) {
if(a>b){
        swap(a,b);
    }
    if(a>c){
        swap(a,c);
    }
    if(b>c){
        swap(b,c);
    }
    return;
}

int main() {
int a, b, c;
cin >> a >> b >> c;
sort(a, b, c); 
cout << a << " " << b << " "  << c << endl;
}



Measured memory_bytes: 3088
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long F[10100000], InvF[10100000], Mod = 998244353, po[10100000];
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r * a%Mod;
		a = a * a%Mod; b >>= 1;
	}
	return r;
}
long long Comb(int a, int b) {
	return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
int main() {
	int i;
	scanf("%d", &n);
	F[0] = 1;
	po[0] = 1;
	for (i = 1; i <= n; i++) {
		F[i] = F[i - 1] * i%Mod;
		po[i] = po[i - 1] * 2 % Mod;
	}
	InvF[n] = Pow(F[n], Mod - 2);
	for (i = n; i >= 0; i--)InvF[i - 1] = InvF[i] * i%Mod;

	long long res = 0;
	for (i = n / 2 + 1; i <= n; i++) {
		res = (res + Comb(n, i) * po[n - i]) % Mod;
	}
	res = res * 2 % Mod;
	long long rr = 1;
	for (i = 1; i <= n; i++)rr = rr * 3 % Mod;
	printf("%lld\n", (rr - res + Mod) % Mod);
}

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

using namespace std;

int lcs(string s1, string s2) {
    int c[1005][1005];
    int m = s1.length();
    int n = s2.length();
    s1 = " " + s1;
    s2 = " " + s2;
    int max1=0;
    for (int i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 0; i <= n; i++) {
        c[0][i] = 0;
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if(s1[i]==s2[j]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=max(c[i-1][j],c[i][j-1]);
            }
            max1=max(max1,c[i][j]);
        }
    }
    return max1;
}

int main() {
    int q;
    cin >> q;
    string s1, s2;
    for (int k = 0; k < q; k++) {
        cin >> s1;
        cin >> s2;
        cout<<lcs(s1,s2)<<endl;
    }

    return 0;
}

Measured memory_bytes: 7132
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


int H, W;
vector<string> S;
vector<vector<int>> used;

pair<int,int> dfs(int y, int x){
	pair<int,int> res, temp;
	
	if(used[y][x]) return {0,0};
	used[y][x] = true;
	
	if(S[y][x] == '#') res.first++;
	else res.second++;
	
	for(int i = 0; i < 4; i++){
		int ny = (i-2)%2 + y, nx = (1-i)%2 + x;
		
		if(ny >= H || ny < 0 || nx >= W || ny < 0) continue;
		
		if(S[ny][nx] == S[y][x]) continue;
		
		temp = dfs(ny, nx);
		
		res.first += temp.first;
		res.second += temp.second;
	}
	
	return res;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	cin>>H>>W;
	
	int ans = 0;
	
	S.resize(H);
	used.resize(H, vector<int>(W));
	
	for(int i = 0; i < H; i++){
		cin>>S[i];
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(used[i][j]) continue;
			
			pair<int,int> x = dfs(i,j);
			// cout<<x<<endl;
			ans += x.first * x.second
			;
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N, D;
  cin >> N >> D;
  ll ans = 0;
  REP(i, N) {
    ll x, y;
    cin >> x >> y;
    if(x*x+y*y<=D*D){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;
#define M 1000000007ll

ll Pow(ll a,ll n){
    ll ret = 1;
    for(;n>0;n/=2,a=a*a%M){
        if(n%2==1){                 
            ret = ret * a % M;
        }
    }
    return ret;
}

ll C(ll n,ll a){
    ll X = 1,Y = 1;
    ll ans;
    for(int i=1;i<=a;i++){
        X = X * (n - i + 1) % M;
        Y = Y * i % M;
    }
    ans = X * Pow(Y,M-2) % M;
    return ans;
}

int main(void){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = Pow(2,n) - 1;
    ans = ans - C(n,a) - C(n,b);
    if(ans < 0){
        ans += 100*M;
        ans %= M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
int d[100005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> d[i];
	sort(d, d + n); cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          998244353
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}


pair<int,pii> proc (string s)
{
  int an = 0 , lef = 0 , rg = 0;;

  for(int i=0;i<sz(s);i++)
  {
    if(s[i]=='(') an--;
    else an++;
    lef = max(lef,an);
  }
  
  an = 0;
  for(int i=sz(s)-1;i>=0;i--)
  {
    if(s[i]=='(')an++;
    else an--;
    rg = max(rg,an);
  }

  return {lef,{rg,an}};
  
}

int arr[1000001],vis[1000001];
void solve()
{
 
 int n;
 
 cin >> n;
 
 vector<pair<int,pii> >  sq;
  
 vpi lef,rg;
 for(int i=0;i<n;i++)
 {
   string s;
   cin >> s;
   pair<int,pii> rm = proc(s);
   //cout<<rm.fi<<" "<<rm.se.fi<<" "<<rm.se.se<<endl;
   lef.pb({rm.fi,i});
   rg.pb({rm.se.fi,i});
   arr[i] = rm.se.se;
 }
 

 sort(lef.begin(),lef.end());
 sort(rg.begin(),rg.end());

 int i = 0,j=0,fw=0,bk=0,fl=0;


 while(i<sz(lef) && j<sz(rg))
 {
    if(vis[lef[i].se]) i++;
    else if(vis[rg[j].se]) j++;
    else
    {
      if(fw - lef[i].fi < 0 || bk + rg[j].fi > 0) fl=1;
      fw += arr[lef[i].se];
      vis[lef[i].se] =1;
      i++;
      if(!vis[rg[j].se]) bk += arr[rg[j].se] , vis[rg[j].se]=1;
      j++;
    }
 }


 
 if(fl || (fw+bk)!=0)
 {
   cout<<"No\n";
 }
 else  cout<<"Yes\n";

}

int32_t main()
{
 pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

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

int main(){
    int a,b;
    cin >> a >> b;
    if ((a+b) % 2 == 0){
        cout << (a+b) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include"bits/stdc++.h"
using namespace std;
 
#define input_from_file freopen("inp.txt","r",stdin)
#define output_to_file freopen("out.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int main() {
	#ifdef LOCAL 
	input_from_file; 
	output_to_file; 
	#endif
   
    fastio;cin.tie(0);cout.tie(0);
	unsigned long long int n,k,c=0;
	cin >> n>>k;

	vector<unsigned long long int>H(n);

	for(int i=0;i<n;i++)
		cin>>H[i];

	if(n<=k)
		cout<<0;
	else
	{

		sort(H.begin(),H.end());
		for(int i=0;i<n-k;i++)
			c+=H[i];

		cout<<c;



	}

	

	
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
 
 
long long pgcd(long long a,long long b)
{
    return a==0?b:pgcd(b%a,a);
}
 
long long ppcm(long long a,long long b)
{
    return a*b/pgcd(a,b);
}
 
int main()
{
    long long a,b;
    while(cin>>a>>b)
    {
        cout<<pgcd(a,b)<<" "<<ppcm(a,b)<<endl;
    }
}

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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

vector<int> H(100);

int main() {
    int N, count = 1, flag;

    cin >> N;
    f(i, N) cin >> H.at(i);

    for(int i = 1; i < N; i++) {
        flag = 0;
        for(int j = 0; j < i; j++) {
            if(H.at(i) < H.at(j)) flag = 1;
        }
        if(flag == 0) count++;
    }

    cout << count << endl;

    return 0;
}

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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 INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) { cin >> A[i]; }
    copy(A.begin(), A.end(), B.begin());
    copy(A.begin(), A.end(), C.begin());
    rep(i, N) { C[i] = abs(C[i]); }

    vector<ll>::iterator min_iter = min_element(C.begin(), C.end());
    ll min_index = distance(C.begin(), min_iter);
    ll ans = 0;

    for (ll i = 0; i != min_index; i++) {
        ll first = A[i];
        ll second = A[i + 1];
        if (first > 0 && second > 0) {
            continue;
        } else if (first < 0 && second < 0) {
            A[i] *= -1;
            A[i + 1] *= -1;
        } else if (first < 0 && second >= 0) {
            A[i] *= -1;
            A[i + 1] *= -1;
        }
    }
    for (ll i = A.size() - 1; i != min_index; i--) {
        ll first = A[i];
        ll second = A[i - 1];
        if (first > 0 && second > 0) {
            continue;
        } else if (first < 0 && second < 0) {
            A[i] *= -1;
            A[i - 1] *= -1;
        } else if (first < 0 && second >= 0) {
            A[i] *= -1;
            A[i - 1] *= -1;
        }
    }
    ans = accumulate(A.begin(), A.end(), 0LL);

    for (ll i = B.size() - 1; i != min_index; i--) {
        ll first = B[i];
        ll second = B[i - 1];
        if (first > 0 && second > 0) {
            continue;
        } else if (first < 0 && second < 0) {
            B[i] *= -1;
            B[i - 1] *= -1;
        } else if (first < 0 && second >= 0) {
            B[i] *= -1;
            B[i - 1] *= -1;
        }
    }
    for (ll i = 0; i != min_index; i++) {
        ll first = B[i];
        ll second = B[i + 1];
        if (first > 0 && second > 0) {
            continue;
        } else if (first < 0 && second < 0) {
            B[i] *= -1;
            B[i + 1] *= -1;
        } else if (first < 0 && second >= 0) {
            B[i] *= -1;
            B[i + 1] *= -1;
        }
    }
    ans = max(ans, accumulate(B.begin(), B.end(), 0LL));

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


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			int r = s.nextInt();
			int d = s.nextInt();
			int x2000 = s.nextInt();

			int x = x2000;
			for (int i = 1; i <= 10; i++) {
				x = r * x - d;
				System.out.println(x);
			}
		}
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define iii pair<int, ii>
#define fi first
#define se second
const int MAX = 300000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int h, w, k;
ii s, e;
vector<vector<char>> M;
vector<vector<vector<int>>> dist;
int dx[] = {1, 0, 0, -1};
int dy[] = {0, -1, 1, 0};

bool check(int x, int y)
{
	return x >= 0 and x < h and y >= 0 and y < w;
}

int32_t main()
{
	scanf(" %d %d %d", &h, &w, &k);
	scanf(" %d %d %d %d", &s.fi, &s.se, &e.fi, &e.se);
	
	s.fi--; s.se--;
	e.fi--; e.se--;
	
	M.resize(h);
	dist.resize(h);
	
	for(vector<vector<int>> &v : dist)
	{
		v.resize(w);
		for(int i = 0; i < v.size(); i++)
			v[i].resize(4, OO);
	}	
	for(vector<char> &v : M)
	{
		v.resize(w);
		for(int i = 0; i < v.size(); i++)
			scanf(" %c", &v[i]);
	}	
	
	priority_queue<array<int, 5>, vector<array<int, 5>>, greater<array<int, 5>>> q; 
	for(int i = 0; i < 4; i++)
	{
		dist[s.fi][s.se][i] = 1;
		q.push({1, k, i, s.fi, s.se});
	}	
	while(!q.empty())
	{
		ii cur = {q.top()[3], q.top()[4]};
		int c = q.top()[1];
		int t = q.top()[2];
		int d = q.top()[0];
		q.pop();
		
		if(dist[cur.fi][cur.se][t] < d) continue;

		for(int i = 0; i < 4; i++)
		{
			int x = cur.fi + dx[i], y = cur.se + dy[i];
			if(!check(x, y) or M[x][y] != '.') continue;
			bool fl = false;
			if(t == i)
			{
				if(c >= 1)
				{
					if(dist[x][y][i] > dist[cur.fi][cur.se][t])
					{
						dist[x][y][i] = dist[cur.fi][cur.se][t];				
						q.push({dist[x][y][i], c - 1, i, x, y});
					}
				}
				else
					fl = true;
			}
			if(t != i or fl)
			{
				if(dist[x][y][i] > dist[cur.fi][cur.se][t] + 1)
				{
					dist[x][y][i] = dist[cur.fi][cur.se][t] + 1;				
					q.push({dist[x][y][i], k - 1, i, x, y});
				}
			}
		}
	}
	int ans = OO;
	for(int i = 0; i < 4; i++)
		ans = min(ans, dist[e.fi][e.se][i]);
	if(ans == OO) ans = -1;
	cout << ans << '\n';
	
	return 0;
}


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

int main()
{
    long long H,r,a;
    r=1;
    cin>>H;
    if(H==1){
        cout <<1<<endl;
        exit(0);
    }
    for(int i=0;i<1000000000;i++){
        H/=2;
        r++;
        if(H==1){
            break;
        }
    }
    a=-(1-pow(2,r));
    cout <<a<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(N)]

F = [0]*M
for i in range(N):
  for j in range(1, K[i][0] + 1):
    F[K[i][j] - 1] += 1

print(F.count(N))

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

int main() {
  int D;
  cin>>D;
  if (D==25) {
    cout<<"Christmas"<<endl;
  }
  else if (D==24) {
    cout<<"Christmas Eve"<<endl;
  }
  else if (D==23) {
    cout<<"Christmas Eve Eve"<<endl;
  }
  else {
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  
}


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

int main()
{
  int N;
  cin >> N;
  string S;
  rep(i, N){
    cin >> S;
    if(S == "Y"){
      break;
    }
  }
  if (S == "Y"){
      cout << "Four" << endl;
  }else{
  cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
k=[[],[".",",","!","?"," "],["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"],["m","n","o"],["p","q","r","s"],["t","u","v"],["w","x","y","z"]]
for i in range(n):
  b=input()
  #print(b)
  S=[]
  count=0
  for i in range(len(b)):
    if b[i]=="0":
      if count==0:
        pass
      else:
        if b[i-1]=="1":
          co=count%5-1
          S.append(k[1][co])
          count=0
        elif b[i-1]=="2":
          co=count%3-1
          S.append(k[2][co])
          count=0
        elif b[i-1]=="3":
          co=count%3-1
          S.append(k[3][co])
          count=0
        elif b[i-1]=="4":
          co=count%3-1
          S.append(k[4][co])
          count=0
        elif b[i-1]=="5":
          co=count%3-1
          S.append(k[5][co])
          count=0
        if b[i-1]=="6":
          co=count%3-1
          S.append(k[6][co])
          count=0
        if b[i-1]=="7":
          co=count%4-1
          S.append(k[7][co])
          count=0
        if b[i-1]=="8":
          co=count%3-1
          S.append(k[8][co])
          count=0
        if b[i-1]=="9":
          co=count%4-1
          S.append(k[9][co])
          count=0
    else:
      count+=1
    
  for i in range(len(S)):
    print(S[i],end="")
  print("")


Measured memory_bytes: 5648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        int[] nums2 = new int[n];
        for(int i = 0; i < n; i++) {
            int num = sc.nextInt();
            nums[i] = num;
            nums2[i] = num;
        }
        
        Arrays.sort(nums2);
        int medianA = nums2[n / 2 - 1];
        int medianB = nums2[n / 2];
        
        for (int i = 0; i < n; i++) {
            int num = nums[i];
            if (num <= medianA) {
                System.out.println(medianB);
            } else {
                System.out.println(medianA);
            }
        }
    }
}


Measured memory_bytes: 100876
def main():
    N, A, B = map(int, input().split())
    X = map(int, input().split())

    ret = 0
    curr = next(X)
    for x in X:
        ret += min((x - curr) * A, B)
        curr = x
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11100
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string s;
	for (; cin >> s;)
	{
		vector<int> a;
		for (int i = 0; i < s.length(); i++)
		{
			a.push_back(atoi(s.substr(i, 1).c_str()));
		}

		
		for (; a.size() > 1;)
		{
			vector<int> b;
			for (int i = 1; i < a.size(); i++)
			{
				int x = (a.at(i - 1) + a.at(i)) % 10;
				b.push_back(x);
			}

			a = b;
		}

		cout << a.back() << endl;
	}
}


Measured memory_bytes: 3124
#include<iostream>

using namespace std;

int main() 
{
  long long H,W;
  long long ans;
  cin>>H>>W;
  
  if(H==1||W==1)
  {
    ans=1;
    goto end;
  }
  ans=H*W;
  if(ans%2==0)
  {
    ans=ans/2;
  }
  else ans=ans/2+1;
  
  end:;
  cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

n_min = min(a,b,c,d,e)

if n_min >= n:
    print(5)

else:
    if n%n_min ==0:
        print(5 -1 + n//n_min)
    else:
        print(5 + n//n_min)

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a,b;
    int rankmax = 0;
    int rankmin = INF+1;
    int scoremax = 0;
    int scoremin = INF+1;

    Scd(n);
    Rep(i,n){
        Scd2(a,b);
        if( scoremax < b ){
            scoremax = b;
            rankmin = a;
        }
        if( scoremin > b ){
            scoremin = b;
            rankmax = a;
        }
    }

    int ans = rankmax + scoremin;
    printf ("%d\n", ans);

    return 0;
}



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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> vs(H, vector<char> (W));
    int cnt = 0;
    for (auto& s : vs) for (auto& c : s) cin >> c, cnt += c == '#';

    vector<vector<int>> cost(H, vector<int> (W, INT_MAX));
    queue<pair<int, int>> qp;
    qp.push({0, 0});
    cost[0][0] = 0;
    const int d[] = {0, 1, 0, -1, 0};
    for (; qp.size();) {
        auto p = qp.front();
        qp.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + d[i];
            int nx = p.second + d[i + 1];
            if (ny < 0 || nx < 0 || ny >= H || nx >= W || vs[ny][nx] == '#' || cost[ny][nx] != INT_MAX) continue;
            qp.push({ny, nx});
            cost[ny][nx] = min(cost[ny][nx], cost[p.first][p.second] + 1);
        }
    }

    cerr << cost[H - 1][W - 1] << " " << cnt << endl;
    cout << (cost[H - 1][W - 1] == INT_MAX ? -1 : H * W - cost[H - 1][W - 1] - cnt - 1) << endl;

    return 0;
}


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

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

    int T;
    cin>>T;
    int A;
    cin>>A;
  
    vector<int> h(n);
    rep(i,n)cin>>h[i];
  
    vector<double> t(n);
    rep(i,n)t[i]=T-h[i]*0.006;
   
    vector<double> a(n);
    rep(i, n)a[i]=abs(A-t[i]);
    
    double min=a[0];
    int index=0;
    
    rep(i,n){
        if(a[i]<=min){
            min=a[i];
            index=i+1;
        }
    }
    
    cout<<index<<endl;
    
//    3
//    21 -11
//    81234 94124 52141

    
    return 0;
    }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(x) begin(x), end(x)
#define gets(s) fgets(s,size(s),stdin)
using namespace std;
typedef long long ll;
typedef string str;
template<typename T>
using vec=vector<T>;
template<typename T>
using uset=unordered_set<T>;
template<typename T,typename S>
using umap=unordered_map<T,S>;
 
const int mod=1000000007;
const double pi=3.1415926535;

int main() {
    int x,n;
    bitset<102> b;
    scanf("%d%d",&x,&n);
    rep(i,n) {
        int t;
        scanf("%d",&t);
        b[t]=true;
    }
    rep(i,102) {
        if(!b[x-i]) {
            printf("%d",x-i);
            break;
        } else if(!b[x+i]) {
            printf("%d",x+i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3836
import itertools
n, m = map(int, input().split())

nn = []
i = 0
for _ in range(n):
    nn.append(i)
    i += 2

mm = []
i = 1
for _ in range(m):
    mm.append(i)
    i += 2

ans = 0
l = nn + mm

for v in itertools.combinations(l, 2):
    if (v[0] + v[1]) % 2 == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9188
from bisect import bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A)

ret = 0
for i in range(N) :
    j = bisect_left(B, A[i])
    if i % 2 != j % 2 :
        ret += 1
        
print(ret // 2)

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

typedef long long ll;

ll table[45];
bool flg[45];

ll fib(int n){

    if(n==0)return 1;
    else if(n==1)return 1;
    else{
        if(flg[n])return table[n];
        else{
            flg[n]=true;
            return table[n]=fib(n-1)+fib(n-2);
        }
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    table[0]=table[1]=1;
    flg[0]=flg[1]=true;
    int n;
    cin >> n;
    cout << fib(n) << endl;
}



Measured memory_bytes: 3160
#include <stdio.h>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define LIM_N 100001
int P, Q, R;
int A[LIM_N];
int B[LIM_N];
int C[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d", &P, &Q, &R);
}

void solve() {
	int a[3];
	a[0] = P + Q;
	a[1] = Q + R;
	a[2] = R + P;

	int m = a[0];
	for (size_t i = 0; i < 3; i++) {
		m = m < a[i] ? m : a[i];
	}
	printf("%d\n", m);
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 100000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	if(h % 3 == 0 || w % 3 == 0) cout << 0 << endl;
	else{
		ll m = min(h, w);
		REP(i, h){
			ll s1 = w * i;
			ll s2, s3;
			if(w % 2 == 0){
				s2 = (h - i) * (w / 2);
				s3 = (h - i) * (w / 2);
			}
			else{
				s2 = (h - i) * (w / 2);
				s3 = (h - i) * (w / 2 + 1);
			}
			ll minimum = min(s1, min(s2, s3));
			ll maximum = max(s1, max(s2, s3));
			if(m > (maximum - minimum)) m = (maximum - minimum);
		}
		REP(i, w){
			ll s1 = h * i;
			ll s2, s3;
			if(h % 2 == 0){
				s2 = (w - i) * (h / 2);
				s3 = (w - i) * (h / 2);
			}
			else{
				s2 = (w - i) * (h / 2);
				s3 = (w - i) * (h / 2 + 1);
			}
			ll minimum = min(s1, min(s2, s3));
			ll maximum = max(s1, max(s2, s3));
			if(m > (maximum - minimum)) m = (maximum - minimum);
		}
		cout << m << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

using namespace std;


int main(){
    int N;
    cin >> N;
    pair<int,int> ab[200000];
    for(int i=0; i<N; i++){
        cin >> ab[i].second >> ab[i].first;
    }
    sort(ab,ab+N);
    for(int i=0; i<N; i++){
        swap(ab[i].first, ab[i].second);
    }
    int time=0;
    for(int i=0; i<N; i++){
        time+=ab[i].first;
        if(time<=ab[i].second){
            
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    
    return 0;
}


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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second %2 == 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans = a * b;
  ans -= a * d + b * c - c*d;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
int main() {
	ll n = 1, p, ans = 1;
	int cnt = 0;
	scanf("%lld%lld", &n, &p);
	if (n == 1) {
		printf("%lld\n", p);
		return 0;
	}
	for (int i = 2; (ll)i * i <= p; i++) {
		while (p % i == 0) {
			cnt++;
			p /= i;
			// printf("%d * ", i);
		}
		if (cnt >= n) {
			for (int j = 0; j < cnt / n; j++) {
				ans *= i;
			}
		}
		cnt = 0;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n,Max,Min;
    long int Sum;
    int a[10000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    Min=a[0];
    Max=a[0];
    for(int i=0;i<n;i++){
        
        if(Max<a[i]){
            Max=a[i];
        }
        if(Min>a[i]){
            Min=a[i];
        }
        Sum+=a[i];
    }
    printf("%d %d %ld\n",Min,Max,Sum);
}













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

int main() {
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i,N) cin >>A[i];
    int sum = 0;
    rep(i,N) sum += A[i];
    if(H<=sum)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c, sum=0;
    cin >> a >> b >> c;
    

        for(int i = a; i <= b; i++)
        {
            if(c%i == 0)
            {
                sum += 1;

            }
        }

    cout << sum << endl;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
using namespace std;

int main()
{
    int A, B, T;
    int cnt = 0;
    std::cin >> A >> B >> T;
    for (int time = A; time < T + 0.5; time = time + A)
    {
        cnt = cnt + B;
    }
    std::cout << cnt << "\n";
}

Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = Counter(list(accumulate(a))+[0])

ans = 0
for x in b:
    ans += b[x] * ( b[x] - 1 ) // 2

print(ans)

Measured memory_bytes: 46044