akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    int m=sqrt(n);
    for(int i = 1; i < m; i++) {
        for(int j = 1; j < m; j++) {
            for(int k = 1; k < m; k++) {
                if(i*i+j*j+k*k+i*j+j*k+k*i<=n){
                    ans[i*i+j*j+k*k+i*j+j*k+k*i-1]++;                      
                }
            }
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <vector>
#include <iostream>

#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int mod=1'000'000'007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);

  rep(i,n) cin >> a[i];
  ll ans = 0;
  ll sum = 0;
  rep(i,n) {
    ans = (ans + a[i] * sum) % mod;
    sum = (sum+ a[i]) % mod;  
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define MOD 1000000007

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int q = ri();
	std::string s[n];
	for (int i = 0; i < n; i++) std::cin >> s[i];
	
	std::vector<std::vector<int> > k(n + 1, std::vector<int>(m + 1));
	std::vector<std::vector<int> > yok(n, std::vector<int>(m + 1));
	std::vector<std::vector<int> > tat(n + 1, std::vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '1') {
				k.at(i + 1).at(j + 1)++;
				if (i + 1 < n && s[i + 1][j] == '1') yok.at(i + 1).at(j + 1)++;
				if (j + 1 < m && s[i][j + 1] == '1') tat.at(i + 1).at(j + 1)++;
			}
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= m; j++) {
			k.at(i + 1).at(j) += k.at(i).at(j);
			if (j < m) tat.at(i + 1).at(j) += tat.at(i).at(j);
			if (i + 1 < n) yok[i + 1][j] += yok[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < m; j++) {
			k[i][j + 1] += k[i][j];
			if (i < n) yok[i][j + 1] += yok[i][j];
			if (j + 1 < m) tat[i][j + 1] += tat[i][j];
		}
	}
	for (int i = 0; i < q; i++) {
		int x1 = ri() - 1, y1 = ri() - 1, x2 = ri() - 1, y2 = ri() - 1;
		int res = k[x2 + 1][y2 + 1] - k[x2 + 1][y1] - k[x1][y2 + 1] + k[x1][y1];
		res -= yok[x2][y2 + 1] - yok[x1][y2 + 1] - yok[x2][y1] + yok[x1][y1];
		res -= tat[x2 + 1][y2] - tat[x1][y2] - tat[x2 + 1][y1] + tat[x1][y1];
		std::cout << res << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 53544
/**
*    author:  boutarou
*    created: 09.06.2020 14:36:43
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const long long MOD = 1e9 + 7;
const long long INF = 3e18;
const double PI = 3.1415926535897932;

string s;

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

	cin >> s;
	if (s.size() % 2 ==0) {
		if (s[0] == s[s.size() - 1]) {
			cout << "First" << endl;
		}
		else {
			cout << "Second" << endl;
		}
	}
	else {
		if (s[0] == s[s.size() - 1]) {
			cout << "Second" << endl;
		}
		else {
			cout << "First" << endl;
		}
	}

	return 0;
}

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

int main(){
    int A[3][3];
    int B;
    bool mark[3][3]={0};
    string ans="No";
    int i,j,k;
    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;

    for(k=0; k<N; k++){
        cin >> B;
        for(i=0; i<3; i++){
            for(j=0; j<3; j++){
                if(A[i][j]==B) mark[i][j]=1;
            }
        }
    }

    for(i=0; i<3; i++){
        if(mark[i][0]==1 && mark[i][1]==1 && mark[i][2]==1) ans="Yes";
        if(mark[0][i]==1 && mark[1][i]==1 && mark[2][i]==1) ans="Yes";
    }
    if(mark[0][0]==1 && mark[1][1]==1 && mark[2][2]==1) ans="Yes";
    if(mark[0][2]==1 && mark[1][1]==1 && mark[2][0]==1) ans="Yes";    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
const main = input => {
  const mod = 2019
  let s = input.trim().split('')
  let ln = s.length
  
  let ms = new Array(ln+1).fill(0)
  let cr = 1
  for(let i = ln-1; 0 <= i; i--) {
    ms[i] = (ms[i+1] + cr*Number(s[i])) % mod
    cr = (cr*10) % mod
  }
  
  let cnt = new Array(mod).fill(0)
  ms.forEach(v => cnt[v] += 1)
  let ans = 0
  cnt.forEach(v => {if(v >= 2) ans += v*(v-1)/2})
  console.log(ans.toString())
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

long long int gcd( long long int n, long long int m ) {
	if( n < m ) {
		return gcd( m, n );
	}
	if( m == 0 ) {
		return n;
	} else {
		return gcd( m, n%m );
	}
}

long long int lcm( long long int n, long long int m ) {
	return n*m / gcd( n, m );
}



int main() {
	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a;
	for( size_t i = 0; i < n - 1; i++ ) {
		cin >> b;
		a = lcm( a, b );
	}
	cout << a << endl;
}

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	int n;
	int a[101];
	int count[9] = {};
	int mini = 0, maxi = 0;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
		if (a[i] <= 399) {
			count[0]++;
		}else if (a[i] <= 799) {
			count[1]++;
		}
		else if (a[i] <= 1199) {
			count[2]++;
		}
		else if (a[i] <= 1599) {
			count[3]++;
		}
		else if (a[i] <= 1999) {
			count[4]++;
		}
		else if (a[i] <= 2399) {
			count[5]++;
		}
		else if (a[i] <= 2799) {
			count[6]++;
		}
		else if (a[i] <= 3199) {
			count[7]++;
		}
		else{
			count[8]++;
		}
	}
	FOR(i, 0, 7) {
		if (count[i] != 0) {
			mini++;
		}
	}
	if (mini == 0) {
		cout << 1 << " " << endl;
	}
	else {
		cout << mini << " " << endl;
	}

	
		maxi = mini + count[8];
	

	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool f = false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j == n) f = true;
        }
    }
    cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ){
    int n, i, j, flag, m, count;
    scanf("%d", &n);
    int A[n];
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    flag = 1;
    i = 0;
	count = 0;
    while(flag == 1){
        flag = 0;
        for(j = n - 1; j >= i + 1; j--){
            if(A[j] < A[j - 1]){
                m = A[j];
                A[j] = A[j - 1];
                A[j - 1] = m;
                flag = 1;
                count++;
            }
        }
        i++;
    }
    for(i = 0; i < n; i++){
        printf("%d", A[i]);
        if(i < n - 1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 2092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
bool F[400][400];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N) rep(j, N) F[i][j] = true;
  rep(_, M) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (F[x][y]) {
      F[x][y] = F[y][x] = false;
      rep(k, N) {
        if (k == x || k == y) continue;
        if (!F[y][k]) F[x][k] = F[k][x] = false;
      }
      rep(k, N) {
        if (k == x || k == y) continue;
        if (!F[x][k]) F[y][k] = F[k][y] = false;
      }
    }
    else {
      rep(k, N) F[y][k] = F[k][y] = false;
      rep(k, N) F[x][k] = F[k][x] = false;
    }
  }
  int ctr = 0;
  rep(i, N) rep(j, i) ctr += F[i][j];
  cout << ctr << "\n";
  return 0;
}


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

string s, t;
vector<long long> v[1000];
long long ans = -1;
long long n;

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

	cin >> s;
	cin >> t;

	n = s.size();

	for(long long i=0; i<n; i++) {
		v[s[i] - 'a'].push_back(i);
	}

	for(long long i=0; i<t.size(); i++) {
		long long c = t[i] - 'a';

		if(v[c].size() == 0) {
			cout << -1;
			return 0;
		}

		vector<long long>::iterator it = upper_bound(v[c].begin(), v[c].end(), ans % n);
		if(it != v[c].end()) {
			ans = *it + ans / n * n;
		}
		else {
			it = upper_bound(v[c].begin(), v[c].end(), ans % n - n);
			ans = *it + ans / n * n + n;
		}
	}

	cout << ans+1;
}

Measured memory_bytes: 1736
from collections import Counter
N = int(input())
c1 = Counter([int(_) for _ in input().split()])
M = int(input())
c2 = Counter([int(_) for _ in input().split()])
for a,b in c2.items():
    if c1[a]<b:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 122960
#include<cstdio>
#include<vector>
using namespace std;
int answer,num;
long long dp[2][21];
vector<int> number;
void Input()
{
	scanf("%d",&num);
	for(int f1=0;f1<num-1;f1++){
		int ibuf;
		scanf("%d",&ibuf);
		number.push_back(ibuf);
	}
	scanf("%d",&answer);
}
int main(void)
{
	Input();
	int flg=0;
	dp[0][number[0]]=1;
	for(int f1=1;f1<(int)number.size();f1++){
		if(!flg){
			for(int f2=0;f2<21;f2++){
				if(f2+number[f1]<=20){
					dp[1][f2+number[f1]]+=dp[0][f2];
				}
				if(f2-number[f1]>=0){
					dp[1][f2-number[f1]]+=dp[0][f2];
				}
			}
		}
		else{
			for(int f2=0;f2<21;f2++){
				if(f2+number[f1]<=20){
					dp[0][f2+number[f1]]+=dp[1][f2];
				}
				if(f2-number[f1]>=0){
					dp[0][f2-number[f1]]+=dp[1][f2];
				}
			}
		}
		flg=!flg;
		for(int f2=0;f2<21;f2++){
			dp[!flg][f2]=0;
		}
	}
	printf("%lld\n",dp[flg][answer]);
	return 0;
}

Measured memory_bytes: 1052
"use strict";

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v);
  let prd = input[0] * input[1];
  let ans = prd % 2 === 0 ? "Even" : "Odd";
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import math
a,b,h,m = map(int,input().split())
t1 = 30*h + 0.5*m
t2 = 6*m
k = math.radians(min(abs(t1-t2),360-(abs(t1-t2))))
print(math.sqrt((a**2)+(b**2)-(2*a*b*(math.cos(k)))))

Measured memory_bytes: 9336
#include<iostream>
using namespace std;
int main(){
  int a,b,gTotal;
  cin >> a >> b;
  gTotal = 0;
  for(int i = 0; i <= 1; i++){
    if(a >= b){
      gTotal += a;
      a--;
    }else{
      gTotal += b;
      b--;
    }
  }
  cout << gTotal;
}  

Measured memory_bytes: 256
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int h,w,m;
  cin>>h>>w>>m;
  vector<map<int,int>> target(h);
  vector<int> row(h);
  map<int,int> col;
  rep(i,m){
    int hi,wi;
    cin>>hi>>wi;
    hi--;wi--;
    target[hi][wi]++;
    row[hi]++;
    col[wi]++;
  }
  int w_max = 0;
  for(auto&[wi,val]:col)chmax(w_max,val);
  vector<pll> a;
  for(auto&[wi,val]:col){
    if(val==w_max)a.emplace_back(wi,val);
  }

  /*
  ll colmax1=-1,colmax2=-1;
  ll col_i1=-1,col_i2=-1;
  for(auto&[wi,val]:col){
    if(val>colmax1){
      if(col_i2!=wi){
        colmax2 = colmax1;
        col_i2 = col_i1;
      }
      colmax1 = val;
      col_i1 = wi;
    }
    else if(val>colmax2 and wi!=col_i2){
      colmax2 = val;
      col_i2 = wi;
    }
  }
  */
  ll ans = 0;
  rep(hi,h){
    for(auto&[wi,val]:a){
      if(target[hi].count(wi)==0){
        chmax(ans,row[hi]+val);
        break;
      }else{
        chmax(ans,row[hi]+val-1);
      }
    }
  }
  cout<<(ans)<<endl;
  

}

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

using namespace std;

#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);

#define debug(x)        cerr << #x << '=' << x << endl;
#define debug2(x, y)    cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)      cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a)       cerr << #a << ":\n"; \
                        for (auto v: a) { for(const auto x: v) cerr << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

#define SIZE 1000000
vi primes;
bool isPrime[SIZE+1];

void sieve() {
	for (int i = 2; i <= SIZE; i++) {
		if (!isPrime[i]) {
			primes.push_back(i);
			for (int j = i; j <= SIZE; j +=i) {
				isPrime[j] = true;
			}
		}
	}
}

int32_t main()
{
	FAST_IO;
	sieve();
	int x;
	cin >> x;

	cout << *lower_bound(ALL(primes), x) << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 2424
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    s=input()
    t=input()
    count=len(t)
    temp=0
    for i in range(len(s)-len(t)+1):
        temp=0
        for j in range(len(t)):
            a=s[i+j]
            b=t[j]
            if s[i+j]!=t[j]:
                temp+=1
        count=min(temp,count)
    print(count)



if __name__ == "__main__":

    main()


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint n,k; cin>>n>>k;
	lint ans=0;
	for(int b=k+1;b<=n;b++){
		ans+=(b-k)*(n/b)+max(n%b-k+1,0LL);
	}
	if(k==0) ans-=n;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list()
name_dict = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', 6:'g', 7:'h', 8:'i', 9:'j', 10:'k', 11:'l', 12:'m', 13:'n', 14:'o', 15:'p', 16:'q', 17:'r', 18:'s', 19:'t', 20:'u', 21:'v', 22:'w', 23:'x', 24:'y', 25:'z'}
name = ''

while n != 0:
	n -= 1
	l.append(n%26)
	n = n//26

if l != []:
	for i in reversed(l):
		name += name_dict[i]

print(name)


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

int h, w;
char a[1005][1005];
int dp[1005][1005];


int f(int i, int j) {
    if(dp[i][j] != -1) return dp[i][j];
    if(i == h-1 and j == w-1) return 1;
    
    int x[] = {1, 0};
    int y[] = {0, 1};
    
    int ans = 0;
    for(int k = 0; k < 2; k++) {
        if(i+x[k] < h and j+y[k] < w and a[i+x[k]][j+y[k]] == '.') {
            // cout << i+x[k] << j+y[k];
            ans += f(i+x[k], j+y[k]);
        }
    }
    
    return dp[i][j] = ans%(1000000007);
}

int main() {
	// your code goes here
	cin >> h >> w;
	
	for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
	        cin >> a[i][j];
	    }
	}
	memset(dp, -1, sizeof dp);
	
	cout << f(0, 0);
	return 0;
}


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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int c=s[0]=='R', mx=s[0]=='R';
	for(int i=1; i<3; ++i) {
		if(s[i]=='R')
			++c;
		else
			mx=max(mx, c), c=0;
	}
	mx=max(mx, c);
	cout << mx << "\n";
}


Measured memory_bytes: 3648
n = gets.to_i
a = gets.split.map &:to_i
color = Array.new(9, 0)
a.each do |rate|
  rate = 3599 if rate >= 3600
  color[rate / 400] += 1
end
num = color.count {|col| col > 0}
if color[8] == 0 then
  min = num; max = num
else
  min = num == 1 ? 1 : num - 1
  max = num - 1 + color[8]
end
puts "#{min} #{max}"


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

int main() {
  int n;cin>>n;
  int d=0;
  while (pow(2,d) <= n) d++;
  cout << pow(2, d-1);
}


Measured memory_bytes: 256
//
// Created by たかえすみずき on 2017/07/15.
//

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

#define PRINT(s) cout << (s);
#define PRINTLN(s) cout << (s) << endl;

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if( a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

#pragma region DSL
class BITree{//1-index
	int N;
	vector<LL> bit;
public:
	BITree(int n){
		N = n;
		bit = vector<LL>(N+1,0);//1-index
	}
	void add(int a,LL w){//aにwを足す
		if( a <= 0 || N < a) return;//a:[1,N]
		for(int i=a;i<=N;i += i & -i){
			bit[i] += w;
		}
	}
	LL sum(int a){//[1,a]の和,a:[1,N]
		/*
		1番目からa番目までの和、1-index
		*/
		LL ret = 0;
		if( a > N ) a = N;
		for(int i=a; i > 0; i -= i & -i){
			ret += bit[i];
		}
		return ret;
	}
};
#pragma endregion //BIndexTree

void solve(){
	int N,M;
	cin >> N >> M;
	BITree bit(N+1);
	vector<int> A(N+1);
	vector<int> hist(N+1,0);
	vector<int> seg(N+1,0);
	for(int i=0;i<N;++i){
		cin >> A[i+1];
		int ter = A[i+1]-hist[A[i+1]];
		if( ter >= 1 ){
			seg[ ter ]++;
		}
		hist[ A[i+1] ]++;
	}
	for(int i=1;i<=N;++i){
		if( seg[i] ){
			bit.add(i,1);
		}
	}
	while(M--){
		int X,Y;
		cin >> X >> Y;
		hist[ A[X] ]--;
		int ter = A[X] - hist[ A[X] ];
		if( ter >= 1 ){
			seg[ ter ]--;
			if( seg[ ter ] == 0 ){
				bit.add( ter, -1);
			}
		}

		A[X] = Y;
		
		if( Y-hist[Y] >= 1 ){
			if( seg[ Y-hist[Y] ] == 0 ){
				bit.add( Y-hist[Y], 1);
			}
			seg[ Y-hist[Y] ]++;
		}
		hist[Y]++;
		int res = bit.sum(N);
		cout << N - res << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vvll digit(63,vll(2));
    ll a;
    rep(i,n){
        cin>>a;
        bitset<63> tmp(a);
        rep(i,63)digit[i][tmp[i]]++;
    }
    ll res=1;ll ans=0;
    rep(i,63){
        ans+=(((digit[i][0]*digit[i][1])%inf)*(res%inf))%inf;
        ans%=inf;
        res*=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int p[110][110];
int func(int* a, int* b)
{
    int i, j;
    for(i=0;b[i];++i) {
        for(j=0;a[j];++j) if (a[j]==b[i]) break;
        if (!a[j]) return 0;
    }
    return 1;
}
int main(void)
{
    int n;
    while (scanf("%d", &n), n) {
        int i, j, k, m, res, q[110]={0};
        memset(p, 0, sizeof(p));
        for(i=1;i<=n;++i) {
            scanf("%d", &m);
            for(j=0;j<m;++j) scanf("%d", &p[i][j]);
        }
        scanf("%d", &k);
        for(i=0;i<k;++i) scanf("%d", q+i);

        res=0;
        for(i=1;i<=n;++i) if (func(p[i], q)) res=!res ? i : -1;
        if (!res) res=-1;
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 652
import math

s = input().split(' ')
a = int(s[0])
b = int(s[1])
a1 = a / 0.08
a += 0.9999
a2 = a / 0.08
b1 = b / 0.1
b += 0.9999
b2 = b / 0.1

# print(a1, a2, b1, b2)
if a2 < b1 or b2 < a1:
    print(-1)
elif a1 >= b1:
    print(int(math.ceil(a1)))
else:
    print(int(math.ceil(b1)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a,b,f[N],c,d;
char s[N];
int find(int x){
	if (f[x]==x)return x;
	return f[x]=find(f[x]);
}
int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
/*	for (int i=1;i<=n;i++)f[i]=i;
	for (int i=1;i<n;i++)
		if (s[i]=='.'){
			if (s[i+1]=='.')f[find(i)]=find(i+1);
			if (s[i+2]=='.')f[find(i)]=find(i+2);
		}
	if (find(a)==find(c)&&find(b)==find(d))puts("Yes");
	else puts("No");	*/
	while (a!=c||b!=d){
		if (a>b){
			swap(a,b);
			swap(c,d);
		}
		if (a+1<=c&&a+1!=b&&s[a+1]=='.'){
			a++;
			continue;
		}
		if (a+2<=c&&a+2!=b&&s[a+2]=='.'){
			a+=2;
			continue;
		}		
		if (b+1<=d&&b+1!=a&&s[b+1]=='.'){
			b++;
			continue;
		}
		if (b+2<=d&&b+2!=a&&s[b+2]=='.'){
			b+=2;
			continue;
		}					
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;	
}

Measured memory_bytes: 384
N = int(input())
Lists = []
ans = 0
for _ in range(3):
    s = [int(e) for e in input().split()]
    s.sort()
    Lists.append(s)
def bin(i,j):
    global t,s
    right = N-1;left = 0
    while(right >= left):
        mid = int(left + (right-left)/2)
        if(j==0):
            if(i>Lists[j][mid]):
                left = mid + 1
            else:
                right = mid -1
        else:
            if(i>=Lists[j][mid]):
                left = mid + 1
            else:
                right = mid - 1
    if(j == 0):
        t = left
    else:
        s = N - left
for i in Lists[1]:
    bin(i,0)
    bin(i,2)
    ans += t*s
print(ans)

Measured memory_bytes: 104932
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S = read::<String>();
    println!("{}", S.replace("2017", "2018"));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

bool hoge (pair<ll,ll> x, pair<ll,ll> y) {
	if (x.se < y.se) return true;
	else return false;
}

int main() {
	ll n;
	cin >> n;
	vector<pair<ll,ll> > a(n);
	ll temp1, temp2;
	rep(i,n) {
		cin >> temp1 >> temp2; 
		if(temp2 < temp1) {
			cout << "No" << endl;
			return 0;
		}
		a.pb(pair<ll,ll>(temp1,temp2));
	}
	sort(a.begin(), a.end(), hoge);

	ll currentTime = 0;

	for(auto& i : a) {
		currentTime += i.first;
		//cout << currentTime << " " << i.first << endl;
		if(currentTime > i.second) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
  return 0;
}


Measured memory_bytes: 8448
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(-(-N//2))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	int a[n];
	map<int,int> m;
	ll sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
		m[a[i]]++;
	}
	int q;
	cin>>q;
	rep(i,q){
		int b,c;
		cin>>b>>c;
		sum+=m[b]*(c-b);
		cout<<sum<<endl;
		m[c]=m[c]+m[b];
		m[b]=0;
	}
	re 0;
}

Measured memory_bytes: 8396
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N,A,B;
int main() {
	cin>>N>>A>>B;
	if(N*A>B)cout<<B<<endl;
	else cout<<N*A<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<P> towns;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		P tmp; tmp.first = x; tmp.second = y;
		towns.push_back(tmp);
	}
	double sum = 0;
	int cnt = 0;

	vector<int> keys;
	for (int i = 0; i < N; i++) {
		keys.push_back(i);
	}
	vector<P> tmpTowns(towns);

	do {
		cnt++;
		double tmp = 0.0;
		for (int i = 0; i < N; i++) {
			tmpTowns[i] = towns[keys[i]];
		}
		P cur = tmpTowns[0];
		for (int i = 1; i < N; i++) {
			tmp += sqrt((tmpTowns[i].first - cur.first) * (tmpTowns[i].first - cur.first) + (tmpTowns[i].second - cur.second) * (tmpTowns[i].second - cur.second));
			cur = tmpTowns[i];
		}
		sum += tmp;
	} while (next_permutation(keys.begin(), keys.end()));

	printf("%.8lf\n", sum / (double)cnt);







	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T = int>T in() { T x; cin >> x; return x; }
#define REP(i,n) for(int i=0;i<(n);++i)
#define _REP(i,n)for(int i=1;i<=(n);++i)
#define REPC(i,c)for(auto i:c)
struct vec2d
{
	double x, y;
	vec2d() {}
	vec2d(double _x, double _y) :x(_x), y(_y) {}
	double norm()const
	{
		return hypot(x, y);
	}
	double operator*(const vec2d&v)const
	{
		return x * v.x + y * v.y;
	}
	vec2d operator-(const vec2d&v)const
	{
		return vec2d(x - v.x, y - v.y);
	}
	bool operator==(const vec2d&v)const
	{
		return x == v.x && y == v.y;
	}
	bool operator!=(const vec2d&v)const
	{
		return !operator==(v);
	}
	static double cos_arg(const vec2d&v1, const vec2d&v2)
	{
		return v1 * v2 / v1.norm() / v2.norm();
	}
};
int main()
{
	for (int n = in(); n != 0; n = in())
	{
		vector<vec2d>v(n);
		int min_x_idx;
		double min_x = 2000;
		REP(i, n)
		{
			v[i].x = in<double>();
			in<char>();
			v[i].y = in<double>();
			if (min_x > v[i].x)
			{
				min_x = v[i].x;
				min_x_idx = i;
			}
		}
		vector<vec2d>wrap;
		wrap.push_back(v[min_x_idx]);
		auto previous = vec2d(v[min_x_idx].x, -2000);
		while (true)
		{
			int max_cos_idx;
			double max_cos = -10;
			REP(i, v.size())
			{
				if (v[i] != wrap.back() && v[i] != previous)
				{
					double cosine = vec2d::cos_arg(wrap.back() - previous, v[i] - wrap.back());
					if (max_cos < cosine)
					{
						max_cos = cosine;
						max_cos_idx = i;
					}
				}
			}
			if (v[max_cos_idx] == wrap.front())break;
			previous = wrap.back();
			wrap.push_back(v[max_cos_idx]);
		}
		cout << v.size() - wrap.size() << endl;
	}
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,n,i,s=1;
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if(a<=0&&b>=0) cout<<"Zero"<<endl;
	else if((abs(min(a,b))-abs(max(a,b)))%2==0) cout<<"Negative"<<endl;
	else cout<<"Positive"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  int N,M;
  cin >> N >> M;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  double sum = 0;
  for(int i=0; i<N; i++){
    sum += vec.at(i);
  }
  
  double stan = sum / (4*M);
  
  sort(vec.begin(),vec.end());
  
  if(vec.at(N-M) >= stan){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  
  
  

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 200;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll d[MAX][MAX];

void warshall_floyd(ll int n){
    rep(k, n){
        rep(i, n){
            rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    rep(i, MAX)rep(j, MAX) d[i][j] = INF;
    cin >> n >> m;
    LPP aa[m];
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
        aa[i].first = a - 1;
        aa[i].second.first = b - 1;
        aa[i].second.second = c;
    }
    warshall_floyd(n);

    //rep(i, n)rep(j, n)cout << d[i][j] << endl;

    bool used[m];
    rep(i, m) used[i] = false;
    rep(i, MAX) d[i][i] = 0;
    rep(i, n){

        rep(j, n){
            if(i != j) rep(s, m){
                //if(i != aa[s].first && i != aa[s].second.first && j != aa[s].first && j != aa[s].second.first){
                    if(d[i][j] == d[i][aa[s].first] + aa[s].second.second + d[aa[s].second.first][j]) {
                        used[s] = true;
                        //cout << i << " " << j <<" " << aa[s].first << " " << aa[s].second.first << endl;
                    }
                //}
            }
        }
    }
    int ans = 0;
    rep(i, m) if(!used[i]) ans ++;
    cout << ans << endl;
}

// || d[i][j] == d[i][aa[s].second.first] + aa[s].second.second + d[aa[s].first][j]

Measured memory_bytes: 640
from collections import defaultdict


def primes(n):
    if n == 1:
        return None

    while n % 2 == 0:
        ps[2] += 1
        n //= 2

    i = 3
    while i <= int(n ** .5) + 1:
        while n % i == 0:
            ps[i] += 1
            n //= i
        i += 2

    if n != 1:
        ps[n] += 1
    return None


N = int(input())
ps = defaultdict(int)

for n in range(1, N + 1):
    primes(n)

ans = 1
MOD = 10 ** 9 + 7
for key in ps:
    ans *= (ps[key] + 1) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s", s);
	long long int p = 1000000007;
	long long int i, j, k, n = strlen(s);
	long long int amari[2][13];
	for (i = 0; i < 13; i++)
		amari[0][i] = 0;
	if (s[0] == '?')
		for (i = 0; i < 10; i++)
			amari[0][i] = 1;
	else
		amari[0][s[0] - '0'] = 1;
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < 13; j++)
			amari[1][j] = 0;
		if (s[i] == '?')
		{
			for (j = 0; j < 10; j++)
				for (k = 0; k < 13; k++)
					amari[1][(10 * k + j) % 13] += amari[0][k];
		}
		else
		{
			for (j = 0; j < 13; j++)
				amari[1][(10 * j + (s[i] - '0')) % 13] += amari[0][j];
		}
		for (j = 0; j < 13; j++)
			amari[1][j] %= p;
		for (j = 0; j < 13; j++)
			amari[0][j] = amari[1][j];
	}
	printf("%lld\n", amari[0][5]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    string s; cin >> s;

    // 長さ2ならXXのみ
    if(s.size() == 2) {
        if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
        else cout << -1 << " " << -1 << endl;
        return 0;
    }

    // XXがあったら出力して終了
    rep(i, s.size()-1) {
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    
    // XYXがあったら出力して終了
    rep(i, s.size()-2) {
        if(s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    // どれもなければ-1
    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

int n, d, x;

double calc(int n, double d, double x)
{
	if(n == 1)
		return d + x / 2.0;
	return d + x * n - x * 0.5 + calc(n - 1, d * (n - 1) / n + (d + 2 * x) / (2 * n) + (3 * d + 3 * x) / (2 * n), x * (n * 2 + 4) / (2 * n));
}

int main()
{
	scanf("%d%d%d", &n, &d, &x);
	printf("%.12lf\n", calc(n, d, x));

	return 0;
}

Measured memory_bytes: 6528
[N,K] = [int(s) for s in input().rstrip().split(' ')]
L_A = [int(s) for s in input().rstrip().split(' ')]
if N < K:
  print("error")
elif N == K:
  print((sum(L_A) + N) / 2)
else:
  a = N - K
  p = 0
  for i in range(K):
    p += L_A[i]
  q = p
  for j in range(N-K):
    q += L_A[j+K]-L_A[j]
    p = max(p,q)
  print((p + K) / 2)

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

int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        
        if(x > y) cout << y << " " << x << endl;
        else cout << x << " " << y << endl;
    }
}


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

long long pow2(long long x, long long n, int mod=0) {
  if (n == 0) return 1;
  if (mod) {
    if (n & 1) return x * pow2(x, n - 1, mod) % mod;
    long long y = pow2(x, n / 2, mod);
    return y * y % mod;
  } else {
    if (n & 1) return x * pow2(x, n - 1);
    long long y = pow2(x, n / 2);
    return y * y;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k; cin >> n >> k;
  int c1 = n / k;
  int c2 = n / (k / 2);
  long long cnt;
  if (k & 1) {
    cnt = pow(c1, 3);
  } else {
    cnt = pow2(c1, 3) + pow2(c2 - c1, 3);
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;

  int n, k; cin>>n>>k;

  k--;
  forn(i){
    char x; cin>>x;

    if( i != k ) cout<<x;
    else{
      if( x == 'A' ) cout<<'a';
      if( x == 'B' ) cout<<'b';
      if( x == 'C' ) cout<<'c';
    }
  }


  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    ll n;
    ll a[100000];
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a + n, greater<ll>());

    cout << a[0] << " ";
    ll max = a[0];
    if (max % 2 == 0) {
        ll mid = max / 2;
        for (int i = 1; i < n; i++) {
            if (a[i] < mid) {
                if (mid - a[i] > a[i - 1] - mid)
                    cout << a[i - 1] << endl;
                else
                    cout << a[i] << endl;
                break;
            }
        }
    } else {
        ll mid = max / 2;
        for (int i = 1; i < n; i++) {
            if (a[i] <= mid) {
                if (mid - a[i] > a[i-1] - mid - 1)
                    cout << a[i-1] << endl;
                else
                    cout << a[i] << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <functional>
#include <map>
#include <cmath>
#include <iostream>
#include <string>
 
 
using namespace std;



int main()
{
	int N, M;
	cin >> N >> M;
	int ans = N - M + 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

n1 = list(map(int , input().split()))
n2 = list(map(int , input().split()))
n3 = list(map(int , input().split()))
A = np.array([n1,n2,n3])

def check(b1, b2, b3):
    if b1==b2 and b2 ==b3:
        return True
    else:
        return False
      
flg = False
for i in range(max(A[0])+1):
    diff_n1 =  A[0] - i
    b1 = A[1][0] - diff_n1[0]
    b2 = A[1][1] - diff_n1[1]
    b3 = A[1][2] - diff_n1[2]
    c1 = A[2][0] - diff_n1[0]
    c2 = A[2][1] - diff_n1[1]
    c3 = A[2][2] - diff_n1[2]
    if check(b1, b2, b3) and check(c1, c2, c3):
        flg = True
if flg:
    print('Yes')
else:
    print('No')      

Measured memory_bytes: 12508
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

//const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void) {
	ijt n, k; cin >> n >> k;
	vector<ijt> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(all(a));
	int l = -1, r = n;
	while(r-l>1)
	{ 
		int i = (r + l) / 2;
		if (a[i] >= k) { r = i; }
		else {
			vector<ijt> b;
			for (int j = 0; j < n; j++)
			{
				if (j != i and a[j] < k) b.pb(a[j]);
			}
			ijt m = b.size();
			vector<vector<bool>> dp(m + 1, vector<bool>(k + 2, false));
			/*
			ある部分集合の和がk-a[i]以上であると，a[i]を付け加えた和がk以上になってしまいかつa[i]をのぞいたときk未満になってしまうので，NG
			この判定をナップザックDPによって行う。
			*/
			//初期化は，dp[0][0] = true,dp[0][b[0]] = true
			dp[0][0] = dp[0][b[0]] = true;
			for (int j = 1; j < m; j++)
			{
				for (int l = 0; l < k + 2; l++)
				{
					if (l - b[j] >= 0) {
						if (dp[j - 1][l - b[j]]) dp[j][l] = true;
					}
					if (dp[j - 1][l]) dp[j][l] = true;
				}
			}
			bool check = true;
			for (int j = k - a[i]; j < k; j++) {
				if (dp[m - 1][j]) {
					check = false; break;
				}
			}
			if (check)l = i;
			else r = i;
		}
	}
	cout << l + 1 << endl;
	return 0;
}


Measured memory_bytes: 3704
N = int(input())
A = list(map(int, input().split()))

res = 0
min_abs = float('inf')
cnt_neg = 0
for a in A:
    if a < 0:
        cnt_neg += 1
    abs_a = abs(a)
    res += abs_a
    if min_abs > abs_a:
        min_abs = abs_a

if cnt_neg%2==0:
    print(res)
else:
    print(res-2*min_abs)

Measured memory_bytes: 14212
#include <iostream>
#include <map>

using namespace std;

int fib(int n);

map<int, int> fib_array;


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

	cout << fib(input) << endl;
	return 0;


}

int fib(int n){
	switch (n)
	{
	case 0:
	case 1:
		return 1;
		break;
	default:
		break;
	}
	
	if (fib_array[n] == 0){
		int new_fib = fib(n - 1) + fib(n - 2);
		fib_array[n] = new_fib;
		return new_fib;
	}
	else{
		return fib_array[n];
	}

}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H, W; cin >> H >> W;
  int A, B; cin >> A >> B;

  int res{};
  constexpr int ICHI = 1;
  for (int row = 0; row < H; ++row){
    res ^= ICHI;
    if(row == B) res ^= ICHI;
    for (int column = 0; column < W; ++column){
      if(column == A) res ^= ICHI;
      cout << res;
    }
    cout << CRLF;
  }

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1280