akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define ff(i,a,b) for(int i=a;i<=b;++i)

using namespace std;

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

const int N = 2e5+5;

int n,h[N],dp[N];

void solve(){
	cin>>n;
	ff(i,1,n)cin>>h[i];
	ff(i,1,n)dp[i]=1e9;
	dp[0]=0;
	dp[1]=0;
	ff(i,2,n){
		if(i-1>=1)
			dp[i]=min(dp[i],dp[i-1]+abs(h[i-1]-h[i]));
		if(i-2>=1)
			dp[i]=min(dp[i],dp[i-2]+abs(h[i-2]-h[i]));
	}
	//ff(i,1,n)
	//	cerr<<dp[i]<<' ';

	cout<<dp[n];
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while (T--)solve();
}

Measured memory_bytes: 4360
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

  int N,M;
  int a;

  while(1){
    vector<int> v1;
    vector<int> v2;
    vector<int> vh;
    vector<int> vw;
    int count = 0;
    int k = 0;
    int check = 0;
    int l = 0;

    cin>>N>>M;

    if(N == 0 && M == 0){
      break;
    }

    for(int i = 0;i < N;++i){
      cin>>a;
      v1.push_back(a);
    }

    for(int i = 0;i < M;++i){
      cin>>a;
      v2.push_back(a);
    }

    for(int i = 0;i < N;++i){
      int temp1 = 0;

      for(int j = i;j < N;++j){
	temp1 += v1[j];
	vh.push_back(temp1);
      }
    }

    for(int i = 0;i < M;++i){
      int temp2 = 0;

      for(int j = i;j < M;++j){
        temp2 += v2[j];
        vw.push_back(temp2);
	++l;
      }
    }

    sort(vh.begin(),vh.end());
    sort(vw.begin(),vw.end());

    for(auto e : vh){
      while(1){
        if(k == l){
	  break;
        }
        if(e == vw[k]){
	  ++count;
        }
        else if(e < vw[k]){
	  break;
        }
        else{
	  check = k+1;
        }
        ++k;
      }
      k = check;
    }
    cout<<count<<endl;
  }

  return 0;
}

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

// using ll = long long;
#define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int memo[10][10];

int getHead(int a) {
  string s = to_string(a);
  return (int) s[0] - '0';
}
int getTail(int a) {
  string s = to_string(a);
  return (int) s[s.length()-1] - '0';
}
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  if(n == 10) {
    cout << 9 << endl;
    return 0;
  }
  if(n < 10) {
    cout << n << endl;
    return 0;
  }
  REPS(i,1,n+1) {
    ++memo[getHead(i)][getTail(i)];
  }
  int ans = 0;
  REPS(i,1,10) REPS(j,1,10) ans += memo[i][j] * memo[j][i];
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <math.h>
#include <list>
#include <bits/stdc++.h>

using namespace std;

int main(void){
  string s;
  cin >> s;
  if(s == "RRR"){
    cout << 3 << endl;
  }else if(s == "RRS" || s == "SRR"){
    cout << 2 << endl;
  }else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<ll>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)cin >> a[i];
  ll l; cin >> l;
  int ln = log2(n);
  Graph next (ln+ 1, vector<ll>(n));
  for(int i = 0; i < n; ++i){
    int idx= upper_bound(a.begin(),a.end(), a[i]+l)-a.begin();
    next[0][i] = idx-1;
    //cout << next[0][i] << endl;
  }
  
  for(int k = 0; k < ln; ++k){
    for(int i = 0; i < n; ++i){
      next[k+1][i] = next[k][next[k][i]];
    }
  }
  int Q;cin >> Q;
  for(int _ = 0; _ < Q; ++_){
    int a,b;cin >> a >> b;
    --a;--b;
    if(a>b)swap(a,b);
    int lb = -1, ub = n;
    while(ub-lb>1){
      int mb = (ub+lb)/2;
      int now = a;
      for(int i = ln; i >= 0; --i){
        if((mb>>i)&1){
          now = next[i][now];
        }
      }
      if(now>=b)ub = mb;
      else lb = mb;
    }
    cout << ub << endl;
  }
}


Measured memory_bytes: 15104
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	vector<bool>v(N, false);
	rep(i, N) {
		int num;
		cin >> num;
		if (num == i + 1)v[i] = true;
	}
	int cnt = 0;
	rep(i, N) {
		if (v[i]) {
			cnt++;
			if (i != N - 1)v[i] = v[i + 1] = false;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

			double n = sc.nextDouble();

			double p = (n /2) / n;
			if ( n % 2 == 0 ) {
				p = 1f/2f;
			}
			else {
				p =( Math.floor(n/2) + 1) / n;
			}
			
			System.out.println(p);
						
			
		}
	}
}


Measured memory_bytes: 23252
C = (0...3).map{ gets.split.map(&:to_i) }
puts (0...3).all?{ |a|
  (0...3).map{ |b| C[b][(a+1)%3] - C[b][a] }.uniq.size == 1 && (0...3).map{ |b| C[(a+1)%3][b] - C[a][b] }.uniq.size == 1
} ? "Yes" : "No"

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << (s < t ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1010;
const int M = 128;

int dp[M][N];

int DP(int x, int n){
    if(dp[x][n] != -1){
        return dp[x][n];
    }
    int a, b;
    for(int i=0; i<128; i++){
        a = i;
        b = x ^ i;
        dp[x][n] = max(dp[x][n], DP(a, 1)+DP(b, n-1));
        dp[x][n] = max(dp[x][n], DP(b, 1)+DP(a, n-1));
    }
    return dp[x][n];
}

void init(){
    memset(dp, -1, sizeof(dp));
    for(int i=0; i<128; i++){
        dp[i][1] = i;
    }
    for(int i=0; i<128; i++){
        dp[i][1000] = DP(i, 1000);
    }
}

int main(){
    init();
    int T, x, n;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &x);
        printf("%d\n", dp[x][n]);
    }
    return 0;
}


Measured memory_bytes: 768
S = input()
S = list(S)
keta1 = int(S[3])
keta2 = int(S[2])*10
keta3 = int(S[1])
keta4 = int(S[0])*10
keta21 = keta1 + keta2
keta43 = keta3 + keta4

#00<=YY<=99,01<=MM<=12
# YYMM only
if (0 == keta43 or 13 <= keta43) and 1<= keta21 <= 12:
  print('YYMM')
# MMYY only
elif 1 <= keta43 <= 12 and (0 == keta21 or 13 <= keta21):
  print('MMYY')
# YYYY only
elif (0 == keta43 or 13 <= keta43)  and (0 == keta21 or 13 <= keta21):
  print('NA')
else:
  print('AMBIGUOUS')

Measured memory_bytes: 3064
a,b=map(int,input().split())
s=input()
flag=True
for i in range(0,a+b+1):
  if i<a and not s[i].isdecimal():
    flag=False
    break
  elif i==a and not s[i]=="-":
    flag=False
    break
  elif a<i and not s[i].isdecimal():
    flag=False
    break
if flag:
  print("Yes")
else:
  print("No")
    

Measured memory_bytes: 3060
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()

def is_war(x, y, N, M):
    if x[N-1] >= y[0]:
        return False
    elif x[N-1] >= Y:
        return False
    elif y[0] <= X:
        return False
    else:
        return True

if is_war(x, y, N, M):
    print("No War")
else:
    print("War")

Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))
res = 1
for a_i in a:
    if 0 == a_i:
        print(0)
        exit(0)
    elif res > 10 ** 18:
        continue
    else:
        res *= a_i

print(-1 if res > 10 ** 18 else res)


Measured memory_bytes: 84736
n=int(input())
l=[]
for i in range(n):
  a,b,c=map(int,input().split())
  l.append([a,b,c])

dp=l[0]
for i in range(1,n):
    dp=[max(dp[1],dp[2])+l[i][0],max(dp[0],dp[2])+l[i][1],max(dp[0],dp[1])+l[i][2]]
print(max(dp))

Measured memory_bytes: 22772
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, k = 1;
	cin >> a >> b;
	FOR(i, 0, 100)
	{
		if(k>=b){
			cout << i << endl;
			return 0;
		}
		else{
			k += (a - 1);
		}
	}

	return 0;
}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

int main(){
    FIO;
    int n;
    cin >> n;
    double arr[n], ans = 0;
    for(int i = 0 ; i < n ; i++){
        cin >> arr[i];
        ans += (1/arr[i]);
    }
    ans = 1/ans;
    printf("%0.9lf", ans);
    return 0;
}


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

int n;
string s[412345];

// 4 * 4 * 4e5 * log(4e5)
// うーん
// hashing(intに収まる自明なもの)で4倍速，いけるんじゃないか
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  set<string> st;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    for(int k = 0; k < s[i].size(); k++) for(int j = 1; j <= 4; j++) st.insert(s[i].substr(k, j));
  }
  string ans = "a";
  while(st.count(ans)) {
    int x = ans.size() - 1;
    while(x >= 0) {
      if(ans[x] == 'z') {
        ans[x] = 'a';
        if(x == 0) ans = 'a' + ans;
        x--;
      } else {
        ans[x]++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 45688
#include <iostream>
#include <set>
#include <string>
#include <algorithm>

using namespace std;


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

    int n = (int) s.size();

    set<string> st;

    for (int j = 1; j <= 5; ++j) {
        for (int i = 0; i < n - j + 1; ++i) {
            st.insert(s.substr(i, j));
        }
    }

    auto it = st.begin();
    for (int i = 0; i < k - 1; ++i) {
        it++;
    }

    cout << *it << endl;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
#ABC121 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
h = []
for _ in range(n):
    a,b = LI()
    heappush(h,(a,b))

cnt = 0
ans = 0
while cnt < m:
    a,b = heappop(h)
    if b + cnt <= m:
        cnt += b
        ans += a*b
    else:
        ans += (m-cnt)*a
        cnt = m
print(ans)


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

int main() {
  long long x, k, d;
  cin >> x >> k >> d;

  long long ans;
  x = abs(x);
  long long num = x/d;
  if ( num <= k ) {
    ans = abs(x - (d*num));
    k -= num;
    ans = ( k%2 == 0 ) ? abs(x-(d*num)) : abs(x-(d*(num+1)));
  } else {
    ans = abs(x-(d*k));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn=100000+10;
int fa[maxn];
int p[maxn];
int n,m,x,y,ans;
int father(int p)
{
	if (fa[p]==p) return p;
	else return fa[p]=father(fa[p]);
}
int main()
{
    cin>>n>>m;
	for(int i=1;i<=n;i++) scanf("%d",&p[i]),fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		x=father(x);y=father(y);
		fa[x]=y;
	}	
	ans=0;
	for(int i=1;i<=n;i++)
		if (father(p[i])==father(i))
			ans++;
	cout<<ans<<endl;
	system ("pause");
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, w;
    while(cin>>n>>w, n){
        vector<int> cnt(20, 0); // 0-indexed
        int ub=0;
        for(int i=0; i<n; i++){
            int v; cin>>v;
            cnt[v/w]++;
            ub=max(ub, v/w);
        }

        int maxcnt=0;
        for(int i=0; i<=ub; i++){
            maxcnt=max(maxcnt, cnt[i]);
        }

        double ans=0.01;
        for(int i=0; i<=ub; i++){
            ans+=1.*cnt[i]/maxcnt*(ub-i)/ub;
        }
        cout << fixed << setprecision(10) << ans << endl;
    }
}


Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



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





pair<int, int> count_nonzero_cluster(vector<int>& vs) {

	int number = 0;
	int prev = 0;
	int vmax = -1;
	pair<int, int> re = make_pair(number, vmax);
	for (auto& v:vs)
	{
		if (prev <= 0 && v > 0) {
			re.first += 1;
		}
		if (re.second < v)re.second = v;
		prev = v;
	}


	return re;
}





int main() {
	
	int N, K;
	cin >> N >> K;

	vector<int> h(N);
	int ans = 0;
	int temp;
	for (auto i = 0; i < N; i++)
	{
		cin >> temp;
		if (temp >= K)ans += 1;
	}

	cout << ans << endl;

	return 0;
}

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

int main() { 
  int N;
  cin >> N;
  vector<ll> A(N);
  map<ll, int> a;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    a[A[i]]++;
  }

  sort(A.rbegin(), A.rend());
  
  ll x = 0, y = 0;
  for (int i = 0; i < N; i++) {
    if (a[A[i]] >= 2) {
      if (x == 0) {
        x = A[i];
        a[A[i]] -= 2;
        continue;
      } else if (x != 0 && y == 0) {
        y = A[i];
        break;
      }
    }
  }
  ll ans = x * y;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10316
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		ll int arr[n+1];
		ll int x=1,l=1e18;
		for(ll int i=1;i<=n;i++)
			cin>>arr[i];
		sort(arr+1,arr+1+n);
		if(arr[1]==0)
		{
			cout<<0<<endl;
			return 0;
		}
		for(ll int i=1;i<=n;i++)
		{
			ll int tmp=l/arr[i];
			if(x>tmp)
			{
				cout<<-1<<endl;
				return 0;
			}
			x*=arr[i];
		}
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 4440
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int x = b - a;
    int y = c - b;
    
    if(x == y)
        cout << "YES" << endl;
    else
        cout << "NO"  << endl;
    
    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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int k, max_k = 100000;
  cin >> k;
  vector<long> r;

  vector<vector<string>> s_set;

  vector<string> s_unit;
  for(int i = 1; i < 10; i++) s_unit.push_back(to_string(i));
  s_set.push_back(s_unit);

  for(int i = 0; i < 10; i++) {
    s_unit = s_set[i];
    vector<string> tmp;
    for(string s : s_unit) {
      int tail = s[s.length() - 1] - '0';
      tmp.push_back(s + to_string(tail));
      if(tail == 0) {
        tmp.push_back(s + to_string(tail + 1));
      } else if(tail == 9) {
        tmp.push_back(s + to_string(tail - 1));
      } else {
        tmp.push_back(s + to_string(tail + 1));
        tmp.push_back(s + to_string(tail - 1));
      }
    }
    s_set.push_back(tmp);
  }

  for(vector<string> tmp : s_set) {
    for(string s : tmp) r.push_back(stol(s));
  }

  sort(ALL(r));

  cout << r[k - 1] << endl;

  return 0;
}


Measured memory_bytes: 50972
while True:
    n = int(input())
    if n == 0:
        break
    arr = list(map(int, input().split()))
    arr.sort()
    ge = arr[-1]
    for i in range(n - 1):
        tmp = arr[i + 1] - arr[i]
        if tmp < ge:
            ge = tmp
    print(ge)



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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    s1[0] = toupper(s1[0]), s2[0] = toupper(s2[0]), s3[0] = toupper(s3[0]);
    cout << s1[0] << s2[0] << s3[0] << endl;
}


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

bool isRTri(int a, int b, int c)
{
    return a * a + b * b == c * c;
}

int main()
{
    int n;
    cin >> n;
    for (int k = 1; k <= n; k++)
    {
        int a[3];
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a + 3);
        bool r = isRTri(a[0], a[1], a[2]);
        cout << (r ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 2996
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		long A_sum[] = new long[N + 1];
		for (int i = 1; i <= N; i++) {
			int a = scn.nextInt();
			A_sum[i] = A_sum[i - 1] + a;
		}
		int NN = N * (N + 1) / 2;
		long A[] = new long[NN];
		int num = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N + 1; j++) {
				A[num] = A_sum[j] - A_sum[i];
				num++;
			}
		}

		long div = (long) Math.pow(2, 40);
		ArrayList<Long> A_pure = new ArrayList<Long>();

		for(int i = 0;i < NN;i++) {
			A_pure.add(A[i]);
		}


		long max = 0;
		while (div != 0) {
			num = 0;
			for (int i = 0; i < A_pure.size(); i++) {
				if ((A_pure.get(i) & div) == div) {
					num++;
				}
			}

			if (num >= K) {
				max += div;
				ArrayList<Long> A_pure_buff = new ArrayList<Long>();
				for (int i = 0; i < A_pure.size(); i++) {
					if ((A_pure.get(i)& div) == div) {
						A_pure_buff.add(A_pure.get(i));
					}
				}

				A_pure = new ArrayList<Long>();
				A_pure.addAll(A_pure_buff);

			}
			div /= 2;
		}
		System.out.println(max);

	}
}


Measured memory_bytes: 52624
#include<bits/stdc++.h>
using namespace std;
int ara[200005], freq[1000006], val[1000006];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    scanf("%d", &ara[i]), freq[ ara[i] ]++;
    for(int i=1; i<=1000000; i++)
    for(int j=i; j<=1000000; j+= i)
    val[j]+= freq[i], val[j]= min(val[j], 2);
    int res= 0;
    for(int i=0; i<n; i++)res+= (val[ ara[i] ]==1);
    printf("%d\n", res);
    return 0;
}


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

using namespace std;

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

	if (N > 999) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}


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

int main(){
	int H,W;
	cin >> H >> W;
	string a[H+2];
	a[0]="#";
	a[H+1]="#";
	int loop;
	for(loop=1;loop<W+2;loop++){
		a[0]+="#";
		a[H+1]+="#";
	}
	for(loop=1;loop<=H;loop++){
		cin >> a[loop];
		a[loop].insert(0,"#");
		a[loop].append("#");
	}
	for(loop=0;loop<H+2;loop++){
		cout << a[loop] << endl;
	}
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  a -= b;
  c -= min(c, a);
  cout << c << '\n';  
  return 0;
}

Measured memory_bytes: 3596
//"BISMILLAHIR RAHMANIR RAHIM"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1000000007 ;
ll fact(ll x, ll y){
    ll f=1,i=1;
    while(i<=y){
        f=( (f%M) * (x%M) )%M;
        i++;
    }
    return f;
}
int main()
{
   ll n,ans=0;
   cin>>n;
   ans = fact(10,n)%M; ans %= M;
   ans -= fact(9,n)%M; ans %= M;
   ans -= fact(9,n)%M; ans %= M;
   ans += fact(8,n)%M; ans %= M;
   ans= (ans+M)%M;

   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<string> vs(N);
    map<string, int> cnt;
    for(int i=0; i<N; i++) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        vs[i] = s;
        cnt[ vs[i] ]++;
    }

    ll ans = 0;
    for(auto e : cnt) {
        ll c = e.second;
        ans += c * (c - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int rec(int l, int r, VVI& mem, const VI& w){
    if(r-l <= 1) return 0;
    int& res = mem[l][r];
    if(res != -1) return res;
    rep(i, l+1, r) chmax(res, rec(l, i, mem, w)+rec(i, r, mem, w));
    if(rec(l+1, r-1, mem, w) == r-1-l-1){
        if(abs(w[l]-w[r-1]) < 2) chmax(res, rec(l+1, r-1, mem, w)+2);
        else chmax(res, rec(l+1, r-1, mem, w));
    }
    return res;
}


signed main(){
    int n;
    while(cin >> n, n){
        VI w(n);
        rep(i, 0, n) cin >> w[i];
        VVI mem(n+1, VI(n+1, -1));
        cout << rec(0, n, mem, w) << endl;
    }

    return 0;
}


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

string s;


int main(){
    cin >> s;
    int a = s.size();
    if (s[a-1]== '3') cout << "bon" << endl;
    else if(s[a-1] == '0' || s[a-1] == '1' || s[a-1] == '6' || s[a-1] =='8') cout << "pon" <<endl;
    else cout << "hon" << endl;


}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	int a,b,c,t=1;

	cin>>a>>b>>c;

	if(a-b!=0)t++;
	if((a-c)*(b-c))t++;

	PRINT(t);

	return 0;
}

Measured memory_bytes: 256
S=list(input())
#print(S)
q=int(input())
x=0
appends=[[] for i in range(2)]
for i in range(q):
    s=list(input().split())
    if int(s[0])==1:
        x+=1
    else:
        appends[(x+int(s[1])+1)%2].append(s[2])
        #print(appends)
if  x%2==1:
    S=S[::-1]
S=appends[x%2][::-1]+S+appends[(x+1)%2]
#print(S)
for k in S:
    print(k,end='')

Measured memory_bytes: 9860
from itertools import product

n = int(input())
s = input()
ans = 0

for i in product(range(10), repeat = 3):
    a = s.find(str(i[0]))
    if a != -1 and a != n - 1:
        b = s[a + 1:].find(str(i[1]))
        if b != -1:
            b += a + 1
            if b != n - 1:
                c = s[b + 1:].find(str(i[2]))
                if c != -1:
                    ans += 1
print(ans)

Measured memory_bytes: 9284
//*Here I go out to sea again
//*The sunshine fills my hair
//*And dreams hang in the air

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

#define ll long long
#define mp make_pair
#define pb push_back

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,l;
    cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
      cout<<s[i];
    }
    cout<<"\n";

    return 0;
}


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

using matrix = vector<vector<int>>;

matrix mat_op(matrix a, matrix b) {
    const int n = a.size();
    matrix res(n, vector<int>(n, -1));
    for(int k = 0; k < n; ++k) {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < n; ++j) {
                if(a[i][k] == -1 || b[k][j] == -1) continue;
                res[i][j] = max(res[i][j], a[i][k] + b[k][j]);
            }
        }
    }
    return res;
}

matrix matpow(matrix a, int n) {
    const int V = a.size();
    matrix res(V, vector<int>(V, -1));
    for(int i = 0; i < V; ++i) {
        res[i][i] = 0;
    }
    while(n > 0) {
        if(n & 1) res = mat_op(move(res), a);
        a = mat_op(a, a);
        n >>= 1;
    }
    return res;
}


int main() {
    int V, E, K; cin >> V >> E >> K;
    matrix a(V, vector<int>(V, -1));
    for(int i = 0; i < V; ++i) {
        a[i][i] = 0;
    }
    for(int i = 0; i < E; ++i) {
        int u, v, c; cin >> u >> v >> c;
        a[u][v] = max(a[u][v], c);
    }

    auto check = [&] (int cnt) {
        const auto res = matpow(a, cnt);
        for(int i = 0; i < V; ++i) {
            for(int j = 0; j < V; ++j) {
                if(res[i][j] >= K) return true;
            }
        }
        return false;
    };
    int lb = 0, ub = K + 1;
    while(ub - lb > 1) {
        const auto mid = (lb + ub) >> 1;
        (check(mid) ? ub : lb) = mid;
    }

    if(ub == K + 1) {
        cout << -1 << endl;
        return 0;
    }

    cout << ub << endl;
    if(ub <= 100) {
        vector<int> dp(V);
        vector<vector<int>> path(V);
        for(int i = 0; i < V; ++i) {
            path[i] = {i};
        }
        for(int i = 0; i < ub; ++i) {
            vector<int> ndp(V, -1), nfrom(V, -1);
            vector<vector<int>> npath(V);
            for(int from = 0; from < V; ++from) {
                if(dp[from] == -1) continue;
                for(int to = 0; to < V; ++to) {
                    if(from == to || a[from][to] == -1) continue;
                    if(ndp[to] < dp[from] + a[from][to]) {
                        ndp[to] = dp[from] + a[from][to];
                        nfrom[to] = from;
                    }
                }
            }
            for(int j = 0; j < V; ++j) {
                if(nfrom[j] == -1) continue;
                npath[j] = path[nfrom[j]];
                npath[j].push_back(j);
            }
            dp = move(ndp);
            path = move(npath);
        }
        vector<int> ans_path;
        int maxi = -1;
        for(int i = 0; i < V; ++i) {
            if(dp[i] > maxi) {
                maxi = dp[i];
                ans_path = path[i];
            }
        }
        for(int i = 0; i <= ub; ++i) {
            cout << ans_path[i] << " \n"[i == ub];
        }
    }
}



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

using namespace std;

const int maxn = 3010,mod = 1e9 + 7;
int n,m,sum[maxn],R[maxn],f[maxn][maxn];
char s[maxn];

int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",s + 1);
    for (int i = 1; i <= n; i++)
    {
        sum[i] = sum[i - 1] + s[i] - '0';
        R[i] = i;
    }
    R[n + 1] = n + 1;
    sum[n + 1] = sum[n];
    for (int i = 1; i <= m; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        R[x] = max(R[x],y);
    }
    for (int i = 2; i <= n + 1; i++)
        R[i] = max(R[i],R[i - 1]);
    f[1][sum[R[1]]] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= n; j++)
        {
            if (!f[i][j])
                continue;
            int k = sum[R[i + 1]] - sum[R[i]];
            if (j)
                (f[i + 1][j - 1 + k] += f[i][j]) %= mod;
            if (i + j <= R[i])
                (f[i + 1][j + k] += f[i][j]) %= mod;
        }
    printf("%d\n",f[n + 1][0]);

    return 0;
}


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

int main() {
  int N, K, S;
  cin >> N >> K;
  S = 1;
  for (int i = 0; i < N; i++) {
    if (S < K) {
      S *= 2;
    }
    else {
      S += K;
    }
  }
  cout << S << endl;
}

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

int main(){

  int N,i,j,minj,box,count=0;
  int *A;

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

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++)
      if(A[j]<A[minj])
	minj = j;
    if(i!=minj){
      box = A[i];
      A[i] = A[minj];
      A[minj] = box;
      count++;
    }
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  free(A);

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n,x = s.nextInt
    val l = List.fill(n)(s.nextInt)
    var t = 0
    var c = 1
    for (i <- 0 until n) {
      t = t + l(i)
      if (t > x) return c.toString
      c = c + 1
    }
    c.toString
  }

  val tests = List(
    """3 6
      |3 4 5""".stripMargin -> """2""",
    """4 9
      |3 3 3 3""".stripMargin -> """4"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25768
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {

	unsigned long long N;
	unsigned long long K;

	cin >> N;
	cin >> K;

	vector<unsigned long long> H(N, 0);

	for (unsigned long long i = 0; i < N; i++) {
		cin >> H[i];
	}

	sort(H.begin(), H.end());

	unsigned long long ans = 0;
	long long jdg = N - K;

	if (jdg > 0) {
		for (unsigned long long i = 0; i < N - K; i++) {
			ans += H[i];
		}
	}
	else {
		ans = 0;
	}
	

	cout << ans << endl;

	return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
  long long c = a % b;
  while(c){
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 1;
  for(int i=0; i<n; i++){
    long long x;
    cin >> x;
    ans /= gcd(ans, x);
    ans *= x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define EPS     1e-11
#define INF     0x7fffffff
#define LL_INF  0x7fffffffffffffff

typedef long long LL;
struct Point {
        int x, y;
};
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};


int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    x4 = x1-(y2-y1);
    y4 = y1+(x2-x1);
    x3 = x2 + x4 - x1;
    y3 = y2 + y4 - y1;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


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

int main(){
  int n, N, k = 0;
  cin >> n;
  N = n;
  while (n){
    k += n % 10;
    n /= 10;
  }
  if(N % k == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int k = 1;
	string t = "";
	t = s[0];
	for (int i = 1; i < n - 2; i++)
	{
		string d = "";
		d = s[i];
		if (d == t)
		{
			t = s[i] + s[i + 1];
			i++;
		}
		else
		{
			t = s[i];
		}
		k++;
	}
	string d = "", f = "";
	d = s[n - 2];
	f = s[n - 1];
	if (d == t)
	{
		k++;
	}
	else
	{
		if (d == f)
		{
			k++;
		}
		else
		{
			k += 2;
		}
	}
	cout << k;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
/********************************************************

Digvijay Bahadur Singh
MNNIT

*********************************************************/


const int MOD=1e9+7;
const int N = 1e6+100;
/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans * a);
   a = (a * a);
   b=b>>1;
   }
   return ans;
}

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  // ifstream cin("a1.in");
  // ofstream cout("a1.out");
	ll T;
 // cin>>T;
  
    T=1;
    
    while(T--)
  {
    
        int n,r;
        cin>>n>>r;
        int count=0;
        while(n)
        {
          n/=r;
          count++;
        }
        cout<<count<<"\n";
       







  
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin>>n;
  int y=0;
  for(int i=0;i<n;i++){
    cin>>s ;
    if(s=="Y"){
      y=1;
   }
  }
  if(y){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
  if(input.indexOf("C") == -1 || input.indexOf("F") == -1){
     console.log("No");
    return;
  }
  var list = [];
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i+1);
    if(tmp == "C" || tmp == "F"){
       list.push(tmp);
       }
  }
  list = list.join("");
  console.log((list.indexOf("CF") != -1) ? "Yes" : "No");
}

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


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

int main() {
  vector<char> alphabet(26);
  iota(alphabet.begin(), alphabet.end(), 'A');

  int N;
  string S;
  cin >> N >> S;

  for(int i=0;i<S.size();i++) {
    int index = 0;
    for(int j=0;j<26;j++) {
      if(alphabet[j] == S[i]) {
        index = j;
        break;
      }
    }

    cout << alphabet[(index + N) % 26];
  }

  cout << endl;

  return 0;
}

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

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void caddi2018b_b(vector<vector<int>> v) {

    int n = v[0][0];
    int h = v[0][1];
    int w = v[0][2];

    int cnt = 0 ;

    for (int i = 1; i <= n; i++) {

        if (h <= v[i][0] && w <= v[i][1]) {

            cnt += 1;
        }

    }

    cout << cnt << endl;

}

int main() {

    //    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    caddi2018b_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

Measured memory_bytes: 384
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.12 23:08:22
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;



template<typename T>
class KMP {
public:
    std::vector<T> pattern;
    int plen;
    std::vector<int> table;
    
    KMP(const std::vector<T>& s) : pattern(s), plen((int)pattern.size()), table(plen + 1) {
        table[0] = -1;
        int j = -1;
        for (int i = 0; i < plen; i++) {
            while (j >= 0 && pattern[i] != pattern[j]) j = table[j];
            j++;
            if (i + 1 < plen && pattern[i + 1] == pattern[j]) table[i + 1] = table[j];
            else table[i + 1] = j;
        }
    }
    
    std::vector<int> search(const std::vector<T>& text) {
        std::vector<int> res;
        int head = 0, j = 0, tlen = (int)text.size();
        while (head + j < tlen) {
            if (pattern[j] == text[head + j]) {
                if (++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = std::max(table[j], 0);
        }
        return res;
    }
};
int main() {
    int n;cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> c(2*n),d(n);
    for (int i = 0; i < n; i++) {
        c[i] = a[i] ^ a[(i+1)%n];
        c[i + n] = c[i];
        d[i] = b[i] ^ b[(i+1)%n];
    }
    c.pop_back();
    KMP<int> kmp(d);
    auto v = kmp.search(c);
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " " << (b[i]^a[(i+v[i])%n]) << endl;
    }
    return 0;
}


Measured memory_bytes: 10068
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
A,B,C,D= map(int, input().split())
print(B-A+1-B//C+(A-1)//C-B//D+(A-1)//D+B//lcm(C,D)-(A-1)//lcm(C,D))


Measured memory_bytes: 2940
#include <iostream>

int main(void) {
	int n, x;
	std::cin >> n >> x;
	int min = x, max = x;
	long long s = x;
	for (int i = 1; i < n; ++i) {
		std::cin >> x;
		if (x < min) { min = x; }
		if (x > max) { max = x; }
		s += x;
	}
	std::cout << min << " " << max << " " << s << std::endl;
	return 0;
}

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

using namespace std;

const int N = 100100;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;

long long a[N];
long long sum[N];


int main(){
    int n;
    scanf("%d", &n);
    // printf("%d", n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }

    sort(a+1, a+n+1);
    a[n+1] = INF;

    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i-1] + a[i];
    }

    // for each one, the quantity of times that he eats is logn
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int s = 0;
        long long sz = a[i];
        //printf("i %d\n", i);
        while(1) {
            int pos = lower_bound(a+1, a+n+1, 2*sz+1) - a - 1;
            
            if(pos <= s)break;
            sz = sum[pos];
            s = pos;
        }
        // printf("%d\n", s);
        if(s == n) ans++; 
    }
    printf("%d\n", ans);

    

    
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int A = 80;

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

    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int b;
            cin >> b;
            a[i][j] -= b;
        }
    }

    int am = (n + m - 1) * A + 1;

    bool dp[n][m][am];
    fill(&dp[0][0][0], &dp[n][0][0], false);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == 0 && j == 0) {
                dp[i][j][abs(a[i][j])] = true;
            } else {
                for (int q = -1; q <= 1; q += 2) {
                    if (i > 0) {
                        for (int k = 0; k < am - A; k++) {
                            if (dp[i-1][j][k]) {
                                dp[i][j][abs(k+q*a[i][j])] = true;
                            }
                        }
                    }
                    if (j > 0) {
                        for (int k = 0; k < am - A; k++) {
                            if (dp[i][j-1][k]) {
                                dp[i][j][abs(k+q*a[i][j])] = true;
                            }
                        }
                    }
                }
            }
        }
    }

    int ans = am;
    for (int i = 0; i < am; i++) {
        if (dp[n-1][m-1][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 79744