akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

vector<Int> zalgorithm(string s){
  Int n=s.size();
  vector<Int> a(n,0);
  a[0]=n;
  Int i=1,j=0;
  while(i<n){
    while(i+j<n&&s[j]==s[i+j]) j++;
    a[i]=j;
    if(j==0){
      i++;
      continue;
    }
    Int k=1;
    while(i+k<n&&k+a[k]<j) a[i+k]=a[k],k++;
    i+=k;
    j-=k;
  }
  return a;
}

//INSERT ABOVE HERE
using vint = vector<Int>;
void print(const vint &v){
  for(Int i=0;i<(Int)v.size();i++){
    if(i) cout<<" ";
    cout<<v[i];
  }
  cout<<endl;
}

vint add(const vint &a,const vint &b){
  vint c(26,0);
  for(Int i=0;i<26;i++) c[i]=a[i]+b[i];
  return c;
}
vint sub(const vint &a,const vint &b){
  vint c(26,0);
  for(Int i=0;i<26;i++) c[i]=a[i]-b[i];
  return c;
}

signed main(){
  string s;
  cin>>s;
  Int l,r;
  cin>>l>>r;
  l--;
  {
    string t(s);
    t.erase(unique(t.begin(),t.end()),t.end());
    if(t.size()==1u){
      vint ans(26,0);
      ans[t[0]-'a']=r-l;
      print(ans);
      return 0;
    }
  }
  
  Int n=s.size(),k=n/2+1;
  vector<Int> z=zalgorithm(s);
  while(k<n&&k+z[k]<n) k++;
  if(k==n){
    s=s+s;
    z=zalgorithm(s);
    k=n+1;
    n=n+n;
    while(k<n&&k+z[k]<n) k++;
  }
  
  vector<Int> x;
  x.emplace_back(n);
  x.emplace_back((n-z[k])*2);
  //cout<<n<<":"<<k<<":"<<z[k]<<endl;
  for(Int i=0;x.back()<=r;i++)
    x.emplace_back(Int(x[i]+x[i+1]));

  vector<vint> a(n+1,vint(26,0));
  for(Int i=0;i<n;i++)
    for(Int j=0;j<26;j++)
      a[i+1][j]=a[i][j]+(s[i]=='a'+j);
  
  using P = pair<Int, Int>;
  map<P, vint> dp;
  function<vint(Int, Int)> dfs=
    [&](Int l,Int r){
      //cout<<l<<" "<<r<<":"<<endl;
      //if(dp.count(P(l,r))) print(dp[P(l,r)]);
      if(dp.count(P(l,r))) return dp[P(l,r)];
      vint &res=dp[P(l,r)];
      if(r<=n) return res=sub(a[r],a[l]);
      Int p=0;
      while(r>x[p]) p++;
      Int y=x[p]/2;
      if(y<=l) return res=dfs(l-y,r-y);
      return res=add(dfs(l,y),dfs(0,r-y));
    };
  
  print(dfs(l,r));
  return 0;
}


Measured memory_bytes: 100696
N = int(input())
A = [0]*N
B = [0]*N
C = [0]*N
for i in range(N):
    A[i],B[i],C[i] =  [int(x) for x in input().split()]
dp = [[0 for _ in range(3)] for _ in range(N)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+A[i],dp[i-1][2]+A[i])
    dp[i][1] = max(dp[i-1][0]+B[i],dp[i-1][2]+B[i])
    dp[i][2] = max(dp[i-1][1]+C[i],dp[i-1][0]+C[i])
print(max(dp[-1][0],dp[-1][1],dp[-1][2]))


Measured memory_bytes: 64216
#!/usr/bin/env python3

def main():
    N = list(map(int, open(0).read().split()))
    
    N_value = N[0]
    S = sum(list(map(int, str(N_value))))
    if N_value % S == 0:
        print("Yes")
    else:
        print("No")


main()

Measured memory_bytes: 2940
N, M = list(map(int, input().split()))
if N - M >= 2 or M - N >= 2:
	print(0)
else:
	if N == M:
		n = 1
		for i in range(N):
			n = (n * (i + 1)) % 1000000007
		n = (n ** 2) % 1000000007
		n = (2 * n) % 1000000007
		print(n)

	elif N - M == 1:
		n = 1
		for i in range(M):
			n = (n * (i + 1)) % 1000000007
		n = (n ** 2) % 1000000007
		n = (n * N) % 1000000007
		print(n)
	else:
		n = 1
		for i in range(N):
			n = (n * (i + 1)) % 1000000007
		n = (n ** 2) % 1000000007
		n = (n * M) % 1000000007
		print(n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 10010;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
long long h;
long long abc(long long i)
{
	if(i==1)return 1;
	return 2*abc(i/2)+1;
}
signed main()
{
	h = read();
	printf("%lld",abc(h));
	return 0;
}

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

def f(i, j):
    if len(list(str(i))) <= len(list(str(j))):
        return len(list(str(j)))
    else:
        return len(list(str(i)))


def main():
    n = int(input())

    min_degit = float('inf')
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            degit = f(n // i, i)
            if min_degit > degit:
                min_degit = degit
    print(min_degit)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import math
a,b=map(int,input().split())
ast=math.ceil(a*12.5)
aend=math.ceil((a+1)*12.5)-1
bst=b*10
bend=(b+1)*10-1
flag=0
for i in range(bst,bend+1):
    if ast<=i<=aend:
        print(i)
        flag=1
        break
if flag==0:
    print(-1)

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

int H[100];

int main(void){
    int N;

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &H[i]);
    }

    int ans = 1;
    int mx = H[0];
    for(int i = 1; i < N; i++){
        if(mx <= H[i]){
            ans++;
            mx = H[i];
        }
    }

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


Measured memory_bytes: 760
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define N            1000000//31630=sqrt(pow(10,9))
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
//bool pf[N+1ll];
//vec prim;
//void sieve()
//{
//    repi(i,0,N)
//    pf[i]=true;
//	pf[0] = pf[1] = false;
//    for (int i = 2; i <= N; i++) {
//        if (pf[i]) 
//		{
//            prim.push_back(i);
//            for (int j = i + i; j <= N; j+=i) {
//                pf[j] = false;
//            }
//        }
//    }
//}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll m;
    	cin>>m;
    	cout<<fixed<<setprecision(5);
    	lld k=3.14159;
    	k=k*(2.00)*(m*1.00);
    	cout<<k;
	}
	return 0;
} 

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int plan1 = A * N;
  int plan2 = B;
  if(plan1 < plan2){
  	cout << plan1 << endl;
  }else{
  	cout << plan2 << endl;
  }
}

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

int main() {
    string s, ans = "1";
    ll k;
    cin >> s >> k;
    rep(i, k) {
        if (i == s.size()) break;
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
hlst = list(map(int, input().split()))
inf = 10 ** 10
dp = [inf for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j < 0:
            break
        dp[i] = min(dp[i - j] + abs(hlst[i] - hlst[i - j]), dp[i])
print(dp[-1])

Measured memory_bytes: 89924
#include <bits/stdc++.h>
using namespace std;
int util(const vector<vector<int>> & v,vector<vector<int>> & dp,int n,int p)
{
    if(n==0)
    return 0;
    
    if(dp[p][n]!=-1)
    
    return dp[p][n];
    
    
    for(int i=1;i<=3;i++)
    {
        if(i==p)
        continue;
        
        dp[p][n]=max(dp[p][n],util(v,dp,n-1,i)+v[n-1][i-1]);
    }
    
    return dp[p][n];
}

int main() {
	int n;
	cin>>n;
	
	vector<vector<int>> v(n,vector<int>(3,0));
	
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    cin>>v[i][j];
	}
	int p=0;
	vector<vector<int>> dp(4,vector<int>(n+1,-1));
	util(v,dp,n,p);
	
	cout<<util(v,dp,n,p);
	return 0;
}

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, i, j, dap=0, dp[10000001]={0, 1}, sosu[10000001]={1, 1}, soinsu[10000001]={};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        j=n/i;
        dap+=i*j*(j+1)/2;
    }
    cout<<dap;
}

Measured memory_bytes: 3636
# クッキー枚数（A,B）を整数で入力
A,B = map(int,input().split())
# AかBかA+Bのどれかを3匹に分けれればPossible、できなければImpossible
if A%3==0 or B%3==0 or (A+B)%3==0:
    print("Possible")
else:
    print("Impossible")

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;

void solve(string S) {
    long long ans = 0;
    long long b = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'W') ans += b;
        b += S[i] == 'B';
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    string S;
    cin >> S;
    solve(S);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 788
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n, m;
  int ans = 0;

  cin >> n >> m;
  vi x(n), y(n), z(n);
  REP(i, n) {
    cin >> x[i] >> y[i] >> z[i];
  }
  REP(b, 1 << 3) {
    bool xm = b & 1, ym = b & 2, zm = b & 4;
    vi v(n);
    REP(i, n) {
      v[i] = (xm ? x[i] : -x[i]) + (ym ? y[i] : -y[i]) + (zm ? z[i] : -z[i]);
    }
    RSORT(v);
    int s = 0;
    REP(i, m) {
      s += v[i];
    }
    ans = max(ans, s);
  }

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MAX_DIGIT = 50;
long long dp[100][2]; // dp[上から i 桁まで][ smaller ]

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
    
  memset(dp, -1, sizeof(dp)); // DP 配列を -1 で初期化
  dp[0][0] = 0; // 初期条件
  for (int d = 0; d < MAX_DIGIT; ++d) {
    long long mask = 1LL<<(MAX_DIGIT - d - 1);
        
    // A で元々 d 桁目にビットが立っているものの個数
    int num = 0;
    for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
        
    // X の d 桁目を 0, 1 にしたときのコスト
    long long cost0 = mask * num;
    long long cost1 = mask * (N - num);
        
    // smaller -> smaller
    if (dp[d][1] != -1) {
      chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0 でも 1 でも自在に大きい方
    }
        
    // exact -> smaller
    if (dp[d][0] != -1) {
      if (K & mask) { // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
        chmax(dp[d+1][1], dp[d][0] + cost0);
      }
    }
        
    // exact -> exact (K にぴったり合わせる)
    if (dp[d][0] != -1) {
      if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
      else chmax(dp[d+1][0], dp[d][0] + cost0);
    }
  }
  cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

double solve(double a, double b, double x) {
  double ok = 0, ng = 90;
  for (int i = 0; abs(ok - ng) >= 1e-9 && i < 100; ++i) {
    double m = (ok + ng) / 2;
    double t = m * M_PI / 180;
    double h = a * tan(t);

    double y;
    if (h > b) {
      y = a * b * b / tan(t) / 2;
    } else {
      y = (b - h) * a * a + a * a * h * 0.5;
    }

    if (y > x) {
      ok = m;
    } else {
      ng = m;
    }
  }
  return ok;
}

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  printf("%.15f\n", solve(a, b, x));
  return 0;
}


Measured memory_bytes: 384
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
x,y = map(int, listA[0])
l1 = listA[1][1:]
la = []
for a in l1:
  if x == 1:
    la.extend(l1)
    break
  b = True
  for lr in listA[2:]:
    if lr[1:].count(a) == 0:
      b=False
      break
  if b:
    la.append(a)


print(len(la))

Measured memory_bytes: 3064
from collections import deque
import collections
import math
import sys

n, m = map(int, input().split())

def bfs(i, ans):
    d = deque()
    ans[i] = 0
    d.append(i)
    while len(d) > 0:
        v = d.popleft()
        for node in table[v]:
            if ans[node] == -1:
                ans[node] = v
                d.append(node)
    return ans


table = [[] for j in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    table[a-1].append(b-1)
    table[b-1].append(a-1)
ans = [-1 for i in range(n)]

ans = bfs(0, ans)

if -1 in ans:
    print('No')
else:
    print('Yes')
    for a in ans[1:]:
        print(a+1)

Measured memory_bytes: 34724
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int a[] = new int[4];
		int b[] = new int[4];
		while(scan.hasNext()){
			for(int i = 0;i < 4;i++){
				a[i] = Integer.parseInt(scan.next()); 
			}
			for(int i = 0;i < 4;i++){
				b[i] = Integer.parseInt(scan.next());
			}
			int hit = 0,blow = 0;
			for(int i = 0;i < 4;i++){
				for(int j = 0;j < 4;j++){
					if(a[i] == b[j]){
						if(i == j){
							hit++;
						}else{
							blow++;
						}
					}
				}
			}
			System.out.println(hit + " " + blow);
		}
		System.exit(0);
	}

}

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

int main(){
    int N, K;
    cin >> N;
    cin >> K;
    vector<int> v1;
    vector<int> v2;

    for(int i = 0;i < N; i++){
        v1.push_back((K + i + 1) - N);
        cout << v1[i] << endl;
    }

    for(int j = 0;j < N - 1; j++){
        v2.push_back(K + j + 1);
        cout << v2[j] << endl;
    }

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  sort(all(s));
  
  if(s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3616
import java.util.*



fun main(args: Array<String>?): Unit {
    val (v, e) = readLine()!!.trim().split(' ').map(String::toInt)
    val color = IntArray(v){-1}
    val nodes = Array(v){Stack<Int>()}
    repeat(e){
        val (a, b) = readLine()!!.trim().split( ' ').map(String::toInt)
        nodes[a - 1].push(b - 1)
        nodes[b - 1].push(a - 1)
    }
    val networks = ArrayList<Int>()
    for (i in 0 until v) {
        if (color[i] == -1) {
            var diff = 1
            color[i] = 0
            val stack = Stack<Int>().also { it.push(i) }
            while (stack.isNotEmpty()) {
                val top = stack.pop()
                for (next in nodes[top]) if (color[next] == -1) {
                    color[next] = (color[top] + 1) % 2
                    if (color[next] % 2 == 0) ++diff
                    else --diff
                    stack.push(next)
                }else if (color[next] == color[top]) {
                    println(-1)
                    return
                }
            }
            networks.add(Math.abs(diff))
        }
    }
    val sum = networks.sum()
    val canMake = BooleanArray(sum / 2 + 1){false}.also{it[0] = true}
    for (s in networks) {
        for (i in canMake.lastIndex - s downTo 0) if (canMake[i]) {
            canMake[i + s] = true
        }
    }
    val minDiff = canMake.lastIndex - canMake.lastIndexOf(true)
    val side = v.toLong() / 2 - minDiff
    println(side * (v - side) - e)
}


Measured memory_bytes: 97444
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

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

	int n;
	cin >> n;

	set<int> s;

	for (int a, i = 0; i < n; ++i) {
		cin >> a;
		if (s.find(a) != s.end()) 
			s.erase(a);
		else
			s.insert(a);
	}

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

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
  int a[10];
  vector<int>m;

  for(int i=0; i<10; i++)
  {
    cin>>a[i];
    m.push_back(a[i]);
  }

  sort(m.begin(),m.end(),greater<int>());

  for(int i=0; i<3; i++)
  {
    cout<<m[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

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

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    int x,y;
    cin >> x >> y;
    if((x+y) %3 != 0){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    int m = (2*x-y)/3;
    int n = (2*y-x)/3;
    cout << COM(n+m,n) << endl;
    return 0;
}


Measured memory_bytes: 23680
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    string S;
    cin>>S;
    sort(S.begin(),S.end());
    bool ans=false;
    if(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2]) ans=true;
    cout<<(ans?"Yes":"No")<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define eps 1e-6
int main(){
	LL a,b,c;
	double d;
	scanf("%lld%lf",&a,&d);
	d+=eps;//此句很关键
	b=d*100;
	c=a*b/100;
	printf("%lld\n",c);
}

Measured memory_bytes: 1752
#include<stdio.h>

void bubbleSort(int A[],int N){
  int j,i,v,k,flag,cnt=0;
  flag = 1;
  for(i=0; i< N-1 ; i++){
    for(j=N-1 ; j > i;j--){
      if(A[j] < A[j-1]){
	v=A[j - 1];
	A[j-1]=A[j];
	A[j]=v;
	cnt++;
      }
    }
	
  }
   for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k<N-1)printf(" ");
      else printf("\n");
    }
   printf("%d\n",cnt);
}

int main(){
  int N, i;
  int A[100];
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  bubbleSort(A,N);
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  long result = 0;
  for (int a = 0; a < N-2; a++) {
    for (int b = a+1; b < N-1; b++) {
      int tmp = L[a] + L[b];
      int c = b+1;
      while (c < N && L[c] < tmp) c++;
      result += c-(b+1);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int n,ans=0,t;
signed main(){
	//cin>>t; 
	//while(t--){
	cin>>n>>s;
	int a=0,b=n-1;
	while(a<b){
	//	cout<<a<<"v"<<b<<endl;
		if(s[a]=='R'&&s[b]=='W'){a++;b--;continue;
		}
		if(s[a]=='R'){a++;continue;
		}
		if(s[b]=='W'){
			b--;continue;
		}
		ans++;a++;b--;
	}
	cout<<ans<<endl;ans=0;
	//}
	return 0;
}

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

int main() {
	int  x, n,i,ans=1,sum=0;
	cin >> n >> x;
	vector<int> a(n,0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (x >=sum) {
			ans++;
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef map<int, int> MI;
typedef set<int> SI;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int n, m; cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(10, 0));
    vector<int> p(m);
    rep(i, m) {
        int k; cin >> k;
        rep(j, k) cin >> s[i][j];
    }
    rep(i, m) cin >> p[i];

    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++) {
        int flg = 1;
        for(int i = 0; i < m; i++) {
            int cnt = 0;
            for(int j = 0; j < s[i].size(); j++) {
                if(bit & (1<<s[i][j])) cnt++;
            }
            if(cnt % 2 != p[i]) flg = 0;
        }
        if(flg) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# 2019/09/27

from collections import Counter
s=input()
n=len(s)
c=Counter(s)

res=c.values()
if len(res)<3:
    if n==len(res):
        print('YES')
    else:print('NO')
    exit()


if max(res)-min(res)>1 :
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3444
def main():
    N, K = list(map(int, input().split()))
    ans = 0
    for i in range(1, N+1):
        times = 0
        while(1):
            if (i * pow(2, times) >= K): break
            times += 1
        ans += (1.0/N) * pow(0.5, times)

    print(ans)

main()


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

#define pb push_back
#define se second
#define fi first

using namespace std;

typedef long long ll;

int a, b, cnt = 1, ans;

int main(){
    cin >> a >> b;
    while(cnt < b){
        cnt += a - 1;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long i, ans=0;
    bool anine=true;
    string n;
    cin >> n;
    for(i=0;i<n.size();i++){
        if(i==0) ans+=n[i]-'0'-1;
        else ans+=9;
        if(n[i]!='9' && i!=0) anine=false;
    }
    if(n.size()==1){
        ans=n[0]-'0';
    }
    if(anine && n.size()!=1){
        ans++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3604
var
    sa,sb:array[0..101] of longint;
    n,i,a,max:longint;
begin
    readln(n);
    sa[0]:=0; sb[0]:=0; max:=0;
    for i:=1 to n do
    begin
        read(a);
        sa[i]:=sa[i-1]+a;
    end;
    for i:=1 to n do
    begin
        read(a);
        sb[i]:=sb[i-1]+a;
    end;
    for i:=1 to n do
        if max<sa[i]+sb[n]-sb[i-1] then
            max:=sa[i]+sb[n]-sb[i-1];
    writeln(max);
end.

Measured memory_bytes: 128
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
c1=input()
c2=input()
for i in range(3):
  if c1[2-i]!=c2[i]:
    print("NO")
    break
else:
  print("YES")

Measured memory_bytes: 65240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=l;i<r;i++)
using ll=long long;
const ll MOD=1000000007;
const ll MAX=1100000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    repl(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k)return 0;
    if(n<0 or k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll modpow(long long a, long long n) {
    ll res = 1;
    while(n>0){
        if (n & 1)res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}
int main(){
    ll N,a,b;cin>>N>>a>>b;
    COMinit();
    ll ans=modpow(2,N);
    ll A=1,B=1;
    rep(i,a){
        A*=(N-i);
        A%=MOD;
    }
    rep(i,b){
        B*=(N-i);
        B%=MOD;
    }
    
    ans+=MOD-(A*finv[a]%MOD+B*finv[b]%MOD+1)%MOD;
    ans%=MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 25984
#include <iostream>

using namespace std;

int main() {

	int N;
	int bin[7] = { 1,2,4,8,16,32,64 };
	cin >> N;

	for (int i = 0; i < 7; i++) {
		if (N == bin[i]) {
			cout << bin[i] << endl;
			break;
		}
		else if (N < bin[i]) {
			cout << bin[i - 1] << endl;
			break;
		}
		else if (i == 6)
			cout << "64" << endl;
	}

}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    print(chr(ord(S)+1))
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <cassert>
#include <iostream>
#include <string>

bool IsValid(const std::string& Text)
{
    return 
        Text.find("the")  != std::string::npos ||
        Text.find("this") != std::string::npos ||
        Text.find("that") != std::string::npos;
}
std::string RotateChar(const std::string& Code, int Key)
{
    std::string Text = Code;
    for(std::size_t i = 0; i < Text.size(); ++i){
        if(Text[i] == ','
        || Text[i] == '.'
        || Text[i] == ' '){
            continue;
        }
        int c = Text[i] + Key;
        if(c < 'a') c += 26;
        if(c > 'z') c -= 26;
        Text[i] = c;
    }
    return Text;
}
std::string Decrypt(const std::string& Code)
{
    for(int i = 0; i < 26; ++i){
        std::string Text = RotateChar(Code, i);
        if(IsValid(Text)){
            return Text;
        }
    }
    assert(false);
    return "";
}
int main()
{
    while(true){
        std::string Code;
        std::getline(std::cin, Code);
        if(std::cin.eof()) break;
        std::cout << Decrypt(Code) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	long long int n,t;
	vector<long long int> v;
	long long int total=0;
 
	int now=0;
 
	cin>>n>>t;
 
 
	for(int i=0;i<n;i++){
		long long int tmp;
		cin>>tmp;
		v.push_back(tmp);
	}
	now=v[0];
 
	for(int i=1;i<n;i++){
		int a=min(t,v[i]-v[i-1]);
		total+=a;
	}
	total+=t;
	cout<<total<<endl;
 
	
 
	return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner kb = new Scanner( System.in);   
         
        while( true ) {
            int H = kb.nextInt();
            int W = kb.nextInt();
             
            if( 0==W && 0==H ) { break; }
             
            boolean cPattern=true;
            for( int i=0; i<H; i++ ) {
                cPattern= (0==(i&1))? true: false;
                for( int j=0; j<W; j++ ) {
                    if( cPattern ) {
                        System.out.print( "#" );
                        cPattern=!cPattern;
                    } else {
                        System.out.print( "." );
                        cPattern=!cPattern;
                    }
                }
                System.out.print( "\n" );
            }
            System.out.print( "\n" );
        }
    }
}

Measured memory_bytes: 31936
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define mem(i,j) memset(i,j,sizeof i);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define bit(s,i) (((s)>>(i))&1LL)
#define lowbit(x) (x&-x)
#define siz(v) (long long)v.size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

int main() {
    EmiliaMyWife

    int n, a;
    cin >> n;
    vector<int> can;
    map<int, int> now;
    for(int i = 0; i < n; i++) {
        cin >> a;
        now[a]++;
        if(now[a]>1) {
            can.pb(a);
            now[a]=0;
        }
    }
    if(can.size()>1) {
        sort(all(can), greater<int>());
        cout << 1LL*can[0]*can[1];
    }
    else cout << 0;

	return 0;
}


Measured memory_bytes: 4992
#ifndef ___CLASS_MODINT
#define ___CLASS_MODINT

#include <cstdint>

template<std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::uint64_t n_) : n(n_ % mod) {};
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	std::uint32_t get() const { return n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint binpow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
	modint inv() { return (*this).binpow(mod - 2); }
};

#endif // ___CLASS_MODINT

#include <vector>
#include <iostream>
#include <functional>
using namespace std;
const int mod = 1000000007;
using modulo = modint<mod>;
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<modulo> fact(H + W + 1), inv(H + W + 1), factinv(H + W + 1);
	fact[0] = 1; inv[1] = 1; factinv[0] = 1;
	for (int i = 1; i <= H + W; ++i) fact[i] = fact[i - 1] * i;
	for (int i = 2; i <= H + W; ++i) inv[i] = inv[mod % i] * (mod - mod / i);
	for (int i = 1; i <= H + W; ++i) factinv[i] = factinv[i - 1] * inv[i];
	function<modulo(int, int)> comb = [&](int n, int k) {
		if (k < 0 || n < k) return modulo(0);
		return fact[n] * factinv[k] * factinv[n - k];
	};
	if (K >= 2) {
		modulo ans = 0;
		for (int i = 0; i <= H - 1; ++i) {
			int t = (K - 2) - i;
			if (0 <= t && t <= W - 1) {
				modulo sub = comb(H - 1, i) * comb(W - 1, t);
				ans += sub;
			}
		}
		ans *= modulo(2) * modulo(H) * modulo(W) * fact[K - 2];
		modulo all = 0;
		for (int i = 0; i <= H; ++i) {
			int t = K - i;
			if (0 <= t && t <= W) {
				modulo sub = comb(H, i) * comb(W, t);
				all += sub;
			}
		}
		all *= fact[K];
		modulo coeff = 0, addi = 0;
		for (int i = 1; i <= K; ++i) {
			coeff += modulo(i - 1) * modulo(K - i + 1);
			addi += modulo(i + 1);
		}
		modulo final_ans = ans * coeff + addi * all;
		cout << final_ans.get() << endl;
	}
	else {
		cout << modulo(2 * (H + W)).get() << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    string s;
    cin>>s;
    string res ="";
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='0')   res +='0';
        else if(s[i]=='1')  res += '1';
        else if(s[i]=='B'){
            if(res.length()>0) 
                res.pop_back();
            else 
                continue;
        }
        //cout<<res<<endl;
    }

    cout<<res<<endl;
    return 0;
}



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


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

  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll x=0;
  for(int i=41; i>=0; i--){
    int co=0;
    int cz=0;
    rep(j,n){
      if((1LL<<i)&a[j]) cz++;
      else co++;
    }
    if(cz<co){
      ll xt=x|(1LL<<i);
      if(xt<=k){         //ｘがｋより大きくなるかチェック
	    x|=(1LL<<i);
      }
    }
  }
  ll ans=0;
  rep(i,n){
    ans+=x^a[i]; 
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1024
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int h;
        cin >> h;

        int x = 0, c = 1;
        while(h)
        {
            x += c;
            c *= 2;
            h /= 2;
        }

        cout << x << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

int main(void){

    int H,W;
    cin>>H>>W;

    int A[W],B[H];
    for(int i=0;i<W;i++){
        A[i]=1;
    }

    string C[H];
    for(int i=0;i<H;i++){
        B[i]=1;
        cin>>C[i];

    }
    
    for (int w=0; w<W; w++) {
        for (int h=0; h<H; h++) {
            if (C[h][w] == '#') {
                A[w] = 0;
                break;
            }
        }
    }

    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            if (C[h][w] == '#') {
                B[h] = 0;
                break;
            }
        }
    }
    
    for (int h=0; h<H; h++) {
        for (int w=0; w<W; w++) {
            if (A[w] == 0 && B[h] == 0) {
                cout << C[h][w];
            }
        }
        if (B[h] == 0) {
            cout << endl;
        }
    }
    
  

    // for (int i=0;i<H;i++){  
       

    //     int N=0;
    //     for(int j=0;j<W;j++){
            
    //         if(C[i][j]=='.'){
    //             N=N+1;
    //             A[j]=A[j]+1;
    //         }
    //     }
    //     if(N==W){
    //         B[i]=1;
    //     }
        
    // }
    
    // for(int i=0;i<H;i++){

    //     if(B[i]==0){
    //         int outputted = 0;
    //         for(int j=0;j<W;j++){
    //             if(A[j]!=W){
    //                 cout<<C[i][j];
    //                 outputted = 1;
    //             }
    //         }
    //         if (outputted  > 0) {
    //             cout << endl;
    //         }

    //     }
    // }
    // cout<<endl;

    return 0;
}

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

using namespace std;

// xのn乗のmodでのmodを返す

long long int modpow(long long int x,long long int n,long long int mod){
    long long int res = 1;
    while(n>0){
        if(n&1){
            res = (res*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    long long n,a,b,ans,suba=1,subb=1,div=1;
    cin >> n >> a >> b;
    ans = modpow(2,n,1000000007);

    for(int i=0;i<a;i++){
        suba *= n-i;
        div *= a-i;
        suba %= 1000000007;
        div %= 1000000007;
    }

    suba *= modpow(div,1000000005,1000000007);
    suba %= 1000000007;

    div = 1;
        
     for(int i=0;i<b;i++){
        subb *= n-i;
        div *= b-i;
        subb %= 1000000007;
        div %= 1000000007;
    }

    subb *= modpow(div,1000000005,1000000007);
    subb %= 1000000007;

    if(n==2){
        cout << 0 << endl;
    }else{
        cout << (ans-suba-subb-1+2000000014)%1000000007 << endl;
    }
}

Measured memory_bytes: 256
//Counter-Clockwise
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    return s.p1 + (base * (dot(base, p - s.p1) / base.norm()));
}

Point reflect(Segment s, Point p) {
    return p + (project(s, p) - p) * 2;
}

enum {
    COUNTER_CLOCKWISE,
    CLOCKWISE,
    ONLINE_BACK,
    ONLINE_FRONT,
    ON_SEGMENT
};

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > ESP) return COUNTER_CLOCKWISE;
    else if (cross(a, b) < -ESP) return CLOCKWISE;
    else if (dot(a, b) < -ESP) return ONLINE_BACK;
    else if (a.norm() < b.norm()) return ONLINE_FRONT;
    else return ON_SEGMENT;
}

int main() {
    int q;
    double x0, y0, x1, y1, x2, y2;
    cin >> x0 >> y0 >> x1 >> y1 >> q;
    Point p0 = Point(x0, y0), p1 = Point(x1, y1);
    for(int i = 0; i < q; i++) {
        cin >> x2 >> y2;
        Point p2 = Point(x2, y2);
        switch(ccw(p0, p1, p2)) {
            case COUNTER_CLOCKWISE:
                cout << "COUNTER_CLOCKWISE" << endl;
                break;
            case CLOCKWISE:
                cout << "CLOCKWISE" << endl;
                break;
            case ONLINE_BACK:
                cout << "ONLINE_BACK" << endl;
                break;
            case ONLINE_FRONT:
                cout << "ONLINE_FRONT" << endl;
                break;
            case ON_SEGMENT:
                cout << "ON_SEGMENT" << endl;
                break;
            default:
                break;
        }
    }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    ll k; cin >> k;
    vector<ll> as_sum = {0};
    REP(i, n){
        ll a; cin >> a;
        as_sum.push_back(as_sum[i] + a);
    }
    vector<ll> bs_sum = {0};
    REP(i, m){
        ll b; cin >> b;
        bs_sum.push_back(bs_sum[i] + b);
    }
    ll ans = 0;
    ll as_idx = n;
    REP(bs_idx, m+1){
        while(as_sum[as_idx] + bs_sum[bs_idx] > k){
            as_idx--;
            if (as_idx < 0){
                cout << ans << endl;
                return 0;
            }
        }
        ans = max(ans, as_idx + bs_idx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7984
def comb(n, k, mod):
  r = min(k, n-k)
  p = q = 1
  for i in range(r):
    p = p*(n-i)%mod
    q = q*(i+1)%mod
  return p*pow(q, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = (10**9+7)
ans = (pow(2, n, mod)-comb(n, a, mod)-comb(n, b, mod)-1)%mod
print(ans)

Measured memory_bytes: 3064
import java.util.*;

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

    int n = scan.nextInt();
    int[] b = new int[n];
    int[] c = new int[n];
    for (int i=0 ;i<n; i++){
      int t = scan.nextInt();
      b[i] = t;
      c[i] = t;
    }

    Arrays.sort(c);
    if (n == 1){
      System.out.println(c[0]);
      return;
    }
    for (int j=0;j<n;j++){
      if (b[j] != c[n-1]){
        System.out.println(c[n-1]);
      }
      else{
        System.out.println(c[n-2]);
      }
    }
  }
}


Measured memory_bytes: 72768
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}Point;

void koch(int,Point,Point);
void zahyou(Point,Point,Point,Point,Point);
void print(Point);


int main()
{
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  print(a);
  koch(n,a,b);
  print(b);

  return 0;
}

void koch(int d,Point p1,Point p2)
{
  Point s,t,u;
  double th;

  
  if(d==0) return;

  th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;

  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x; 
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(d-1,p1,s);
  print(s);
  koch(d-1,s,u);
  print(u);
  koch(d-1,u,t);
  print(t);
  koch(d-1,t,p2);
}


void print(Point p)
{
  printf("%.8f %.8f\n",p.x,p.y);
}
  



Measured memory_bytes: 1968