akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>

#define LL long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define vecprint(vec) for (int i=0;i<vec.size();i++)printf("%d ",vec[i]);
#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define MEM(v,x) memset(v,x,sizeof v)

const double eps=1e-7,PI=3.1415926;
const int N=2e5+10;

using namespace std;

int n,q,m,k,x,y,a[N],mx=-1,mn=1e9,sum,t;
char c[N];
string s,s1,s2;
map < int , int > mp;
vector < int > vec;

int main(){
    cin>>n>>s;
    s+="###";
    for (int i=0;i<n;i++){
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	string n;
	cin>>n;
	n[3]='8';
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

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

int gcd(int i, int j) {
	if(i == 0)
		return j;
	if(i == 1)
		return i;
	return gcd(j%i,i);
}
int main() {
	fastio;
	int n; cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				int val1 = gcd(i, j);
				int val2 = gcd(k, val1);
				sum += val2;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

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

int main(){
  string str,order,rep,t_str;
  int q,a,b;

  cin >> str >> q;

  for (int i = 1; i <= q; i++){
    cin >> order >> a >> b;

    if (order == "replace"){
      cin >> rep;
      str.replace(a,b-a+1,rep);
    }
    else if (order == "reverse"){
      t_str = str.substr(a,b-a+1);

      for (int j = 0; j<t_str.size(); j++){
        str[a + j] = t_str[t_str.size() - 1 - j];
      }
    }
    else{
      cout << str.substr(a,b-a+1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3216
n=int(input())
if n==1:
    print(0)
else:
    def fac(n):
        arr=[]
        temp=n
        for i in range(2,int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp//=i
                arr.append(cnt)
        if temp!=1:
            arr.append(1)
        if arr==[]:
            arr.append(1)
        return arr
    anss=fac(n)
    dic={}
    ans=0
    for i in anss:
        if i in dic:
            ans+=dic[i]
        elif i==1:
            dic[i]=1
            ans+=1
        else:
            j=i
            ansss=0
            cou=1
            while j>=cou:
                ansss+=1
                j-=cou
                cou+=1
            ans+=ansss
            dic[i]=ansss
    print(ans)

Measured memory_bytes: 9504
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var abcd = lines[0].split(' ');
 var one = Number(abcd[0]);
 var two = Number(abcd[1]);
 var three = Number(abcd[2]);
 var four = Number(abcd[3]);

 var ans = [];
 ans.push(three + (two - four));
 ans.push((three + four) - one);
 ans.push((one + two) - four);
 ans.push((three + two) - one);

 console.log(ans.join(' '));
 
});

Measured memory_bytes: 11596
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int) (x).size())
#define mp(x,y) make_pair((x), (y))
#define mp3(x,y,z) make_pair((x), make_pair( (y), (z)))
#define foreach(C, i) for(auto i = (C).begin(); i != (C).end(); i++)
#define xx first
#define yy second
#define clr clear()
#define var(x) cout<< #x << " = "<<x<<"\n";
#define print(x) for_each((x).begin(), (x).end(), [](auto n) { cout<<x<<" " })
typedef int32_t i3;
typedef int64_t i6;
typedef vector<i3> vi;
typedef pair<i3,i3> pii;
typedef vector<pair<i3,i3> > vpii;
template class 	std::vector<int> ;


int main()
{
	int n; cin >> n;
	vector<int> vec(2*n);
	REP(i,2*n)
		cin >> vec[i];
	sort(all(vec));
	int cost = 0;
	for(int i = 0; i < SZ(vec) - 1; i += 2)
		cost += min(vec[i], vec[i+1]);
	cout << cost << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[110][100100];

int main() {
	ll n,W;
  cin>>n>>W;
  vector<pair<ll,ll> > v;
  rep(i,0,n){
    ll a,b;
    cin>>a>>b;
    v.pb(mp(a,b));
  }
  rep(i,0,110)rep(j,0,100100)dp[i][j]=1000000000000000000LL;
  dp[0][0] = 0;
  rep(i,0,n){
    rep(j,0,100100){
      if(dp[i][j]!=1000000000000000000LL){
        dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        if(j+v[i].se<100100){
          dp[i+1][j+v[i].se] = min(dp[i+1][j+v[i].se],dp[i][j]+v[i].fi);
        }
      }
    }
  }
  ll mx = 0;
  rep(i,0,100100){
    if(dp[n][i]<=W){
      mx = max(mx,i);
    }
  }
  cout << mx << endl;
	return 0;
}

Measured memory_bytes: 86272
#include <stdio.h>
  
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if((i+j)%2 == 0)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}


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

using namespace std;
#define long long long

int const N = 1e5 + 10;

int n;
double p[N], dp[N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    dp[0] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = i; j; --j)
            dp[j] = dp[j - 1] * p[i] + dp[j] * (1 - p[i]);
        dp[0] = dp[0] * (1 - p[i]);
    }

    double res = 0;
    for (int i = n / 2 + 1; i <= n; ++i) res += dp[i];
    cout << fixed << setprecision(9) << res;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    rep (i, 3) {
        cin >> s;
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  unsigned long long N, T;
  cin >> N >> T;
  vector<unsigned long long> t(N);
  for(int i = 0; i < N; i++){
    cin >> t[i];
  }
  unsigned long long ans = 0;
  int pos = t[0];
  for(int i = 1; i < N; i++){
    if(t[i - 1] + T <= t[i]){
      ans += T;
      pos = t[i];
    }else {
      ans += t[i] - t[i - 1];
    }
  }
  ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] dam = new int[n];
		int[] mnt = new int[n];
		int all = 0;
		int temp = 0;

		for ( int i = 0; i < n; i++ ) {
			dam[i] = in.nextInt();
			all += dam[i];
			if ( i % 2 == 0 ) temp += dam[i] * 2;
		}

		// 2*(ダ0 + ダ2 + …) = all + 山0
		mnt[0] = temp - all;

		// 山0が決まれば後は順番に決まる
		for ( int i = 1; i < n; i++ ) {
			mnt[i] = dam[i - 1] * 2 - mnt[i - 1];
		}

		for ( int i : mnt ) System.out.print(i + " ");
		in.close();
	}
}


Measured memory_bytes: 66364
#include<stdio.h>
#include<math.h>
int main(){
    int n, i;
    double scores[1001], m, v;
    while(1){
        scanf("%d", &n);
        if(n == 0)break;
        m = 0;
        for(i=0;i<n;i++){
            scanf("%lf", &scores[i]);
            m+=scores[i];
        }
        m /= n;
        v = 0;
        for(i=0;i<n;i++){
            v += ((m - scores[i])* (m - scores[i]));
        }
        v /= n;
        v = sqrt(v);
        printf("%lf\n", v);
    }
return 0;
}



Measured memory_bytes: 2112
s=input()
n=len(s)
count=0
a=(n-1)//2
b=(n+3)//2
for i in range(n//2):
  if s[i]!=s[-abs(i+1)]:
    count+=1
    
for i in range(a//2):
  if s[i]!=s[(a-1-i)]:
    count+=1

for i in range((n-b+1)//2):
  if s[-(i+1)]!=s[b-1+i]:
    count+=1

if count!=0:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 3064
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
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() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N, K;cin >> N >> K;
    VI H(N);
    REP(i, N)
    {
        cin >> H.at(i);
    }
    VI dp(N, INF);
    dp.at(0) = 0;

    FOR(i, 1, N)
    {
        FOR(j, max(0, i-K), i)
        {
            chmin(dp.at(i), dp.at(j)+abs(H.at(i)-H.at(j)));
        }
    }

    cout << dp.back() << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n, ans=0;
  	cin >> n;
  	int d[n] = {0};
  	for(int i=0; i<n; i++) cin >> d[i];
  	for(int i=0; i<n-1; i++){
      if(d[i] == 0) continue;
      for(int j=i+1; j<n; j++) ans += d[i]*d[j];
    }
    cout << ans << endl;  

}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    ll x,y;
    cin>>x>>y;

    ll cnt=0;

    while(x<=y){
        x*=2;
        cnt++;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(9)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 3010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

long double dp[N][N];
long double p[N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,m;
    cin>>n;
    rep(i,1,n)cin>>p[i];
    dp[0][0]=1;
    rep(i,1,n)
    {
        dp[i][0]= dp[i-1][0]*(1-p[i]);
        for(int j=1;j<i;j++)
        {
            dp[i][j]=(dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i]);
        }
        dp[i][i]= dp[i-1][i-1]*p[i];
    }
    long double ans = 0;
    for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
    fout<<ans<<"\n";

    
    return 0;
}


Measured memory_bytes: 139776
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cassert>
using namespace std;

string s;
int cur = 0;

int digit() {
  assert(isdigit(s[cur]));
  return s[cur++] - '0';
}

int number() {
  int ans = 0;
  while (cur < s.length() && isdigit(s[cur])) {
    int temp = digit();
    ans = ans*10 + temp;
  }
  return ans;
}

int senkyoku() {
  int ans = number();
  return ans/2+1;
}

int min() {
  assert(s[cur] == '[');
  cur++;
  int vot[4000];
  int len = 0;
  while(s[cur] != ']') {
    if (isdigit(s[cur])) {
      vot[len] = senkyoku();
    } else {
      vot[len] = min();
    }
    len++;
  }
  cur++;
  sort(vot, vot+len);
  int sum = 0;
  for (int i=0; i<len/2 + 1; i++) {
    sum += vot[i];
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    cur = 0;
    cin >> s;
    cout << min() << endl;
  }
}

Measured memory_bytes: 1296
from collections import deque
k=int(input())
t=[1]*k
q=deque()
q.append((1,1))

while q:
  p,r=q.popleft()
  if p==0:
    print(r)
    break
  if t[p]:
    t[p]=0
    q.appendleft(((p*10)%k,r))
    q.append(((p+1)%k,r+1))

Measured memory_bytes: 20052
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
a = LIST()

if max(a) == 0:
	print(*[0]*N)
	exit()

n = ceil(log2(max(a)))+1

A = ["{:b}".format(x).zfill(n) for x in a]


b = a[0]
for i in range(1, N):
	b ^= a[i]
b = "{:b}".format(b).zfill(n)


ans = []

for x in A:
	tmp = 0
	for i in range(n):
		tmp += ((int(b[i])+int(x[i]))%2) * (2**(n-1-i))

	ans.append(tmp)

print(*ans)

Measured memory_bytes: 131080
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char arr[1010][1010];
int dist[1010][1010];
bool visited[1010][1010];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int r,c;
    int tox,toy;
    cin >> r >> c;
    cin >> x >> y;
    cin >> tox >> toy;
    getchar();
    for(i=1;i<=r;i++) {
        for(j=1;j<=c;j++) {
            scanf("%c",&arr[i][j]);
            dist[i][j]=1e9;
        }
        getchar();
    }
    set<pair<int, pair<int,int> > > s;
    s.insert({0, {x,y}});
    dist[x][y]=0;
    while(!s.empty()) {
        x = (*s.begin()).second.first;
        y = (*s.begin()).second.second;
        s.erase(s.begin());
        if(visited[x][y]) continue;
        visited[x][y] = 1;

        if(x+1<=r&&arr[x+1][y]=='.') {
            if(dist[x+1][y]>dist[x][y]) {
                dist[x+1][y]=dist[x][y];
                s.insert({dist[x+1][y],{x+1,y}});
            }
        }
        if(x-1>0&&arr[x-1][y]=='.') {
            if(dist[x-1][y]>dist[x][y]) {
                dist[x-1][y]=dist[x][y];
                s.insert({dist[x-1][y],{x-1,y}});
            }
        }
        if(y+1<=c&&arr[x][y+1]=='.') {
            if(dist[x][y+1]>dist[x][y]) {
                dist[x][y+1]=dist[x][y];
                s.insert({dist[x][y+1],{x,y+1}});
            }
        }
        if(y-1>0&&arr[x][y-1]=='.') {
            if(dist[x][y-1]>dist[x][y]) {
                dist[x][y-1]=dist[x][y];
                s.insert({dist[x][y-1],{x,y-1}});
            }
        }

        // magic
        for(i=x-2;i<=x+2;i++) {
            for(j=y-2;j<=y+2;j++) {
                if(i>r||i<1||j>c||j<1) continue;
                if(i==x&&j==y) continue;
                if(arr[i][j]=='#') continue;
                if(dist[i][j]>dist[x][y]+1) {
                    dist[i][j]=dist[x][y]+1;
                    s.insert({dist[i][j],{i,j}});
                }
            }
        }
    }
    if(dist[tox][toy]==1e9) ans = -1;
    else ans = dist[tox][toy];
    cout<<ans<<endl;
    return 0;
}


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

int main () {
    string s, t;
    cin >> s >> t;
    vector<int> a(26, 0), b(26, 0);
    for (int i = 0; i < s.size(); i++) {
        a[s[i] - 'a']++;
        b[t[i] - 'a']++;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int ans = 0;
  for(int i = 0; i < min(k, n); i++){
    ans += a[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
n = int(input())
l = []
if n == 0:
    l.append(2)
elif n == 1:
    l.append(1)
elif n >= 2:
    l = [2, 1]
    for i in range(2, n+1):
        l.append(l[i-2]+l[i-1])
print(l[-1])

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

#include <iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n,k,c;cin>>n>>k>>c;
	vector<int> f,b;
	string s;cin>>s;
	for(int i=0;i<n;i++){
		if(f.size()==0){
			if(s[i]=='o'){
				f.push_back(i);
			}
		}else{
			if(s[i]=='o'){
				if(i>c+f.back()){
					f.push_back(i);
				}
			}
		}
	}
	if(f.size()>k){
		return 0;
	}
	for(int i=n-1;i>=0;i--){
		if(b.size()==0){
			if(s[i]=='o'){
				b.push_back(i);
			}
		}else{
			if(s[i]=='o'){
				if(i<b.back()-c){
					b.push_back(i);
				}
			}
		}
	}
	vector<int> count(n,0);
	for(int i=0;i<k;i++){
		count[f[i]]++;
		count[b[i]]++;
	}
	for(int i=0;i<n;i++){
		if(count[i]==2){
			cout<<i+1<<endl;
		}
	}
	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = 100100101;
int H, N;
int A[1010], B[1010];
int dp[2][20100];

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

  std::cin >> H >> N;

  for(int i=0;i<N;++i){
      std::cin >> A[i] >> B[i];
  }

  std::fill(&dp[0][0], &dp[0][0] + 2 * 20100, INF);
  dp[0][0] = 0;

  int (&pr)[20100] = dp[0], (&nx)[20100] = dp[1];
  
  for(int i=0;i<N;++i){
      for(int j=0;j<=20000;++j){
          nx[j] = std::min(nx[j], pr[j]);
          
          {
              int j2 = j - A[i];
              if(j2 >= 0){
                  nx[j] = std::min(nx[j], nx[j2] + B[i]);
              }
          }
      }

      for(int j=19999;j>=0;--j){
          nx[j] = std::min(nx[j], nx[j+1]);
      }

      std::swap(pr, nx);
      std::fill(nx, nx + 20100, INF);
  }

  std::cout << pr[H] << std::endl;
}


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

# sys.setrecursionlimit(10 ** 7)

N, MOD = map(int, input().split())


G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)
G[0].append(1)
G[1].append(0)

DP1 = [0] * (N + 1)

parent = [-1] * (N + 1)
parent[1] = 0

order = []
order_append = order.append

stack = [1]
stack_pop = stack.pop
stack_append = stack.append

while stack:
    x = stack_pop()
    order_append(x)
    for next_ in G[x]:
        if next_ == parent[x]:
            continue
        parent[next_] = x
        stack_append(next_)

for v in order[::-1]:
    tmp = 1
    for next_ in G[v]:
        tmp *= DP1[next_] + 1
        tmp %= MOD
    DP1[v] = tmp
# print (DP1)

DP2 = [1] * (N + 1)

for x in order:
    # 累積積のパート
    #ここが同じ値を返すかチェックする
    n = len(G[x])
    lst1 = [1] * (n + 1)
    lst2 = [1] * (n + 1)
    for i in range(n):
        #親のときだけは違うルールで対処
        if G[x][i] == parent[x]:
            lst1[i + 1] = lst1[i] * DP2[x] % MOD
        else:
            lst1[i + 1] = lst1[i] * (DP1[G[x][i]] + 1) % MOD

        if G[x][n - 1 - i] == parent[x]:
            lst2[n - i - 1] = lst2[n - i] * DP2[x] % MOD
        else:
            lst2[n - i - 1] = lst2[n - i] * (DP1[G[x][n - 1 - i]] + 1) % MOD
    
    for i in range(n):
        if G[x][i] == parent[x]:
            continue
        tmp = lst1[i] * lst2[i + 1] % MOD
        tmp += 1 #白色の分
        DP2[G[x][i]] = tmp
        # stack.append(G[x][i])

# print (DP2)

for i in range(1, N + 1):
    print ((DP1[i] * DP2[i]) % MOD)

# print (DP1)
# print (DP2)

Measured memory_bytes: 36116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n1,n2,n3,n4;
    cin>>n1>>n2>>n3>>n4;
    map<int,int>M;
    M[n1]++;
    M[n2]++;
    M[n3]++;
    M[n4]++;
    int ct=0;
    if(M.size()==4)
    {
        for(auto it=M.begin();it!=M.end();it++)
        {
            if(it->first==9 || it->first==7 || it->first==4 || it->first==1)
            {
                ct++;
            }
        }
    }
    if(ct==4)
    {
        cout<<"YES"<<"\n";
    }
    else
    {
        cout<<"NO"<<"\n";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	string S;
	while (cin >> S) {
		int ans = INF;
		rep(a, 26) {
			if (count(S.begin(), S.end(), 'a' + a) == 0)
				continue;
			int cost = 0;
			rep(i, S.size()) {
				if (S[i] != 'a' + a) {
					int t = INF;
					reu(j, i, S.size() + 1) {
						if (j == S.size() || S[j] == 'a' + a)
							amin(t, j - i);
					}
					amax(cost, t);
				}
			}
			amin(ans, cost);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

ma, mi = A.map.with_index{|a, i| [a, i]}.max_by{|a, i| a}
A.delete_at(mi)
r = A.min_by{|a| (a - ma/2.0).abs}

puts [ma, r].join(" ")


Measured memory_bytes: 16156
#ABC49-C
S=input()
divide=["dream","dreamer","erase","eraser"]
for i in range(4): #４つの文字群を反転
    divide[i]=divide[i][::-1]
len_s=len(S)
S=S[::-1]

check=0
i=0
a=[]
while check==0:
    if i==len_s: #ぴったり終わりの時
        a.append(1)
        break
    if len_s-i <5: #残りが５文字未満のとき、これ以上見つけられない。
        check=1
        a.append(2)
        break
    if S[i:i+5] == divide[0]:
        i=i+5
        a.append(3)
        continue
    if S[i:i+5] == divide[2]:
        i=i+5
        a.append(4)
        continue
    if len_s-i <6: #残りが6文字未満のとき、これ以上見つけられない。
        check=1
        a.append(5)
        break
    if S[i:i+6] == divide[3]:
        i=i+6
        a.append(6)
        continue
    if len_s-i <7: #残りが７文字未満のとき、これ以上見つけられない。
        check=1
        a.append(7)
        break
    if S[i:i+7] == divide[1]:
        i=i+7
        a.append(8)
        continue
    check=1 #上のif文どれにも引っかからなかったとき。

if check==0:
    print("YES")
else:
    print("NO")
#print(a)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
	
ll dist[200007];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int c = 0;
	ll n, k; cin >> n >> k;
	vi v(n); FOR(i, n) cin >> v[i], v[i]--;

	int p = 0;
	do{
		dist[p] = ++c;
		p = v[p];
	}while(dist[p] == 0);


	if(p != 0 && k < dist[p]){
		FOR(i, n) if(dist[i] == k+1)
			cout << i+1 << '\n';
		return 0;
	}

	c-=dist[p]-1;
	k-=dist[p]-1;

	k%=c;

	while(k){
		p = v[p];
		k--;
	}

	cout << p+1 << '\n';

	return 0;
}

Measured memory_bytes: 5656
n,k=map(int,input().split())

ans=0



for i in range(n):
  
#でためのかずがi+1のかくりつpi
#なんかい２をかけたらkを超えるか
  count=0
  score=i+1
  for j in range(30):
    if score>=k:
      break
    score=score*2
    count+=1

  ans+= 1/(2**count)
  
print(ans/n)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;
  vector<int> ok(N);
  int ans1 = 0;
  vector<int> memo(N);
  int ans2 = 0;
  for (int i = 0; i < M; i++) {
    int a;
    string b;
    cin >> a >> b;
    if (ok.at(a - 1) == 0 && b == "WA") {
      memo.at(a - 1)++;
    }
    else if (ok.at(a - 1) == 0 && b == "AC") {
      ans1++;
      ans2 += memo.at(a - 1);
      ok.at(a - 1) = 1;
    }
  }
  cout << ans1 << " " << ans2 << endl;
}
     


Measured memory_bytes: 3996
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
#define X real()
#define Y imag()
#define EPS (1e-10)
#define INF (1e9)
using namespace std;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
}

double closest_pair(P *a, int n){
  if(n <= 1) return INF;
  int m = n/2;
  double x = a[m].X;
  double d = min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,cmp_y);
  vector<P> b;
  for(int i = 0; i < n; ++i){
    if(abs(x-a[i].X) >= d) continue;
    for(int j = 0; j < b.size(); ++j){
      P dp = a[i] - b[b.size()-1-j];
      if(dp.Y >= d) break;
      d = min(d,abs(dp));
    }
    b.push_back(a[i]);
  }
  return d;
}

double compute_shortest(P *a, int n){
  sort(a, a+n);
  return closest_pair(a,n);
}

int main(){
  int n;
  cin >> n;
  double x, y;
  P p[n];
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    p[i] = P(x,y);
  }
  printf("%.10lf\n", compute_shortest(p,n));
  return 0;
}

Measured memory_bytes: 7868
#include <stdio.h>
int main(void)
{
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?'){break;}
		else if(op=='+'){
			printf("%d\n",a+b);
		}
		else if(op=='-'){
			printf("%d\n",a-b);
		}
		else if(op=='*'){
			printf("%d\n",a*b);
		}
		else if(op=='/'){
			printf("%d\n",a/b);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
    int n,m,l,i,j,k;long long sum;cin >> n >> m >> l;
    int a[n][m];int b[m][l];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++) cin >> a[i][j];
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++) cin >> b[i][j];
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            sum = 0;
            for(k=0;k<m;k++) sum += a[i][k]*b[k][j];
            cout << sum;
            if(j+1 != l) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e9);
const int mod = (int)(1e9) + 7; // check modulo


pair <int, int> calc(string s) {
    int bal = 0;
    int mn = inf, mx = 0;
    for(auto i : s) {
        bal += (i == '(' ? 1 : -1);
        mn = min(mn, bal);
    }
    return {bal, mn};
}

pair <int, int> bals[N];
string s[N];

void solve() {
    int n; cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> s[i];
        bals[i] = calc(s[i]);
    }
    sort(bals + 1, bals + n + 1, [&](pair <int, int> x, pair <int, int> y) {
        if ((x.first >= 0) != (y.first >= 0)) return (x.first >= 0);
        if (x.first >= 0) return x.second > y.second;
        return x.first + y.second > y.first + x.second;
    });
    int bal = 0;
    for(int i = 1; i <= n; ++i) {
        if (bal + bals[i].second < 0) {
            cout << "No"; return;
        }
        bal += bals[i].first;
    }
    if (bal != 0) {
        cout << "No";
        return;
    }
    cout << "Yes";

}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("elevator.in", "r", stdin);
//    freopen("elevator.out", "w", stdout);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
        solve();
//    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

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

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, X,  T;
    cin >> N >> X >> T;

    cout << (N+(X-1))/X * T << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main()
{
    rapido;
   int n;int k;cin>>n>>k;
   vector<int>arr(n);
   for(int i=0;i<n;i++)
   cin>>arr[i];
   
   sort(arr.begin(),arr.end());
   int ans=0;
   for(int i=0;i<k;i++)
   ans+=arr[i];
   
   cout<<ans<<endl;
}


Measured memory_bytes: 3660
from math import pi, sqrt, cos

a, b, h, m = map(int, input().split())

minutes = h * 60 + m

short_angle = pi * minutes / 360
long_angle = pi * m / 30
angle = abs(short_angle - long_angle)
if angle > pi:
    angle = 2 * pi - angle

print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(angle)))


Measured memory_bytes: 9500
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll X;

//解法
void solve() {

	if (X == 7 || X == 5 || X == 3) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return;
}

int main() {
	//入力

	cin >> X;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
c = Counter(s)
x = c.most_common()
ans = []
maxcnt = x[0][1]
for i in range(len(x)):
    if x[i][1] == maxcnt:
        ans.append(x[i][0])
    else:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

const int MAX_N = 1e5;
int arr[MAX_N];

int main(void)
{
    cin.sync_with_stdio(false); cin.tie(NULL);
    int N;  cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> arr[i];

    int res = 0;
    for (int i = 1; i <= N; i++)
    {
        if (arr[i-1] == i)
        {
            if (i != N && arr[i] == i+1)
            {
                res++;
                i++;
                continue;
            }

            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define lop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;

void func(){
    float d,t,s;
    cin>>d>>t>>s;
    if((d/s)<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main(){
    fastio;
    int t=1;
    //cin>>t;
    while(t--){
        func();
    }
}

Measured memory_bytes: 3732
package main

import "fmt"

var (
	n, m int
	tmp  string
	ss   = make(map[string]int)
	ts   = make(map[string]int)
)

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		ss[tmp]++
	}

	fmt.Scan(&m)
	for i := 0; i < m; i++ {
		fmt.Scan(&tmp)
		ts[tmp]++
	}

	score := 0
	for k := range ss {
		if ss[k]-ts[k] > score {
			score = ss[k] - ts[k]
		}
	}

	fmt.Println(score)
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  ll n, k, d, i, j, a_tmp, cnt = 0;
  cin >> n >> k;
  vector<ll> a(n, false);
  for (i = 0; i < k; ++i) {
    cin >> d;
    for (j = 0; j < d; ++j) {
      cin >> a_tmp;
      a[a_tmp - 1] = true;
    }
  }
  for (i = 0; i < n; ++i) {
    if (a[i] == false) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
int main(void){
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    int h[n];
    for(int i=0;n>i;++i)
    scanf("%d",&h[i]);
    for(int i=0;n>i;++i){
        if(h[i]>=k)
        ++ans;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double theta = 0;
    double ans = 0;
    if (x > a * a * b / 2)
    {
        theta = atan(2*(a*a*b-x)/(a*a*a));
    }
    else if (x < a * a * b / 2)
    {
        theta = atan((a*b*b)/(2*x));
    }
    else
    {
        cout << 45 << endl;
        return 0;
    }
    ans = 180 * theta / 3.14159265358;
    cout <<fixed<<setprecision(10)<< ans << endl;
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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; }

void Main(){
    int x, n;
    cin >> x >> n;
    VI pv(n);
    REP(i, n) cin >> pv[i];
    REP(i, 200) {
        if (find(ALL(pv), x-i) == pv.end()) {
            cout << x - i << en;
            return;
        }
        if (find(ALL(pv), x+i) == pv.end()) {
            cout << x + i << en;
            return;
        }   
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3592
n, k = gets.split.map(&:to_i)

sum = 0
1.upto(n) do |i|
  if i >= k
    sum += 1
    next
  end
  cnt = 1
  while k > i * 2 ** cnt
    cnt += 1
  end
  sum += 0.5 ** cnt
end
sum /= n
puts sum

Measured memory_bytes: 1916
# include<iostream>
# include<cstdio>
# include<cstdlib>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==1)
  {
    if(b>=1&&b<=31) cout<<"1"<<endl;
  }
  if(a==2)
  {
    if(b>=2&&b<=28) cout<<"2"<<endl;
    else cout<<"1"<<endl;
  }
  if(a==3)
  {
      if(b<3) cout<<"2"<<endl;
      else cout<<"3"<<endl;
  }
  if(a==4)
  {
    if(b<4) cout<<"3"<<endl;
    else cout<<"4"<<endl;
  }
  if(a==5)
  {
    if(b<5) cout<<"4"<<endl;
    else cout<<"5"<<endl;
  }
  if(a==6)
  {
    if(b<6) cout<<"5"<<endl;
    else cout<<"6"<<endl;
  }
  if(a==7)
  {
    if(b<7) cout<<"6"<<endl;
    else cout<<"7"<<endl;
  }
  if(a==8)
  {
    if(b<8) cout<<"7"<<endl;
    else cout<<"8"<<endl;
  }
  if(a==9)
  {
    if(b<9) cout<<"8"<<endl;
    else cout<<"9"<<endl;
  }
  if(a==10)
  {
    if(b<10) cout<<"9"<<endl;
    else cout<<"10"<<endl;
  }
  if(a==11)
  {

    if(b<11) cout<<"10"<<endl;
    else cout<<"11"<<endl;
  }
  if(a==12)
  {
    if(b<12) cout<<"1"<<endl;
    else cout<<"12"<<endl;
  }
  return 0;

}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> roads(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    roads.at(a - 1)++;
    roads.at(b - 1)++;
  }

  for (int i = 0; i < n; i++) cout << roads.at(i) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        String S = sc.next();
        int ans = 0;
        for(int i = 0; i + 3 <= N; ++i) {
            ans += ("ABC".equals(S.substring(i, i + 3))) ? 1 : 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    H,W = list(map(int,_in[0].split(' ')))  # type:list(int)
    S_arr = [[None]*(W+2) for i in range(H+2)]
    for i in range(H):
        _ = list(_in[i+1])   # type:str
        S_arr[i+1][1:-1] = _
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    num_arr = [[None]*W for i in range(H)]
    for i in range(1,H+1):
        for j in range(1,W+1):
            if S_arr[i][j] == '#':
                num_arr[i-1][j-1] = '#'
            else:
                cnt = 0
                cnt += 1 if S_arr[i-1][j-1]=='#' else 0
                cnt += 1 if S_arr[i-1][j]=='#' else 0
                cnt += 1 if S_arr[i-1][j+1]=='#' else 0
                cnt += 1 if S_arr[i][j-1]=='#' else 0
                cnt += 1 if S_arr[i][j+1]=='#' else 0
                cnt += 1 if S_arr[i+1][j-1]=='#' else 0
                cnt += 1 if S_arr[i+1][j]=='#' else 0
                cnt += 1 if S_arr[i+1][j+1]=='#' else 0
                num_arr[i-1][j-1] = str(cnt)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    for num in num_arr:
        print(''.join(num))


Measured memory_bytes: 40428
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;
const double EPS = 1e-10;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = w * h / 2.0;

    cout << fixed << setprecision(10) << ans << " ";
    cout << (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const [w, h, n] = args[0].map(x => parseInt(x));

let [low_x, high_x] = [0, w];
let [low_y, high_y] = [0, h];

for (let i = 0; i < n; i++) {
    const [x, y, a] = args[i + 1].map(x => parseInt(x));
    switch (a) {
        case 1:
            low_x = Math.max(low_x, x);
            break
        case 2:
            high_x = Math.min(high_x, x);
            break
        case 3:
            low_y = Math.max(low_y, y);
            break
        case 4:
            high_y = Math.min(high_y, y);
            break
    }
}

const lx = high_x - low_x;
const ly = high_y - low_y;

const cnt = (lx > 0 && ly > 0) ? lx * ly : 0;

console.log(cnt);



Measured memory_bytes: 7884
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int henkan(char s){
	switch(s){
		case '0':
		return 0;
		case '1':
		return 1;
		case '2':
		return 2;
		case '3':
		return 3;
		case '4':
		return 4;
		case '5':
		return 5;
		case '6':
		return 6;
		case '7':
		return 7;
		case '8':
		return 8;
		case '9':
		return 9;
	}
	return 0;
}

int main(){
int a,b,c,d,i,j,k,l;
string s;
bool f;
vector<int> v,vi;
	while(1){
		cin >> a >> l;
		if(l == 0)break;
		i = 0;
		f = true;
		vi.clear();
		vi.push_back(a);
		while(1){
		v.clear();
		b = c = 0;
		s = to_string(a);
		for(k = l - 1;k >= 0;k--){
			if(s.size() >= k){
				v.push_back(henkan(s[k]));
			}
			else if(s.size() < k){
				v.push_back(0);
			}
//			cout << v[l - k - 1] << " ";
		}	
//		cout << endl;
		sort(v.begin(),v.end());
		for(k = 0;k < l;k++){
			b += v[k] * pow(10,k);
		}
		sort(v.begin(),v.end(),greater<int>());
		for(k = 0;k < l;k++){
			c += v[l - k - 1] * pow(10,l-k-1);
		}
		d = b - c;
//		cout << b << " " << c << " " << d <<endl;
		for(j = 0;j < vi.size();j++){
			if(vi[j] == d){
				f = false;
				break;
			}
		}
		if(f == false){
			cout << j << " " << d << " " << i - j + 1 <<endl;
			break;
		}
		vi.push_back(d);
		a = d;
		i++;
		}
	}
return 0;
}

Measured memory_bytes: 3444