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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef long long ll;

const int MAX_N=18;
const ll INF=1e12;

int N;
ll A[1<<MAX_N],ans[1<<MAX_N][2],temp[4];

int main(){
	cin>>N;
	REP(i,1<<N){
		cin>>A[i];
		ans[i][0]=A[i];
		ans[i][1]=-INF;
	}
	REP(i,N){
		REP(j,1<<N){
			if (j&(1<<i)){
				REP(k,2){
					temp[k]=ans[j][k];
					temp[k+2]=ans[j-(1<<i)][k];
				}
				sort(temp,temp+4);
				REP(k,2){
					ans[j][k]=temp[3-k];
				}
			}
		}
	}
	REP(i,1<<N){
		ans[i][0]+=ans[i][1];
	}
	FOR(i,1,1<<N){
		ans[i][0]=max(ans[i][0],ans[i-1][0]);
		cout<<ans[i][0]<<endl;
	}
	return 0;
}


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

int main()
{
	string a;
	getline(cin, a);
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] >= 'a'&&a[i] <= 'z')
		{
			a[i] -= 32;
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
const int N=3008;
template<class T>
T chmax(T &x, T y) {
	return x=(x>y?x:y);
}
pair<int,int> f[N][N];
int main() {
	string s, t;
	getline(cin, s);
	getline(cin, t);
	for (int i=0; i<s.size(); i++)
	for (int j=0; j<t.size(); j++) {
		f[i+1][j+1].second=-5;
		if (s[i]==t[j]) chmax(f[i+1][j+1], {f[i][j].first+1, 0});
		chmax(f[i+1][j+1], max(mp(f[i][j+1].first, -1), mp(f[i+1][j].first, -2)));
	}
	
	string ans = "";
	int n = s.size(), m=t.size();
	while (n>=1&&m>=1) {
		int g=f[n][m].second;
		if (g==-2) m--; else
		if (g==-1) n--; else 
		ans=t[m-1]+ans, m--, n--;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 70784
x = input ()
if int(x[0])>int(x[1]):
  print (x[0]*3)
elif int(x[0])==int(x[1]):
  if int(x[0])>=int(x[2]):
    print (x[0]*3)
  else:
    print (str(int(x[0])+1)*3)
else:
  print (str(int(x[0])+1)*3)

Measured memory_bytes: 9016
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

n = 41

B = [0 for _ in range(n)]
result = [0 for _ in range(n)]

for a in A:
    for i in range(n):
        B[i] += (a >> i) & 1

#print(B)

result = 0
k_rest = K

for i in list(range(n))[::-1]:
    if B[i] * 2 < N and (k_rest >= (1 << i)):
        k_rest = k_rest - (1 << i)
        result += (1 << i) * (N - B[i])
    else:
        result += (1 << i) * B[i]

print(result)


Measured memory_bytes: 14708
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int sub12, sub23, sub31;
  sub12 = abs(a1-a2);
  sub23 = abs(a2-a3);
  sub31 = abs(a3-a1);
  int result = sub12 + sub23 + sub31 - max(max(sub12, sub23), sub31);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int INF = 1 << 30;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
ll m[88];
ll fib(ll n) {
	if (n == 0)return 2;
	if (n == 1)return 1;
	if (m[n] != -10)return m[n];
	else {
		ll nn = fib(n - 1) + fib(n - 2);
		m[n] = nn;
		return nn;
	}
}
int main() {
	ll N;
	std::cin >> N;
	TFOR(i, 87)m[i] = -10;
	std::cout << fib(N) << endl;
	return 0;
}

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

struct Node{
	int v, id;
};

const int N = 1e5 + 10;

Node a[N];

bool cmp(const Node& x, const Node& y){
	return x.v < y.v;
}

int main(){
	int n, ans;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++){
		scanf("%d",&a[i].v);
		a[i].id = i;
	}
	sort(a + 1, a + n + 1, cmp);
	ans = 0;
	for (int i = 1; i <= n; i++){
		if ((a[i].id + i) % 2) ans++;
	}
	printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 1024
/**
 * Contest : AtCoder Beginner Contest 163
 * Contest URL : https://atcoder.jp/contests/abc163/tasks
 * Problem : D - Sum of Large Numbers
 * Problem URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
 */

#include "bits/stdc++.h"
using namespace std;
#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) {
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 {
#ifdef LOCAL
~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 << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

const int mod = 1e9 + 7;
void add_self (int & a, int b) {
	a += b;
	if ( a >= mod) a -= mod;
}

void solve() {
	int n, k; cin >> n >> k;
	int ans = 0;
	ll left = 0ll, right = 0ll;
	int a = 0, b = n;
	for (int cnt = 1; cnt < k; cnt++) {
		left += a; right += b;
		a++, b--;
	}
	for (int cnt = k; cnt <= n + 1; cnt++) {
		left += a, right += b;
		int num = (right - left + 1) % mod;
		add_self (ans, num);
		a++, b--;
	}
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s, t = input().split()
    a, b = LI()
    u = input()
    if u == s:
        print("{} {}".format(a - 1, b))
    elif u == t:
        print("{} {}".format(a, b - 1))
    return


# B
def B():
    s = input()
    print('x' * len(s))
    return


# C
def C():
    n = I()
    a = LI()
    s = set()
    for i in a:
        s.add(i)
    if len(s) == n:
        print('YES')
    else:
        print('NO')
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 93908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    int ans = (N + M) * (N + M - 1) / 2 - N * M;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		
		//Sは天気予報、Tは実際の天気
		char [] s = stdIn.next().toCharArray();
		char [] t = stdIn.next().toCharArray();
		
		int count = 0;
		for(int i = 0; i < s.length; i++){
			if(s[i]== t[i]){
				count++;
			}
		}
		
		System.out.println(count);
		
	}

}


Measured memory_bytes: 23636
#include<stdio.h>
#include<math.h>

int main(){
  int i, j, n, input, count=0;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &input);
    j = 2;
    while(j <= sqrt(input)){
	if(input % j == 0){
	  j = 1;
	  break;
	}
	j++;
      }
      if(j != 1){
	count++;
      }
  }
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std; 
int main() {
    string S;
    cin >> S;
    string t1 = S.substr(0, 2) , t2 = S.substr(2);
    int a = stoi(t1), b = stoi(t2);
    if (0 < a && a <= 12) {
        if (0 < b && b <= 12) {
            cout << "AMBIGUOUS" << endl;
        }
        else {
            cout << "MMYY" << endl;
        }
    }
    else {
        if (0 < b && b <= 12) {
            cout << "YYMM" << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
 
}

Measured memory_bytes: 3552
import bisect

A,B,Q = map(int,input().split())
INF = 10**18
sa = [-INF] + [int(input()) for i in range(A)] + [INF]
tb = [-INF] + [int(input()) for i in range(B)] + [INF]
xq = [int(input()) for i in range(Q)]

for x in xq:
    ans = INF
#     near_s = sa[np.argmin([abs(s-x) for s in sa])]
#     near_t = tb[np.argmin([abs(near_s-t) for t in tb])]
#     ans += abs(near_s-x)+abs(near_t-near_s)
    
#     ans2 = 0
#     near_t_2 = tb[np.argmin([abs(t-x) for t in tb])]
#     near_s_2 = sa[np.argmin([abs(near_t_2-s) for s in sa])]
#     ans2 += abs(near_t_2-x) + abs(near_s_2 -near_t_2)

    b, d = bisect.bisect_right(sa,x), bisect.bisect_right(tb,x)
    for S in [sa[b],sa[b-1]]:
        for T in [tb[d], tb[d-1]]:
            d1, d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(T-S)
            ans = min(ans,d1,d2)
    
    print(ans)

Measured memory_bytes: 17936
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int h, w, k;
string c[6];

int solve() {
    int res = 0;
    for (int i = 0; i < (1<<h); i++) {
        for (int j = 0; j < (1<<w); j++) {
            int cnt = 0;
            for (int a = 0; a < h; a++) {
                for (int b = 0; b < w; b++) {
                    if (((i>>a)&1) && ((j>>b)&1) && c[a][b] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == k) {
                res++;
            }
        }
    }
    return res;
}

void input() {
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) cin >> c[i];
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
  string s;
  cin >> s;
  deque<char> ds(s.size());
  for (int i = 0; i < s.size(); ++i) ds[i] = s[i];
  
  int q; cin >> q;
  int rev = 0;
  for (int i = 0; i < q; ++i){
    int type; cin >> type;
    if (type == 2){
      int f; char c;
      cin >> f >> c; --f;
      if (rev) f = 1 - f;
      if (f == 0) ds.push_front(c);
      else ds.push_back(c);
    }
    else rev =1 - rev;
  }
  if (rev) reverse(ds.begin(), ds.end());
  for (auto c:ds) cout << c;
  cout << endl;
}


Measured memory_bytes: 3972
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
  vi x(m);
  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());
  vi v(m - 1);
  rep(i, m - 1) v[i] = x[i + 1] - x[i];
  sort(v.begin(), v.end());
  int ans = x[m - 1] - x[0];
  rep(i, n - 1) ans -= v[m - 2 - i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int D = scan.nextInt();

        int count = 0;
        long a,b;
        double c;

        for (int i=0;i<N;i++ ){
            a = scan.nextLong();
            b = scan.nextLong();

            c = Math.sqrt(a * a + b * b);

            if(c<=D){
                count++;
            }
        }

    System.out.println(+ count + "");
    }
}


Measured memory_bytes: 61592
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    ll ans = 0;
    int cnt = 0;
    for(int i = n - 1; i >= 0; i--){
        if(i - 1 >= 0 && s[i] == 'C' && s[i - 1] == 'B'){
            cnt++;
            i--;
        }else if(s[i] == 'A'){
            ans += cnt;
        }else{
            cnt = 0;
        }
    }
    cout << ans << '\n';
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, A, B;
  cin >> N >> A >> B;
  VL xs(N);
  REP(i,N) cin >> xs[i];
  SORT(xs);

  LL lb = 0, ub = 1e15 / B;
  while(ub - lb > 1){
	LL m = (lb + ub) / 2;
	LL sum = m;
	REP(i,N){
	  LL rest = xs[i] - m * B;
	  if(rest > 0){
		sum -= (rest + A-B-1) / (A-B);
		if(sum < 0) break;
	  }
	}
	if(sum >= 0)
	  ub = m;
	else
	  lb = m;
  }
  cout << ub << endl;

  return 0;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int k, n;
	cin >> k >> n;
	int a[200010];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	a[n] = k + a[0]; 

	int ans = k;
	for(int i = 0;i < n;i++){
		chmin(ans, k-(a[i+1]-a[i]));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;

int main(){
	long long int n,k,i,diff=0;
	cin>>k>>n;
	long long int a[n+1];
	cin>>a[0]>>a[1];
	diff=a[1]-a[0];
	for(i=2;i<n;i++){
		cin>>a[i];
		if(a[i]-a[i-1]>diff){
			diff=a[i]-a[i-1];
		}		
	}
	a[n]=k+a[0];
	
		if(a[i]-a[i-1]>diff){
			diff=a[i]-a[i-1];
		}
		
	cout<<k-diff;	
	
	return 0;
}

Measured memory_bytes: 1792
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
if N == 2:
    ans = max(A)
else:
    GCDF, GCDB = [0]*N, [0]*N
    GCDF[1],GCDB[-2] = A[0], A[N-1]
    for i in range(2, N):
        GCDF[i] = gcd(GCDF[i-1],A[i-1])
        GCDB[-(i+1)] = gcd(GCDB[-i], A[-i])
    GCDm = [0]*N
    GCDm[0] = GCDB[0]
    GCDm[N-1] = GCDF[N-1]
    for i in range(1, N-1):
        GCDm[i] = gcd(GCDF[i],GCDB[i])
    ans = max(GCDm)
print(ans)
        


Measured memory_bytes: 16156
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
res = 0
last = -1
for a in A:
  res += B[a-1]
  if a - last == 1:
    res += C[last-1]
  last = a
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const int N=200001;
ll n,a[N],ans=0,b[N];
ll dp[N];
ll did[N];

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
		b[a[i]-1]=i;
	}
	FOR(i,0,n)did[i]=0;
	FOR(j,0,n)dp[j]=1;

	FOR(i,0,n){
		ll k=a[i];
		did[k]=1;
		if(k!=1){
			if(did[k-1]==1)dp[k]=dp[k-1]+1;
		}
	}
	FOR(i,0,n+1)ans=max(ans,dp[i]);
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,m,a[N],b[N]; char st[N];
int main()
{
	int i,x,l,r,mid,sum;
	scanf("%s",st+1);
	n = strlen(st+1);
	l=0,r=n;
	for(i=1;i<=n;i++) a[i]=st[i]-'0';
	for(i=1;i<=n/2;i++) swap(a[i],a[n-i+1]);
	for(i=1;i<=n;i++)
		x=a[i]*9+x/10,a[i]=x%10;
	if(x/10) a[++n]=x/10;
	while(r-l>1){
		mid=(l+r)>>1;
		for(i=1;i<=n;i++) b[i]=a[i];
		m=n,x=mid*90,sum=0;
		for(i=1;i<=m;i++)
			x=b[i]+x/10,b[i]=x%10;
		while(x/10) x/=10,b[++m]=x%10;
		for(i=1;i<=m;i++) sum+=b[i];
		if(sum<=9*mid) r=mid;
		else l=mid;
	  }
	cout<<r;
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main() {
    int n, T;
    cin >> n >> T;

    int ans = T;
    int pre = 0;
    for (int i=0; i<n; i++) {
        int t;
        cin >> t;
        t -= pre;

        if (t < T)
            ans += t;
        else
            ans += T;

        pre += t;
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int _pow2[110000];
Int *pow2 = _pow2 + 55000;
Int n, m;
Int dp[5500][5500];
Int dp2[5500][5500];
int main(){
    cin >> n >> m;
    pow2[0] = 1;
    for(int i = 1;i < 54000;i++){
        pow2[i] = pow2[i-1] * 2 % MOD;
        pow2[-i] = pow2[1-i] * ((MOD+1) / 2) % MOD;
    }
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            if(i == 0){
                dp[i][j] = 1;
            }
            else{
                dp[i][j] = dp[i-1][j] * (j+1) % MOD;
                if(j >= 2)
                    (dp[i][j] += dp2[i-1][j-1] * pow2[j-1] % MOD) %= MOD;
            }
            if(j)
                (dp2[i][j] = (dp2[i][j-1] + dp[i][j] * j % MOD * pow2[-j] % MOD) % MOD) %= MOD;
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 433768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

#define BUF_SIZE 7

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

#define NUM_MAX 44

int main(void) {
    uint64_t ans[NUM_MAX+1];
    int n = get_int();
    ans[0] = 1; ans[1] = 1;
    int i;

    for(i = 2; i <= n; i++) {
        ans[i] = ans[i-1] + ans[i-2];
    }
    printf("%lld\n", ans[n]);
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
   int n;
   cin >> n;
   vector<int>a(n);
   rep(i,n) cin >> a[i];
   int minv = a[0];
   int maxv = -2000000000;
   for(int i = 1;i<n;i++) {
       maxv = max(maxv,a[i]-minv);
       minv = min(minv,a[i]);
   }

   cout << maxv << endl;
   return 0;
}


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

int main() {
  long long K;
  long long account = 100;
  long long cnt = 0;
  cin >> K;
  while (true) {
    account *= 1.01;
    ++cnt;
    if (account >= K) break;
  }
  cout << cnt;
}

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	int cnt = unique(s.begin(),s.end())-s.begin();
	if(cnt==2)
		cout << "Yes";
	else cout << "No";
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    string s;
    cin >> s;
    Int n = s.size();
    vector<Int> a;
    Int i = 0;
    while (i < n) {
        Int cnt = 0;
        char x = s[i];
        while (s[i] == x) {
            cnt++;
            i++;
        }
        a.emplace_back(cnt);
    }
    for (Int i = 0; i < (Int)a.size(); i+=2) {
        for (Int j = 0; j < a[i] - 1; j++) {
            cout << "0 ";
        }
        cout << (a[i] + 1) / 2 + a[i + 1] / 2 << " ";
        cout << a[i] / 2 + (a[i + 1] + 1) / 2 << " ";
        for (Int j = 0; j < a[i + 1] - 1; j++) {
            cout << "0 ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
#include<string.h>
int main(void){
	int m[6]={0};
	int c,i,t,k;
	char d[101]="\0";
	for(c=0;c<6;c++){
	scanf("%d",&m[c]);
	}
	scanf("%s",d);
	k=strlen(d);
	for(i=0;i<k;i++){
		if(d[i]=='N'){
				
			t=m[0];
			m[0]=m[1];
			m[1]=m[5];
			m[5]=m[4];
			m[4]=t;
				
		}else if(d[i]=='S'){
		
			t=m[0];
			m[0]=m[4];
			m[4]=m[5];
			m[5]=m[1];
			m[1]=t;
			
		}else if(d[i]=='E'){
		
			t=m[0];
			m[0]=m[3];
			m[3]=m[5];
			m[5]=m[2];
			m[2]=t;
			
		}else if(d[i]=='W'){
		
			t=m[0];
			m[0]=m[2];
			m[2]=m[5];
			m[5]=m[3];
			m[3]=t;
			
		}
		
	
	
	}
		printf("%d\n",m[0]);
	
		return 0;
}
			


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const int MAX_N = 1024;
const int MAX_W = 110000;
ll dp[MAX_N][MAX_W];
ll ans=1<<29;
void Main(){
    ll W;cin>>W;
    ll n;cin>>n;
    vector<ll> weight(n),value(n);
    For(i,0,n) cin>>weight[i]>>value[i];

    // DP初期条件: dp[i][0] = 0
    for (int i = 0; i < MAX_N; ++i) for (int w = 0; w < MAX_W; ++w) dp[i][w] = 1 << 29; // INF
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;

    // DPループ
    for (int i = 0; i < n; ++i) {
        for (int w = 0; w <= 100000; ++w) {
            dp[i + 1][w] = min(dp[i + 1][w], dp[i][w]);
            if (w >= weight[i]) dp[i + 1][w] = min(dp[i + 1][w], dp[i + 1][w - weight[i]] + value[i]);
        }
    }
    For(j,W,99999) ans=min(ans,dp[n][j]);
    cout << ans << endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 880384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		long a = as.nextLong();
		long b = as.nextLong();
		long n = as.nextLong();
		long l = 0;
		if(a%n==0){
			l = b/n-a/n+1;
		}else{
			l = b/n-a/n;
		}
		System.out.println(l);
	}
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> ab(n, 0);
  
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 2; j++) {
      int num;
      cin >> num;
      ab.at(num - 1)++;
    }
  }
  for(const auto& i : ab){
    cout << i << endl;
  }
}

Measured memory_bytes: 256
include Math
require 'prime'

n = gets.to_i
root_prime = Prime.each(10000).to_a
c = 0

n.times {
  x = gets.to_i
  if (x <= 10000)
    c += 1 if (root_prime.include?(x))
    next
  end
  xs = sqrt(x).floor
  catch(:next) do
    root_prime.each{ |rp|
      break if (rp > xs)
      throw :next if (x % rp == 0)
    }
    c += 1
  end
}
puts c

Measured memory_bytes: 9008
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
 unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if(cur == nil)break;
    if(isf == 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
  
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33000
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int N, M;
    cin >> N >> M;
    V D(N);
    rep(i, N) cin >> D[i];
    V C(M);
    rep(j, M) cin >> C[j];

    VV dp(N + 1, V(M + 1, inf));
    dp[0][0] = 0;
    rep(i, N + 1) {
        rep(j, M) {
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            if (i < N) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + D[i] * C[j]);
        }
    }

    cout << dp[N][M] << endl;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> c(H);
    for (int i =0; i < H; i++){
        cin >> c.at(i);
    }
    for (int i = 0; i < H; i++){
        cout << c[i] << endl;
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import accumulate

def solve(N: int, K: int, x: "List[int]"):
    minus = []
    plus = []
    answer = 10**9
    for i in range(N):
        if x[i] >= 0:
            plus.append(x[i])
        else:
            minus.append(abs(x[i]))
    minus = minus[::-1]

    for plus_count in range(0,K+1):
        minus_count = K- plus_count

    
        if 0 <= plus_count <= len(plus) and 0 <= minus_count <= len(minus):
            if plus_count == 0:
                answer = min(answer,minus[minus_count-1])
            elif minus_count ==0:
                answer = min(answer,plus[plus_count-1])
            else:
                answer = min(answer,plus[plus_count-1]+minus[minus_count-1]*2,plus[plus_count-1]*2+minus[minus_count-1])   

    print(answer)    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19884
from collections import Counter as c
n=int(input())
*l,=map(int,input().split())

ca=sorted(c(l[1::2]).items(),key=lambda x:x[1])[::-1]
cb=sorted(c(l[0::2]).items(),key=lambda x:x[1])[::-1]

v1=sum([i[1] for i in ca])
v2=sum([i[1] for i in cb])

a1=ca[0][0]
for i in cb:
  if a1==i[0]:continue
  b=i[1]
  break
else:
  b=0
ans1=v2-b+v1-ca[0][1]

a1=cb[0][0]
for i in ca:
  if a1==i[0]:continue
  b=i[1]
  break
else:
  b=0
ans2=v1-b+v2-cb[0][1]

print(min(ans1,ans2))

Measured memory_bytes: 20692
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

double cal_dis(vector<vector<double>> pts, double x, double y) {
    double ans = 0;
    vector<double> arr;
    for(int i = 0; i < pts.size(); i++) {
        double xx = pow(x-pts[i][0], 2);
        double yy = pow(y-pts[i][1], 2);
        arr.push_back(sqrt(xx+yy));
    }
    return *max_element(arr.begin(), arr.end());
}

double sub_tri(vector<vector<double>>& pts, double x) {
    double l = 0.0, r = 1000.0;
    while (r - l > 1e-8) {
        vector<double> arr(4, 0);
        arr[0] = cal_dis(pts, x, l);
        arr[1] = cal_dis(pts, x, l*2.0/3.0 + r/3.0);
        arr[2] = cal_dis(pts, x, l/3.0 + r*2.0/3.0);
        arr[3] = cal_dis(pts, x, r);
        int delta = 0;
        for(int i = 1; i < 4; i++) {
            if (arr[i-1] > arr[i])
                delta -= 1;
            else if (arr[i-1] < arr[i])
                delta += 1;
        }
        if (delta == -3 || delta == -1)
            l = l*2.0/3.0 + r/3.0;
        else
            r = l/3.0 + r*2.0/3.0;
        // printf("(l, r) = %lf, %lf\n", l, r);
        // printf("d(l, r) = %lf, %lf\n", );
    }
    double ans = cal_dis(pts, x, l);
    // cout << ans << endl;
    return ans;
}
int main() {
    int n;
    double a, b;
    cin >> n;
    vector<vector<double>> pts;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        pts.push_back({a, b});
    }
    double l = 0.0, r = 1000.0;
    while (r - l > 1e-8) {
        vector<double> arr(4, 0);
        arr[0] = sub_tri(pts, l);
        arr[1] = sub_tri(pts, l*2.0/3.0 + r/3.0);
        arr[2] = sub_tri(pts, l/3.0 + r*2.0/3.0);
        arr[3] = sub_tri(pts, r);
        int delta = 0;
        for(int i = 1; i < 4; i++) {
            if (arr[i-1] > arr[i])
                delta -= 1;
            else if (arr[i-1] < arr[i])
                delta += 1;
        }
        if (delta == -3 || delta == -1)
            l = l*2.0/3.0 + r/3.0;
        else
            r = l/3.0 + r*2.0/3.0;
    }
    cout << fixed << setprecision(12) << sub_tri(pts, l) << endl;
    return 0;
}




Measured memory_bytes: 256
n, k = map(int, input().split())
ans = 0
max = 0
min = 0
for i in range(0, k):
    min += i
    max += n - i
for i in range(k, n + 2):
    #print(ans, max, min, i)
    ans = (ans + max - min + 1) % (10 ** 9 + 7)
    max += n - i
    min += i

print(ans)


Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
int main(){
   ll N,Y;
   cin>>N>>Y;
   if (Y%1000!=0){
      cout<<-1<<" "<<-1<<" "<<-1<<endl;
       return 0;
   }
   Y/=1000;
   for(ll i=N;i>=0;i--){
       for(ll j=0;j<=N;j++){
           ll k=N-i-j;
            if(i+j>N){
               break;
           }
           else if(i*10+j*5+k==Y){
               cout<<i<<" "<<j<<" "<<k<<endl;
               return 0;
           }
       }
   }
   cout<<-1<<" "<<-1<<" "<<-1<<endl;
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define LL long long

using namespace std;
const int maxn = 2e3 + 5;
typedef pair<int, int> P;
int dp[maxn][maxn];
int pre[maxn << 1][maxn][2];
int a[maxn], b[maxn];
int n;
char s[maxn];
int main() {
#ifdef TT
    freopen("xxx.in", "r", stdin);
#endif // TT
    scanf("%d", &n);
    for(int i = 1, u; i <= n + n; ++i) {
        scanf("%s%d", s, &u);
        if(s[0] == 'W') {
            a[u] = i;
            pre[i][u][0] ++;
        } else {
            b[u] = i;
            pre[i][u][1] ++;
        }
    }
    for(int T = 0; T < 2; ++T) {
        for(int i = 1; i <= n + n; ++i) {
            for(int j = 1; j <= n; ++j) {
                pre[i][j][T] += pre[i - 1][j][T];
            }
        }
        for(int i = 1; i <= n + n; ++i) {
            for(int j = n; j; --j) {
                pre[i][j][T] += pre[i][j + 1][T];
            }
        }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            if(i < n) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + pre[a[i + 1]][i + 2][0] + pre[a[i + 1]][j + 1][1]);
            }
            if(j < n) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + pre[b[j + 1]][j + 2][1] + pre[b[j + 1]][i + 1][0]);
            }
        }
    }
    cout <<dp[n][n] <<endl;
    return 0;
}


Measured memory_bytes: 78720
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

using ll = long long;
using ld = long double;

const ll inf = LONG_LONG_MAX;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1){
            res = (res * a)%mod;
        }
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}

signed main(){
	ll t;
	//	cin >> t;
	 t = 1;
	while(t--){
		ll n,k;
		cin >> n;

		vector<bool>v(n+1);
		cin >> k;

		for(ll i=0;i<k;i++){
			ll x;
			cin >> x;

			for(ll i=0;i<x;i++){
				ll y;
				cin >> y;
				v[y] = 1;
			}
		}

		ll cnt = 0;
		for(ll i=1;i<=n;i++){
			if(!v[i]){
				cnt++;
			}
		}

		cout << cnt << "\n";
	}
	return 0;
}

Measured memory_bytes: 3488
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 100005
using namespace std;

int main(){
    int x;
    cin>>x;
    int cnt=0;
    while(1){
        cnt++;
        //cout<<x<<endl;
        x-=cnt;
        if(x<=0)break;
        
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<cmath>
#include<vector>
#include<cstdio>
using namespace std;
int fn(int n){
	return (n%2==0)?n/2:3*n+1;
}
int main(void){
	int i,j,s,a[10000];
	cin>>s;
	bool ch=true;
	a[0]=s;
	for(i=1;ch==true;i++){
		int tmp=fn(a[i-1]);
		for(j=0;j<i;j++){
			if(a[j]==tmp){
				ch=false;
				break;
			}
		}
		if(ch)a[i]=tmp;
	}
	cout<<i<<endl;
	
	return 0;
}


Measured memory_bytes: 256
N,M,W = map(int,input().split())
x=[0 for _ in range(N)]
y=[0 for _ in range(N)]
for i in range(N):
	x[i],y[i]=map(int,input().split())
ans=0
for i in range(N):
	if x[i] >= M and y[i] >= W:
		ans+=1
print(ans)

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

int main(){
  string S;cin>>S;
  if(S=="RRR") cout<<3<<endl;
  else if(S=="SSS") cout<<0<<endl;
  else if(S=="RRS") cout<<2<<endl;
  else if(S=="SRR") cout<<2<<endl;
  else cout<<1<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
char S[8005];
int X,Y,n,t,x,f[17000],g[17000],a[17000];
int main(){
	scanf("%s",S+1); n=strlen(S+1);
	scanf("%d%d",&X,&Y);
	for (int i=1;i<=n;++i){
		if (S[i]=='F') ++x; else a[++t]=x,x=0;
	}
	if (x) a[++t]=x;
	f[8000]=1;
	for (int i=1;i<=t;i+=2){
		if (i==1){
			f[8000]=0;
			f[8000+a[1]]=1;
			continue;
		}
		for (int j=0;j<=16000;++j)
		if (f[j]) g[j-a[i]]=g[j+a[i]]=1;
		for (int j=0;j<=16000;++j)
			f[j]=g[j],g[j]=0;
	}
	if (!f[X+8000]){
		puts("No"); return 0;
	}
	memset(f,0,sizeof f);
	f[8000]=1;
	for (int i=2;i<=t;i+=2){
		for (int j=0;j<=16000;++j)
		if (f[j]) g[j-a[i]]=g[j+a[i]]=1;
		for (int j=0;j<=16000;++j)
			f[j]=g[j],g[j]=0;
	}
	if (!f[Y+8000]){
		puts("No"); return 0;
	}
	puts("Yes");
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long A, long long B){
    ll counter = 0;
    FOR(i, A, B+1) {
        string j = to_string(i);
        if (j[0] == j[4] && j[1] == j[3]) {
            counter++;
        }
    }
    cout << counter << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long ans,n;
int main(){
  
  cin >> n;
  for (long long i = sqrt(n); i>=1; i--) {
    if (n % i != 0) continue;
       int b=n/i;
       while(b>0)
       {
       	 ans++;b/=10;
       }
       break;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,tune=native")

#include <x86intrin.h>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    if (N >= M) {
	cout << '0';
	exit(EXIT_SUCCESS);
    }
    int X[M], dist[M - 1], res = 0;
    cin >> X[0];
    for (int i = 1; i < M; i++)
	cin >> X[i];
    sort(X, X + M);
    for (int i = 0; i < M - 1; i++) {
	dist[i] = X[i + 1] - X[i];
	res += dist[i];
    }
    sort(dist, dist + M - 1, greater<int>());
    for (int i = 0; i < N - 1; i++)
	res -= dist[i];
    cout << res;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[300], w = new int[300];
		int cnt = 0;
		
		while(true){
			h[cnt] = sc.nextInt();
			w[cnt] = sc.nextInt();
			
			if(h[cnt] == 0 && w[cnt] == 0)
				break;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			for(int j = 0; j < h[i]; j++){
				for(int k = 0; k < w[i]; k++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 35200
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<ll> b(n);
  int flg = 0;
  ll k = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a < 0) flg ^= 1;
    b[i] = abs(a);
    if(b[k] > b[i]) k = i;
  }

  b[k] *= 1 - 2 * flg;
  ll ans = 0LL;
  rep(i, n) ans += b[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
string w;
  cin>>w;
  set<char>S;
  int N=w.size();
  for(int i=0;i<N;i++){
  if(S.count(w.at(i)))
    S.erase(w.at(i));
    else
      S.insert(w.at(i));
  }if(S.size()==0)
    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++)
using namespace std;
using ll = long long;
int main(){
  double a;
  cin >> a;
  if(a == 1)cout << fixed << setprecision(12) << 1.000000000000 << endl;
  else {
    int wa = a/2;
    if(fmod(a,2) == 1)wa++;
    double res = double(wa/a);
    cout << fixed << setprecision(12) << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

import static java.lang.Math.max;
import static java.lang.Math.min;

public
class Main
{
    public static
    void main(String[] args)
    {
        new Main().run();
    }

    private
    void run()
    {
        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();

        int left = max(c, a);
        int right = min(b, d);

        System.out.println(right - left > 0 ? right - left : 0);
    }
}


Measured memory_bytes: 21844
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    print('{} {}'.format(s[:4], s[4:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

int main() 
{
    FAST;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
    subt;   
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int n,dis[maxn],dis2[maxn],cntf=0,cnts=0;
vector<int> edge[maxn];
void dfs(int x,int f)
{
	for(int i=0;i<edge[x].size();i++)
	{
		int to=edge[x][i];
		if(f!=to)
		{
			dis[to]=dis[x]+1;
			dfs(to,x);
		}
	}
}
void dfs2(int x,int f)
{
	for(int i=0;i<edge[x].size();i++)
	{
		int to=edge[x][i];
		if(f!=to)
		{
			dis2[to]=dis2[x]+1;
			dfs2(to,x);
		}
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		--x,--y;
		edge[x].push_back(y);
		edge[y].push_back(x);	
	}
	dfs(0,-1);
	dfs2(n-1,-1);
	for(int i=0;i<n;i++)
		if(dis[i]<=dis2[i])
			++cntf;
		else
			++cnts;
	puts(cntf<=cnts?"Snuke":"Fennec");
	return 0;
}

Measured memory_bytes: 12800
#include <cstdio>

int main(void) {
	while(true) {
		int n;
		scanf("%d", &n);
		if(n == -1)
			break;

		int ans = 1150;
		if(10 < n && n <= 20)
			ans += 125 * (n - 10);
		if(20 < n && n <= 30)
			ans += 125 * 10 + 140 * (n - 20);
		if(30 < n)
			ans += 125 * 10 + 140 * 10 + 160 * (n - 30);

		printf("%d\n", 4280 - ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a==1){
        if(b==2) cout << "3" << "\n";
        if(b==3) cout << "2" << "\n";
    }else if(a==2){
        if(b==1) cout << "3" << "\n";
        if(b==3) cout << "1" << "\n";
    }else{
        if(b==1) cout << "2" << "\n";
        if(b==2) cout << "1" << "\n";
    }
}


Measured memory_bytes: 256
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(){
  val s = readInt()
  println("${s + s*s + s*s*s}")
}

Measured memory_bytes: 34432