akhauriyash/Code-Regression huggingface dataset:
S = input()
L = len(S)
oioi =""
ioio =""
Aoi = 0
Aio = 0
for i in range(L):
  if i%2 == 0:
    oioi = oioi+"0"
    ioio = ioio+"1"
  else:
    oioi = oioi + "1"
    ioio = ioio + "0"

for j in range(L):
  if S[j] != oioi[j]:
    Aoi = Aoi+1
  
  if S[j] != ioio[j]:
    Aio = Aio+1

print(min(Aoi,Aio))


Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	ans := 0
	A := K * (K - 1) / 2
	B := K*(K-1)/2 + (N-K+1)*K
	ans += B - A + 1
	ans %= 1e9 + 7
	//fmt.Println(0, B, A)

	for i := 1; i <= N-K+1; i++ {
		A += K + i - 1
		B += N - K - (i - 1)
		ans += B - A + 1
		ans %= 1e9 + 7

		//fmt.Println(i, B, A)
	}
	fmt.Println(ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){

ll n , m ;
cin>>n>>m;

ll best = 1ll<<50;

for(ll i=1;i<n;i++){

    ll A = m*i;
    ll B = ((n-i+1ll)/2ll)*m;
    ll C = ((n-i)/2ll)*m;

    best=min( best ,  max( A,max(B,C) )-min( A,min(B,C) ) );
}

for(ll i=1;i<n;i++){

    ll A = m*i;
    ll B = (n-i)*((m)/2ll);
    ll C = (n-i)*((m+1ll)/2ll);

    best=min( best ,  max( A,max(B,C) )-min( A,min(B,C) ) );

}
swap(n,m);
for(ll i=1;i<n;i++){

    ll A = m*i;
    ll B = ((n-i+1ll)/2ll)*m;
    ll C = ((n-i)/2ll)*m;

    best=min( best ,  max( A,max(B,C) )-min( A,min(B,C) ) );
}

for(ll i=1;i<n;i++){

    ll A = m*i;
    ll B = (n-i)*((m)/2ll);
    ll C = (n-i)*((m+1ll)/2ll);

    best=min( best ,  max( A,max(B,C) )-min( A,min(B,C) ) );
}

cout<<best<<endl;
return 0;
}


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

int a[3];
int out;
int sum;

int main(void){
	int i;
	int set;
	char buf[8];
	char hit[4] = "HIT", OUT[4]="OUT", homerun[8]="HOMERUN";
	
	scanf("%d", &set);
	for (i = 0; i < set; i++){
		while (1){
			scanf("%s", buf);
			if (strcmp(buf, hit) == 0){
				sum += a[2];
				a[2] = a[1];
				a[1] = a[0];
				a[0] = 1;
			}
			else if (strcmp(buf, homerun) == 0){
				sum += a[2] + a[1] + a[0] + 1;
				a[0] = a[1] = a[2] = 0;
			}
			else if (strcmp(buf, OUT) == 0){
				out++;
			}
			
			if (out == 3){
				a[0] = a[1] = a[2] = 0;
				out = 0;
				printf("%d\n", sum);
				sum = 0;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
        string s;
        int n;
        int sum;
        while(1){
                getline(cin,s);
                n = s.length();
                sum = 0;
                if(atoi(s.c_str()) == 0) break;
                for (int i = 0; i < n; i++){
                        sum += int(s[i] - '0');
                }
                cout << sum << endl;
        }
}


Measured memory_bytes: 3176
taro, hanako = 0, 0
(n = gets.to_i).times do

  t, h = gets.split
  if t == h
    taro += 1
    hanako += 1
  elsif t < h
    hanako += 3
  elsif t > h
    taro += 3
  else
  end
end

puts "#{taro} #{hanako}"

Measured memory_bytes: 6096
#include <iostream>

using namespace std;

int main(){
    int n;
    int b,f,r,v;
    int member[4][3][10] = {};
    cin >> n;
    while(cin >> b >> f >> r >> v){
        member[b-1][f-1][r-1] += v;
        if(!--n)break;
    }
    for(int i = 0;i <4;i++){
            for(int j = 0;j < 3;j++){
                for(int k = 0;k < 10;k++){
                    cout << " " << member[i][j][k];
                }
                cout << endl;
            }
            if(i<3)cout << "####################" << endl;   
        }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b > c * d) {
        cout << a * b << endl;
    }else{
        cout << c * d << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isPerfectSquare(double x) 
{ 
 	double sr = sqrt(x);  
  	return ((sr - floor(sr)) == 0); 
}   
int main()
{
  int n,d,i,j,k,c=0;
  double s=0.0;
  cin>>n>>d;
  int a[n][d];
  for(i=0;i<n;i++)
  {
    for(j=0;j<d;j++)
      cin>>a[i][j];
  }
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<n;j++)
    {
      s=0.0;
      for(k=0;k<d;k++)
      {
       	s+=pow((a[i][k]-a[j][k]),2);
      }
      if (isPerfectSquare(s)) 
      c++;
    }
  }
  cout<<c;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 30000;
	public static final int SQRT = (int)(Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		boolean[] is_prime = new boolean[MAX + 1];
		Arrays.fill(is_prime, 2, MAX + 1, true);
		for(int i = 2; i <= SQRT; i++){
			if(is_prime[i]){
				for(int j = i * 2; j <= MAX; j += i){
					is_prime[j] = false;
				}			
			}
		}
		
		
		while (true) {

			final int T = sc.nextInt();
			
			if(T == 0){ break; }
			
			long count = 0;
			for(int fst = T; fst >= 2; fst--){
				if(!is_prime[fst]){ continue; }
				
				for(int snd = fst; snd >= 2; snd--){
					if(!is_prime[snd]){ continue; }
					else if(fst + snd > T){ continue; }
					
					final int thd = T - (fst + snd);
					if(!is_prime[thd]){ continue; }
					else if(thd > snd){ continue; }
					else if(fst >= snd + thd) { continue; }
					
					//System.out.println(fst + " " + snd + " " + thd);
					
					count++;
				}
			}
			
			System.out.println(count);
			
		}

	}
}

Measured memory_bytes: 18796
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll H;
    cin >> H;

    ll ans = 0, cnt = 0;
    while (H != 0) {
        ans += pow(2, cnt);
        H /= 2;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,m;
vl a;

int main(){
	cin>>n>>m;
	a=vl(n);
	for(auto &i:a) cin>>i;
	double X=0,Y=0;
	for(int i=0;i<n;i++){
		int t=n-2;
		for(int j=(i+1)%n;t;j=(j+1)%n){
			double arg=pi*(a[i]+a[j]+(j<i?m:0))/m;
			X+=cos(arg)*t;
			Y+=sin(arg)*t;
			t--;
		}
	}
	X/=n*(n-1)*(n-2)/6;
	Y/=n*(n-1)*(n-2)/6;
	cout<<syosu(11)<<X<<' '<<Y<<endl;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static class Rstrt {
        String s;
        int p;
        int id;
        public Rstrt(int index, String city, int rank) {
            s = city;
            p = rank;
            id = index;
        }
    }
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        ArrayList<Rstrt> Rstrts = new ArrayList<>();
        for (int i = 0; i < n; i++){
            Rstrts.add(new Rstrt(i, in.next(), in.nextInt()));
            Rstrts.sort(new Comparator<Rstrt>() {
                @Override
                public int compare(Rstrt o1, Rstrt o2) {
                    int strComp = o1.s.compareTo(o2.s);
                    if (strComp != 0)
                        return strComp;
                    return o1.p < o2.p ? 1 : -1;
                }
            });
        }
        for (int i = 0; i < n; i++){
            System.out.println(Rstrts.get(i).id + 1);
        }
    }
}


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

    divisors.sort()
    return divisors


divisors=make_divisors(n)
#print(divisors)
minval = 10**15

if len(divisors)%2 == 0:
    #print("hoge")
    for i in range(len(divisors)//2):
        a,b = divisors[i],divisors[len(divisors)-1-i]
        if (a+b)<minval:
            minval = a+b
            
if len(divisors)%2 == 1:
    for i in range(len(divisors)//2+1):
        if i ==len(divisors)//2:
            a,b = divisors[i],divisors[i]
        else:
            a,b = divisors[i],divisors[len(divisors)-1-i]
        #print(a,b)
        if (a+b)<minval:
            minval = a+b
print(minval-2)

Measured memory_bytes: 39280
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    ll preb=0;
    ll prea=0;
    rep(i,n){
        cin>>a[i];
        prea+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        preb+=b[i];
    }
    ll sum = 0;

    rep(i,n){
        if(a[i]>b[i]){
            sum-=a[i]-b[i];
        }else if(b[i]>a[i]){
            sum+=(b[i]-a[i])/2;
        }
    }
    if(sum>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
#include <deque>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n, a[maxn];

int main() {
  //freopen("in.cpp","r",stdin);
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin>>a[i];
  }
  ll ret = a[0] - 1;
  int mi = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] > mi + 1) {
      ret += (a[i] - 1) / (mi + 1);
    } else mi = max(mi, a[i]);
  }
  cout<< ret << endl;
  return 0;
}


Measured memory_bytes: 640
l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Measured memory_bytes: 107404
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
 cin>>s;
 if(s=="Sunny") cout<<"Cloudy"<<endl;
 if(s=="Cloudy") cout<<"Rainy"<<endl;
 if(s=="Rainy") cout<<"Sunny"<<endl;
 return 0;
}


Measured memory_bytes: 256
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
 
 
int main()
{
	IOS;
	cin>>n>>m;
	ll prod =1LL*n*m;
	ll g = __gcd(m,n);
	// dbg(g);dbg(prod);
	ll ans = prod/g;
	cout<<ans<<ln;
}

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

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

int main (){
    
  int a[3];
  int ans;
  
  for(int i = 0;i < 3;i++){
  scanf("%d",&a[i]);
  }
  qsort(a, sizeof(a) / sizeof(int), sizeof(int), asc);
  
  ans += a[1] - a[0];
  ans += a[2] - a[1];
  
  printf("%d",ans);
      return 0;
  
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#include<cctype>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repp(i,j,n) for (int i = (j); i < (n); i++)
#define Reo(i,j,n) for(int i=(j); i <= (n); i++)
using namespace std;
typedef long long ll;
int main() {
	string s;
    cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N, M; cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int N,K; cin >> N>> K;
    long double ans = 0;
    for(int i = 1; i <= N; i++){
        long double tmp = (1.0L)/(N*1L);
        int ti = i;
        while(ti < K){
            ti *= 2;
            tmp /= 2L;
        }
        ans += tmp;
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
//             بسم الثالوث الاقدس

#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;

				
bool prime(int x)
{
	if (x == 1)
		return false;
	else if (x == 2)
		return true;
	for (int i = 2; i*i <= x; i++)
	{
		if (x%i == 0)
			return false;

	}
	return true;
}
void fun2(int t)
{
	if (t == 1)
	{
		cout << "*";
		return;
	}
	cout << "*";
	return fun2(t - 1);
}

void fun(int s)
{
	map<int, int>asd;
	map<int, int>::iterator ir;
	ir = asd.begin();
	ir->first;
	if (s)
	{
		cout << s % 10 << endl;
		fun(s / 10);
		
	}
}
long long numb(long long i){
	if ( i == 2 || i == 1)
		return 1;
	else{
		long long n = i, z = 0;
		while (n>1){
			if (i%n == 0){
				z++;
			}
			n--;
		}
		return z;
	}

}

/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	int x, y, z;
	cin >> x >> y >> z;
	if ((x%(y+z)<z))
		cout << (x / (y + z)) - 1 << endl;
	else 
		cout << (x / (y + z)) << endl;

	//system("pause");
	return 0;
}
/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());
    auto comPair = [](const P &firstElof, const P &secondElof) {
        int m1 = min(firstElof.first, firstElof.second);
        int m2 = min(secondElof.first, secondElof.second);
        return m1 < m2;
    };
    priority_queue<P, vector<P>, decltype(comPair)> que(comPair);

    ll ans = a[0];
    que.emplace(a[0], a[1]);
    que.emplace(a[0], a[1]);
    repeat(i, 2, n) {
        auto p = que.top();
        que.pop();

        ans += min(p.first, p.second);

        que.emplace(p.first, a[i]);
        que.emplace(p.second, a[i]);
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 6100
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)



int main() {
	
	int N, M;
	cin >> N >> M;
	
	vl a[3];
	REP(i, N)REP(j, 3) {
		ll num; cin >> num;
		a[j].push_back(num);
	}

	ll res = 0;
	REP(bit, 1 << 3) {
		vl b;
		REP(i, N) {
			ll tmp = 0;

			REP(j, 3) {
				if (bit &(1 << j))tmp += a[j][i];
				else tmp -= a[j][i];
			}

			b.push_back(tmp);

		}

		sort(b.begin(), b.end(), greater<ll>());

		ll sum = 0;

		REP(i, M)sum += b[i];

		res = max(res, sum);
	}

	cout << res << endl;
}

	

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    """Function."""
    a, b = map(int, input().split())

    if a > 0 and b > 0:
        print("Positive")
    elif a <= 0 and b >= 0:
        print("Zero")
    elif a < 0 and b < 0:
        if (b - a) % 2 == 0:
            print("Negative")
        else:
            print("Positive")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n;
double a[105];
double ans;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		ans+=double(1/a[i]);
	}
	ans=1/ans;
	cout<<ans;
	return 0;
}

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

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean boo = false;
        while(n > 0){
            if(n % 4 == 0){
                boo = true;
                break;
            }
            else if(n % 7 == 0){
                boo = true;
                break;
            }
            else n -= 7;
        }
        if(boo) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
import numpy as np
s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = np.zeros(total_X + 1, dtype = np.int32)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    # print (lst_X)
    # print (lst_X[i:])
    # print (lst_X[:-i])
    # print (np.maximum(lst_X[i:], lst_X[:-i]))

    lst_X[i:] = np.maximum(lst_X[i:], lst_X[:-i])

# print (lst_X)

lst_Y = np.zeros(total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    lst_Y[i:] = np.maximum(lst_Y[i:], lst_Y[:-i])

if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and int(lst_X[(total_X - x) // 2]) == 1 and int(lst_Y[(total_Y - y) // 2]) == 1:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 13568
W, B = map(int, input().split())
h = 100
w = 100
X = [['#'] * w if i < (h // 2) else ['.'] * w for i in range(h)]

for i in range(0, h, 2):
    for j in range(0, w, 2):
        if W == 1:
            break
        X[i][j] = '.'
        W -= 1

for i in range(h//2 + 1, h, 2):
    for j in range(0, w, 2):
        if B == 1:
            break
        X[i][j] = '#'
        B -= 1
print(h, w)
for i in range(h):
    print("".join(X[i]))

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

int main(void) {
    string A,B,C;
    cin >> A >> B >> C;

    if ( A[A.size()-1] == B[0] && B[B.size()-1] == C[0] ) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int ans = 1e9;
	int p[n+1],t[n+1];
	p[0]=0,t[0]=0;
	rep(i,n){
		if(!i)p[i+1] = (s[i] == 'E'?1:0);
		else p[i+1] = p[i]+(s[i] == 'E');
	}
	for(int i = n-1;i >= 0;--i){
		if(i == n-1)t[i+1] = (s[i] == 'W'?1:0);
		else t[i+1] = t[i+2]+(s[i] == 'W');
	}
	for(int i = 1;i <= n;++i){
		if(i!=1 && i!=n)ans = min(ans,n-p[i-1]-1-t[i+1]);
		if(i==1)ans=min(ans,n-1-t[i+1]);
		if(i==n)ans=min(ans,n-1-p[i-1]);
	}
	cout<<ans;

}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N=52;
ll n,m,a,k,x[N],dp[N][N][N*N],ans;

int main(){
    fast;
    cin>>n>>m;
    forn(i,n) cin>>x[i],a+=x[i];
    dp[0][0][0]=1;
    forn(i,n){
        forn(j,n){
            forn(k,a+1){
                ll add=dp[i][j][k];
                dp[i+1][j][k]+=add;
                dp[i+1][j+1][k+x[i]]+=add;
            }
        }
    }
    for1(i,n) ans+=dp[n][i][i*m];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 54272
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, dp[210000], a[210000], b[210000];
string str, ss;
bool f[210000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[410000];
vector<Pll>v;
map<string, LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	m = n;
	for (int i = 21; i >= 0; i--) {
		if (n&(1 << i)) {
			p = i;
			break;
		}
	}

	for (int i = 0; i < p; i++) {
		vec[i].push_back(Edge{ i + 1,1<< i });
		vec[i].push_back(Edge{ i + 1,0 });
		sum += 2;
	}
	n -= (1 << p);

	for (int i = 0; i < 32; i++) {
		if ((n)&(1 << i)) {
			vec[i].push_back(Edge{ p,(1<<p)+q });
			sum += 1;
			q += (1 << i);
		}
	}
	cout << p + 1 << " " << sum << endl;
	rep(i, p) {
		rep(j, vec[i].size()) {
			cout << i + 1 << " " << vec[i][j].to + 1 << " " << vec[i][j].cost << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 10496
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}

pub fn min(left: i32, right: i32) -> i32 {
    if(left > right) {
        return right;
    }
    left
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let n:String = r.readl();
    let each_digits_of_n:Vec<&str> = n.rsplit_terminator("").collect();
    let mut dp = vec![vec![std::i32::MAX;2]; each_digits_of_n.len()];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for i in 0..each_digits_of_n.len() - 1 {
        let d:i32 = match each_digits_of_n[i].parse() {
            Ok(j) => j,
            Err(e) => continue
        };
        dp[i + 1][0] = min(dp[i][0] + d, dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i][0] + d + 1, dp[i][1] + 10 - d - 1);
    }
    println!("{}",dp[each_digits_of_n.len() - 1][0]);
}
    


Measured memory_bytes: 53620
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    unordered_set<ll>   usll;
typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
typedef    unordered_multiset<int>   umsi;
typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9222372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
#define    gt(v,x)     v.en()-upb(all(v),x)
#define    lt(v,x)     lowb(all(v),x)-v.be()
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(x==0)return 0;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}



 
int main()
{       io 
int testcases=1;   //          cin>>testcases;
while(testcases--)
{
 

 si s;
 for(int i=0;i<5;i++)
 {int x;
 cin>>x;
 s.insert(x);

}
 for(int i=0;i<5;i++)
 {
 	if(s.find(i+1)==s.end())
 	{
 		cout<<i+1;
 		break;
	 }
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
}return 0;}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int n;
char s1[109],s2[109];

int main()
{
	scanf("%d%s%s",&n,s1+1,s2+1);
	for(int i=n;i>=1;i--)
	{
		for(int j=1;j<=i;j++)
			if(s1[j+n-i]!=s2[j])
				goto nxt;

		printf("%d\n",n+n-i);
		return 0;
		nxt:;
	}
	printf("%d\n",n+n);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> S(n);
  unordered_map<string, int> ss;
  map<int, int> size;
  int mn = inf;
  rep(i, n) {
    cin >> S[i];
    reverse(all(S[i]));
    ss[S[i]]++;
    size[S[i].size()]++;
    mn = min((int)S[i].size(), mn);
  }
  ll ans = 0;
  rep(i, n) {
    vector<bool> alpha(26);
    while(S[i].size() >= 0) {
      if(S[i].size()+1 < mn) break;
      rep(k, 26) if(alpha[k]) {
        S[i] += char('a'+k);
        if(size.find(S[i].size()) != size.end() && ss.find(S[i]) != ss.end()) ans++;
        S[i].pop_back();
      }
      if(S[i].size() == 0) break;
      alpha[S[i].back()-'a'] = true;
      S[i].pop_back();
    }
  }
  ans -= n;
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 23956
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
/* -- template -- */

const int MAX = 1000100;
ll 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;//拡張euclid互除法によるi!の逆元計算
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll 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;
}
//a^nをかえす
ll modpow(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    COMinit();
    ll n, a, b;
    cin >> n >> a >> b;
    ll A = 1, B = 1;
    for(ll i = n; i > n - a; --i){
        A = (A * (i)) % MOD;
    }
    for(ll i = n; i > n - b; --i){
        B = (B * (i)) % MOD;
    }
    A = (A * finv[a])%MOD;
    B = (B * finv[b]) % MOD;
    ll ans = modpow(2, n) - 1 - A - B;
    ans += 10 * MOD;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
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(){
    ll a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3552
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

struct GetNumberOfTrailingZeros {
  constexpr GetNumberOfTrailingZeros() : table() {
    uint64_t hash = 0x03F566ED27179461UL;

    for (int i = 0; i < 64; i++)
    {
      table[hash >> 58] = i;
      hash <<= 1;
    }
  }
  int Calc(int64_t x)
  {
    if (x == 0) return 64;

    uint64_t y = (uint64_t)(x & -x);
    int i = (int)((y * 0x03F566ED27179461UL) >> 58);
    return table[i];
  }
  int table[64];
} gntz;


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;
  vector<int> as(M);
  vector<int> bs(M);
  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    as[i] = a;
    F0R(j, b) {
      int c;
      cin >> c;
      c--;
      bs[i] |= 1 << c;
    }
  }

  vector<vector<int>> dp(M + 1, vector<int>(1 << N, 1000001));
  dp[0][0] = 0;

  F0R(i, M) {

    int ib = ~bs[i];
    F0R(j, 1 << N) {
      dp[i + 1][j] = min(dp[i][j], dp[i][j & ib] + as[i]);
    }
  }

  int r = dp[M][(1 << N) - 1];
  if (r > 1000000) r = -1;
  cout << r;
}
#endif


Measured memory_bytes: 16384
#include <cstdio>
#include <iostream>

using namespace std;


char str[7][10] = {"Thursday", "Friday", "Saturday","Sunday", "Monday", "Tuesday", "Wednesday"};
int days[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; 

int main() {
	int month, day;
	while (scanf("%d%d", &month, &day), month + day) {
		printf ("%s\n", str[(days[month] + day - 1) % 7]);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

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

int main() {
    int N, K;
    cin >> N >> K;

    vector<ll> cnt(K + 1);
    ll ans = 0;
    for (int i = K; i >= 1; --i) {
        ll tmp = modpow(K/ i, N, mod);

        for (int l = i * 2; l <= K; l += i) {
            tmp -= cnt[l];
        }

        while (tmp < 0) tmp += mod;

        ans += (tmp * i) % mod;
        ans %= mod;
        cnt[i] = tmp;
    }

    cout << ans << endl;
}

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

def main():
    scores = [i*400 for i in range(1, 8)]
    scores.reverse()

    scores_d = {}
    input()
    god = []
    for a in map(int,input().split()):
        if a >= 3200:
            god.append(a)
            continue
        for i in scores:
            if a >= i:
                scores_d[i] = 1
                break
        if a < 400:
            scores_d[0] = 1

    counts = sum(scores_d.values())
    print(counts if counts > 0 else 1, counts + len(god))

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll n,m,p[12],ans;
vector<ll>ch[12];
bool li[12];
void dep(ll now){
	if(now==n){
		for(ll i=0;i<m;i++){
			ll cnt=0;
			for(ll j=0;j<ch[i].size();j++){
				if(li[ch[i][j]]){
					cnt++;
				}
			}
			if(cnt%2!=p[i]){
				//cout << cnt;
				return;
			}
		}
		ans++;
		return;
	}
	li[now]=true;dep(now+1);
	li[now]=false;dep(now+1);
}
int main() {
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll t;
			cin>>t;
			t--;
			ch[i].push_back(t);
		}
	}
	for(ll i=0;i<m;i++){
		ll now;
		cin>>now;
		p[i]=now;
	}
	//cout << p[1];
	dep(0);
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    string s;
    cin >> s;

    int n = s.size();
    for (char c = 'a'; c <= 'z'; ++c) {
        int mn = 1e9, p = 0;
        int cur = 0;
        for (int i = 0; i < n; ++i) {

            int was = cur;

            if (s[i] == c)
                cur++;
            else
                cur--;

            if (mn < cur) {
                cout << p + 1 << ' ' << i + 1 << endl;
                exit(0);
            }   

            if (was < mn) {
                mn = was;
                p = i;
            }   
        }   
    }   
    cout << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 3864
package main

import "fmt"

func main() {
	var (
		a, b, c, x, count int
	)
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

puts yn_judge(get_nsp.map(&:to_i).inject(:+)%9==0)

Measured memory_bytes: 26436