akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,maxi = 0;
    string S;
    cin >> N >> S;
    for(int i = 0;i < N;i++){    
        
        int A[26] = {};
        int B[26] = {};
        for(int j = 0;j < i;j++){
            A[S[j] - 'a'] = 1;
        }
        for(int j = i;j < N;j++){
            B[S[j] - 'a'] = 1;
        }
        int cnt = 0;
        for(int j = 0;j < 26;j++){
            if(A[j] && B[j])cnt++;
        }
        maxi = max(maxi, cnt);
    }
    cout << maxi << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int d = b - a;
	int sum = 0;
	for (int i = 0; i < d; i++) sum += (i + 1);
	cout << sum - b << endl;
	return 0;
}

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

flg = 1
for i in range(a-1,c-2):
    if S[i:i+2] == ['#','#']:
        flg *= 0

for i in range(b-1,d-2):
    if S[i:i+2] == ['#','#']:
        flg *= 0

if c>d:
    flg2 = 0
    for i in range(b-1,d):
        if S[i-1:i+2] == ['.','.','.']:
            flg2 = 1
    flg *= flg2

if flg == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 10740
#include<stdio.h>
int main(void){
int n;
int i,j=0,k=0;
scanf("%d", &n);
char s[n+1], t[n+1];
scanf("%s %s", s, t);

for (i = 0; i < n * 2;i++){
  if(i%2==0){
    printf("%c", s[j]);
    j++;
  }else{
    printf("%c",t[k]);
    k++;
  }
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;



int32_t main() {

    fast

    int a,b,c;
    cin>>a>>b>>c;

    int k;
    cin>>k;

    while(a>=b){
        b*=2;
        k--;
    }
    while(b>=c){
        c*=2;
        k--;
    }
    if(k>=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



    return 0;
}



Measured memory_bytes: 3648
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main(void) {
    int e;
    while (1) {
        cin >> e;
        if (e == 0) break;
        int m = INF;
        for (int z = 0; z <= 100; z++) {
            for (int y = 0; y <= 1000; y++) {
                if (y * y + z * z * z > e) continue;
                int x = e - y*y - z*z*z;
                m = min(x+y+z, m);
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int,input().split()))
su = a[0]
for i in range(1,n):
    su = su^a[i]

lis = []

for i in range(n):
    lis.append(su^a[i])

print(*lis)


Measured memory_bytes: 119256
import java.util.*;
 
public class Main {
  	static Scanner scanner = new Scanner(System.in);
  
	public static void main(String[]$) {
    	System.out.println(String.format("Christmas%0" + (26 - scanner.nextInt()) + "d", 1).replace("0", " Eve").replace("1", ""));
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<ctype.h>


using namespace std;


void func(string s1, string s2, string s3){
	string ans;
	ans += toupper(s1[0]);
	ans	+= toupper(s2[0]);
	ans += toupper(s3[0]);

	cout << ans << endl;
}


int main(){
	string s1, s2, s3;

	cin >> s1 >> s2 >> s3;

	func(s1, s2, s3);

	return 0;
}




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

cnt = 0
for i in range(1,n-1):
    if (p[i] < p[i+1] and p[i] > p[i-1]) or (p[i] > p[i+1] and p[i] < p[i-1]):
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
	int n;
	std::cin >> n;
	
	std::vector<int64_t> vecs[3];
	for (auto&& v : vecs) {
		v.resize(n);

		for (auto&& e : v)
			std::cin >> e;

		std::sort(v.begin(), v.end());
	}

	int64_t ans = 0;
	for (auto&& mid : vecs[1]) {
		auto it1 = std::upper_bound(vecs[0].rbegin(), vecs[0].rend(), mid, std::greater<>{});
		auto it2 = std::upper_bound(vecs[2].begin(), vecs[2].end(), mid);

		ans += (vecs[0].rend() - it1) * (vecs[2].end() - it2);
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 2560
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}


int main() {
  string a,b,c;
  cin>>a>>b>>c;
  char d=a.at(0)-0x20;
  char e=b.at(0)-0x20;
  char f=c.at(0)-0x20;
  cout<<d<<e<<f<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=50005;
int a[N],b[N],c[N],fa[N*6];
int ycl[2][N*20];
#define zb(a,b,c) (a)*6+(b)*3+(c)
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
void mer(int a,int b){
	fa[gf(a)]=gf(b);
}
int main(){
	int n=read(),m=read(),q=read(),mod=read();
	For(i,0,n*6+6)fa[i]=i;
	For(i,1,m){
		a[i]=read(); b[i]=read(); c[i]=read();
	}
	int g=mod;
	For(i,2,m)g=__gcd(g,abs(c[i]-c[1]));
	mod=__gcd(mod,3*g);
	int k=mod/g;
	int z=c[1]%g;
	For(i,1,m){
		c[i]=c[i]%mod/g;
		For(o,0,1)For(j,0,k-1){
			mer(zb(b[i],o,j),zb(a[i],o^1,(j*2+c[i])%k));
			//cout<<b[i]<<" fjz "<<a[i]<<" "<<j<<" "<<(j*2+c[i])%k<<" "<<gf(zb(3,0,0))<<" "<<gf(zb(1,0,2))<<endl;
			//mer(zb(b[i],o,j),zb(a[i],o^1,(j*2+c[i])%k));
		}
	}
	int jb=z;
	for(int i=0;i<mod*2;i++){
		ycl[i&1][jb]=1; //cout<<(i&1)<<" "<<jb<<" "<<endl;
		jb=jb*2%mod;
	}
	For(i,1,q){
		int t=read(),s=read(),wt=(read()+z)%mod,ans=0;
		//cout<<gf(zb(s,0,0))<<" "<<gf(zb(t,0,2))<<endl;
		For(o,0,1)For(j,0,k-1)if(gf(zb(s,0,0))==gf(zb(t,o,j))){
			if(ycl[o][(wt+mod-g*j)%mod])ans=1;
			//cout<<o<<" fjzzq "<<j<<" "<<t<<" "<<o<<" "<<k<<endl;
		}
		puts(ans?"YES":"NO");
	}
}
/*
3 2 1 2019
1 2 1
2 3 2
1 3 4
*/

Measured memory_bytes: 9984
n,C=map(int,input().split())
que=[]
for _ in range(n):
    x,v=map(int,input().split())
    que.append((x,v))

dpl=[0 for i in range(n+1)] #dpl[i]=左からi番目に行くまでのお腹の値のプラス
dpr=[0 for i in range(n+1)] #dpr[j]＝右からj番目に行くまでのお腹の値のプラス

c=0
for i in  range(n):
    c+=que[i][1]
    dpl[i+1]=c-que[i][0]

d=0
for i in range(1,n+1):
    d+=que[-i][1]
    dpr[i]=d-(C-que[-i][0])

max1=max(dpl)
max2=max(dpr)

dpb_l=[0 for i in range(n+1)]#dpb_l[i]=左からi番目に行って戻るときに達成できるお腹の値のプラス
dpb_r=[0 for i in range(n+1)]#dpb_r[i]=右からi番目に行って戻るときに達成できるお腹の値のプラス

c=0

for i in  range(n):
    c+=que[i][1]
    dpb_l[i+1]=c-2*que[i][0]

d=0
for i in range(1,n+1):
    d+=que[-i][1]

    dpb_r[i]=d-2*(C-que[-i][0])

#dpl[i]=左からi番目のところに行くまでに達成できるお腹の値のプラスの最大値
#dpr[i]=右からi番目のところに行くまでに達成できるお腹のあたいのプラスの最大値

for i in range(1,n+1):
    dpl[i]=max(dpl[i-1],dpl[i])
for i in range(1,n+1):
    dpr[i]=max(dpr[i],dpr[i-1])

max3=0

for i in range(1,n):
    max3=max(max3,dpb_l[i]+dpr[n-i],dpb_r[i]+dpl[n-i])

print(max(max1,max2,max3))




Measured memory_bytes: 68696
/* ***************************************************
 *	Author        :mutinner
 *	Created Time  :Sat 05 May 2018 08:01:02 PM CST
 *	File Name     :20:01:02.cpp
 *************************************************** */

#include <bits/stdc++.h>
using namespace std;

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


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

int main() {
    string S;
    cin >> S;
    set<char> count;
    for(int i=0; i<S.size(); i++) count.insert(S[i]);
    for(char j='a'; j<='z'; j++) 
        if(!count.count(j)) {
            cout<<j<<endl;
            return 0;
        }
    cout<<"None"<<endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string s;
   cin >> s;
   if (s <= "2019/04/30") cout << "Heisei" << endl;
   else cout << "TBD" << endl;

   return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cstdio>

const int N = 100000;

int a[3][N];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 3; ++ i) {
        for (int j = 0; j < n; ++ j) {
            scanf("%d", a[i] + j);
        }
        std::sort(a[i], a[i] + n);
    }
    long long result = 0;
    for (int i = 0, j = 0, k = 0; j < n; ++ j) {
        while (i < n && a[0][i] < a[1][j]) {
            i ++;
        }
        while (k < n && a[1][j] >= a[2][k]) {
            k ++;
        }
        result += 1LL * i * (n - k);
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K,S;
    cin >> N >> K >> S;
    if(S == INF) {
        for(int i = 0; i < N; i++) {
            if(i) {
                cout << " ";
            }
            if(i < K) {
                cout << S;
            }
            else {
                cout << 1;
            }
        }
        cout << endl;
    }
    else {
        for(int i = 0; i < N; i++) {
            if(i) {
                cout << " ";
            }
            if(i < K) {
                cout << S;
            }
            else {
                cout << INF;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3644
#include<stdio.h>
#define SIZE 200000

int main(void)
{
  int i, j, max;
  int N, M, K;
  int A[SIZE], B[SIZE];
  long long a[SIZE+1], b[SIZE+1]; /* A,B の上から i 冊読む時間 */
  
  scanf("%d %d %d", &N, &M, &K);
  for ( i=0; i<N; ++i)
    scanf("%d", &A[i]);
  for ( i=0; i<M; ++i)
    scanf("%d", &B[i]);
  
  a[0] = b[0] = 0;
  for ( i=0; i<N; ++i)
    a[i+1] = a[i] + A[i];
  for ( i=0; i<M; ++i)
    b[i+1] = b[i] + B[i];
  
  max = 0;
  j = M;
  for ( i=0; i<=N; ++i) {
    if ( a[i] > K)
      break;
    while ( b[j] > K - a[i])
      --j;
    if ( max < i+j)
      max = i+j;
  }
  
  printf("%d\n", max);
  
  return 0;
}

Measured memory_bytes: 6388
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    char A, B;
    cin >> A >> B;
    if (A > B) {
        cout << ">" << endl;
    } else if (A < B) {
        cout << "<" << endl;
    } else {
        cout << "=" << endl;
    }
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k; cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mp;
  rep(i, n) ++mp[a[i]];

  vector<int> vec;
  for(auto x : mp) vec.push_back(x.second);
  sort(ALL(vec));

  int ans = 0;
  rep(i, (int)vec.size()-k) ans += vec[i];
  cout << ans << endl;
}


Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int int64_t

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,i,ans,maxi;
    cin>>n;

    int a[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    maxi=a[0];
    ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i] < maxi)
        {
            ans+=(maxi - a[i]);
        }
        maxi=max(maxi,a[i]);
    }
    
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[4];
  for(int i=0; i<3; i++){
  cin>>a[i];
  }
  sort(a,a+3,greater<int>());
  cout<<a[0]*10+a[1]+a[2]<<'\n';
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n,m; cin>>n>>m;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    rep(i,n){
        ll a; cin>>a;
        pq.push(a);
    }

    vector<vector<ll>>bc(m,vector<ll>(2));
    rep(i,m)cin>>bc[i][1]>>bc[i][0];
    sort(bc.begin(),bc.end());
    reverse(bc.begin(),bc.end());
    rep(i,m){
        ll cnt=0;
        ll B=bc[i][0];
        while(B>pq.top()){
            pq.pop();
            pq.push(B);
            cnt++;
            if(cnt==bc[i][1])break;
        }
    }
    ll ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}



















































Measured memory_bytes: 6516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static final int INF = 100000;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] tmp = br.readLine().split(" ");
        int d = Integer.parseInt(tmp[0]);
        int n = Integer.parseInt(tmp[1]);
        int[] t = new int[d];
        for(int i = 0; i < d; i++) {
            t[i] = Integer.parseInt(br.readLine());
        }
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int j = 0; j < n; j++) {
            tmp = br.readLine().split(" ");
            a[j] = Integer.parseInt(tmp[0]);
            b[j] = Integer.parseInt(tmp[1]);
            c[j] = Integer.parseInt(tmp[2]);
        }

        int[][] dp = new int[d][n];
        for(int j = 0; j < n; j++) {
            if(t[0] < a[j] || b[j] < t[0]) dp[0][j] = -INF;
        }

        for(int i = 0; i < d - 1; i++) {
            for(int j = 0; j < n; j++) {
                if(a[j] <= t[i + 1] && t[i + 1] <= b[j]) {
                    for(int k = 0; k < n; k++) {
                        dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + Math.abs(c[j] - c[k]));
                    }
                }else {
                    dp[i + 1][j] = -INF;
                }
            }
        }

        int ans = -INF;
        for(int j = 0; j < n; j++) {
            ans = Math.max(ans, dp[d - 1][j]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25588
--{-# LANGUAGE StandaloneDeriving #-}
--{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Control.Monad
import Data.List
--import Data.Char
--import qualified Data.Set as Set
import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  a <- read <$> getLine
  --a `traceShow`
  let m = createMap a
  forM_ [1..a] $ \i -> do
    print $ Map.findWithDefault 0 i m


createMap :: Int -> Map.Map Int Int
createMap n = foldr myInsert Map.empty $ [(x, y, z, val x y z) | x <- [1..n], x * x <= n, y <- [x..n], y * y <= n, z <- [y..n], z * z <= n]

myInsert :: (Int, Int, Int, Int) -> Map.Map Int Int -> Map.Map Int Int
myInsert (x, y, z, v) m = case length . group . sort $ [x, y, z] of
   1 -> Map.insertWith (+) v 1 m
   2 -> Map.insertWith (+) v 3 m
   3 -> Map.insertWith (+) v 6 m

val :: Int -> Int -> Int -> Int
val x y z = x * x + y * y + z * z + x * y + y * z + z * x


Measured memory_bytes: 13024
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll fact[200005];

ll power(ll b, ll e){
    ll res = 1;
    while (e > 0){
        if (e % 2 == 1) res = res * b % mod;
        b = b * b % mod;
        e /= 2;
    }
    return res;
}

ll inv(ll a){
    return power(a, mod-2);
}

ll factorial(int a){
    if (a == 0) return fact[a] = 1;
    if (fact[a] != -1) return fact[a];
    return fact[a] = factorial(a-1) * a % mod;
}

ll comb(int n, int r){
    if (n <= 200000) return factorial(n)* inv(factorial(n-r)) % mod * inv(factorial(r)) % mod;
    ll ans = 1;
    for (int i = n; i > n-r; i--){
        ans = (ans * i) % mod;
    }
    for (int i=1; i <= r; i++){
        ans = (ans * inv(i)) % mod;
    }
    return ans;
}

ll N, A, B;
int main() {
    cin >> N >> A >> B;
    memset(fact, -1, sizeof(fact));
    factorial(min(N, 200000LL));
    ll ans = ((((power(2,N) - comb(N, A) ) % mod - comb(N, B)) % mod) - 1) % mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
static const int MAX=10000;
vector<int> A[MAX];
int B[MAX];

void unit(int x,int y){
    int s,t;
    s=B[x];t=B[y];//x,yの属する集合s,t
    if(s==t)return;
    int sSize=A[s].size();int tSize=A[t].size();
    if(sSize<=tSize){
    for(int i=0;i<sSize;i++){
        A[t].push_back(A[s][i]);//sの要素を全てtに追加
        B[A[s][i]]=t;
    }
    A[s].clear();//sの要素を全部削除
    }
    else{
    for(int i=0;i<tSize;i++){
        A[s].push_back(A[t][i]);
        B[A[t][i]]=s;
    }
    A[t].clear();
    }
    return ;
}

bool isSame(int x,int y){
    if(B[x]==B[y])return true;//xとyの属する集合が同じだったらtrue
    else return false;
}

int main(){
    int n,q,k,x,y;
    cin>>n>>q;
    for(int i=0;i<n;i++){A[i].push_back(i);B[i]=i;}
    for(int i=0;i<q;i++){
        scanf("%d %d %d",&k,&x,&y);
        if(k==0)unit(x,y);
        else if(isSame(x,y))printf("1\n");
        else printf("0\n");
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c(n, -1);
  for (int i = 0; i < m; i++) {
    int si, ci;
    cin >> si >> ci;
    if (c.at(si - 1) != -1 && c.at(si - 1) != ci) {
      cout << -1 << endl;
      return 0;
    }
    c.at(si - 1) = ci;
  }
  if (c.at(0) == 0 && n != 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (c.at(i) == -1) {
      cout << ((i == 0 && n != 1) ? 1 : 0);
    } else {
      cout << c.at(i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,d1,x;
int main(){
	scanf("%d%d%d",&n,&d1,&x);
	double s=d1*2+x*(n*2-1),z=n,ans=0;
	for(int i=n*2;i;i-=2){
		ans+=s*z/i;
		z-=4*z/i/i;
	}
	printf("%.10f",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input().split()
A = [int(x) for x in A]

k = 1
c = 0
for i in range(N):
  if A[i] == k:
    k +=1
  else:
    c +=1
if c == N:
  print(-1)
else:
  print(c)

Measured memory_bytes: 25768
N = int(input())

import numpy as np
#'A','T','G','C'
a = np.zeros([4,4,4],np.int64)
a+=1

a[0,2,3]=0
a[2,0,3]=0
a[0,3,2]=0

for i in range(N-3):
  b = np.zeros([4,4,4],np.int64)
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if ( j==0 and k==2 ) or ( j==2 and k==0 ) or ( i==0 and k==2 ) or (i==0 and j==2 ):
          b[j,k,0] += a[i,j,k]
          b[j,k,1] += a[i,j,k]
          b[j,k,2] += a[i,j,k]
        elif ( j==0 and k==3 ):
          b[j,k,0] += a[i,j,k]
          b[j,k,1] += a[i,j,k]
          b[j,k,3] += a[i,j,k]
        else:
          b[j,k,0] += a[i,j,k]
          b[j,k,1] += a[i,j,k]
          b[j,k,2] += a[i,j,k]
          b[j,k,3] += a[i,j,k]
  a=b%(1000000007)
  
        

print ( np.sum(a)%1000000007 ) 
      
      
      
        
        
        
        
      


Measured memory_bytes: 12516
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
ll dp[N][N];
pair<int, int> a[N];

ll calc (pair<int, int> cur, int pos) {
	return abs(cur.second-pos) * (ll)cur.first;
}

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

	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a + 1, a + n + 1);
	ll ans = -INF;
	for (int pref = 0; pref <= n; ++pref) {
		for (int x = 0; x <= pref; ++x) {
			int y = pref - x;
			if(pref == n) {
				ans = max(ans, dp[x][y]);
				continue;
			}
			dp[x+1][y] = max(dp[x+1][y], dp[x][y] + calc(a[n-pref], x+1));
			dp[x][y+1] = max(dp[x][y+1], dp[x][y] + calc(a[n-pref], n-y));
		}
	}
	cout << ans;


	return Accepted;
}

// B...a

Measured memory_bytes: 26704
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,as=0,bs=0,k; cin>>n;
    vector<ll> a(n,0),b(n,0);
    rep(i,n){
        cin>>a[i]; as+=a[i];
    }
    rep(i,n){
        cin>>b[i]; bs+=b[i];
    }
    k=bs-as;
    rep(i,n){
        k-=max(0LL,(b[i]-a[i]+1)/2);
    }
    cout<<(k>=0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a,&b,&c,&d)
	if math.Abs(a - c) <= d {
		fmt.Println("Yes")
		return
	} else if math.Abs(a - b) <= d && math.Abs(b - c) <= d {
		fmt.Println("Yes")
		return
	} else {
		fmt.Println("No")
		return
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[200005];
ll cnt[1000005];
ll val[1000005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}


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

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		cnt[a[i]]++;
	}
	ll ans=0;
	for(ll i=1;i<=1000000;i++){
		val[i]=mod_inverse(i,MOD);
	}
	for(ll i=1;i<=1000000;i++){
		ll sum=0;
		for(ll j=i;j<=1000000;j+=i){
			if(i<j){
				val[j]+=MOD-val[i];
				val[j]%=MOD;
			}
			ans+=((cnt[j]*(cnt[j]-1)/2LL)%MOD)*((val[i]*j%MOD)*j%MOD)%MOD;
			ans%=MOD;
			ans+=((cnt[j]*j)%MOD)*(sum*val[i]%MOD)%MOD;
			ans%=MOD;
			sum+=cnt[j]*j%MOD;
			sum%=MOD;
		}
		//if(i<=6)printf("%lld %lld\n",i,sum);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  int64_t N;
  cin >> N;

  vector<int64_t> A(N);
  for(int64_t n = 0; n < N; ++n) { cin >> A[n]; }

  vector<int64_t> B(N), C(N);
  for(int64_t n = 0; n < N; ++n) {
    B[n] = (n + 1) + A[n];
    C[n] = (n + 1) - A[n];
  }

  map<int64_t, int64_t> counter;
  for(int64_t n = 0; n < N; ++n) {
    ++counter[C[n]];
  }

  int64_t S = 0;
  for(int64_t n = 0; n < N; ++n) {
    S += counter[ B[n] ];
  }
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 30712
n,k = map(int, raw_input().split(' '))
r,s,p = map(int, raw_input().split(' '))
seq = raw_input()


dp = [[0,0,0] for _ in range(len(seq))]
"""
	0 rock
	1 paper
	2 scisor
"""

for i in range(len(dp)):
	if i - k < 0:
		dp[i][0] = r if seq[i]  == 's' else 0
		dp[i][1] = s if seq[i]  == 'p' else 0
		dp[i][2] = p if seq[i]  == 'r' else 0
	elif i - k >=0:
		dp[i][0] = max(dp[i- k][1], dp[i-k][2]) + 	(r if seq[i]  == 's' else 0)
		dp[i][1] = max(dp[i- k][0], dp[i-k][2]) + 	(s if seq[i]  == 'p' else 0)
		dp[i][2] = max(dp[i- k][0], dp[i-k][1]) + 	(p if seq[i]  == 'r' else 0)

cumul = 0
seen = set([])
for j in range(len(dp)-1, -1, -1):
	#print j % k
	if (j % k) not in seen:
		seen.add(j % k)
		cumul += max(dp[j])

print cumul


Measured memory_bytes: 51100
#include<stdio.h>
#define N 101
#define INF 100000000

int min(int x,int y ){
  if(x<y)return x;
  return y;
}

int main(){
  int i,j,k,l,n,r[N],M[N][N];

  scanf("%d",&n);

  for(i=1;i<=n;i++)scanf("%d%d",&r[i-1],&r[i]);
  for(i=1;i<=n;i++)M[i][i]=0;

  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      l=i+j-1;
      M[i][l]=INF;
      for(k=i;k<=l-1;k++){
	M[i][l]=min(M[i][l],M[i][k]+M[k+1][l]+r[i-1]*r[k]*r[l]);
      }
    }
  }printf("%d\n",M[1][n]);
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int main() {
	int N;
	cin >> N;
	vector<int>ans(N);
	for (int i = 1; i <=N; i++) {
		for (int x = 1; pow(x, 2) <= i; x++) {
			for (int y = 1; pow(x + y, 2) <= 2 * i; y++) {
				for (int z = 1; pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2) <= 2 * i;z++) {
					if (pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2) == 2 * i) {
						ans[i - 1]++;
					}
				}
			}
		}
	}
	rep(i, N) {
		cout << ans[i] << endl;
	}
}
	


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    int cnt[26] = {};
    
    while( cin >> ch ){
        ch = tolower(ch);
        if ( isalpha(ch) ){
            cnt[ch-'a']++;
        }
    }
    
    for ( int i = 0; i < 26; i++ ){
        printf("%c : %d\n", i+'a', cnt[i]);
    }
    
    return 0;
}


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

int N;
int A[200];

int main() 
{
    cin >> N;
    for( int i=0 ; i<N ; i++ ) cin >> A[i];

    set<int> s;

    for( int i=0 ; i<N ; i++ )
    {
        s.insert( A[i] );
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    int t;
    t=x;
    x=y;
    y=t;
    t=z;
    z=x;
    x=t;
    printf("%d %d %d\n",x,y,z);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H,W;
  cin>>H>>W;
  int n = 10;
  MAT<int> c=MATINIT(int,n,n,0);
  REP(i,0,n){
    REP(j,0,n){
      cin>>c[i][j];
    }
  }
  MAT<int> A=MATINIT(int,H,W,1);
  REP(i,0,H){
    REP(j,0,W){
      int t;
      cin>>t;
      A[i][j]=t==-1?1:t;
    }
  }
  REP(k,0,n){
    REP(i,0,n){
      REP(j,0,n){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  LL sum = 0;
  REP(i,0,H){
    REP(j,0,W){
      sum+=c[A[i][j]][1];
    }
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[100005],b[100005];
void solve() {
	int A,B,m;
	cin>>A>>B>>m;
	int ans=infl;
	fr(i,1,A)
		cin>>a[i];
	fr(i,1,B)
		cin>>b[i];
	fr(i,1,m) {
		int x,y,c;
		cin>>x>>y>>c;
		ans=min(ans,a[x]+b[y]-c);
	}
	ans=min(ans,(*min_element(a+1, a+A+1))+(*min_element(b+1,b+B+1)));
	cout<<ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(8);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

H,W=map(int,input().split())

A=[list(map(int,input().split())) for i in range(H)]
B=[list(map(int,input().split())) for i in range(H)]

SA=[[0]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        SA[i][j]=abs(A[i][j]-B[i][j])

DP=[[0 for i in range(W)] for j in range(H)]

DP[0][0]=1<<(H+W)*80+SA[0][0]

for i in range(H):
    for j in range(W):
        tempbit=DP[i][j]
        if i+1<H:
            DP[i+1][j]|=tempbit<<SA[i+1][j]
            DP[i+1][j]|=tempbit>>SA[i+1][j]

        if j+1<W:
            DP[i][j+1]|=tempbit<<SA[i][j+1]
            DP[i][j+1]|=tempbit>>SA[i][j+1]

ANS=1<<30
for i in range((H+W)*160+1):
    if 1<<i & DP[-1][-1]!=0:
        ANS=min(ANS,abs(i-(H+W)*80))

print(ANS)


Measured memory_bytes: 62044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Mb,Ma; cin >> N >> Ma >> Mb;
    vector<int> a(N),b(N),c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];

    int M = N/2;
    vector<pair<int, int>> left(1 << M),right(1 << (N-M));
    for (int tmp = 0; tmp < (1 << M); tmp++) {
        bitset<20> s(tmp);
        int C = 0;
        int val = 0;
        rep(i,M) {
            if (s.test(i)) {
                val += (a[i]*Mb - b[i]*Ma);
                C += c[i];
                left[tmp] = make_pair(val,C);
            }
        }
    }
    for (int tmp = 0; tmp < (1 << (N-M)); tmp++) {
        bitset<20> s(tmp);
        int C = 0;
        int val = 0;
        rep(i,(N-M)) {
            if (s.test(i)) {
                val += (a[M+i]*Mb - b[M+i]*Ma);
                C += c[M+i];
                right[tmp] = make_pair(val,C);
            }
        }
    }
    sort(all(left)); sort(all(right));
    rep (i,(1 << M)-1) {
        if (left[i].second == 0) continue;
        if (left[i+1].first == left[i].first) {
            left[i+1].second = left[i].second;
        }
    }
    rep (i,(1 << (N-M))-1) {
        if (right[i].second == 0) continue;
        if (right[i+1].first == right[i].first) {
            right[i+1].second = right[i].second;
        }
    }
    int ans = INF;
    for (auto i : left) {
        auto it = lower_bound(all(right),make_pair(-i.first,-1));
        if (it == right.end()) continue;
        if (i.second+it->second == 0) it++;
        if (it == right.end()) continue;
        if (it->first != -i.first) continue;
        chmin(ans,i.second+it->second);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll a, b;
    cin >> a >> b;
    if(a * b % 2) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ld r;
	cin >> r;
	cout << 2 * M_PI * r << endl;    
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  string S;
  cin >> S;
  string s[S.length()];
  for(int i = 0; i < S.length(); i++){
    s[i] = S.substr(i, 1);
  }
  int cnt = 0;
  int maxcnt = 0;
  F(i, S.length()){
    if(s[i] == "A" || s[i] == "T" || s[i] == "G" || s[i] == "C"){
      cnt++;
      if(i == S.length() - 1){
        if(maxcnt < cnt){
          maxcnt = cnt;
        }
      }
    }
    else{
      if(maxcnt < cnt){
        maxcnt = cnt;
      }
      cnt = 0;
    }
  }
  cout << maxcnt << endl;
  return 0;
}


Measured memory_bytes: 256
main(){float d,e,f,g,h,i,m,n,p;for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);puts(((f-d)*(n-e)-(m-d)*(g-e))*p>0&&p*((d-h)*(n-i)-(m-h)*(e-i))>0?"YES":"NO"))p=(h-f)*(n-g)-(m-f)*(i-g);}

Measured memory_bytes: 0
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; typedef long double ldouble ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int n;
  cin>>n;
  string s=to_string(n);
  s=s.substr(s.length()-1,1);
  if(s=="3"){
    cout<<"bon"<<endl;
  }else if(s=="0" or s=="1" or s=="6" or s=="8"){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }

}


Measured memory_bytes: 3752
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> a(n + 1);
    for (int i = 0; i <= n; ++i)
        std::cin >> a[i];
    if (n == 0) {
        if (a[0] == 1) {
            std::cout << 1 << std::endl;
        } else {
            std::cout << -1 << std::endl;
        }
        return 0;
    }
    if (a[0] > 0) {
        std::cout << -1 << std::endl;
        return 0;
    }
    long long sum = std::accumulate(a.begin(), a.end(), 0ll) - a[0];
    long long ans = 1;
    long long x = 1;
    for (int i = 1; i <= n; ++i) {
        sum -= a[i];
        x = std::min(2 * x - a[i], sum);
        if (x < 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
        ans += x + a[i];
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  scanf("%d ",&n);
  while(n--){
    string s;
    for(getline(cin,s),i=0;i<s.size();i++){
      if(s[i]=='H')if(s[i+1]=='o')if(s[i+2]=='s')
        if(s[i+3]=='h')if(s[i+4]=='i')if(s[i+5]=='n')
          if(s[i+6]=='o')s[i+6]='a';
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3176
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  string s; readV(s);
  auto a = s.map!(c => cast(int)(c-'0')).array;

  foreach (i; 0..1<<3) {
    auto b = a.dup;
    foreach (j; 0..3)
      if (i.bitTest(j)) b[j+1] = -b[j+1];
    if (b.sum == 7) {
      write(a[0]);
      foreach (j; 0..3) {
        write(b[j+1] < 0 ? "-" : "+");
        write(a[j+1]);
      }
      writeln("=7");
      return;
    }
  }
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
import math
hourR, minR, H, M = map(int, input().split())
hourPos = [math.sin(((H * 60 + M) / 360) * math.pi) * hourR,
           math.cos(((H * 60 + M) / 360) * math.pi) * hourR]
minPos = [math.sin((M / 30) * math.pi) * minR,
          math.cos((M / 30) * math.pi) * minR]
distance = math.sqrt(
    pow(hourPos[0] - minPos[0], 2) + pow(hourPos[1] - minPos[1], 2))
print(distance)


Measured memory_bytes: 9588