akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a > b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a < b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	int x; cin >> x;
	if (x < 100) {
		cout << 0 << endl;
		return 0;
	}
	bool ok = true;
	int a = x / 100;
	int b = x % 100;
	for (int i = 1; i*100<=x; ++i) {
		int key = x - 100 * i;
		if (key <= 5 * i) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

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

    int begin = 0;
    int end = k - 1;

    for (int i = 0; i < n - k; i++) {
        if (v[begin++] < v[++end]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str, ans = "";
	bool flagA = false;
	cin >> str;
	for (int i = 0; i < str.size(); ++i)
	{
		if (str[i] == 'A')
		{
			flagA = true;
		}
		else if (str[i] == 'Z' && flagA == true)
		{
			flagA = false;
			ans += "AZ";
		}
	}
	if (ans != "")
	{
		cout << ans << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    int ans = 0;
    int n;
    cin >> n;
    while(n--) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3652
<?php
fscanf(STDIN,'%s',$W);
$A=str_split($W);
sort($A);
$C=0;
if(count($A)%2==0){
     for ($i=0; $i <=count($A)-2 ; $i+=2) { 
         # code...
         if ($A[$i]==$A[$i+1]) {
             # code...
             $C++;
         }
     }
     if ($C==count($A)/2) {
         # code...
         echo "Yes\n";
     }else{
         echo "No\n";
     }
}else{
    echo "No\n";
}




?>

Measured memory_bytes: 3576
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	string s;
	cin >> s;

	string sub = s.substr(1, s.size()-2);
	string sub_len = to_string(sub.size());
	string res = s[0] + sub_len + s[s.size()-1];
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define int ll
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)




using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> PL;

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

const ll N_MAX = 200100;

ll N;
ll K;

ll A[N_MAX];
ll Aorder[N_MAX];

signed main() {
    
    cin >> N >> K;
    
    rep(i,N){
        Aorder[i] = -1;
    }
    

    rep(i, N){
        ll a;
        cin >> a;
        A[i] = a - 1;
    }

    ll nextTown = 0;
    ll loopCount = -1;
    rep(i,K){
        Aorder[nextTown] = i;
        nextTown = A[nextTown];
        bool trimmed = false;
        if(Aorder[nextTown] >= 0 && trimmed == false){
            trimmed = true;
            loopCount = (i) - Aorder[nextTown] + 1;
            i = i + loopCount * ((K-i-1)/loopCount);
        }
    }

    cout << nextTown+1 << endl;
    
    return 0;
}


Measured memory_bytes: 6728
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mk make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
const int MAX_V = 2*MAX_N;

int V;                 //頂点数
vector<int> G[MAX_V];  //グラフの隣接リスト
int match[MAX_V];      //マッチングのペア
bool used[MAX_V];      //dfsで既に調べたかのフラグ

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i], w = match[u];
    if (w < 0 || (!used[w] && dfs(w))) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  for (int v = 0; v < V; ++v) {
    if (match[v] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(v)) {
        ++res;
      }
    }
  }
  return res;
}

int n;
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,n) cin >> c[i] >> d[i];

  V = 2*n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i] < c[j] && b[i] < d[j]) add_edge(i, j+n);
    }
  }

  cout << bipartite_matching() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int i, j, num, array[N], count = 0, mini_j, tmp;

  //input data number and actual data
  scanf("%d", &num);
  for (i = 0; i < num; i++)
    scanf("%d", &array[i]);

  //selection sort procedure
  for (i = 0; i < num; i++){
    mini_j = i;
    //find smallest value
    for (j = i; j < num; j++)
      if (array[j] < array[mini_j])
	mini_j = j;
    //exhange procedure
    if (mini_j != i){
      count++;
      tmp = array[i];
      array[i] = array[mini_j];
      array[mini_j] = tmp;
    }
  }

  //display procedure
  for (i = 0; i < num; i++){
    printf("%d", array[i]);
    if (i < num-1)
      printf(" ");
  }
  printf("\n%d\n", count);

  return 0;
}
  



Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	ll n,m,a,b,c;
	ll dp[1010][1010]={};
	cin>>n>>m;
	rep(i,1,n+1)rep(j,1,n+1){
		if(i!=j)dp[i][j]=-INF;
	}
	rep(i,0,m)cin>>a>>b>>c,dp[a][b]=c;
	rep(k,1,n+1)rep(i,1,n+1){
		if(dp[i][k]==-INF)continue;
		rep(j,1,n+1)if(dp[i][k]+dp[k][j]>dp[i][j])
			dp[i][j]=dp[i][k]+dp[k][j];
	}
	dp[1][1]>0?print("inf"):print(dp[1][n]);
	return 0;
}

Measured memory_bytes: 8192
gets
    cnt = 0
    is_loop = true
    list = gets.chomp.split(" ").map(&:to_i);
    while is_loop do
        divide = 2 ** (cnt + 1)
        list.each do |n|
            if n % divide > 0 then
                print(cnt)
                is_loop = false
                break
            end
        end
        cnt = cnt + 1
    end

Measured memory_bytes: 1788
N, K = map(int, input().split())
A = list(map(int, input().split()))
M = []
m = []
for a in A:
    if a < 0:
        m.append(abs(a))
    else:
        M.append(a)

i = 0
j = 0
tmp = 1
P = 10**9 + 7

if (K%2 == 0 and (len(m)//2*2 + len(M)//2*2) >= K) or (K%2 == 1 and (len(M) + len(m)//2*2) >= K and len(M) > 0):
    m.sort(reverse=True)
    M.sort(reverse=True)
    while K > 0:
        if K >= 2:
            if j+2 <= len(M) and i+2 <= len(m):
                if m[i]*m[i+1] < M[j]*M[j+1]:
                    tmp *= M[j]
                    j += 1
                    K -= 1
                else:
                    tmp *= m[i]*m[i+1]
                    i += 2
                    K -= 2
            elif j+2 <= len(M):
                tmp *= M[j]
                j += 1
                K -= 1
            elif i+2 <= len(m):
                tmp *= m[i]*m[i+1]
                i += 2
                K -= 2
            else:
                tmp *= m[i]*M[j]
        else:
            tmp *= M[j]
            K -= 1
        tmp %= P
else:
    m.sort()
    M.sort()
    for _ in range(K):
        if j+1 <= len(M) and i+1 <= len(m):
            if M[j] < m[i]:
                tmp *= M[j]
                j += 1
            else:
                tmp *= m[i]
                i += 1
        elif j+1 <= len(M):
            tmp *= M[j]
            j += 1
        else:
            tmp *= m[i]
            i += 1
        tmp %= P
    tmp *= -1
    tmp %= P
        
print(tmp)





Measured memory_bytes: 31764
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    println(if (readLn().toCharArray().contains('7')) "Yes" else "No")

}

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

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

int main() {
	int n = ri();
	std::vector<std::pair<int, std::string> > dp[1 << n];
	dp[0].push_back({0, std::string(n, '0')});
	for (int i = 0; i < 1 << n; i++) {
		if (i == ((1 << n) - 1)) continue;
		int min = 100000;
		for (int j = 0; j < n; j++) if (!(i >> j & 1)) {
			min = j;
			break;
		}
		for (int j = 1; j < 1 << n; j++) {
			if (i & j) continue;
			if (!(j >> min & 1)) continue;
			for (auto k : dp[i]) {
				std::string tmp = k.second;
				for (int l = 0; l < n; l++) if (j >> l & 1) tmp[l] = k.first + 'a';
				dp[i | j].push_back({k.first + 1, tmp});
			}
		}
	}
	std::vector<std::string> res;
	for (auto i : dp[(1 << n) - 1]) res.push_back(i.second);
	std::sort(res.begin(), res.end());
	for (auto i : res) std::cout << i << std::endl;
	return 0;
}




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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string t;
    cin >> t;
    int n = (t.find('N') != string::npos);
    int e = (t.find('E') != string::npos);
    int s = (t.find('S') != string::npos);
    int w = (t.find('W') != string::npos);
    if (n == s && e == w) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> vec(H,vector<char>(W));
  vector<int> flagW(W,0);
  int  flagH=0;
  
  for(int i=0;i<H;i++){
    flagH=0;
    for(int j=0;j<W;j++){
      cin>>vec.at(i).at(j);
      if(vec.at(i).at(j)=='#'){
        flagW.at(j)=1;
        flagH=1;
      }
    }
    if(flagH==0){
        i--;
        H--;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(flagW.at(j)==1)
        cout<<vec.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

void factorize(ll n, vector<ll> &cnt){
    for (ll i = 2; i*i <= n; ++i){
        if (n%i) continue;
        while (n%i == 0){
            n /= i;
            cnt[i]++;
        }
    }
    if(n != 1) cnt[n]++;
}

int main(){
    int n;
    cin >> n;
    vector<ll> cnt(n+1);
    for(int i = 2; i <= n; i++){
        factorize(i, cnt);
    }
    ll ans = 1;
    const int mod = 1e9+7;
    for(int i = 2; i <= n; i++){
        ans *= cnt[i]+1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e2 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int n, w;
vii v;
map<int, int> dp[N];
int solve(int idx, int wi) {
	if (idx >= n)
		return 0;
	if (dp[idx].count(wi))
		return dp[idx][wi];
	int &ret = dp[idx][wi];
	ret = 0;
	if (wi >= v[idx].F)
		ret = max(ret, solve(idx + 1, wi - v[idx].F) + v[idx].S);
	ret = max(ret, solve(idx + 1, wi));
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> w;
	lp(i,1,n)
	{
		int x, y;
		cin >> x >> y;
		v.pb( { x, y });
	}
	cout<<solve(0,w)<<"\n";
	return 0;
}

Measured memory_bytes: 4736
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
    string a,b; cin>>a>>b;
    int n = a.length();
    int ans = 0;
    f(i,n){
    	if(a[i] != b[i]) ans++;
	}
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3816
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        int[] X = ReadInts();
        int ans = int.MaxValue;
        int sum;
        for (int i = 1; i <= 100; i++)
        {
            sum = 0;
            for (int j = 0; j < N; j++)
            {
                sum += (X[j] - i) * (X[j] - i);
            }
            ans = Math.Min(ans, sum);
        }

        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main() {
  int a;
    cin>>a;
  
  if(a==25){
    cout<<"Christmas"<<endl;
  }
  if(a==24){
    cout<<"Christmas Eve"<<endl;
  }
  if(a==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  if(a==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

char get(){
	static int hoge = 0;
	++hoge;
	hoge %= 2;
	return hoge;
}


int main(){
	string str;
	cin >> str;
	ll k;
	cin >> k;
	if(str.size()==1){
		cout << k / 2 << endl;
		return 0;
	}
	auto hoge = [&](string str){
		int left = 0;
		rep(i, str.size()){
			if(str.front()==str[i])++left;
			else break;
		}
		if(left==str.size()){
			return (ll)str.size() * k / 2;
		}
		int right = 0;
		per(i, str.size()){
			if(str.front()==str[i])++right;
			else break;
		}
		ll res = (right+left)/2 * (k-1) + left  / 2 + right / 2;
		for(int i=left-1;i<str.size()-right-1;++i){
			if(str[i]==str[i+1]){
				str[i+1] = get();
				res += k;
			}
		}
		return res;
	};

	ll ans = hoge(str);
	reverse(all(str));
	ans = min(ans, hoge(str));
	cout << ans << endl;



	return 0;
}

//is_i_is_i_


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    ll ans = 0;
    for (char c : S) {
        if (c == '1') {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

char a[4];
int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

long long b,c,d,e,f,g,h;
cin>>a;


if(a[0]==a[1] and a[1]==a[2])
{
	cout<<"Yes"<<endl;
}
else if(a[1]==a[2] and a[2]==a[3]){
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}

return 0;
}

Measured memory_bytes: 3640
/*
 * ID: ITP1_7_A
 * Problem: Grade judge
 */

#include <stdio.h>

int main(void)
{
    int middle, final, makeup;

    while (1) {
        scanf("%d %d %d", &middle, &final, &makeup);
        if (middle == -1 && final == -1 && makeup == -1)
            return 0;
        else if (middle == -1 || final == -1)
            puts("F");
        else if (middle + final >= 80)
            puts("A");
        else if (middle + final >= 65)
            puts("B");
        else if (middle + final >= 50)
            puts("C");
        else if (middle + final >= 30)
            if (makeup >= 50)
                puts("C");
            else
                puts("D");
        else
            puts("F");
    }

    return 0;
}



Measured memory_bytes: 2048
n,m=map(int,input().split())
w={}
for i in range(m):
    a,b=map(int,input().split())
    if a in w: w[a].add(b)
    else: w[a]=set([b])
    if b in w: w[b].add(a)
    else: w[b]=set([a])

d=[-1]*(n+1)
p=[set([]),set([1])]
d[1]=0
f=1
while 1:
    x=f%2
    y=(x+1)%2
    for i in p[x]:
        for j in w[i]:
            if d[j]==-1 or f<d[j]:
                d[j]=f
                p[y].add(j)
    p[x]=set([])
    if len(p[y])==0: break
    f+=1
print("Yes")
for i in range(2,n+1):
    for j in w[i]:
        if d[j]+1==d[i]:
            print(j)
            break


Measured memory_bytes: 138472
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    akari<seika> ss = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cout << 7 - distance(ss.begin(), find(ss.begin(), ss.end(), s)) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi >
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
#define M 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,w;
        cin>>n>>w;
        ll wt[n],p[n];
        rep(i,n)
        {
            cin>>wt[i]>>p[i];
        }
        ll dp[n+1][w+1];
        memset(dp,0,sizeof(dp));
        rep1(i,n)
        {
            rep1(j,w)
            {
                if(j>=wt[i-1])
                {
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+p[i-1]);
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
        cout<<dp[n][w];
    }
}


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

int main(){
	long a, b;
	while (cin >> a >> b){
		long c = a;
		long d = b;
		while (1){
			if (c < d) swap(c, d);
			// c >= d
			if (c % d == 0){
				cout << d << " " << (a * b) / d << endl;
				break;
			}
			else{
				long tmp = c;
				c = d;
				d = tmp % d;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
s = input()
s_list = list(s)
a_list = ['A','C','G','T']
c = 0
ans = 0
k = 0
for hoge in s_list:
  if hoge in a_list:
    c += 1
  else:
    ans = max(ans,c)
    c = 0
  k += 1
  if k == len(s_list):
    ans = max(ans,c)
print(ans)

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

int main() {
	ll result = 0;

	ll N = 1, K = 0;
	cin >> N >> K;

	vector<ll> H(max(N, K), 0);
	for(ll i = 0; i < N; i++) {
		cin >> H[i];
		result += H[i];
	}

	sort(H.begin(), H.end(), greater<ll>());
	for(ll i = 0; i < K; i++) {
		result -= H[i];
	}

 	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

a = [0]* n
b = [0]* n
for i in range(n):
    a[i], b[i] = map(int, input().split())

ans= 0
for i in reversed(range(n)):
    a[i]+=ans
    tmp = -(-a[i] // b[i])
    ans += tmp*b[i]-a[i]

print(ans)


Measured memory_bytes: 14836
S = input()

flag = 1
while len(S):
    if S[-7:] == 'dreamer':
        S = S[:-7]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    else:
        flag = 0
        break

if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const int maxN = 30;

ll k;

bool calc[maxN][maxN][10];
ll memo[maxN][maxN][10];

ll dp(int i, int L, int last) {
    if(i >= L) {
        return 1;
    }

    if(calc[i][L][last]) {
        return memo[i][L][last];
    }

    int d = 0;
    if(i == 0) {
        d = 1;
    }

    ll ans = 0;

    for(int dig = d; dig < 10; dig++) {
        if(abs(dig - last) > 1 && (i != 0)) {
            continue;
        }

        ans += dp(i + 1, L, dig);
    }

    calc[i][L][last] = true;
    return (memo[i][L][last] = ans);
}

void trace(int i, int len, int last, ll rem) {
    if(i >= len) {
        return;
    }

    for(int d = (i == 0) ? 1 : 0; d < 10; d++) {
        if(abs(d - last) > 1 && (i != 0)) {
            continue;
        }

        if(rem > dp(i + 1, len, d)) {
            rem -= dp(i + 1, len, d);
        } else {
            cout << d;
            trace(i + 1, len, d, rem);
            return;
        }
    }
}

void find(int len) {
    for(int i = 1; i < len; i++) {
        k -= dp(0, i, 0);
    }

    trace(0, len, 0, k);
}

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

    cin >> k;

    ll pref = 0;

    for(int i = 1; i <= 10; i++) {
        pref += dp(0, i, 0);
        if(pref >= k) {
            find(i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
s=input();t=input()
ls=len(s);lt=len(t)
dp=[[0]*(lt+1) for _ in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
ans=""
while ls and lt:
  if dp[ls][lt]==dp[ls-1][lt]:
    ls-=1
  elif dp[ls][lt]==dp[ls][lt-1]:
    lt-=1
  else:
    ls-=1;lt-=1
    ans+=s[ls]
print(ans[::-1])

Measured memory_bytes: 113116
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    num = []
    for i in range(5):
        num.append(int(readline()))

    k = 99
    ind = -1
    for i in range(5):
        r = num[i] % 10
        if r != 0:
            if r < k:
                k = r
                ind = i

    ans = 0
    for i in range(5):
        if i == ind:
            ans += num[i]
        else:
            ans += 10 * ((num[i] - 1) // 10 + 1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    if(S[0] == T[0]) ans++;
    if(S[1] == T[1]) ans++;
    if(S[2] == T[2]) ans++;
    cout << ans << endl;
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}
#define MOD 1000000007

typedef int64_t s64;
template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;

mint mpow(s64 num, s64 times) { // O(log(times))
    mint next = num%MOD;
	mint res = 1;
	while (times) {
		if (times%2)
            res *= next;
		next *= next;
		times /= 2;
	}
	return res;
}

struct MComb {
    std::vector<mint> fact;
    std::vector<mint> inversed;
    MComb(int n) { // O(n+log(mod))
        fact = std::vector<mint>(n+1,1);
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
        inversed = std::vector<mint>(n+1);
        inversed[n] = mpow((int)fact[n], MOD-2);
        for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
    }
    
    mint ncr(int n, int r) {
        return (fact[n] * inversed[r] * inversed[n-r]);
    }
    
    mint npr(int n, int r) {
        return (fact[n] * inversed[n-r]);
    }
    
    mint nhr(int n, int r) {
        assert(n+r-1 < (int)fact.size());
        return ncr(n+r-1, r);
    }
};

int main() {
	int n = ri();
	int a = ri();
	int b = ri();
	int c = ri();
	mint x;
	MComb com(2 * n + 1);
	for (int i = 0; i < n; i++) {
		x += mpow(a, n) * mpow(b, i) / mpow(a + b, n + i) * com.ncr(n + i - 1, i) * (n + i);
		x += mpow(b, n) * mpow(a, i) / mpow(a + b, n + i) * com.ncr(n + i - 1, i) * (n + i);
	}
	x *= (mint) 100 / (mint) (100 - c) ;
	std::cout << x << std::endl;
	return 0;
}


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

int main() {
    string s, t;
    cin >> s;
    int div = 1000;
    int T;
    for(int i=0; i < s.size()-2; i++) {
        t = s.substr(i, 3);
        T = stoi(t);
        div = min(abs(753-T), div);
    }
    cout << div << endl;
}



Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  int res = 1000;
  for (int i = 0; i < S.size() - 2; ++i) {
    res = min(res, abs(753 - stoi(S.substr(i, 3))));
  }
  printf("%d\n", res);
}

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

int Q;
int main() {
    cin>>Q;
    long long p,a,b;
    cin>>p>>a>>b;

    priority_queue<long long> l;
    priority_queue<long long, vector<long long>, greater<long long> > r;
    l.push(a),r.push(a);
    long long bsum=b,lsum=a,rsum=a;
    int size=1;
    while(Q-->1) {
        cin>>p;
        if(p==1) {
            cin>>a>>b;
            bsum+=b;
            if(size%2) {
                if(a<l.top()) {
                    lsum-=l.top();lsum+=a;
                    l.pop();l.push(a);
                } else if(a>r.top()) {
                    rsum-=r.top();rsum+=a;
                    r.pop();r.push(a);
                }
            } else {
                if(a<l.top()) {
                    lsum+=a;rsum+=l.top();
                    l.push(a);r.push(l.top());
                } else if(a>r.top()) {
                    rsum+=a;lsum+=r.top();
                    r.push(a);l.push(r.top());
                } else if(l.top()<=a && a<=r.top()) {
                    lsum+=a,rsum+=a;
                    l.push(a);r.push(a);
                }
            }
            size++;
        } else {
            long long res = rsum - lsum + bsum;
            cout<<l.top()<<" "<<res<<endl;
        }
    }
}

Measured memory_bytes: 3828
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        long[] ABN = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        long A = ABN[0], B = ABN[1], N = ABN[2];

        long x = Math.Min(N, B - 1);
        Console.WriteLine((long)((double)A * x / B) - A * (x / B));
    }
}

Measured memory_bytes: 27932
N = gets.to_i
h = Hash.new{0}
N.times{
    s = gets.chomp
    h[s] += 1
}
puts "AC x %d" % h["AC"]
puts "WA x %d" % h["WA"]
puts "TLE x %d" % h["TLE"]
puts "RE x %d" % h["RE"]


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> G[n];
	int d[n] = { };
	REP(i, n+m-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].pb(b);
		d[b]++;
	}
	int p = -1;
	REP(i, n) if(d[i] == 0) p = i;
	int len[n], ans[n];
	REP(i, n) len[i] = -1;
	ans[p] = 0;
	len[p] = 0;
	queue<int> que;
	que.push(p);
	vector<int> ts;
	while(!que.empty()){
		int f = que.front(); que.pop();
		ts.pb(f);
		for(int v: G[f]){
			d[v]--;
			if(d[v] == 0){
				que.push(v);
				ans[v] = f+1;
			}
		}
	}
	REP(i, n) cout << ans[i] << endl;
} 

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

int main(){
  int A,B;
  cin >> A;
  cin >> B;
  
  if(A + B == 3) cout << 3 <<endl;
  else if(A + B == 4) cout << 2 <<endl;
  else if(A + B == 5) cout << 1 <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,n,m,ans,count=0,mx=0,x;
    vector<long long int>v1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v1.push_back(x);
    }
    for(i=0;i<n-1;i++)
    {
        if(v1[i]>=v1[i+1])
        {
            count++;
        }
        else if(v1[i]<v1[i+1])
        {
            count=0;
        }
        mx=max(count,mx);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;
    int n,m;
    n=a.size();
    m=b.size();
    vector<vector<int> > v(26);
    for(int i=0;i<n;i++)
    {
        v[a[i]-'a'].push_back(i);
    }
    for(int i=0;i<n;i++)
    {
        v[a[i]-'a'].push_back(n+i);
    }
    long long cnt=0;
    for(int i=0;i<m;i++)
    {
       if(v[b[i]-'a'].size()==0)
       {
           cout<<"-1";
           return 0;
       }
    }int x=0;
    for(int i=0;i<m;i++)
    {
        int y=b[i]-'a';
         x=*lower_bound(v[y].begin(),v[y].end(),x)+1;
         if(x>=n)
         {
             cnt++;
             x-=n;

         }
    }
	cnt=1ll*cnt*n;
	cnt+=1ll*x;
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 1724
K,N=map(int,input().split())
A=list(map(int,input().split()))
B=[0 for k in range(N)]
for k in range(N-1):
    B[k]=A[k+1]-A[k]
B[N-1]=K-A[N-1]+A[0]
print(K-max(B))

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

using namespace std;

const int N = 3005;

int n; long double p[N], f[N][N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i][0] = (1 - p[i]) * f[i - 1][0];
    for (int j = 1; j <= i; ++j) {
      f[i][j] = p[i] * f[i - 1][j - 1] + (1 - p[i]) * f[i - 1][j];
    }
  }
  long double ans = 0;
  for (int j = n / 2 + 1; j <= n; ++j) {
    ans += f[n][j];
  }
  printf("%0.16f\n", (double) ans);
  return 0;
}



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

void solve(std::string S) {
    if (S.find("RRR") != S.npos) {
        cout << 3 << endl;
    } else if (S.find("RR") != S.npos) {
        cout << 2 << endl;
    } else if (S.find("R") != S.npos) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,temp,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        temp=b-a+1;
        ans+=temp;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n == 0){
        cout << 2 << endl;
        return 0;
    }
    else if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    ll a = 2, b = 1, c = 0;
    for(int i=2; i<=n; i++){
        c = a + b;
        a = b;
        b = c;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools
import collections
from queue import Queue
import functools
import math
INF = 10**9


def solve(N: int, K: int, x: "List[int]"):
    x_neg = ([-xx for xx in x if xx < 0]+[0])[::-1]
    x_pos = [0] + [xx for xx in x if xx >= 0]

    # 左先を考える
    left = [x_neg[i]*2 + x_pos[K-i] for i in range(len(x_neg))
            if 0 <= K-i and K-i < len(x_pos)]
    if len(left) > 0:
        ansleft = min(left)
    else:
        ansleft = INF

    # 右先
    right = [x_pos[i]*2 + x_neg[K-i] for i in range(len(x_pos))
             if 0 <= K-i and K-i < len(x_neg)]
    if len(right) > 0:
        ansright = min(right)
    else:
        ansright = INF
    # print(left)
    # print(right)
    print(min(ansright, ansleft))

    return


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
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int i=0;i<(n);i++)        //repeat n times
#define REP2(i,s,n) for(int i=(s);i<(n);i++)   //repeat from s to n 
#define REPD(i,n) for(int i=(n);i>=0;i--)      //repeat from n to 0
#define REPD2(i,s,e) for(int i=(s);i>=(e);i--) //repeat from s to e
#define RANGE(i,v) for(auto &i:v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int X,N;
    cin>>X>>N;
    Vi p(N);
    REP(i,N) cin>>p[i];

    int ans = 0;
    int abs_ans = X;
    REP(i,102){
        bool skip = false;
        REP(j,N){
            if(i == p[j]) skip = true;
        }
        if(skip) continue;

        if(abs_ans>abs(X-i)){
            ans = i;
            abs_ans = abs(X-i);
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
 
int l[MAX/2+2], r[MAX/2+2];
int cnt;
 
void merge(int [], int, int, int, int);
void mergeSort(int [], int, int, int);
 
int main(){
  int a[MAX], n, i;
 
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  mergeSort(a, n, 0, n);
  for(i = 0;i < n;i++){
    if(i) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  printf("%d\n", cnt);
  return 0;
}
 
void merge(int a[], int n, int left, int mid, int right){
  int n1, n2, i, j, k;
 
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0;i < n1;i++){
    l[i] = a[left+i];
  }
  for(i = 0;i < n2;i++){
    r[i] = a[mid+i];
  }
  l[n1] = r[n2] = SENTINEL;
  i = j = 0;
  for(k = left;k < right;k++){
    cnt++;
    if(l[i] <= r[j]){
      a[k] = l[i++];
    }
    else a[k] = r[j++];
  }
}
 
void mergeSort(int a[], int n, int left, int right){
  int mid;
 
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(a, n, left, mid);
    mergeSort(a, n, mid, right);
    merge(a, n, left, mid, right);
  }
}

Measured memory_bytes: 4508
// Example program
#include <iostream>
using namespace std;

int main()
{
    int n, b, s;
    b = -1000001;
    s = 1000001;
    long long a, k;
    k = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        k = k+a;
        if (b<a){
            b = a;
        }
        if (s>a){
            s = a;
        }
    }
    
    cout << s << " " << b << " " << k << endl;
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll MOD = 1e9+7;
vector < P > pairs;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
#define ALL(c) (c).begin(), (c).end()
 
// pair (降順, 降順)
bool compare_pair(P a, P b) {
    if (a.first > b.first) return true;//firstが先に書いてあるからfirst基準ソート
    if (a.first < b.first) return false;
    if (a.second > b.second) return true;//今は降順、true falseひっくり返せば降順、昇順切り替え
    if (a.second < b.second) return false;
    return false;
}

int main(){
    ll X , ans;
    cin >> X;
    if( (X % 105) == 0 ) {
        cout << 1;
        return 0;
    }
    ll kosuu = (X / 105) +1 ;
    ll OverNedan =kosuu * 105;
    if(  (OverNedan - X) > (5*kosuu) ){
        ans = 0;
    }else{
        ans = 1;
    }
    cout << ans;
    return 0;
}

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

const int maxn=1e5+5;

int n,m;
ll pos[maxn],maxx[maxn];//记录本身权值和该点与相邻节点的最大权值 

signed main()
{
	while(cin>>n>>m){
		memset(pos,0,sizeof pos);
		memset(maxx,0,sizeof maxx);
		for(int i=1;i<=n;i++)
		cin>>pos[i];
		ll x,y;
		for(int i=1;i<=m;i++){
			cin>>x>>y;
			maxx[x]=max(maxx[x],pos[y]);
			maxx[y]=max(maxx[y],pos[x]);
		}
		int cnt=0;
		for(int i=1;i<=n;i++)
		if(maxx[i]<pos[i])cnt++;
		cout<<cnt<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5160
#include <iostream>
#include <array>
#include <algorithm>
   
int main(){
    std::array<u_int, 10> heights;
      
    for (int i = 0; i < 10; ++i){
        std::cin >> heights[i];
    }
      
    std::sort(heights.begin(), heights.end(), std::greater<u_int>());
      
    for (int i = 0; i < 3; ++i){
        std::cout << heights[i] << std::endl;
    }
     
    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n;
  cin>>n;
  vector<int>x(n+2);
  for(int i=0;i<n;i++){
  	cin>>x[i+1];
  }
  x[n+1]=0,x[0]=0;
  ll tot = 0;
  for(int i=1;i<n+1;i++){
  	tot+=abs(x[i]-x[i-1]);
  }
  tot+=abs(x[n]);
  ll temp = tot;
  for(int i=0;i<n;i++){
  	temp=tot;
  	temp-=abs(x[i+1]-x[i]);
  	temp-=abs(x[i+1]-x[i+2]);
  	temp+=abs(x[i]-x[i+2]);
  	cout<<temp<<endl;
  }
  
}  


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;

	string abc = "ABC";
	int res = 0;
	rep (i, 0, n - 2) {
		if (equal(s.begin() + i, s.begin() + i + 3, abc.begin()))
			res++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256