akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FR first
#define SE second
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}
char obuf[S],*oS=obuf,*oT=oS+S-1,c,qu[55];int qr;
inline void flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
inline void putc(char x){*oS++ =x;if(oS==oT) flush();}
inline void printd(int d,double x)
{
    long long t=(long long)floor(x),f=t;
    while(t) qu[++qr]=t%10,t/=10;
    while(qr) putc(qu[qr--]+'0');
    putc('.');x-=f;
    while(d--)
    {
        double y=x*10;x*=10;
        int c=(int)floor(y);
        putc(c+'0');x-=floor(y);
    }
}

typedef long long LL;
typedef pair<LL,double> pld;
const int N=500010;
LL t[N],v[N];
pld q[N];
int l=1,r=0;

int main()
{
    int n=read(),L=read();
    for(int i=1;i<=n;i++)
        t[i]=read(),v[i]=read();
    int sum=0;double cur=0;
    for(int i=1;i<=n;i++)
    {
        while(v[i]+sum>L)
        {
            int pour=min(v[i]+sum-L,q[l].FR);
            sum-=pour;
            q[l].FR-=pour;
            cur-=q[l].SE*pour;
            if(!q[l].FR) l++;
        }
        q[++r]=pld(v[i],t[i]);
        sum+=v[i];cur+=1ll*t[i]*v[i];
        while(l<r&&q[r].SE<q[r-1].SE)
        {
            q[r-1].SE=(q[r-1].SE*q[r-1].FR+q[r].SE*q[r].FR)/(q[r-1].FR+q[r].FR);
            q[r-1].FR+=q[r].FR;r--;
        }
        printd(7,cur/L);putc('\n');
    }
    flush();
    return 0;
}

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

int a[101];
int main() {
	int n, q;
	while (scanf("%d%d", &n, &q), n) {
		memset(a, 0, sizeof(a));
		rep(i, n) {
			int m; scanf("%d", &m);
			rep(j, m) {
				int d; scanf("%d", &d);
				a[d]++;
			}
		}
		int Max = 0, idx;
		rep(i, 101) {
			if (Max < a[i]) {
				Max = a[i];
				idx = i;
			}
		}
		if (Max < q)puts("0");
		else printf("%d\n", idx);
	}
}

Measured memory_bytes: 3084
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = N * (N - 2) / 2 + N % 2;
    System.out.println(M);
    for (int i = 1; i < N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (j == N - i + 1 - N % 2) continue;
        System.out.printf("%d %d\n", i, j);
      }
    }
  }
}


Measured memory_bytes: 29776
N = int(input())
S = []
count = [0,0,0,0]
for i in range(N):
    temp = input()
    if temp=="AC":
        count[0]+=1
    elif temp=="WA":
        count[1]+=1
    elif temp=="TLE":
        count[2]+=1
    else:
        count[3]+=1
print("AC x "+str(count[0]))
print("WA x "+str(count[1]))
print("TLE x "+str(count[2]))
print("RE x "+str(count[3]))
# N=map(int,input().split())
# S=list(map(int,input().split()))
# B=list(map(int,input().split()))


Measured memory_bytes: 9204
#include<stdio.h>
int main() {
	int cnt = -1, A[201], flag = 1, i,N;
	scanf("%d",&N);
	for (i = 0; i<N; i++) 
		scanf("%d", &A[i]);
	
	while (flag == 1) {
		for (i = 0; i<N; i++) {
			if (A[i] % 2 == 1)flag = 0;
			A[i] = A[i] / 2;
		}
		cnt++;
	}
	
	printf("%d\n", cnt);
	return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int n15 = 1; n15 <= 9; ++n15) {
        for (int n24 = 0; n24 <= 9; ++n24) {
            for (int n3 = 0; n3 <= 9; ++n3) {
                int n = 10000 * n15 + 1000 * n24 + 100 * n3 + 10 * n24 + n15;
                if (A <= n && n <= B) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#define all(c) c.begin(),c.end()
using namespace std;
typedef pair<int,int> P;
int a,b,r;
/*bool check(int x,int y,int s,int t){
	if(){
		return true;
	}
	return false;
}*/
int main(){
	while(scanf("%d%d%d",&a,&b,&r)!=EOF,a||b||r){
		vector<P> ap(a);
		int ans=0;
		for(int i=0;i<a;i++){
			int x,y;
			scanf("%d %d",&x,&y);
			//cin>>x>>y;
			ap[i]=P(y,x);
		}
		sort(all(ap));
		vector<P> pb(b);
		for(int i=0;i<b;i++){
			int x,y;
			//cin>>x>>y;
			scanf("%d %d",&x,&y);
			int x1=x-4*r,x2=x+4*r,y1=y-4*r,y2=y+4*r;
			int ind=lower_bound(all(ap),P(y1,x1))-ap.begin();
			while(ind<ap.size()&&ap[ind].first<=y2){
				if(ap[ind].second>x2){
					ind=lower_bound(all(ap),P(ap[ind].first+1,x1))-ap.begin();
					continue;
				}
				if(/*check(x,y,ap[ind].second,ap[ind].first)*/(x-ap[ind].second)*(x-ap[ind].second)+(y-ap[ind].first)*(y-ap[ind].first)<=16*r*r)
					ans++;
				ind++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
#define INF 100000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n;
ll a[51];
ll tmp[51];

bool C(ll v){
	for(int i=0;i<n;i++){
		tmp[i]=a[i]+v;
	}
	ll cnt=0;
	for(int i=0;i<n;i++){
		ll rest=tmp[i]-(n-1LL);
		if(rest<=0)continue;
		cnt+=(rest+n)/(n+1LL);
		if(cnt>v)return false;
	}
	return true;
}

int main(void){
	scanf("%lld",&n);
	ll sum=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	ll l=0,r=INF*INF;
	ll res=INF*INF*50LL;
	while(l+1<r){
		ll mid=(l+r)/2LL;
		bool flag=false;
		for(ll i=mid*n;i<(mid+1LL)*n;i++){
			if(C(i)){
				flag=true;
				res=min(res,i);
			}
		}
		if(flag)r=mid;
		else l=mid;
	}
	for(ll i=l*n;i<=r*n;i++){
		if(C(i)){
			res=min(res,i);
		}
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _i in range(h)]
visit = [[-1 for _i in range(w)] for _j in range(h)]
r = 0
from collections import deque
for i in range(h):
    for j in range(w):
        if (s[i][j]=="#") and (visit[i][j]<0):
            q = deque([[i, j]])
            black = 1
            white = 0
            visit[i][j] = 1
            while q:
                x, y = q.popleft()
                for n, m in [[1,0], [0, 1], [-1,0], [0,-1]]:
                    if (0<=x+n) and (0<=y+m) and (x+n<h) and (y+m<w):
                        if (visit[x+n][y+m]<0) and (s[x][y]!=s[x+n][y+m]):
                            visit[x+n][y+m]=1
                            if s[x][y] == "#":
                                white += 1
                            else:
                                black += 1
                            q.append([x+n, y+m])
            r += black*white

print(r)

Measured memory_bytes: 50140
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <sstream>
#include <unistd.h>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define rep(n) for(int __x = 0; __x < n; __x++)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (x.at(x.size()-1))

using namespace std;

#define EPS 0.0000000001
#define MOD 1000000007

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

#define MAX_N 200001

Int N;
vector<Int> A;

void buildCum(vector<Int> &src, vector<Int> &sum) {
  sum.push_back(0);
  loop(a,0,src.size()) {
    Int s = last(sum);
    sum.push_back(s + src[a]);
  }
}

Int queryCum(vector<Int> &sum, Int left, Int right) {
  if (left > right) {
    cout << "left is greater than right: " << left << " > " << right << endl;
    return -1;
  }
  if (right >= sum.size()) {
    cout << "right is out of range: " << right << endl;
    return -1;
  }
  return sum.at(right) - sum.at(left);
}

// [2, 4, 3]
void input() {
  Int a;
  cin >> N;
  while (cin >> a) A.push_back(a);
}

void solve() {
  vector<Int> S;
  buildCum(A, S);
  Int min_ = 2020202020;
  loop(s, 1, A.size()) {
    min_ = min(
      min_,
      abs(queryCum(S, 0, s) - queryCum(S, s, A.size()))
    );
  }
  cout << min_ << endl;
}

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



Measured memory_bytes: 4848
number_of_people, required_height = [int(i) for i in input().split()]
heights = [int(i) for i in input().split()]


def counter(heights):
    res = 0
    def inner():
        nonlocal res
        for i in heights:
            if i >= required_height:
                res += 1
        return res
    return inner


solve = counter(heights)

print(solve())


Measured memory_bytes: 11900
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifdef ONLINE_JUDGE
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
pii A[100000];
int d1[100000], d2[100000];
vector<pii> B;

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

    cin >> N;
    rep(i, N) cin >> A[i].fi >> A[i].se;

    sort(A, A+N, [](pii a, pii b) {return a.se < b.se;});

    int ans = 0;
    for_each(A, A+N, [&ans](pii a) {ans = max(ans, a.se-a.fi+1);});

    int cm = -1;
    rep(i, N) {
        if (cm >= A[i].fi) continue;
        cm = A[i].fi;
        B.push_back(A[i]);
    }
    ans += max(0, B[0].se-B.back().fi+1);

    rep(i, sz(B)-1) {
        int v1 = max(0, B[0].se-B[i].fi+1);
        int v2 = max(0, B[i+1].se-B.back().fi+1);
        ans = max(ans, v1+v2);
    }

    cout << ans << endl;
}

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

int compare(const void* a,const void* b){
    return *(int*)b - *(int*)a;
}

int main(void){
    int n,num,max;
    int d[110] = {0};
    scanf("%d",&n);

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

    qsort(d,n,sizeof(int),compare);

    max = d[0];
    num = 1;
    for(int i=1;i<n;i++){
        if(max > d[i] && d[i] != 0){
            num++;
            max = d[i];
        }
    }
    printf("%d\n",num);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	long long a,b,c,k; cin>>a>>b>>c>>k;
	if(k<=a){
		cout<<k;
	}
	else if(k<=a+b){
		cout<<a;
	}
	else if(k<=a+b+c){
		cout<<a - (k-a-b);
	}
	return 0;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
	
	public static long mensa(long Sa, long Sb, long Sc) {
		return Math.max(Math.abs(Sa-Sb), Math.max(Math.abs(Sb-Sc), Math.abs(Sc-Sa)));
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextInt();
		long W = sc.nextInt();
		long ans = Integer.MAX_VALUE;
		long Sa, Sb, Sc;
		for(int i = 1; i < H; i++) {
			Sa = i*W;
			Sb = (H-i)*(W/2);
			Sc = (H-i)*(W-W/2);
			ans = Math.min(ans, mensa(Sa, Sb, Sc));
			Sb = (H-i)/2*W;
			Sc = (H-i-(H-i)/2)*W;
			ans = Math.min(ans, mensa(Sa, Sb, Sc));
		}
		for(int i = 1; i < W; i++) {
			Sa = i*H;
			Sb = (W-i)*(H/2);
			Sc = (W-i)*(H-H/2);
			ans = Math.min(ans, mensa(Sa, Sb, Sc));
			Sb = (W-i)/2*H;
			Sc = (W-i-(W-i)/2)*H;
			ans = Math.min(ans, mensa(Sa, Sb, Sc));
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <string.h>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

template<typename T>
istream& operator >>(istream& is, vector<T>& vec){
    for(T& x: vec) is >>x;
    return is;
}
int main() {
	string S;
	cin>>S;
	int L=int(S.size());
	string ans="AC";
	if(S[0]!='A')
		 ans="WA";
	int cnt=0;
	for(int i=1;i<L;++i){
		if(isupper(S[i])){
			if(i==1 || i==L-1||S[i]!='C') {
				ans = "WA";
			}
			++cnt;
		}
	}
	if(cnt!=1)
		ans = "WA";
	cout<<ans<<endl;
    return 0;
}


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

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

  return 0;
}

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



int main(){
    ll N;cin>>N;
    ll a[100010],ans=0;
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    if(N%2==0){
    rep(i,0,N){
        if(i==N/2)ans+=a[i];
        else if(i>N/2)ans+=2*a[i];
        else if(i==N/2-1)ans-=a[i];
        else ans-=2*a[i];
    }
    }
    else{
        rep(i,0,N){
            if(i>N/2)ans+=2*a[i];
            else if(i==N/2)ans-=a[i];
            else if(i==N/2-1)ans-=a[i];
            else ans-=2*a[i];
        }
        ll MAX=ans;
        ans=0;
        sort(a,a+N,greater<>());
        rep(i,0,N){
            if(i>N/2)ans-=2*a[i];
            else if(i==N/2)ans+=a[i];
            else if(i==N/2-1)ans+=a[i];
            else ans+=2*a[i];
        }
        ans=max(MAX,ans);
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 1024
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    ll n;
    string s[100];
    ll t[100];
    cin>>n;
    ll sum=0;
    rep(i,n){
        cin>>s[i]>>t[i];
        sum+=t[i];
    }
    string x;
    cin>>x;
    ll ans=0;
    rep(i,n){
        if(s[i]==x){
            ans+=t[i];
            break;
        }
        else ans+=t[i];
    }
    cout<<sum-ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int findSmallestNumber(vector<int>& arr, int n) 
{ 
  
    // Initialize both vectors with their initial values 
    vector<int> dp(n, numeric_limits<int>::max() - 5); 
    vector<pair<int, int> > result(n, make_pair(-1, 0)); 
  
    // Sort the vector of digits 
    sort(arr.begin(), arr.end()); 
  
    // Initialize the queue 
    queue<int> q; 
    for (auto i : arr) { 
        if (i != 0) { 
  
            // If modulus value is not present 
            // in the queue 
            if (dp[i % n] > 1e9) { 
  
                // Compute digits modulus given number and 
                // update the queue and vectors 
                q.push(i % n); 
                dp[i % n] = 1; 
                result[i % n] = { -1, i }; 
            } 
        } 
    } 
  
    // While queue is not empty 
    while (!q.empty()) { 
  
        // Remove the first element of the queue 
        int u = q.front(); 
        q.pop(); 
        for (auto i : arr) { 
  
            // Compute new modulus values by using old queue 
            // values and each digit of the set 
            int v = (u * 10 + i) % n; 
  
            // If value is not present in the queue 
            if (dp[u] + 1 < dp[v]) { 
                dp[v] = dp[u] + 1; 
                q.push(v); 
                result[v] = { u, i }; 
            } 
        } 
    } 
  
    // If required condition can't be satisfied 
    if (dp[0] > 1e9) 
        return -1; 
    else { 
  
        // Initialize new vector 
        vector<int> ans; 
        int u = 0; 
        while (u != -1) { 
  
            // Constructing the solution by backtracking 
            ans.push_back(result[u].second); 
            u = result[u].first; 
        } 
  
        return ans.size();
    } 
} 
int main(){
    vector<int> arr = {7};
    int n;
    cin>>n;
    cout<<findSmallestNumber(arr,n)<<"\n";
}

Measured memory_bytes: 19100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#define maxn 100009
using namespace std;
long long fact[maxn];
struct node{
	int x, y;
	int id;
}a[maxn];
struct edge{
	int u, v, w;
	bool operator < (const edge &rhs)const{
		return w < rhs.w;
	}
}e[maxn * 10];
int p[maxn];
int findset(int x){
	return x == p[x] ? x : p[x] = findset(p[x]);
}
void unionset(int x, int y){
	p[findset(x)] = findset(y);
}
bool cmp1(node a, node b){
	return a.x < b.x;
}
bool cmp2(node a, node b){
	return a.y < b.y;
}
long long mst(int n, int tot){
	sort(e, e + tot);
	for(int i = 0; i < n; i++)
		p[i] = i;
	long long ans = 0;
	for(int i = 0; i < tot; i++){
		int u = e[i].u;
		int v = e[i].v;
		if(findset(u) == findset(v))
			continue;
		ans += e[i].w;
		unionset(u ,v);
	}
	return ans;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		scanf("%d%d", &a[i].x, &a[i].y);
		a[i].id = i;
	}
	int tot = 0;
	sort(a, a + n ,cmp1);
	for(int i = 1; i < n; i++){
		e[tot].u = a[i - 1].id;
		e[tot].v = a[i].id;
		e[tot].w = min(abs(a[i].x - a[i - 1].x), abs(a[i].y - a[i - 1].y));
		tot++;
	}
	sort(a, a + n, cmp2);
	for(int i = 1; i < n; i++){
		e[tot].u = a[i - 1].id;
		e[tot].v = a[i].id;
		e[tot].w = min(abs(a[i].x - a[i - 1].x), abs(a[i].y - a[i - 1].y));
		tot++;
	}
	cout << mst(n, tot) << endl;
	return 0;
}

Measured memory_bytes: 7424
#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;
    ll ans=0;
 
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
 
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

const ll M = 1e9+7;
V<ll> dp, prefix;
V<int> a;
int n, K;

ll mod(ll& x)
{
    x = (x % M + M) % M;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> K;
    a.resize(n);
    rep(i,0,n) cin >> a[i];
    dp.assign(K+1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        prefix.assign(K+1, 0);
        for (int k = K; k >= 0; --k) {
            // for (int j = 1; j <= min(a[i], K-k); ++j) {
            //     dp[k+j] += dp[k];
            // }
            // OPTIMIZATION OF CODE ABOVE:
            int left = k+1;
            int right = k+min(a[i],K-k);
            prefix[left] += dp[k];
            mod(prefix[left]);
            if (right+1 <= K) {
                prefix[right+1] -= dp[k];
                mod(prefix[right+1]);
            }
        }
        for (int k = 0; k <= K; ++k) {
            if (k > 0) {
                prefix[k] += prefix[k-1];
                mod(prefix[k]);
            }
            dp[k] += prefix[k];
            mod(dp[k]);
        }
    }
    
    cout << dp[K] << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  int n,k,i,ans=1;
  scanf("%d %d",&n,&k);
  int array[n];
  for(i=0;i<n;i++)
    {
      scanf("%d",&array[i]);
    }
  n -= k;
  if(n >= 0 && n%(k-1) != 0)
    {
      ans += n/(k-1) + 1;
    }
  else if(n >= 0 && n%(k-1) == 0)
    {
      ans += n/(k-1);
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int antennas[5], k;
    int aux = 1;

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

    scanf("%d", &k);

    for (int i = 0; i<5; i++){
        for (int j = 0; j<i; j++){
            if ((antennas[j] - antennas[i]) > k || (antennas[i] - antennas[j]) > k){
                aux =0;
            }
        }
    }

    if (aux){
        printf("Yay!\n");
    } else {
        printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 1620
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N, x;
  	cin >> N >> x;
  	vector<int> a(N);
  	rep(i,N) cin >> a[i];
  
  	ll ans = 0;
  	ll temp;
  	if(a[0] > x){
        ans = a[0]-x;
    	a[0] = x;
    }
  	rep(i,N-1){
     	temp = a[i] + a[i+1] - x;
		if(temp>0){
        	a[i+1] -= temp;
	        ans += temp;
        }
    }
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    int left = (s[0] - '0') * 10 + (s[1] - '0');
    int right = (s[2] - '0') * 10 + (s[3] - '0');

    boolean p1 = left >= 1 && left <= 12;
    boolean p2 = right >= 1 && right <= 12;
    if (p1 && p2) System.out.println("AMBIGUOUS");
    else if (!p1 && p2) System.out.println("YYMM");
    else if (p1 && !p2) System.out.println("MMYY");
    else System.out.println("NA");
  }
}


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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

int main() {
	ll x, a;cin >> x >> a;
	if(x < a) puts("0");
	else puts("10");
}


Measured memory_bytes: 764
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[[t,f,r,l,b,u]]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d,n):
        self.a[n]=[self.a[n][i] for i in self.direction[d]]
n=int(input())
for i in range(n):
    if i==0:
        t, f, r, l, b, u = map(int, input().split())
        dice = Dice(t, f, r, l, b, u)
    else:
        a = list(map(int, input().split()))
        dice.a.append(a)
s='SSSWEEE'
w='YYYY'
ans='Yes'
for u in range(n-1):
    for t in range(u+1,n):
        for j in s:
            for r in w:
                if dice.a[t]==dice.a[u]:
                    ans='No'
                    break
                dice.roll(r,t)
            else:
                dice.roll(j,t)
                continue
            break
        else:
            continue
        break
    else:
        continue
    break
print(ans)


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>

using namespace std;

int main(){
    long long K,A,B;
    cin >> K >> A >> B;

    long long ans=1;
    if(A+2<B){
        ans+=min(K,A-1);
        if(K>A-1){
            ans+=(K-A+1)/2*(B-A);
            ans+=(K-A+1)%2;
        }
    }else{
        ans+=K;
    }

    cout << ans << endl;

}

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

int main(){
    int a, b, c, d;
    cin >> a >> b;
    cout << max(a+b,max(a-b, a*b)) << endl;
    return 0;
}

Measured memory_bytes: 256
def L(cake1,cake2):
	return ((cake1+cake2)**2-abs(cake1-cake2)**2)**0.5

while 1:
	try:
		Raw_cakes=map(int,raw_input().split())
		box=Raw_cakes.pop(0)
		Raw_cakes=sorted(Raw_cakes)[::-1]
		size_min=999
		for j in range(len(Raw_cakes)):
			size=0
			raw_cakes=Raw_cakes[:]
			cakes=[raw_cakes.pop(j)]
			while raw_cakes:
				cos=[L(cakes[-1],i)/(cakes[-1]+i) for i in raw_cakes]
				cakes.append(raw_cakes.pop(cos.index(min(cos))))
			size=cakes[0]+cakes[-1]
			for i in range(len(cakes)-1):
				size+=L(cakes[i],cakes[i+1])
			size_min=min(size,size_min)
		print "OK" if size_min<=box else "NA"
	except:
		break

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int d, n; cin >> d >> n;


    if (d==0) {
        cout << n+(n==100) << endl;
    } else if (d==1) {
        cout << 100*(n+(n==100)) << endl;
    } else {
        cout << 10000*(n+(n==100)) << endl;
    }
}


Measured memory_bytes: 3664
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        if (d == 25) {
            System.out.println("Christmas");
        } else if (d == 24) {
            System.out.println("Christmas Eve");
        } else if (d == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (d == 22) {
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <iomanip>
#define pb push_back
#define mp make_pair
using namespace std;
const int N = 5e6;
const int INF = 1e9;

int main() {
int n;
	set <int> S;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
  	int x;
  	cin >> x;
  	if (S.count(x)) {
  		S.erase(x);
  	} else {
  		S.insert(x);
  	}
  }
  cout << S.size();

  return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;

int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int n; cin>>n;
        int ans=0;
        while(n){
            string x = to_string(n);
            if(x.size()%2) ans++;
            n--;
        }
        cout<<ans;
    }   
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin>>n;
    int dp[n];
    for(int i=0;i<n;i++){
        dp[i]=INT_MAX;
    }
    vector<int>stones;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        stones.push_back(a);
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j:{i+1,i+2}){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(stones[i]-stones[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll x;
    cin>>x;
    if(x>=400 && x<600){
        cout<<8;
    }
    else if(x>=600 && x<800){
        cout<<7;
    }
    else if(x>=800 && x<1000){
        cout<<6;
    }
    else if(x>=1000 && x<1200){
        cout<<5;
    }
    else if(x>=1200 && x<1400){
        cout<<4;
    }
    else if(x>=1400 && x<1600){
        cout<<3;
    }
    else if(x>=1600 && x<1800){
        cout<<2;
    }
    else if(x>=1800 && x<2000){
        cout<<1;
    }
}

Measured memory_bytes: 3632
n, x, y = gets.split.map(&:to_i)
x -= 1
y -= 1

ans = [0] * n

n.times do |j|
  j.times do |i|
    d = j - i
    t = (x - i).abs + 1 + (j - y).abs
    d = t if d > t
    ans[d] += 1
  end
end

puts ans[1,n-1]

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n, ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2, mod) % mod);
	else
		return (x * pow(x, n - 1, mod) % mod);
}ll zero = 0;
signed main() {
	int n, d; std::cin >> n >> d;
	std::vector < std::vector<int >> x(n, std::vector<int>(d));
	rip(i, n) {
		rip(j, d)std::cin >> x[i][j];
	}
	int kotae = 0;
	rip(i, n) {
		for(int j=i+1;j<n;j++) {
			int ans = 0;
			rip(k, d)ans += pow((x[i][k] - x[j][k]), 2);
			if (floor(sqrt(ans)) * floor(sqrt(ans)) == ans)kotae++;
		}
	}
	std::cout << kotae << std::endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::vector<long long> H, std::vector<long long> M, long long K){
    ll start = H[0]*60 + M[0], end = H[1]*60+M[1];
    if (start > end) {
        start += 24*60;
    }
    cout << end - start - K  << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::vector<long long> H(2);
    std::vector<long long> M(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&H[i]);
        scanf("%lld",&M[i]);
    }
    long long K;
    scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3692
A = int(input())
B = int(input())
#A,B= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]

if A+B == 3:
    print('3')
elif A+B ==4:
    print('2')
elif A+B==5:
    print('1')


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

typedef long long ll;

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

    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(i<k) continue;
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

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

	int n;
	cin >> n;

	set<string> S;

	string st1, st2;

	REP(i, n) {
		cin >> st1 >> st2;

		if(st1 == "insert") {
			S.insert(st2);
		}

		else {		// find
			(S.find(st2)  != S.end())?
				cout << "yes" : cout << "no";
			cout << endl;
		}
	}
		return 0;
}

Measured memory_bytes: 27812
#include <stdio.h>

void leap(int a, int b);

int main(void)
{
    int a, b, n;
    n = 0;
    while (1){
	scanf("%d %d", &a, &b);
	if (a == 0 && b == 0) {
	    break;
	}
	if (n != 0) {
	    printf("\n");
	}
	leap(a, b);
	n ++;
    }
    return 0;
}

void leap(int a, int b)
{
    int count = 0;
    for (int i = a; i < b + 1; i ++) {
	if (i % 400 == 0) {
	    printf("%d\n", i);
	    count ++;
	} else if (i % 4 == 0 && i % 100 != 0) {
	    printf("%d\n", i);
	    count ++;
	}
    }
    if (count == 0) {
	printf("NA\n");
    }
}

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));
int n;
string c;

int main()
{
    cin >> n >> c;
    int chk = 0, inv = n - 1, w_cnt = 0, ans = 0;

    rep(i, n)
    {
        if (c[i] == 'W')
        {
            w_cnt++;
        }
    }

    if (w_cnt == n || w_cnt == 0)
    {
        cout << ans << endl;
        return 0;
    }

    while (true)
    {
        loop(i, chk, n)
        {
            if (c[i] == 'W')
            {
                chk = i;
                break;
            }
            else
            {
                chk = n;
            }
        }
        for (int j = inv; j >= 0; j--)
        {
            if (c[j] == 'R')
            {
                inv = j;
                break;
            }
            else
            {
                inv = -1;
            }
        }
        // cout << "lft : " << chk << endl;
        // cout << "rgt : " << inv << endl;
        if (chk > inv)
        {
            break;
        }
        else
        {

            c[chk] = 'R';
            c[inv] = 'W';
            ans++;
        }
    }
    cout << ans << endl;
    // cout << c << endl;

    return 0;
}


Measured memory_bytes: 3740
# coding: utf-8

N = int(input())

ans_cou = 0
ans_num = 1
for i in range(N + 1):
    a = i
    sum = 0
    while a % 2 == 0 and a != 0:
        sum += 1
        a = a // 2
    if sum > ans_cou:
        ans_cou = sum
        ans_num = i

print(ans_num)

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

void replace(std::string& str, int& a, int& b, std::string& p) {
  for (int i = 0; i < p.size(); i++) {
    str[i + a] = p[i];
  }
}

void reverse(std::string& str, int& a, int& b) {
  std::string buf = str.substr(a, b - a + 1);
  for (int i = 0; i < buf.size(); i++) {
    str[i + a] = buf[buf.size() - 1 - i];
  }
}

void print(std::string& str, int& a, int& b) {
  for (int i = a; i <= b; i++) {
    std::cout << str[i];
  }
  std::cout << std::endl;
}

int main() {
  std::string str;
  std::cin >> str;
  int q;
  std::cin >> q;

  while (q-- != 0) {
    std::string command, p;
    int a, b;
    std::cin >> command;
    std::cin >> a >> b;

    if (command == "replace") {
      std::cin >> p;
      replace(str, a, b, p);
    } else if (command == "reverse") {
      reverse(str, a, b);
    } else if (command == "print") {
      print(str, a, b);
    }
  }
  return 0;
}



Measured memory_bytes: 3204
import math

N = 5
F = [int(input()) for i in range(N)]

last = F[0]
for i in F:
    if i % 10 < last % 10 and i % 10 != 0:
        last = i
ans = 0
for i in F:
    ans = ans + math.ceil(i/10)*10

ans = ans - math.ceil(last/10)*10 + last

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	long long X, Y, ans;
	scanf("%lld %lld", &X, &Y);

	ans = 0;
	while (X <= Y) {
		ans++;
		X = 2 * X;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int orig[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  vector<int> a(orig,orig+32);
  int input;
  
  cin>>input;
  cout<<a.at(input-1)<<endl;
  
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, r;
  cin >> n >> r;
  cout << (n >= 10 ? r : r + 100 * (10 - n)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int parent(int i)
{
  return i / 2;
}

int left(int i)
{
  return 2 * i;
}

int right(int i)
{
  return 2 * i + 1;
}

int main()
{
  int H,i,A[255];

  scanf("%d",&H);

  for(i = 1;i <= H;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i = 1;i <= H;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);

      if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
      if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
      if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  int n,i,j,k;
  long long int dp[101000][3],a[101000][3];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      scanf("%lld",&a[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        if(j==k) continue;
        if(dp[i+1][k]<dp[i][j]+a[i][k]) dp[i+1][k]=dp[i][j]+a[i][k];
        else dp[i+1][k]=dp[i+1][k];
      }
    }
  }
  long long int ans=0;
  for(i=0;i<3;i++){
    if(ans<dp[n][i]) ans=dp[n][i];
    else ans=ans;
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool used[100001]={};
vector<int> hen[100001];
int grundy(int a){
  used[a]=true;
  int ans=0;
  for(int i=0;i<hen[a].size();i++){
    if(!used[hen[a][i]])ans^=(1+grundy(hen[a][i]));
  }
  return ans;
}
signed main() {
int n,m;
cin>>n>>m;
int x[n];
for(int i=0;i<n;i++)cin>>x[i];
sort(x,x+n);
int a[m]={},b[m]={},c=1;
for(int i=1;i<n;i++){
  if(x[i-1]!=x[i]){
    a[x[i-1]%m]+=c;
    b[x[i-1]%m]+=c%2;
    c=1;
  }else c++;
}
a[x[n-1]%m]+=c;
b[x[n-1]%m]+=c%2;
int ans=a[0]/2;
if(m%2==0)ans+=a[m/2]/2;
for(int i=1;i<(m+1)/2;i++){
  //cerr<<a[i]<<' '<<a[m-i]<<endl;
  if(a[i]<a[m-i]){
    swap(a[i],a[m-i]);
    swap(b[i],b[m-i]);
  }
  ans+=a[m-i]+(a[i]-max(b[i],a[m-i]))/2;
  
}
cout<<ans<<endl;

return 0;
}


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

long long int Fac(long long int N, long long int MOD);
long long int Exp(long long int N, long long int x, long long int MOD);
long long int comb(long long int n, long long int r, long long int MOD);
const int MOD = 1000000007;

int main()
{
    long long int n, a, b, ans;
    cin >> n >> a >> b;
    ans = (Exp(n, 2, MOD) - comb(n, a, MOD) - comb(n, b, MOD) - 1) % MOD;
    if (ans < 0)
        ans += MOD;
    cout << ans << endl;
}

long long int Fac(long long int N, long long int MOD)
{
    if (N == 0)
    {
        return 1;
    }
    else
    {
        int M = (N * Fac(N - 1, MOD)) % MOD;
        if (M < 0)
            M += MOD;
        return M;
    }
}

long long int Exp(long long int N, long long int x, long long int MOD)
{
    if (N == 0)
    {
        return 1;
    }
    else if (N % 2 == 0)
    {
        long long int A = (Exp(N / 2, x, MOD) * Exp(N / 2, x, MOD)) % MOD;
        if (A < 0)
            A += MOD;
        return A;
    }
    else
    {
        long long int B = (x * Exp(N - 1, x, MOD)) % MOD;
        if (B < 0)
            B += MOD;
        return B;
    }
}

long long int comb(long long int n, long long int r, long long int MOD)
{
    long long int A = Fac(r, MOD);
    long long int B = 1;
    for (int i = 1; i <= r; i++)
    {
        B = (B * (n - i + 1)) % MOD;
        if (B < 0)
            B += MOD;
    }
    return (B * Exp(MOD - 2, A, MOD)) % MOD;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

    set<string> s;
    NREP() {
        string tmp;
        cin >> tmp;
        s.insert(tmp);
    }

    MSG(s.size())

}


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

namespace _1574
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = a[0] - 1;
            int back = a[0];
            for (int i = 1; i < x[1]; i++)
            {
                ret = Math.Max(ret,(a[i] - back) / 2);
                back = a[i];
            }
            Console.WriteLine(Math.Max(ret,x[0] - back));
        }
    }
}


Measured memory_bytes: 12328