akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  ll N;
  cin >> N;
  VL a(N+1,0);
  ll pohe;
  REP(i,1,N+1)
    {
      cin >> pohe;
      a[pohe] = i;
    }
  set<ll> bag;
  ll sum = 0;
  for (ll i = 1; i <= N; i++)
    { 
      ll index = a[i];
      bag.insert(index);
      auto iter_l = bag.find(index);
      auto iter_r = bag.find(index);
      //cout << "index:"<<index<<endl;
      ll l = 0;
      if (iter_l != bag.begin())
	{
	  iter_l--;
	  l = *iter_l;
	}
      //cout << l << endl;
      iter_r++;
      ll r = N+1;
      if (iter_r != bag.end())
	r = *iter_r;
      //cout << r << endl;
      sum += i * (index - l) * (r - index);
      //cout << i <<" * "<<index-l<<" * "<<r-index<<endl;
      
    }
  cout << sum << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;

    int f = stoi(S.substr(0, 2));
    int b = stoi(S.substr(2, 2));

    if(f < 13 && b < 13 && b != 0 && f != 0) {
        cout << "AMBIGUOUS" << endl;
    } else if(f < 13 && f != 0 && (b == 0 || b > 12)) {
        cout << "MMYY" << endl;
    } else if((f > 12 || f == 0) && b != 0 && b < 13) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] +a[1] >=a[2]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    auto func = [](ll n) -> ll {
        vll es;
        for (ll i = 2; i * i <= n; i++) {
            if (n % i != 0) continue;
            ll j = 0; for (; n % i == 0; n /= i) j++;
            es.push_back(j);
        }

        ll res = n > 1;
        for (ll e : es) for (ll i = 1;; i++)
            if (i * (i + 1) / 2 > e) {
                res += i - 1; break;
            }

        return res;
    };

    std::cout << func(n) << '\n';
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int r = 0;
		r =  k;
		for (int i = 1; i < n; i++) {
			r = r*(k-1);
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
N = int(input())
D,X = [int(i) for i in input().split()]
A = [0] * N
for i in range(N) :
    A[i] = int(input())
sum = X
for i in range(N) :
    count = 1
    day = 1
    while True :
        day += A[i]
        if day <= D :
            count+=1
        else :
            sum+=count
            break
print(sum)

Measured memory_bytes: 3064
input = input()

count = 0
s1 = ''
s2 = ''
if len(input) % 2 == 0:
  s1 = list(input[:len(input)//2])
  s2 = list(reversed(input[len(input)//2:]))
elif len(input) % 2 == 1:
  s1 = list(input[:len(input)//2])
  s2 = list(reversed(input[len(input)//2+1:]))

for i in range(len(s1)):
  if s1[i] != s2[i]:
    count += 1
print (count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    string s, t;
    cin >> s >> t;

    int left = 1;
    int right = w;
    for(int i = n-1; i >= 0; i--)
    {
        if(t[i] == 'L') right = min(w, right + 1);
        if(t[i] == 'R') left = max(1, left - 1);
        if(s[i] == 'L') left++;
        if(s[i] == 'R') right--;
        if(left > right)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    if(sc < left || sc > right)
    {
        cout << "NO" << endl;
        return 0;
    }

    int up = 1;
    int down = h;
    for(int i = n-1; i >= 0; i--)
    {
        if(t[i] == 'U') down = min(h, down + 1);
        if(t[i] == 'D') up = max(1, up - 1);
        if(s[i] == 'U') up++;
        if(s[i] == 'D') down--;
        if(up > down)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    if(sr < up || sr > down)
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A[CMax];
long long maz, did;

int main() {
    scanf("%d", &n);

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

    if (A[n-1] > 2) {
        printf("-1\n");
        return 0;
    }

    maz = 2; did = 3;
    for (int i = n - 2; i >= 0; i--) {
        if ((long long)A[i] > did) {
            printf("-1\n");
            return 0;
        } else {
            maz = ((maz / (long long)A[i]) + (long long)(maz % (long long)A[i] > 0 ? 1 : 0)) * (long long)A[i];
            if (maz > did) {
                printf("-1\n");
                return 0;
            } else {
                did = (did / (long long)A[i]) * (long long)A[i] + (long long)A[i] - 1;
            }
        }
    }

    cout << maz << ' ' << did << endl;
}



Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
using namespace std;
int main()
{

    deque<int >vi;
    int n,x,y,z;
    while (cin>>n)
    {
        while (n--)
        {
            scanf("%d %d", &x, &y);
            switch (x)
            {
            case 0:
                scanf("%d", &z);
                if (y == 0)
                {
                    vi.push_front(z);
                    //vi.insert(vi.begin(), z);
                }
                else
                {
                    vi.push_back(z);
                    //vi.insert(vi.end(), z);
                }
                break;
            case 1:
                printf("%d\n",vi[y]);
                break;
            case 2:
                if (y == 0)
                {
                    vi.pop_front();
                    //vi.erase(vi.begin()+0);
                }
                else
                {
                vi.pop_back();
                }
                break;
            default:
                break;
            }

        }
        vi.clear();
    }
    return 0;
}



Measured memory_bytes: 4572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  vector<ll> p(a,0);
  rep(i,a) cin >> p.at(i);
  vector<ll> q(b,0);
  rep(i,b) cin >> q.at(i);
  vector<ll> r(c,0);
  rep(i,c) cin >> r.at(i);

  sort(all(p),greater<ll>());
  sort(all(q),greater<ll>());
  sort(all(r),greater<ll>());

  priority_queue<ll, std::vector<ll>, std::greater<ll> > pq;
  priority_queue<ll, std::vector<ll>, std::greater<ll> > qq;
  ll ptot = 0;
  ll qtot = 0;
  rep(i,x) {
    pq.push(p.at(i));
    ptot += p.at(i);
  }
  rep(i,y) {
    qq.push(q.at(i));
    qtot += q.at(i);
  }

  rep(i,min(x+y,c)){
    if(pq.top() <= qq.top())
    {
      if(r.at(i) > pq.top()) {
        ptot -= pq.top();
        pq.pop();
        pq.push(r.at(i));
        ptot += r.at(i);
      }
    } else {
      if(r.at(i) > qq.top()) {
        qtot -= qq.top();
        qq.pop();
        qq.push(r.at(i));
        qtot += r.at(i);
      }
    }
  }

  cout << ptot + qtot << endl;

  return 0;
}


Measured memory_bytes: 4852
import sys
import math
#input=sys.stdin.buffer.readline  
t=1
#t=int(input())
for _ in range(t):
    n=int(input())
    #n,c=map(int,input().split())
    suma=0
    length=0
    mul=1
    ans=[]
    while n>0:
        n-=1
        ans.append(chr(n%26+97))
        n//=26
    print(*ans[::-1],sep="")    
        
        
            
                

Measured memory_bytes: 62064
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int a[1000005]={};
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<n;i++){
        for(int j=i;j<=n;j+=i){
            a[j]++;
        }
    }
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
  return(0);
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int N(1001000);
	vector<bool>p(N, true); p[0] = p[1] = false;
	for (int i = 2; i*i <= N; i++) {
		if (p[i]) {
			for (int j = i + i; j < N; j += i)p[j] = false;
		}
	}
	int n;
	while (cin >> n, n) {
		int ans(0);
		for (int i = 2; i <= n / 2; i++) {
			if (p[i] && p[n - i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>

int main(void){
    int A, B, C, X;
    int counter = 0;
    scanf("%i %i %i %i", &A, &B, &C, &X);
    int a = X / 500; // Xについて500円玉の最大枚数
    int b = X / 100; // Xについて100円玉の最大枚数
    int c = X / 50; // Xについて50円玉の最大枚数
    if (A < a){
        a = A;
    }
    if (B < b){
        b = B;
    }
    if (C < c){
        c = C;
    }
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if (500 * i + 100 * j + 50 * k == X){
                    counter++;
                }
            }
        }
    }
    printf("%i\n", counter);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> a={0,0,0,0};
    for(int i=0;i<6;i++){
        int x;
        cin >> x;
        a[x-1]++;
    }
    sort(a.begin(), a.end());
    if(a[0]==1 && a[1]==1 && a[2]==2)cout << "YES";
    else cout << "NO" << endl;
    


}

/*



 */


Measured memory_bytes: 256
def selection_sort(array)
  times = 0
  (0...array.size).each do |i|
    mini = i
    (i...array.size).each do |j|
      mini = j if array[j] < array[mini]
    end
    if i != mini
      times += 1
      array[i], array[mini] = array[mini], array[i]
    end
  end
  [array, times]
end
n = gets.to_i
s = gets.split.map(&:to_i)
array, times = selection_sort(s)
puts array.join(' ')
puts times

Measured memory_bytes: 6108
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[][][] list = new int[4][3][10];
        for (int i = 0; i < a; i++) {
            int b = scanner.nextInt() - 1;
            int c = scanner.nextInt() - 1;
            int d = scanner.nextInt() - 1;
            int e = scanner.nextInt();
            list[b][c][d] += e;
        }
 
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + list[i][j][k]);
                }
                System.out.println();
            }
            if (i != 3)
                System.out.println("####################");
        }
 
    }
}


Measured memory_bytes: 29528
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
char field[6][6];

int main()
{
	int H,W,K;
	cin>>H>>W>>K;
	vector<int> row(H,0);
	vector<int> column(W,0);
	int blackNum = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>field[i][j];
			if(field[i][j] == '#'){
				row[i]++;
				column[j]++;
				blackNum++;
			}
		}
	}

	ll ans = 0;
	for(ll bitR = 0; bitR <(1<<H); bitR++){
		int rowNum = 0;
		for(int i = 0; i < H; i++){
			if( (1<<i) & bitR){
				rowNum += row[i];
			}
		}
		for(ll bitC = 0; bitC < (1<<W); bitC++){
			int columnNum = 0;
			for(int j = 0; j < W; j++){
				if( (1<<j) & bitC){
					columnNum += column[j];
				}
			}
			ll sum = columnNum + rowNum;
			for(int i = 0; i < H; i++){
				if( (1<<i) & bitR){
					for(int j = 0; j < W; j++){
						if( (1<<j) & bitC && field[i][j] == '#') sum--;
					}
				}
			}
			if( (blackNum - sum) == K) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int cnt[26] = {};
char s[100005];

int main() {
    scanf("%s", s);
    for(int i = 0; s[i]; i++)
        cnt[s[i] - 'a']++;
    for(int i = 0; i < 26; i++) {
        if(!cnt[i]) {
            printf("%c\n", i + 'a');
            return 0;
        }
    }
    puts("None");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	unsigned int N,K;
	cin>>N>>K;
	
	N--;
	unsigned int ans = K;
	for(int i=0;i<N;i++){
		ans *= K-1;
	}
	
	cout<<ans<<endl;
	
    return 0;
}



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

int main() {
    long n, k, val;
    cin >> n >> k;
    map<long, long> x;
    for (long i=0; i<n; i++) {
        long a, b;
        cin >> a >> b;
        x[a] += b;
    }
    auto itr = x.begin();
    for (; val < k && itr != x.end(); itr++) {
        val += itr->second;
    }
    cout << (--itr)->first << endl;
    return 0;
}

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


def dsMakeSet(ds, x):
    ds[x] = x


def dsFind(ds, x):
    if ds[x] == x:
        return x

    x0 = x
    while ds[x] != x:
        x = ds[x]

    ds[x0] = x
    return x


def dsUnion(ds, x, y):
    xRoot = dsFind(ds, x)
    yRoot = dsFind(ds, y)
    
    if xRoot != yRoot:
        ds[yRoot] = xRoot
        return True

    return False


def main():
    N, M = map(int, input().split())
    ds = {}

    for i in range(N):
        dsMakeSet(ds, i+1)

    n = 0
    for i in range(M):
        X,Y,Z = map(int, input().split())
        if dsUnion(ds, X, Y):
            n += 1
        
    print(N - n)
        

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int col = b + 2;
	string s[a];
	for(int i=0;i<a;i++)
	{
		cin >> s[i];
	}
	for(int i=0;i<col;i++)
		cout << '#';
	cout << endl;
	int k = 0;
	while(a--)
	{
		cout << '#';
		cout << s[k++]; 
		cout << '#' << endl;	
	}	
	for(int i=0;i<col;i++)
		cout << '#';
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    llong n;
    cin >> n;

    if ((n-1)  % 11 <= 5 ) {
        cout << 2 * ((n-1) / 11) + 1 << endl;
    } else {
        cout << 2 * ((n-1) / 11) + 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s; bool finish=false;
  for(int i='a'; i<'z'; i++){
    for(int j=0; j<s.size(); j++){
      if(s[j]==i) break;
      if(j==s.size()-1){
        finish=true;
        s.push_back(i);
      }
    }
    if(finish) break;
  }
  string t=s;
  if(finish==false){
    if(s=="zyxwvutsrqponmlkjihgfedcba") s="-1";
    else{
      next_permutation(s.begin(), s.end());
      for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) s.erase(s.begin()+i+1, s.end());
      }
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int x;
    
    //繰り返し処理をするときは「　for文　」を使う
    for(int i=1; i<=10000; i++){
        cin >> x;
        if(x != 0){
            cout << "Case " << i << ": " << x << endl;
        }
        else{
            break;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
    cin>>a>>b;
    if(a>0)
    {
    	cout<<"Positive";
    }
    else if(a==0||(a<0&&b>0))
    {
    	cout<<"Zero";
    }
    else if((abs(b)-abs(a))%2!=0)
    {
    	cout<<"Positive";
    }
    else
    {
    	cout<<"Negative";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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

	int count=0;
	long long dual=0;
	char rt;
	long long chp=0;
	long long pena=1;
	vector <bool>z(26,false);
	sort(A.begin(),A.end());
	rt=A[0];
	z[(int)A[0]-'a']=true;
	for(int i=1 ;i<A.size() ; i++){
		chp+=i;
		z[(int)A[i]-'a']=true;
		if(rt==A[i]){
			dual+=pena;
			pena+=1;
		}
		else{
			rt=A[i];
			pena=1;
		}
	}
	for(int i=0 ; i<26 ; i++){
		if(z[i]==true)count+=1;
	}

    cout<<1+chp-dual<<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c,d;
    string s,t;
 
    //cin >> a >> b>> c >> d;
    cin >> s >> t;
    if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES"<< endl;
    else cout << "NO"<< endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a=sc.nextInt();
        int b=sc.nextInt();
        int N=sc.nextInt();
        for (int i=0;i<N;++i)
        {
            int s=sc.nextInt();
            int f=sc.nextInt();

            if (s<=a && a<f) {ans=1; break;}
            if (s<b && b<=f) {ans=1; break;}
            if (a<=s && f<=b) {ans=1; break;}
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 26552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
#include <sys/time.h>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ( (a)/__gcd((a),(b))*(b) )

template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}
int main(){
	int n,m;
	while(cin >> n >> m){
		int mx = 3*n/8;
		int mi = n/8;
		int d[1000] = {0};
		vector< vector<int> > v(1000);
		vector<int> c(1000);
		rep(i,m){
			rep(j,n/2){
				int a;
				cin >> a;
				a--;
				v[a].push_back(i);
				d[a]++; 
			}
		}
		int seq[1000] = {0};

		vector< pair<int,int> > p;
		rep(i,n)p.push_back(make_pair(d[i],i));
		sort(p.begin(),p.end(),greater<pair<int,int> >() );
		rep(bigI,n){
			int i = p[bigI].second;
			bool f = true;
			rep(j,v[i].size()) if(c[ v[i][j] ] >= mx ) f = false;
			if(f)rep(j,v[i].size()) c[ v[i][j] ]++ , seq[i] = 1;
		}
		rep(i,n) cout << seq[i];
		cout << endl;
	}	
}

Measured memory_bytes: 2316
#include<iostream>
#include<vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> h(n);

    for(int i ; i < n ; i++){
        std::cin >> h[i];
    }

    int ans = 0 ;
    int active = 0;
    for(int i = 0; i < n ; i++){
        if(active >= h[i]){
            active = h[i];
        }else{
            ans = ans + h[i] - active;
            active = h[i];
        }
    }
    std::cout << ans;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  string s; cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x + r > W || x - r<0 || y + r>H || y - r < 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var V = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var C = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = int.MinValue;

        for (int pattern = 0; pattern < (1 << N); pattern++)
        {
            var X = 0;
            var Y = 0;
            for (int i = 0; i < N; i++)
            {
                if((pattern & (1 << i)) != 0)
                {
                    X += V[i];
                    Y += C[i];
                }
            }

            ans = Math.Max(ans, X - Y);
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 28232
#include<iostream>
#include<algorithm>
#include<cassert>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define N 100

const int INF = 1000100; 
int table[N];
int buycost[N];

int solve(int now,vector<int> *make){
  //  if ( table[now] != -1)return table[now];
  if(  make[now].size()==0)return table[now]=buycost[now];
  

  int ret = buycost[now],tmp=0;  
  rep(i,make[now].size()){
    tmp+=solve(make[now][i],make);
  }
  
  ret= min(ret,tmp);
  return table[now]=ret; 
}

main(){
  int n;
  while(cin>>n && n){
    map<string,int> M;
    rep(i,n){
      string t;int a;
      cin>>t>>a;
      M[t]=i;
      buycost[i]=a;
      table[i]=-1;
    }
    
    vector<int> make[n];
    cin>>n;
    rep(i,n){
      string a;
      cin>>a;
      int now =M[a],m;
      cin>>m;
      rep(j,m){
	cin>>a;
	make[now].push_back(M[a]);
      }     
    }
    string tmp;
    cin>>tmp;
    int tar=M[tmp];
    cout << solve(tar,make) << endl;
    
  }
  return false;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
double t,x;

/*
 *解 
 */
void solve(){
    printf("%lf",t/x);
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>t>>x;
       solve();
       return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define ll long long
#define sz(x) (int)(x).size()
const int mxn=2e5+10;
int g[mxn],v[mxn],nxt[mxn],ed=0;
void add(int x,int y){
	v[++ed]=y;
	nxt[ed]=g[x];
	g[x]=ed;
}
int dp[mxn];
int size[mxn];
int dfs(int fa,int x){
	int cnt=0;
	for(int i=g[x];i;i=nxt[i]){
		if(v[i]==fa)continue;
		dp[x]+=dfs(x,v[i]);
		if(dp[v[i]]==0)cnt++;
	}
	if(cnt>1)dp[x]+=cnt-1;
	return dp[x];
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		size[u]++;
		size[v]++;
		add(u,v);
		add(v,u);
	}
	for(int i=0;i<n;i++){
		if(size[i]>=3){
			cout<<dfs(i,i);
			return 0;
		}
	}
	cout<<1;
	return 0;
}

Measured memory_bytes: 5504
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max],b[Max];
ll n,m,k,res; 
struct BIT {
private:
	vector<ll> node; int n;
public:
	void init(int n_) {
		n = n_; node.resize(n, 0);
	}
	//0-indexed
	void add(int a, ll w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	ll sum(int a) {
		ll ret = 0;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	ll sum(int a, int b) {
		return sum(b) - sum(a);
	}
};
void solve(){
	double A,B;
	
	cin>>A>>B;
	int aa = A,bb = B;
	A*=12.5;
	B*=10;
	for(int x = max(A,B);1;x++){
		//cout<<(int)(x*0.08)<<" "<<(int)(x*0.1)<<endl;
		if(((int)(x*0.08))==aa&&((int)(x*0.1)==bb)){
			cout<<x;
			return ;
		}
		if((int)(x*0.08)>aa||(int)(x*0.1)>bb)break;
	}
	cout<<-1;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,k;
string s;

int main() {
  cin >> n >> s;
  int re=count(all(s),'E');
  int le=0,lw=0,ans=1e9;
  rep(i,n){
    if(s[i]=='E') re--;
    chmin(ans,lw+re);
    if(s[i]=='W') lw++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <stdio.h>
#include <stdlib.h>

int ord(const void * x, const void * y){
	int a = *((int *) x), b = *((int *) y);
 
	if (a<b)
		return -1;
	if (a>b)
		return 1;
 
	return 0;
 
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    
    int vec[n];
    for (int i = 0; i < n;++i){
        scanf("%d", &vec[i]);
    }
    
    qsort(vec, n, sizeof(vec[0]), ord);
    int a = 0;
    for (int i = 0; i < k; ++i){
        a += vec[i];
    }
    printf("%d\n", a);

    return 0;
}


Measured memory_bytes: 1680
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int d[10];
    memset(d,0,sizeof(d));
    for(int i=0;i<k;i++)
    {
        int x;
        cin>>x;
        d[x]=1;
    }
    for(int i=n;i<=100000;i++)
    {
        bool p=true;
        int a[10];
        int temp=i;
        memset(a,0,sizeof(a));
        while(temp>0)
        {
            int t=temp%10;
            temp/=10;
            a[t]++;
        }
        for(int j=0;j<=9;j++)
        {
            if(a[j]>0 && d[j]>0)
            {
                p=false;
                break;
            }
        }
        if(p)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}







Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

struct UnionFind{
	int *par;
	ll *size;
	UnionFind(int n){
		par=(int *)malloc(sizeof(int)*n);
		size=(ll *)malloc(sizeof(ll)*n);
		rep(i,n)par[i]=i;
		rep(i,n)size[i]=1;
	}
	int root(int x){
		if(par[x]==x)return x;
		return par[x]=root(par[x]);
	}


	void unite(int x, int y){
		int rx=root(x);
		int ry=root(y);
		if(rx==ry)return;
		par[ry]=rx;
		size[rx]+=size[ry];
	}

	bool same(int x, int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}

	ll get_size(int x){
		return size[root(x)];
	}
};

int main(void){
	ll n,m;
	cin>>n>>m;
	pair<int,int> a[m];
	rep(i,m)cin>>a[i].first>>a[i].second;

	UnionFind tree(n);
	ll ans[m];
	ans[m-1]=0;
	rep(i,m-1){
		int x=a[m-1-i].first-1, y=a[m-1-i].second-1;
		if(!tree.same(x,y)){
			ans[m-2-i]=ans[m-1-i]+tree.get_size(x)*tree.get_size(y);
			tree.unite(x,y);
		}
		else ans[m-2-i]=ans[m-i-1];
	}
	rep(i,m)cout<<n*(n-1)/2-ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		final int N= 13;
		long[] dp = new long[N];

		dp[0] = 1;
		long mod = 1000000007L;

		int mul = 1;
		for (int i= S.length() -1; i >= 0; i--){

			long[] nextDP = new long[N];

			char c = S.charAt(i);
			if (c == '?'){
				for (int k=0; k < 10; k++){
					for (int j = 0; j < N; j++){
						nextDP[(k * mul + j) % N] += dp[j];
						nextDP[(k * mul + j) % N] %= mod;
					}
				}
			} else {
				int k = c - '0';
				for (int j = 0; j < N; j++){
					nextDP[(k * mul + j) % N] += dp[j];
					nextDP[(k * mul + j) % N] %= mod;
				}
			}
			dp = nextDP;

			mul *= 10;
			mul %= N;
		}
		System.out.println(dp[5]);
	}
}

Measured memory_bytes: 35600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    string s,t;
    cin >> s >> t;
    rep(i,s.length()){
        if(s[i]!=t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    
}

/*
*/



Measured memory_bytes: 3608
def solve():
    N = int(input())
    if N == 0:
        return False
    E = []
    D = {}
    for i in range(N):
        e, p, q = map(int, input().split())
        E.append(e)
        D[e] = D.get(e, 0) + p*q
    cnt = 0
    for e in E:
        if D.get(e, 0) >= 1000000:
            print(e)
            del D[e]
            cnt += 1
    if cnt == 0:
        print("NA")
    return True
while solve():
    ...



Measured memory_bytes: 5784
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    char s[n][50];
    int alp[26];
    int i = 0;
    for (i = 0; i < 26; i++)
    {
        alp[i] = 50;
    }
    for (i = 0; i < n; i++)
    {
        scanf("%s",s[i]);
        int j = 0;
        int alps[26];
        for (j = 0; j < 26; j++)
        {
            alps[j] = 0;
        }
        for (j = 0; j < 50; j++)
        {
            if (s[i][j] == '\0')
                break;
            int l = (int) s[i][j] - 'a';
            alps[l]++;
        }
        for (j = 0; j < 26; j++)
        {
            if (alp[j] > alps[j])
            {
                alp[j] = alps[j];
            }
        }
    }
    for (i = 0; i < 26; i++)
    {
        int j = 0;
        for (j = 0; j < alp[i]; j++)
        {
            printf("%c",'a' + i);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
 
int
main(int argc, char *argv[])
{
  char s[101]; long long k;
  scanf("%s", s);
  scanf("%lld", &k);
 
 
  long long i = 0;
  while(s[i] == '1'){
    i++;
  }
 
  if(i >= k) printf("1\n");
  else printf("%c\n", s[i]);
 
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    std::cin >> n>>m;
    UnionFind u(n);
    rep(i,m){
        int x,y,z;
        std::cin >> x>>y>>z;
        x--;y--;
        u.unite(y,x);
    }
    std::set<int> a;
    rep(i,n){
        a.insert(u.root(i));
    }
    std::cout << a.size() << std::endl;
}

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

int main() {  
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end());

  if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
    cout << "YES" << endl;
  }  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string a;
  int sum=0;
    cin>>a;
  
  for(int i=0;i<a.size();i++)
  {
   sum=sum+( a[i]-'0');  
    sum=sum%9;
  }
  //cout<<sum<<endl;
if(sum==0)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

int main() {
  int n;
  cin >> n;
  vector< vector<int> > graph(n + 1, vector<int>(n + 1));
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      graph[u][v]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cout << graph[i][j];
      if (j == n) cout << endl; else cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define ll long long

ll fibo(ll n) {
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        ll tmp = 1;
        for (int j = 0; j < i-1; j++) {
            tmp *= 2;
        }
        sum += tmp;
    }
    return sum;
}

int main() {
    ll H;
    cin >> H;
    ll attack = 1;
    
    while (H > 1) {
        H /= 2;
        attack += 1;
    }
    cout << fibo(attack) << endl;
}



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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n, a, b, ans = 0; cin >> n >> a >> b;

    REPI(i, n + 1){
        int count = 0;
        for(int j = i; j; ){
            count += j % 10;
            j /= 10;
        }
        if(count <= b & count >= a) ans += i;
    }
    cout << ans;
}


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

using namespace std;

int main() {

	string s;
	int joi, ioi;

	while(cin >> s) {
		joi=ioi=0;
		for(int i=0; i<s.size()-2; i++) {
			if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I') {
				joi++;
			}
			if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I') {
				ioi++;
			}
		}
		cout << joi << endl << ioi << endl;
	}
			
	return 0;

}

Measured memory_bytes: 0
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int n, m;
  cin >> n >> m;
  vector<lint> h;
  for (int i = 0; i < n; i++) {
    lint tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (tonari.at(i).empty()) {
      ans++;
      continue;
    }
    bool flag = true;
    for (int j = 0; j < tonari.at(i).size(); j++) {
      if (h.at(i) <= h.at(tonari.at(i).at(j))) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 9256
from collections import defaultdict

N=int(input())
A=[int(x) for x in input().split()]
dict=defaultdict(int)

for i in range(N):
  dict[A[i]]+=1

ans=[]
for x,y in dict.items():
  if 2 <= y < 4:
    ans.append(x)
  elif y>=4:
    ans.append(x)
    ans.append(x)
  else:
    continue
if len(ans) < 2:
  print(0)
else:
  ans.sort(reverse=True)
  print(ans[0]*ans[1])

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

z=[[0,0,0] for _ in range(n)]
z[0]=[a[0], b[0], c[0]]
for i in range(1, n):
    z[i][0]=max(a[i]+z[i-1][1], a[i]+z[i-1][2])
    z[i][1]=max(b[i]+z[i-1][0], b[i]+z[i-1][2])
    z[i][2]=max(c[i]+z[i-1][0], c[i]+z[i-1][1])

print(max(z[-1]))


Measured memory_bytes: 34636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
long long int A[2000000];


int main(){
    ll N,minn=1000000,cnt=0;
    cin>>N;
    for(ll i=0;i<N;i++) cin>>A[i];
    for(ll i=0;i<N;i++){
      minn=min(minn,A[i]);
      if(A[i]==minn) cnt++;
    }
  cout<<cnt;
      
}

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

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

char s[60][60];
int h,w;
bool ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>s[i][j];

    ans = true;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                if((s[i+1][j]=='#')||(s[i-1][j]=='#')||(s[i][j+1]=='#')||(s[i][j-1]=='#')){}
                else ans=false;
            }

        }
    }
    if(ans){cout<<"Yes\n";}
    else cout<<"No\n";
}


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

char s[101];
bool a, b;

int main() {
	cin >> s;
	for (register int i = 0; s[i]; ++i) 
		if (s[i] == 'C')
			for (register int j = i + 1; s[j]; ++j)
				if (s[j] == 'F') {
					cout << "Yes";
					return 0;
				}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if b[i] >= a[i]:
            ans += a[i]
            b[i] -= a[i]
            if b[i] >= a[i+1]:
                ans += a[i+1]
                a[i+1] = 0
            else:
                ans += b[i]
                a[i+1] -= b[i]
        else:
            ans += b[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24076
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main(void){
    ll n, M = 0, A = 0, R = 0, C = 0, H = 0, ans = 0;
    cin >> n;
    vector<string> data(n);
    for (int i = 0; i < n; ++i) cin >> data[i];
    
    for (int j = 0; j < n; ++j) {
        switch (data[j].at(0)){
            case 'M':
                ++M;
                break;
            case 'A':
                ++A;
                break;
            case 'R':
                ++R;
                break;
            case 'C':
                ++C;
                break;
            case 'H':
                ++H;
                break;
            default:
                break;
        }
    }
    ans += M*A*R;
    ans += M*A*C;
    ans += M*A*H;
    ans += M*R*C;
    ans += M*R*H;
    ans += M*C*H;
    ans += A*R*C;
    ans += A*R*H;
    ans += A*C*H;
    ans += R*C*H;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


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

	int n, m;
	cin >> n >> m;
	int k;
	int index;
	int *a = new int[m] {0};
	for (int i = 0; i < n; i++)
	{
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> index;
			a[index - 1]++;
		}
	}

	int count = 0;
	for (int i = 0; i < m; i++)
	{
		if (a[i] == n)
			count++;
	}

	cout << count << '\n';

	return 0;
}


/*

*/

Measured memory_bytes: 256