akhauriyash/Code-Regression huggingface dataset:
from itertools import product
import bisect

N, A, B, C = map(int, input().split()) 
tl = [C,B,A]

ll = []
for _ in range(N):
    ll.append(int(input()))



ans = 10**8
ite = product(range(4),repeat=N)
for pattern in ite:
    bag = [[],[],[]]
    singles = []
    mp = 0
    for i, p in enumerate(pattern):
        if p == 3: singles.append(ll[i])
        else: bag[p].append(ll[i])
    
    zero_cnt = 0
    for b in bag:
        if not b: zero_cnt+=1
        else: mp += (len(b)-1)*10
    if not singles: zero_cnt+=1
    if zero_cnt >= 2: continue

    bamboos = []
    for b in bag:
        if b: bamboos.append(sum(b))
    for s in singles:
        bamboos.append(s)

    bamboos.sort()
    # print(bamboos)
    
    for t in tl:
        curr_min = 10000
        curr_min_i = 0
        for i, ba in enumerate(bamboos):
            if abs(ba - t) < curr_min:
                curr_min = abs(ba-t)
                curr_min_i = i
        mp += curr_min
        bamboos.pop(curr_min_i)

    ans = min(ans,mp)

print(ans)

Measured memory_bytes: 55260
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    List<Integer>[] pos = new List[26];
    for (int i = 0; i < 26; i++) {
      pos[i] = new ArrayList<>();
    }
    for (int i = 0; i < s.length; i++) {
      pos[s[i] - 'a'].add(i);
    }
    int min = s.length;
    for (int i = 0; i < 26; i++) {
      if (pos[i].isEmpty()) continue;
      int max = 0;
      int p = 0;
      Iterator<Integer> iter = pos[i].iterator();
      while (iter.hasNext()) {
        int q = iter.next();
        max = Math.max(max, q - p);
        p = q + 1;
      }

      max = Math.max(max, s.length - p);
      min = Math.min(min, max);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
 
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  
  int ans=0;
  int n=s.size();
  rep(i,n){
    if(i%2==0&&s[i]=='0')ans++;
    if(i%2==1&&s[i]=='1')ans++;
  }
  
  int tmp=0;
  rep(i,n){
    if(i%2==0&&s[i]=='1')tmp++;
    if(i%2==1&&s[i]=='0')tmp++;
  }
  chmin(ans,tmp);
  cout(ans);
}

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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    string s;
    cin >> s;
    string ans = "No";
    REP(i, 3)
    if (s[i] == '7')
        ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
    fast_io 
    ll n;
    cin>>n;
    ll a[n];
    for(ll i = 0;i<n;i++) cin>>a[i];
    map<ll,ll> mp;
    for(ll i = 0;i<n;i++){
        mp[a[i]]++;
    }
    ll ans1 = 0;
    for(auto x : mp){
        ll k = x.second;
        ll sum = (k*(k-1))/2;
        ans1 += sum;
    }
    for(ll i = 0;i<n;i++){
        ll r = mp[a[i]] - 1;
        cout<<ans1-r<<endl;
    }
    return 0;
}


Measured memory_bytes: 13124
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-4-21 21:12:38
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll C;
ll x[100010];
ll v[100010];
ll w[100010];
ll w_rev[100010];

ll solve()
{
  ll ans = 0;
  fill(w, w + N, 0);
  w[0] = v[0];
  for (auto i = 1; i < N; i++)
  {
    w[i] = w[i - 1] + v[i];
  }
  for (auto i = 0; i < N; i++)
  {
    ans = max(ans, w[i] - x[i]);
  }
  w_rev[N - 1] = v[N - 1];
  for (auto i = N - 2; i >= 0; i--)
  {
    w_rev[i] = w_rev[i + 1] + v[i];
  }
  ll maxi = 0;
  for (auto i = N - 1; i >= 1; i--)
  {
    maxi = max(maxi, w_rev[i] - (C - x[i]));
    ans = max(ans, w[i - 1] - 2 * x[i - 1] + maxi);
  }
  maxi = max(maxi, w_rev[0] - (C - x[0]));
  ans = max(ans, maxi);
  return ans;
}

int main()
{
  cin >> N >> C;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i] >> v[i];
  }
  ll ans = solve();
  for (auto i = 0; i < N; i++)
  {
    x[i] = C - x[i];
  }
  reverse(v, v + N);
  reverse(x, x + N);
  ans = max(ans, solve());
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	priority_queue<int,vector<int>,less<int> > q;
	int n,m,a,b;
	long long s;
	while(cin>>n>>m){
		s=0;
		for(int i=0;i<n;i++){
			cin>>a;
			q.push(a);
		}
		while(m--){
			b=q.top();
			b=b/2;
			q.push(b);
			q.pop();
		}
		for(int j=0;j<n;j++){
			s=s+q.top();
			q.pop();
		}
		cout<<s<<endl;
	}
	return 0;
} 

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

N = INT()
A = [INT() for _ in range(N)]

ans = 0
tmp = A[0]
for i, a in enumerate(A):
	if i < a or tmp+1 < a:
		print(-1)
		break
	if a != tmp+1:
		ans += tmp
	tmp = a

else:
	ans += tmp
	print(ans)


Measured memory_bytes: 18364
//1
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdlib>
#include<cassert>
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    //int ball[200000];
    int num[200001];
    int syurui = 0;

    for(int i=0; i<200001; i++){
        num[i] = 0;
    }

    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        //ball[i] = tmp;
        if(num[tmp] == 0) syurui++;
        num[tmp]++;
        //cout << tmp << num[tmp] << endl;
    }

    //cout << syurui << endl;

    sort(num,num+200001);
    long long ans = 0;
    for(int i=0; i<200001; i++){
        if(syurui <= K){
            i = 2000001;
        }
        else{
            if(num[i] > 0){
                //cout << i << num[i] << endl;
                ans += num[i];
                syurui--;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import copy
s = int(input())

num_list = [s]
unique_set = set(num_list)
record_list = []
n = 0

for m in range(1000000):
    n += 1
    before = num_list[m]
    if before % 2 == 0:
        after = int(before / 2)
        num_list.append(after)
    else:
        after = int(3 * before + 1)
        num_list.append(after)
    if after in unique_set:
        print(n + 1)
        break
    unique_set.add(after)




Measured memory_bytes: 3444
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int num[110000];

int main(){
  ll a[110000],ai=0,aj=0;
  int n;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>a[i];
    ai=max(ai,a[i]);
  }

  double sa=1100000000,ch=(double)ai/2;

  for(int i=0;i<n;i++){
    if(sa>abs(ch-a[i]) && ai!=a[i]){
      sa=abs(ch-a[i]);
      aj=a[i];
    }
  }
  cout<<ai<<" "<<aj<<endl;
}


Measured memory_bytes: 1024
A, V = map(int, input().split())
B, W = map(int, input().split())
T=int(input())

if(A<B):
  if(B+W*T <= A+V*T):
    print("YES")
  else:
    print("NO")
elif(B<A):
  if(A-V*T <= B-W*T):
    print("YES")
  else:
    print("NO")

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;
long L,R;

int main()
{
	int N,ANS=0,count=0;
	cin >> N;
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(i%j==0)
			{
				count++;
			}
		}
		if(count==8&&i%2==1){ANS++;}
		count=0;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
        a,b=map(int,input().split())
        l.append([a,b])
l.sort(key=lambda x:x[1])
f=True
t=0
for i in range(n):
        t+=l[i][0]
        if t>l[i][1]:
                f=False
                break
print('Yes' if f else 'No')

Measured memory_bytes: 84568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define dump(o) { cerr << #o << " " << o << endl; }
#define dumpc(o) { cerr << #o; for (auto e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int lis(const vector<int> &A) {
	int n = A.size();
	vector<int> a(n, INF);
	for (int i = 0; i < n; i++)
		*lower_bound(a.begin(), a.end(), A[i]) = A[i];
	return find(a.begin(), a.end(), INF) - a.begin();
}

int main() {
	int n; cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++)
		cin >> A[i];
	cout << lis(A) << endl;
	return 0;
}

Measured memory_bytes: 3628
s = input()
n = len(s)

s_1 = s[:(n-1)//2]
s_2 = s[((n+3)//2 - 1):]

if s == s[::-1] and s_1 == s_1[::-1] and s_2 == s_2[::-1]:
    print('Yes')
else:
    print('No')

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const long long INF = 1e+18;

template <typename T>
vector<vector<T>> washallFroid(vector<vector<T>>& G){
    int N = G.size();
    vector<vector<T>> d(G);
    REP(i, N) d[i][i] = 0;
    REP(k, N){
        REP(i, N){
            REP(j, N){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    return d;
}


int main()
{
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<long long>> G(N, vector<long long>(N, INF));
    REP(i, N) G[i][i] = 0;
    REP(i, M){
        int A, B, C;
        cin >> A >> B >> C;
        --A, --B;
        G[A][B] = G[B][A] = C;
    }

    auto d = washallFroid<long long>(G);
    G = vector<vector<long long>> (N, vector<long long>(N, INF));
    REP(i, N) G[i][i] = 0;
    REP(i, N){
        REP(j, N){
            if(i != j and d[i][j] <= L) G[i][j] = 1;
        }
    }
    d = washallFroid<long long>(G);

    int Q;
    cin >> Q;
    REP(i, Q){
        int s, t;
        cin >> s >> t;
        --s, --t;
        if(d[s][t] == INF) cout << -1 << endl;
        else cout << d[s][t]-1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  char S[4];
  int a, b;
  cin >> S;
  
  a = (S[0] - '0')*10 + (S[1] - '0');
  b = (S[2] - '0')*10 + (S[3] - '0');
  
  bool ma = (a > 0 && a <= 12), mb = (b > 0 && b <= 12);
  
  if(ma && mb){
    cout << "AMBIGUOUS" << endl;
  } else if(ma){
    cout << "MMYY" << endl;
  } else if(mb){
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


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

using namespace std;

int main(){
	int n; cin >> n;
	int res = 1000000;
	int a, b, c, d; cin >> a >> b >> c >> d;
	a--; b--; c--; d--;
	for (int i = 1; i <= n; i++) {
		int ax = a%i, ay = a/i;
		int bx = b%i, by = b/i;
		int cx = c%i, cy = c/i;
		int dx = d%i, dy = d/i;
		int tmp = abs(ax-bx)+abs(ay-by)+abs(cx-dx)+abs(cy-dy);
		res = min(res, tmp);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1160
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b)
{
    return a%b ? gcd(b, a%b) : b;
}
long long lcm(long long a, long long b)
{
    return a*b/gcd(a, b);
}

void quicken()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void file()
{
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main()
{
    quicken();

    string s; cin >> s;
    if(s.substr(0, 2)=="AB" || s.substr(1, 2)=="AB"
       || s.substr(0, 2)=="BA" || s.substr(1, 2)=="BA")
        cout << "Yes";
    else cout << "No";

    return 0;
}

unsigned long long pow(long long base, long long power)  /// mod?
{
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n)
{
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int x, y, a, b, c;
vector<int> red, green, colorless;
multiset<int> R, G;
int ans;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>x>>y>>a>>b>>c;
    int u;
    f(i, a) {
        cin>>u;
        red.pb(u);
    }
    f(i, b) {
        cin>>u;
        green.pb(u);
    }
    f(i, c) {
        cin>>u;
        colorless.pb(u);
    }
    rs(red); rs(green); rs(colorless);
    f(i, x) R.insert(red[i]), ans += red[i];
    f(i, y) G.insert(green[i]), ans += green[i];
    f(i, c) {
        int red_cand = *R.begin(), green_cand = *G.begin();
        int cand = colorless[i];
        if(cand < red_cand && cand < green_cand) break;
        if(red_cand > green_cand) {
            G.erase(G.find(green_cand));
            G.insert(cand);
            ans += cand;
            ans -= green_cand;
        }
        else {
            R.erase(R.find(red_cand));
            R.insert(cand);
            ans += cand;
            ans -= red_cand;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int r;
  cin>>r;
  cout<<3*r*r<<endl;
  return(0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc167/tasks/abc167_d>
 問題文============================================================
 D - Teleporter
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A){ cin >> in; in--; }
    
    vector<ll> visited(N,-1);
    ll n = 0;
    ll t = 0;
    
    while(K){
        if(visited[n] == -1){
            visited[n] = t++;
            n = A[n];
        }else{
            ll d = t - visited[n];
            K %= d;
            if(K == 0) break;
            n = A[n];
        }
        K--;
    }
    res = n+1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 6376
#include<stdio.h>
int main(void){
  int a, b, c, d;
  scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
  if(a==b&&b==c){
    printf("Yes\n");
  }else if(b==c&&c==d){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
As = list(map(int, input().split()))
MOD = 10**9 + 7
S = sum(As)%MOD
ans = 0
for a in As:
    ans += (a * (S-a))%MOD
    ans %= MOD
ans *= pow(2,MOD-2,MOD)
print(ans%MOD)


Measured memory_bytes: 105236
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;


int main(){
  int r;
  cin >> r;
  int ans = 3*r*r;
  cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

A = list(map(int, input().split()))

ord = [-1 for _ in range(N)]
ord[0] = 0
v = A[0]-1
root = [0]

while ord[v] == -1:
    #ordに何回目のワープかが記録される
    ord[v] = len(root)
        #ワープの軌跡を記録
    root.append(v)

    #次の地点にワープ5
    v = A[v]-1

# print(ord)
# print(root)

#ord[v]:最終地点（ループ起点 or ループ前の道のり）
# ループ起点までの余分な手
l = ord[v]
#ループ距離
c = len(root) - l

if K < l:
    #ループ前にワープが終了した場合、最終地点を出力
    ans = root[K]
else:
    #ループする回数を計算
    # はじめにループ起点までの余分手をKから引く
    K -= l
    # ループのmodを計算
    K %= c
    # 余分手＋ループのmodの位置の国に止まる
    ans = root[l+K]
print(ans+1)



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

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.size() % 2) {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i % 2] != "hi"[i % 2]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

int main()
{
  int N;
  string s;
  cin >> N >> s;
  int count = 0;
  for (auto &c: s)
  {
    if (c == 'R') count++;
  }
  printf("%s\n", count * 2 > N ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(){
  char ch;
  scanf("%c",&ch);
  while(!('\n'==ch)){
    if(islower(ch)){
      printf("%c",toupper(ch));}
    else printf("%c",tolower(ch));
    scanf("%c",&ch);
    }
  printf("\n");
  return 0;}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N];
int arr[N];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i -1] + abs(arr[i] - arr[i -1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n - 1];
	return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

ll N;
ll a[100000];
int ab[100001];
vector<ll> cp_a;
int tmp[100001];

ll cnt_inv(int a[],int n){
  if(n==1)return 0;
  if(n==2){
    if(a[0]<=a[1]){
      swap(a[0],a[1]);
      return 1;
    }
    else 
      return 0;
  }
  ll ret = 0;
  ret += cnt_inv(a,n/2);
  ret += cnt_inv(a+n/2,n-n/2);
  int l=0,r=n/2,i=0;
  while(i<n){
    if(l>=n/2||(r<n&&a[l]<=a[r])){
      tmp[i]=a[r];
      ret+=n/2-l;
      r++;
    }else if(r>=n||(a[l]>a[r])){
      tmp[i]=a[l];
      l++;
    }
    i++;
  }
  REP(n)a[i]=tmp[i];
  return ret;
}

int main(){
  cin>>N;
  ll m=(N+1)*N/2;
  REP(N)cin>>a[i];
  REP(N)cp_a.push_back(a[i]);
  sort(cp_a.begin(),cp_a.end());
  cp_a.erase(unique(cp_a.begin(),cp_a.end()),cp_a.end());
  auto l=0UL,r=cp_a.size();
  while(l+1<r){
    auto mid = l+(r-l)/2;
    REP(N)ab[i+1]=a[i]>=cp_a[mid]?1:-1;
    REP(N)ab[i+1]+=ab[i];
    auto tmp = cnt_inv(ab,N+1);
    if(tmp>=(m/2+m%2))l=mid;
    else r=mid;
  }
  cout<<cp_a[l]<<endl;
  return 0;
}



Measured memory_bytes: 2676
n = int(input())
p = list(map(int,input().split()))
i = 0
ans = 0
while i < len(p) - 3 + 1:
    m = p[i:i+3]
    l = sorted(m)
    if l[1] == m[1]:
        ans += 1
    i += 1
print(ans)

Measured memory_bytes: 8944
calc :: Integer -> Integer -> Integer
calc n m = if m < 2 * n
  then m `div` 2
  else n + (m - 2 * n) `div` 4


main :: IO ()
main = do
  line <- getLine
  let nums = map read $ words line :: [Integer]
      (n:m:[]) = nums
  print $ calc n m


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;
int main(){
    
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h){
        cin >> a[i];
    }

    rep(i,2*h){
        cout << a[i/2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
using namespace std;

signed main() {
	int a; cin >> a;
	cout << 48 - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	double a;
	int n;
	cin>>n;
	double sum=0;
	while(n--){
		cin>>a>>s;
		if(s=="JPY")
			sum+=a;
		else {
			sum+=(380000.0*a);
		}
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
#define abs(a) (a)>0?(a):-(a)
#define llong long long

int main(){
	int N,M; scanf("%d %d",&N,&M);
	int a;
	rep(i,0,M){
		scanf("%d",&a);
		N -= a;
	}
	if( N<0 ) printf("-1");
	else printf("%d",N);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }
int main(){
  llong A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if(2 * C >= A + B){
    cout << A * X + B * Y << endl;
    return 0;
  }else if(2 * C > A && 2 * C > B){
    if(X > Y){
      cout << 2 * C * Y + A * (X-Y) << endl;
      return 0;
    }else{
      cout << 2 * C * X + B * (Y-X) << endl;
      return 0;
    }
  }else if(2 * C < min(A,B)){
    cout << 2 * C * max(X,Y) << endl;
    return 0;
  }else{
    if(X>Y && A>B){
      cout << 2 * C * X << endl;
      return 0;
    }else if(X<=Y && A<=Y){
      cout << 2 * C * Y << endl;
      return 0;
    }else if(X > Y){
      cout << 2 * C * Y + A * (X-Y) << endl;
      return 0;
    }else{
      cout << 2 * C * X + B * (Y-X) << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

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

    for(i=0;i<n;i++){
        if(WorE[i]=='W'){
            a[i]=1;
        }else{
            a[i]=0;
        }
    }

    pre_process(a,sum);//累積和の作成(wならば1 Eならば0)

    ll min=300001,ans;
    for(i=1;i<=n;i++){
        ans=query(0,i-1,sum)+(n-i-query(i,n,sum));
        //累積和で左側と右側の0 1の違いに注意して出力
        //(n-i-query(i,n,sum)は右側の人のうち、リーダー方向を向いていない人の人数)
        //query(0,i-1,sum)は左側のリーダー方向を向いていない人数
        if(ans<min){min=ans;}
    }

    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int n;
double dp[100001][30],ans[100001];

int main()
{
	double pw[30];
	pw[0]=1; rep(i,29)pw[i+1]=pw[i]*0.5;
	
	fill_n(ans,100001,0);
	rep(i,100001)rep(j,30)dp[i][j]=0;
	dp[0][0]=1;
	
	for(int i=1;i<100001;i++)
	{
		rep(j,30)
		{
			dp[i][0]+=dp[i-1][j]*(1-pw[j]);
			if(j<29)dp[i][j+1]+=dp[i-1][j]*pw[j];
		}
		ans[i]=ans[i-1];
		rep(j,29)ans[i]+=dp[i][j+1];
	}
	
	while(cin>>n,n)printf("%.3f\n",ans[n]);
	
	return 0;
}

Measured memory_bytes: 24000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> s(n);
    rep(i,n) cin>>s[i];
    ll q; cin>>q;
    vector<ll> t(q);
    rep(i,q) cin>>t[i];
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    ll res=0;
    rep(i,q){
        auto Iter1=upper_bound(s.begin(),s.end(),t[i]);
        auto Iter2=upper_bound(s.begin(),s.end(),t[i]-1);
        if(Iter1-Iter2>0) res++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            int s1 = 0;
            int s2 = 0;
            for (int i = 0; i < n; ++i) {
                if (i % 2 == 0)
                    s1 += a[i];
                else
                    s2 += a[i];
            }
            if (n % 2 == 0) {
                out.println(Math.max(s1, s2) + " " + Math.min(s1, s2));
                return;
            }
            int left = s1 - s2;
            int right = s1 + s2 + 1;
            outer:
            while (right - left > 1) {
                int middle = (left + right) / 2;
                long bestSoFar = s1 - s2;
                int r1 = s1;
                int r2 = s2;
                for (int i = 1; i <= n; i += 2) {
                    r1 -= a[i - 1];
                    long cost = bestSoFar - (r1 - r2);
                    if (i < n) r2 -= a[i];
                    if (cost >= middle) {
                        if (i == n) {
                            left = middle;
                            continue outer;
                        } else {
                            bestSoFar = Math.max(bestSoFar, r1 - r2);
                        }
                    }
                }
                right = middle;
            }
            out.println((s2 + left) + " " + (s1 - left));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 45876
lines = []
while line = gets
    lines << line.chomp.split(' ')
end

H = lines[0][0].to_i
W = lines[0][1].to_i
K = lines[0][2].to_i

ans = 0
for i in 0..2 ** (H+W) - 1 do   #i: bit
  black = 0
  for j in 1..H do
    for k in 1..W do
      if i[j-1] == 1 and i[H+k-1] == 1 and lines[j][0][k-1] == "#" then  #rest
        black += 1
      end
    end
  end
  if black == K then
    ans += 1
  end
end
    
puts ans

Measured memory_bytes: 14384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
char ss[1005];
scanf("%s",ss);
int n=0,w=0,e=0,s=0;
for(int i=0;ss[i]!='\0';i++){
if(ss[i]=='S'){s++;}
if(ss[i]=='N'){n++;}
if(ss[i]=='W'){w++;}
if(ss[i]=='E'){e++;}
}
if(s==0&&n!=0||s!=0&&n==0){printf("No");}
else if(w==0&&e!=0||w!=0&&e==0){printf("No");}
else{printf("Yes");}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(void){
  const int n = 1000000;
  bool* check_A = (bool*)malloc(sizeof(bool)*n);
  int*  num_A   = (int*)malloc(sizeof(int)*n);
  int N = 0, temp = 2;
  memset(check_A, true, n);
  check_A[0] = false;
  check_A[1] = false;
  num_A[0] = 0;
  num_A[1] = 0;
  for(int i = 0; i < n; i++){
    if(check_A[i]){
      for(;temp < i;temp++){
	num_A[temp] = N;
      }
      temp++;
      num_A[i] = ++N;
      for(int j = 2; i*j < n; j++){
	check_A[i*j] = false;
      }
    }
  }
  for(;temp < n; temp++){
    num_A[temp] = N;
  }
  int s;
  while(cin >> s){
    cout << num_A[s] << endl;
  }
  return 0;
}

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

int main(){
    int a[26];
    string str;
    for(int i=0;i<26;i++){
        a[i]=0;
    }
    while(getline(cin,str)){
        int num;
        for(int i=0;i<str.length();i++){
            if(str[i]>='a'&&str[i]<='z'){
                num=str[i]-'a';
                a[num]++;
            }else if(str[i]>='A'&&str[i]<='Z'){
                num=str[i]-'A';
                a[num]++;
            }
        }
    }
    for(int i=0;i<26;i++){
        char tmp=i+'a';
        cout<<tmp<<" : "<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
function Main(input) {
	var str = input;
	var ans = 0;
  	var ansn = 0;
  	var ansm = 0;
	var str = str.split("\n")[0];
	var num = str.split(" ");
	var n = Number(num[0]);	
	var m = Number(num[1]);	
	
	if(n > 1){
		ansn = n*(n-1)/2;
	}
	if(m > 1){
		ansm = m*(m-1)/2;
	}
	ans = ansn+ansm;
		console.log(ans);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n;

void dfs(string s, char mx){
	if(s.size() == n){
		cout << s << endl;
		return;
	}
	for(char c = 'a'; c <= mx; c++){
		dfs(s + c, (c == mx) ? (char)(mx + 1) : mx);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n;
	dfs("", 'a');
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/




Measured memory_bytes: 1536
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    X = int(input())

    cnt = 0
    res = 100
    while True:
        if res >= X:
            print(cnt)
            break
        res += res // 100
        cnt += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True 

q = int(input())
lr = []
minimum = float('inf')
maximum = 0
for _ in range(q):
    l, r = map(int, input().split())
    minimum = min(minimum, l)
    maximum = max(maximum, r)
    lr += [[l, r]]

prime = {i: 0 for i in range(1, maximum+1)}

for i in range(1, maximum+1):
    if is_prime(i) and is_prime((i+1)//2):
        prime[i] = 1

cum_prime = {i: 0 for i in range(1, maximum+1)}
cum_prime[minimum] = prime[minimum]
for i in range(1, maximum):
    cum_prime[i+1] = prime[i+1] + cum_prime[i]

cum_prime[0] = 0
for l, r in lr:
    print(cum_prime[r]-cum_prime[l-1])

Measured memory_bytes: 81620
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
D = LI()
ans = 0
for x, y in combinations(D, 2):
    ans += x*y
print(ans)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int a,b;
  char c;
  cin >> a >> c >> b;
  c == '+' ? cout << a+b << endl : cout << a-b << endl;




  return 0;
}

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

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

	if (a == b) {
		cout << c << endl;
	}
	if (b == c) {
		cout << a << endl;
	}
	if (a == c) {
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define M 2000001
#define INFTY (1<<30)
 
int H, A[M];
 
void maxHeapify(int i){
    int l, r, biggest, tmp;
    
    l = 2 * i;
    r = 2 * i + 1;

    if(l <= H && A[l] > A[i]) biggest=l;
    else biggest=i;
    
    if(r <= H && A[r] > A[biggest]) biggest=r;
    if(biggest != i){
        tmp = A[i];
        A[i] = A[biggest];
        A[biggest] = tmp;
        maxHeapify(biggest);
    }
}
 
int extract(){
    int maxv;
    if(H < 1)return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}
 
void increKey(int i, int key){
    int tmp;
    if(key < A[i]) return;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        tmp = A[i];
        A[i] = A[i/2];
        A[i/2] = tmp;
        i = i/2;
    }
}
 
void insert(int key){
    H++;
    A[H] = -INFTY;
    increKey(H,key);
}
 
int main(){
    int key;
    char com[10];
    while(1){
        scanf("%s", com);
        if(com[0]=='e' && com[1]=='n'){
            break;
        }
        if(com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }
        else printf("%d\n", extract());
    }
    
    return 0;
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a[100005],ans=1;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
  	if(a[0]==0){
      cout<<0;
      return 0;
    }
    for(int i=0;i<n;i++){
      if(a[i]<=1000000000000000000/ans) ans*=a[i];
      else{
        cout<<-1;
        return 0;
      }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4360
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const distance = input.pop()
  input = input.map((val, index) => {
    let result = true
    for (let i = index; i < input.length; i++) {
      if (result) {
        result = input[i] - val <= distance
      }
    }
    return result
  })

  console.log(input.filter(result => result === false).length === 0 ? 'Yay!' : ':(')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
N, X, Y = list(map(int, input().split()))
X -= 1
Y -= 1
res = 0
A = [0] * N
for i in range(N):
    for j in range(i, N):
        if i == j: continue
        # print(i, j, j - i, abs(X - i) + 1 + abs(Y - j))
        A[min(j - i, abs(X - i) + 1 + abs(Y - j))-1] += 1
for x in range(N-1):
    print(A[x])


Measured memory_bytes: 46428
from itertools import permutations

N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))


Measured memory_bytes: 55004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
int c[MAX_M + 1], x[MAX_N + 1];
int dp[MAX_N + 1][256 + 1];

int POW(int num){
	return num*num;
}

int main(){
	while (cin >> n >> m&&n + m){
		REP(i, MAX_N + 1){
			REP(j, 256 + 1){
				dp[i][j] = INF;
			}
		}
		REP(i, m) cin >> c[i];
		REP(i, n) cin >> x[i];
		dp[0][128] = 0;
		REP(i, n){
			REP(j, 256){
				if (dp[i][j] == INF)continue;
				REP(k, m){
					int num = j + c[k];
					if (num < 0) num = 0;
					if (num > 255) num = 255;
					dp[i + 1][num] = min(dp[i][j] + POW(x[i] - num), dp[i + 1][num]);
				}
			}
		}
		int ans = INF;
		REP(i, 256){
			ans = min(ans, dp[n][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 21316
S = input()

lst = []

for ( i , j ) in enumerate(S) :
  if i % 2 == 1:
    if j not in ["L","U","D"]:      
      print("No")
      exit()
  else:
    if j not in ["R","U","D"]:      
      print("No")
      exit()
print("Yes") 

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

std::map<std::string, int> mp;

int main() {
    int n;
    std::string cmd, str;

    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> cmd >> str;
        if (cmd == "insert") {
            mp[str] = i;
        } else {
            if (mp.find(str) != mp.end()) {
                std::cout << "yes" << std::endl;
            } else {
                std::cout << "no" << std::endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 36912