akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>

using namespace std;

const double eps=1e-8;
const double g=9.8;
const int maxn=8000;

#define Equ(a,b) ((fabs((a)-(b)))<(eps))
#define Less(a,b) (((a)-(b))<(-(eps)))
#define LessEqu(a,b) (((a)-(b))<(eps))
#define More(a,b) (((a)-(b))>(eps))
#define MoreEqu(a,b) (((a)-(b))>(-(eps)))

int main()
{
    //freopen("12381.txt","r",stdin);

    int n;
    double v,X,Y,x,y,t,vx,vy,t1,t2,x1,x2;
    double L[60],B[60],R[60],T[60];
    while(scanf("%d%lf%lf%lf",&n,&v,&X,&Y)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%lf%lf%lf%lf",&L[i],&B[i],&R[i],&T[i]);
        }
        if(Equ(v,0.0))
        {
            printf("No\n");
            continue;
        }

        bool flag=0;

        for(int k=1;k<maxn;k++)
        {
            vx=v*k/maxn;
            vy=sqrt(v*v-vx*vx);
            t=X/vx;
            y=vy*t-0.5*g*t*t;
            if(Less(y,Y)) continue;

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

                if(MoreEqu(X,L[i]))
                {
                    t=L[i]/vx;
                    y=vy*t-0.5*g*t*t;
                    if(MoreEqu(y,B[i])&&LessEqu(y,T[i]))
                    {
                        flag=0;
                        break;
                    }
                }

                if(MoreEqu(vy*vy,2.0*g*B[i]))
                {
                    t1=(vy-sqrt(vy*vy-2.0*g*B[i]))/g;
                    t2=(vy+sqrt(vy*vy-2.0*g*B[i]))/g;
                    x1=vx*t1;
                    x2=vx*t2;
                    if((MoreEqu(X,x1)&&MoreEqu(x1,L[i])&&LessEqu(x1,R[i]))||(MoreEqu(X,x2)&&MoreEqu(x2,L[i])&&LessEqu(x2,R[i])))
                    {
                        flag=0;
                        break;
                    }
                }

                if(MoreEqu(vy*vy,2.0*g*T[i]))
                {
                    t1=(vy-sqrt(vy*vy-2.0*g*T[i]))/g;
                    t2=(vy+sqrt(vy*vy-2.0*g*T[i]))/g;
                    x1=vx*t1;
                    x2=vx*t2;
                    if((MoreEqu(X,x1)&&MoreEqu(x1,L[i])&&LessEqu(x1,R[i]))||(MoreEqu(X,x2)&&MoreEqu(x2,L[i])&&LessEqu(x2,R[i])))
                    {
                        flag=0;
                        break;
                    }
                }

                flag=1;
            }

            if(n==0) flag=1;

            if(flag==1) break;
        }

        if(flag==1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 0
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,  y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return list(i for i in range(self.n) if self.find(i) == root)

    def roots(self):
        return list(i for i, x in enumerate(self.parents) if x < 0)

    def group_count(self):
        return len(self.roots)

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

adj =  []
N, M = map(int, input().split())
for m in range(M):
    a,b = map(int, input().split())
    adj.append([a-1, b-1])

ans = 0
for i in range(M): # 取り除く辺の番号
    uf = UnionFind(N)
    for j in range(M): # 辺を追加しない（取り除く）
        if i == j:
            continue
        uf.union(*adj[j])
    if len(set(uf.roots())) != 1:
        ans += 1
print(ans)



Measured memory_bytes: 9312
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    string s;
    cin>>s;
    int ans = 0;
    for(int i = 2; i < s.length(); i++){
        if(s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C'){
            ans++;
        }
    }
    cout<<ans<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

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

using namespace std;

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

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	int ans = 0;
	if (a + w < b) {
		ans = b - (a + w);
	} else if (b + w < a) {
		ans = a - (b + w);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a; cin>>a; cout<<a+a*a+a*a*a<<endl;
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
  
total = N
for i in range(N-2):
  A = i+2
  B = N - A
  a_total = 0
  for a in range(len(str(A))):
    a_total += int(str(A)[a])
  b_total = 0
  for b in range(len(str(B))):
    b_total += int(str(B)[b])
  #print(a_total, b_total)
  if a_total + b_total < total:
    total = a_total + b_total
    #print("total", total)

print(total)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int X = max(A, max(B, C));
	int Y = min(A, min(B, C));
	int Z = A + B + C - X - Y;

	cout << 10 * X + Z + Y << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100002]={0},p=0,num=0,sum=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);a[n+1]=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]==a[i-1])num++;
		else{
			if(num%2==1)sum++;
			num=1;
		}
	}
	cout<<sum<<endl;
}

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

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

    ll n,y;
    cin >> n >> y;
    bool fin = false;
    
    for (ll i = 0; i <= n; i++){
        for (ll j = 0; j <= (n-i); j++){
            ll k = n-(i+j);
            if ((10000*i + 5000*j + 1000*k) == y){
                cout << i << " " << j << " " << k << "\n";
                fin = true;
                break;
            }
        }
        if (fin){
            break;
        }
    }

    if (!fin){
        cout << "-1 -1 -1" << "\n";
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path; vl A; vl dp; vl Ans;
void warshall_floyd(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
			}
		}
	}
}
int main() {
	cin >> H >> W;
	path.resize(10);
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			ll c;
			cin >> c;
			path[i].push_back(c);
		}
	}
	warshall_floyd(10);
	vll A(H, vl(W));
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] != -1) ans += path[A[i][j]][1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define pb push_back
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	int t,i,x;
	//cin>>t;
	char ch;
	cin>>ch;
	if(ch-'a'>=0)
	cout<<'a';
	else
	cout<<'A';

}


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

int main(){
	ll n,k,ans=0;
	scanf("%lld %lld",&n,&k);
	for(ll b=k+1;b<=n;++b) ans+=(((b-k)*(n/b))+max(0ll,n+1-(b*(n/b)+k)));
	if(k==0) printf("%lld\n",ans-(n-k));
	else printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] h = new int[100000001];
		boolean flag=false;
      for(int i=0;i<n;i++){
        h[i]=sc.nextInt();
      }
		for(int i=n-1;i>=0;i--) {
			
			if( i!=0 && h[i]<h[i-1] ) {
					h[i-1]--;
			}
		}
		for(int i=0;i<n;i++) {
			if(i!=0 && h[i]<h[i-1]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll mt[] = {2,5,5,4,5,6,3,7,6};
ll dp[11111];
bool ok[11111];

int main(){
	
	ll n, m;cin >> n >> m;
	vector<int> v(m);REP(i, m)cin >> v[i],v[i]--;
	sort(ALL(v),greater<int>());
	REP(i, 11111)dp[i] = -LLINF;
	dp[0] = 0;
	
	REP(i, n) {
		REP(j, m){
			dp[i+mt[v[j]]] = max(dp[i+mt[v[j]]], dp[i] + 1);
		}
	}
	
	ok[n] = true;
	REV(i,n){
		REP(j, m){
			if(ok[i+mt[v[j]]] && dp[i] + 1 == dp[i+mt[v[j]]])ok[i] = true;
		}
	}
	
	int now = 0;
	while(now != n){
		REP(i, m){
			if(ok[now+mt[v[i]]] && dp[now+mt[v[i]]] == dp[now] + 1){
				cout << v[i]+1;
				now += mt[v[i]];
				break;
			}
		}
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")


using namespace std;
using ll = long long;

int main(){
    long long ans = 0;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int M;cin >> M;
    queue<pair<ll, ll>> usi;
    for(int i = 0;i < M;i++){
        ll d,c;cin >> d >> c;
        usi.push({d, c});
    }
    vector<int> v;
    while(!usi.empty()){
        pair<ll, ll> u = usi.front();
        usi.pop();
        if(u.second == 1){
            v.push_back(u.first);
            continue;
        }
        int s = u.first * 2;
        if(s >= 10){
            int w = s / 10 + s % 10;
            
            
            ans += u.second / 2 + u.second / 2;
             if(u.second % 2 == 1){
                v.push_back(u.first);
            }
            usi.push({w, u.second / 2});
        }else{
            ans += u.second/2;
            usi.push({s, u.second/2});
            if(u.second % 2 == 1){
                v.push_back(u.first);
            }
        }
    }
    //for(int i = 0;i < v.size();i++)cout<<v[i]<<" ";
    if(v.size() >= 1e7)abort();
    for(int i = 1;i < v.size();i++){
        if(v[i] + v[i-1] < 10){
            v[i] += v[i-1];
            ans++;
        }else{
            int s = v[i] + v[i-1];
            v[i-1] = s/10;
            v[i] = s%10;
            ans++;
            i--;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 21864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];

int main()
{
    ll a,b,c;

    cin>>a>>b>>c;

    ll sum=0;

    sum=b*c;

    if(sum>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int    N = in.nextInt();
			String S   = in.next();
			int ans = 0;
			int tmp = 0;
			for(int i = 0; i < N; i++) {
				if(S.charAt(i) == 'I') {
					tmp++;
				}else if(S.charAt(i) == 'D') {
					tmp--;
				}
				ans = Math.max(ans, tmp);
			}
			out.println(ans);
		}
	}

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

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

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

		public char nextChar() {
			return next().charAt(0);
		}

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

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

class Main {

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

		int n = 0, x = 0;

		while(true){
			int sum = 0;
			n = scan.nextInt();
			x = scan.nextInt();
			if(n == 0 && x == 0)break;
			
			for(int i = 1; i <= n - 2; i++){
				for(int j = i + 1; j <= n - 1; j++){
					for(int k = j + 1; k <= n; k ++){
						if(i + j + k == x){
							sum++;
						}
					}
				}
			}
			System.out.println(sum);
			
		}
		
	}
}	

Measured memory_bytes: 26364
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値用
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
	// write your code here
        int num = Integer.parseInt(br.readLine().trim());
        int[] arr = inputval();
        int[] counter = new int[num];
        for(int i=0; i<num; i++) counter[i] = 0;
        for(int i=0; i<num; i++){
            while(arr[i]%2 != 1){
                arr[i] /= 2;
                counter[i]++;
            }
        }
        int minnum=Integer.MAX_VALUE;
        for(int i=0; i<num; i++){
            if(counter[i]<minnum) minnum = counter[i];
        }
        System.out.println(minnum);

    }

}



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

int main() {
    int n; cin >> n;
    vector<int> s(14), h(14), c(14), d(14);
    for(int i=0; i<n; i++) {
        char a; int x;
        cin >> a >> x;
        if(a == 'S') s[x]++;
        if(a == 'H') h[x]++;
        if(a == 'C') c[x]++;
        if(a == 'D') d[x]++;
    }
    for(int i=1; i<14; i++) {
        if(!s[i]) cout << "S" << " " << i << endl;
    }
    for(int i=1; i<14; i++) {
        if(!h[i]) cout << "H" << " " << i << endl;
    }
    for(int i=1; i<14; i++) {
        if(!c[i]) cout << "C" << " " << i << endl;
    }
    for(int i=1; i<14; i++) {
        if(!d[i]) cout << "D" << " " << i << endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#include<vector>
 
int main(){
  vector<int> x(3);
  cin >> x.at(0) >> x.at(1) >> x.at(2);
  sort (x.begin(), x.end());
  if (x.at(0) + x.at(1) == x.at(2)){
     cout << "Yes" << endl;
  }
  else {
     cout << "No" << endl;
  }
}

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

using namespace std;

int main(){
    int N, D1[100], D2[100], cnt = 0;
    bool flag = 0;

    cin >> N;
    for(int i = 0; i < N; i ++){
        cin >> D1[i] >> D2[i];
        if(D1[i] == D2[i]){
            cnt ++;
            if(cnt == 3)flag = 1;
        }else{
            cnt = 0;
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
    int b, com = 0;
    for (int i = 2; i >= 0; i--) {
        cin >> b;
        com += (b << i);
    }

    if (com == 6 || com == 1) {
        cout << "Open\n";
    }
    else {
        cout << "Close\n";
    }

    return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
template <typename T>
class BIT {
    int sz;
public:
    std::vector<T> node;
    BIT(int sz): sz(sz+1), node(std::vector<T>(sz+1, 0)) {}
    void add(int idx, T val) {
        ++idx;
        assert(0 < idx && idx < sz);
        while(idx < sz) {
            node[idx] += val;
            idx += idx & -idx;
        }
    }
    T sum(int idx) {
        ++idx;
        assert(0 < idx && idx < sz);
        T res = 0;
        while(idx > 0) {
            res += node[idx];
            idx -= idx & -idx;
        }
        return res;
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll n; cin >> n;
  vll a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  int l = 0, r = 1<<30;
  int geta = n + 1;
  while(r - l > 1) {
    int mid = (l + r) / 2;
    ll num = 0;
    BIT<ll> bit(2*n+10);
    int su = 0;
    bit.add(su + geta, 1);
    for(int i=0;i<n;++i) {
      int val;
      if(a[i] <= mid) val = 1;
      else val = -1;
      su += val;
      num += bit.sum(su + geta - 1);
      bit.add(su + geta, 1);
    }
    if(num > (n + 1) * n / 2 / 2) r = mid;
    else l = mid;
  }
  cout << r << endl;
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 2019;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define itn int
bool dbg = false;
int L, R;
void solve()
{
    int ans = INF;
    int M = min(R, L + 2019);
    FORR(i, L, M)
    {
        FORR(j, i + 1, M)
        {
            int t = (i * j) % MOD;
            t = t % MOD;
            ans = min(ans, t);
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> L >> R;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
int n;
ll a[200005],sum;
ll mod = 1e9+7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 1;i <= n;i++) {
        ans = (ans+a[i]*sum)%mod;
        sum += a[i];
        sum %= mod;
    }
    cout << ans;
}

Measured memory_bytes: 5212
n = int(input())
a = []
xy = []

for i in range(n):
    temp_a = int(input())
    s = [list(map(int, input().split())) for _ in range(temp_a)]
    a.append(temp_a)
    xy.append(s)

ans = 0
for bit in range(1<<n):
    h = [0]*n
    flag = True
    sum = 0

    for i in range(n):
        if (bit>>i) & 1:
            h[i] = 1
            sum += 1
                   
    for i in range(n):
        if (bit>>i) & 1:
            for j in range(a[i]):
                if xy[i][j][1] != h[xy[i][j][0]-1]:
                    flag =False

    if flag:
        ans = max((ans, sum))
    
print(ans)




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

#include <stdlib.h>
#include <stdio.h>
//#include <algorithm>
using namespace std;

int S[1000], top = 0;

void push(int operand) {
	top++;
	S[top] = operand;
}

int pop(void) {
	top--;
	return S[top + 1];
}

int main(void) {
//	while(1) {
	char s[100];
	while(scanf("%s", s) != EOF) {
		int a, b;
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-'){
			a = pop();
			b = pop();
			push(b - a);
		} else if (s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	cout << pop() << endl;
	return 0;
}



Measured memory_bytes: 3232
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A, B, C = Integer.parseInt(sc.next())

    println(solve(A,B,C))
  }

  def solve(A: Int, B: Int, C: Int): String = {
    if ((A > C & C > B) | (A < C & C < B)) {
      "Yes"
    } else {
      "No"
    }
  }
}

Measured memory_bytes: 25416
/**
 * JJOOII
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			List<Character> cs = new ArrayList<Character>();
			List<Integer> ls = new ArrayList<Integer>();
			int last = 0;

			//parse
			cs.add('X');
			ls.add(1);
			for (int i = 0; i < line.length(); i++) {
				if (cs.get(last) == line.charAt(i)) {
					ls.set(last, ls.get(last) + 1);
				} else {
					cs.add(line.charAt(i));
					ls.add(1);
					last++;
				}
			}
			cs.add('X');
			ls.add(1);

			//solve
			int k = 0;
			for (int i = 1; i < cs.size() - 1; i++) {
				if (cs.get(i) == 'O') {
					int l = ls.get(i);
					if (cs.get(i - 1) == 'J' && cs.get(i + 1) == 'I'
							&& ls.get(i - 1) >= l && ls.get(i + 1) >= l) {
						k = Math.max(k, l);
					}
				}
			}
			System.out.println(k);
		}
	}
}

Measured memory_bytes: 52000
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
#include <string>
#include "math.h"

using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int count = 0;
  for (size_t i = 0; i < 16; i++) {
    if (s[i] != t[i]) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n, x;
  cin >> n >> x;
  vec1 l(n);
  for(int i = 0; i < n; i++) {
    cin >> l.at(i);
  }
  
  int tmp = 0; 
  int ans = 1;
  for(int i = 0; i < n; i++) {
    if(tmp + l.at(i) > x) {
      cout << ans << endl;
      return 0;
    } else {
      tmp = tmp + l.at(i);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int P = 1e9 + 7;
const int maxn = 1e6 + 5;
int n, d, h;
ll dp[maxn], sum[maxn];
ll power(ll x, ll t) {
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}
int main() {
	cin >> n >> h >> d;
	ll fac = 1, s = 0;
	for(int i = 1; i <= n; ++i) {
		fac = fac * i % P;
		s = (s + fac) % P;
	}
	dp[0] = sum[0] = 1;
	for(int i = 1; i <= h; ++i) {
		dp[i] = (sum[i - 1] - (i - d - 1 >= 0 ? sum[i - d - 1] : 0) + P) % P;
		dp[i] = dp[i] * s % P;
		sum[i] = (sum[i - 1] + dp[i]) % P;
	}
	dp[h] = dp[h] * power(s, P - 2) % P * fac % P;
	cout << dp[h] << '\n';
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<ll,ll> mp=prime_factor(n);
    ll ans=0;
    for(auto [x,y]:mp){
        for(ll i=100;i>=0;i--){
            if(i*(i+1)/2<=y){
                ans+=i;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
N = int(input())
a = list(map(int,input().split()))
c = 0
b = []

while True:
    for i in range(N):
        b += [a[i]%2]
    if b.count(0)== N:
        a = list(map(lambda x:x//2,a))
        c += 1
        b = []
    else:
        break
print(str(c))

Measured memory_bytes: 9108
N, M = map(int, input().split())
a = []
dp = [0]*(N+1)
br = [False]*(N+1)
for i in range(M):
  br[int(input())] = True
  
dp[0] = 1
if br[0] is not True:
  dp[1] = 1

for i in range(2, N+1):
  if br[i-1] is not True:
    dp[i] += dp[i-1]
  if br[i-2] is not True:
    dp[i] += dp[i-2]    
  dp[i] %= 1000000007
    
print(dp[N])

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

int main(){
    ll N;
    cin >> N;
    ll sum = 0;
    vector<ll> A(N+1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    A[N] = A[0];
    if (sum % (N*(N+1)/2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll op = sum / (N*(N+1)/2);
    for (int i = 1; i <= N; i++) {
        if ((A[i-1]-A[i]+op) % N != 0 || A[i] < op) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=1e3+50;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;

ll  kaka;
  ll n, m  ;
  ll a[maxn];
ll mn=1e15;
ll b[maxn][maxn];
ll c[maxn];
ll d[maxn];
void dosth(ll id)
{
  if (id==n)
  {
      ll ans= 0;
      for (int i=1;i<=n-1;i++)
      {
          if (a[i]) ans++;
      }
     // if (ans==0) cout <<"cooooo"<<endl;
     vector<ll> sth;
     sth.pb(0);
     for (int i=1;i<=n;i++)
     {
         c[i]=0;
         d[i]=0;
     }
     for (int i=1;i<=n-1;i++)
     {
           if (a[i])
         {
             sth.pb(i);
            }
     }
     sth.pb( n);
      for (int j=1;j<=m;j++)
      {
          for (int i=0;i<sth.size()-1;i++)
          {
              ll bg=sth[i]+1;
              ll nxt=sth[i+1];
              ll t=0;
              for (int k=bg;k<=nxt;k++)
              {
                  if (b[k][j]) t++;
              }
              if (t>kaka) return ;

              c[i+1]+=t;
              d[i+1]=t;
          }
          bool x=true;
          for (int i=1;i<sth.size();i++)
          {
              if (c[i]>kaka)
              {
                  x=false ;
              }
          }
          if (!x)
          {
              ans++;
              for (int i=1;i<sth.size();i++)
              {
               c[i]=d[i];

              }
          }
      }
      mn=min(mn,ans);
  }
  else
  {
    for (int i=0;i<=1;i++)
    {
        a[id]=i;
        dosth(id+1);
    }
  }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //freopen("FRAC.INP", "r", stdin);
    // freopen("WALKING.OUT", "w", stdout);
    a[0]=0;

    cin>>n>>m>>kaka;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            char x;
            cin>>x;
            b[i][j]=x-'0';
           //  cin>>b[i][j];
        }
    }
    dosth(1);
    cout <<mn;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []float64) (int, float64) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	ps := make([]float64, n, n)
	psum := make([]float64, n, n)
	for i := 0; i < n; i++ {
		p := (nextFloat64() + 1.0) / 2
		ps[i] = p
		if i < k {
			if i == 0 {
				psum[i] = p
				continue
			}
			psum[i] += psum[i-1] + p
		} else {
			psum[i] += psum[i-1] - ps[i-k] + p
		}
	}
	_, ans := max(psum)
	fmt.Printf("%f\n", ans)
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int m_calc(int a, int b)
{
    int max = (a > b) ? a : b;
    int min = (a < b) ? a : b;
    return max * 10 + min;
}
int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;
    int min = (a < b) ? a : b;
    min = (min < c) ? min : c;
    if (min == a)
        ans = m_calc(b, c) + a;
    else if (min == b)
        ans = m_calc(a, c) + b;
    else if (min == c)
        ans = m_calc(a, b) + c;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int abcd = sc.nextInt();
    int a = abcd/1000;
    abcd -= a*1000;
    int b = abcd/100;
    abcd -= b*100;
    int c = abcd/10;
    int d = abcd - c*10;
    int i=0,j=0,k=0;
    ui:for(i = 0;i<2;i++){
      for(j = 0;j<2;j++){
        for(k = 0;k<2;k++){
          int bl = b;
          if(i==1){
            bl*=-1;
          }
          int cl = c;
          if(j==1){
            cl*=-1;
          }
          int dl = d;
          if(k==1){
            dl*=-1;
          }
          if(a+bl+cl+dl==7){
            break ui;
          }
        }
      }
    }
    System.out.print(a);
    if(i==0){
      System.out.print("+");
    }else{
      System.out.print("-");
    }
    System.out.print(b);
    if(j==0){
      System.out.print("+");
    }else{
      System.out.print("-");
    }
    System.out.print(c);
    if(k==0){
      System.out.print("+");
    }else{
      System.out.print("-");
    }
    System.out.println(d+"=7");
  }
}


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


int min(int a, int b) {
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    int step1,step2;
    for (int i = 2; i < n; ++i) {
        step1 = abs(h[i]-h[i-1]);
        step2 = abs(h[i]-h[i-2]);
        dp[i] = min(dp[i-1]+step1,dp[i-2]+step2);
    }

    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 896
#include<stdio.h>
int isPrime(int );

int main(){
    int n,i,judge;
    int count=0;
    int num[10000];
    scanf("%d",&n);

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

       judge = isPrime(num[i]);

    if(judge==1){
        count++;
    }
    }
    printf("%d\n",count);
    return 0;
}

int isPrime(num){
    int i;
    
    if(num == 2)return 1;
    if(num<2 || num%2==0)return 0;
    for(i=3;i*i<=num;i+=2)
      if(num % i == 0)return 0;  
      return 1;
}


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

int main(){
    int i,p,wans=0,kans=0;
    vector<int>W(10),K(10);
    for(i=0;i<10;i++)cin>>W[i];
    for(i=0;i<10;i++)cin>>K[i];
    sort(W.begin(),W.end());
    sort(K.begin(),K.end());
    wans=W[9]+W[8]+W[7];
    kans=K[9]+K[8]+K[7];
    printf("%d %d\n",wans,kans);
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;

  if((((h2-h1)*60+(m2-m1)))-k<=0)out(0);
  else out((((h2-h1)*60+(m2-m1)))-k);

  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


int kind[10];
int pr[100];
main(){
	int n;
	
	while(cin>>n){
		if(n==0)break;
		
		memset(kind,0,sizeof(kind));
		
		for(int i=0;i<n;i++){
			int k;
			cin>>k;
			++kind[k];
		}
		
		for(int i=0;i<10;i++){
			if(kind[i]){
				for(int j=0;j<kind[i];j++)printf("*");
			}else{
				printf("-");
			}
			puts("");
		}
	}
	return 0;
}

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

void display(int *A, int n, int m, int *G, int cnt) {
	int i;
	printf("%d\n", m);
	for (i = 0; i < m - 1; i++) {
		printf("%d ", G[i]);
	}
	printf("%d\n", G[m - 1]);
	printf("%d\n", cnt);
	for (i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}
}

int insertionSort(int *A, int n, int g) {
	int i, j, v;
	int cnt = 0;
	for (i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
	return cnt;
}

void shellSort(int *A, int n) {
	int cnt, m, i;
	int *G;

	cnt = 0;
	m = n / 2;
	if (m < 1) m = 1;
	if (m > 100) m = 100;
	G = (int *)malloc(sizeof(int)*m);
	G[0] = n - 1;
	for (i = 1; i < m - 1; i++) {
		G[i] = G[i - 1] / 2;
	}
	G[m - 1] = 1;

	for (i = 0; i < m; i++) {
		cnt += insertionSort(A, n, G[i]);
	}

	display(A, n, m, G, cnt);
}

int main() {
	int n;
	int *A;
	int i;

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

	shellSort(A, n);

	return 0;
}


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
string s;
bool check(string a,char c,int len)
{
	for(int i=0;i<len;i++)
		if(a[i]!=c)
			return false;
	return true;
}
int main()
{
	while(cin>>s)
	{
		int ans=s.length();
		for(int i=0;s[i];i++)
		{
			int cnt=0,len=s.length();
			char c=s[i];
			string a=s,b=s;
			while(true)
			{
				if(check(a,c,len))
					break;
				cnt++;
				for(int k=0;k<len;k++)
				{
					if(a[k+1]==c)
						a[k]=c;
				}
				len--;		
			}
			ans=min(ans,cnt);
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
local l = io.read("*l")
local beforeNum = nil
local count,result = 0,0
for _ in io.read("*l"):gmatch("%d+") do
  if beforeNum == nil then
    beforeNum = tonumber(_)
  elseif beforeNum >= tonumber(_) then
    count = count + 1
  elseif count > result then
    result = count
    count = 0
  else
    count = 0
  end
  beforeNum = tonumber(_)
end
if count > result then
  result = count
end
print(result)

Measured memory_bytes: 4144
#include <bits/stdc++.h>
#include <algorithm>
#define MAX 100005
int dp[MAX];
using namespace std;
int main() {

  int n;
  int h[MAX];

  cin >> n;

  for ( int i = 1; i <= n; i++ ) cin >> h[i];

  dp[0] = 1000000000;

  for ( int i = 2; i <= n; i++ ) {
    dp[i] = min(dp[i-2] + abs(h[i-2]-h[i]),dp[i-1] + abs(h[i-1]-h[i]));
  }

  cout << dp[n] << endl;

  return 0;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    itn a, b ,c;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);

    cout << a << ' '  << b << ' ' << c << endl;
    return 0;
}

Measured memory_bytes: 256
//  zukonit14 - Kunal Raut

#include<bits/stdc++.h>
using namespace std;
#define ll                  long long
#define int                 long long
#define ld                  long double
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define mod                 1000000007
#define pi                  3.1415926535
#define MAXN                2*100000+10
#define MAX2N               1*1000+10
const   ll INF              = 1e18;
#define all(v)              v.begin(), v.end()
#define allr(v)             v.rbegin(), v.rend()
#define ms(s, n)            memset(s, n, sizeof(s))
#define prec(n)             fixed<<setprecision(n)
#define forci(p,n)          for(ll i=p;i<(ll)n;i++)
#define forcj(p,n)          for(ll j=p;j<(ll)n;j++)
#define bolt                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a)             __builtin_popcountll(a)
#define djokovic            freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
clock_t time_p              = clock();
void rtime()                {time_p = clock() - time_p; cout << "\nTime Taken : " << fixed << (float)(time_p) / CLOCKS_PER_SEC << "s\n";}
ll gcd(ll a, ll b)          {if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b)          {return (a / gcd(a, b) * b);}
ll expo(ll x, ll y)         {ll res = 1; x = x % mod; while (y > 0) {if (y & 1)res = (1ll * res * x) % mod; y = y >> 1; x = (1ll * x * x) % mod;} return res % mod;}
ll inv_mod(ll q, ll m = mod)   {return (expo(q, m - 2) % m);}
ll ncr(ll n, ll r)          {ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b)          {return (a > b) ? a : b;}
bool prime(ll n)            {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, k, x, c, q, a[MAXN], dp[MAXN], best;
void solve()
{
    cin >> n;
    for (ll i = 1; i <= n; i++)  cin >> a[i];
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (ll i = 3; i <= n; i++)
    {
        dp[i] += min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << dp[n];
}
signed main()
{
    bolt;
#ifndef ONLINE_JUDGE
    djokovic;
#endif
    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    //rtime();
}




Measured memory_bytes: 5124
n = int(input())

def dfs(s, cn):
    if len(s) == n:
        print(s)
    else:
        for i in range(0, cn + 1):
            c = chr(ord('a') + i)
            if i == cn: dfs(s+c, cn+1)
            else: dfs(s+c, cn)

dfs('', 0)

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    unordered_set<int> s;
    int n;
    cin>>n;
    int p;
    while(n-->0)
    {
        cin>>p;
        if(s.find(p)==s.end()) s.insert(p);
        else s.erase(p);
    }
    cout<<s.size();
    return 0;
}


Measured memory_bytes: 4388
import sys
import random
from copy import copy
from math import floor, e

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def write_output(out):
    with open("my_sample3.out", mode="w") as f:
        for x in out:
            f.write(str(x + 1) + "\n")


def main():
    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]

    sat_cur = 0
    last = [1] * 26
    out = [-1] * d

    for day in range(d):
        estimate = [0.0] * 26
        for cid in range(26):
            if s[day][cid] > 16000:
                estimate[cid] = s[day][cid] / 100 + last[cid] * c[cid]
        cur = estimate.index(max(estimate))
        out[day] = cur
        sat_cur += s[day][cur]
        last[cur] = 1
        for cid in range(26):
            if cid != cur:
                sat_cur -= last[cid] * c[cid]
                last[cid] += 1

    out_best = copy(out)
    sat_best = sat_cur
    num_of_try = 12000
    for i in range(1, num_of_try + 1):
        change_num = (num_of_try - i) // 3333
        out_temp = copy(out_best)
        for j in range(change_num):
            # c_day = int(random.triangular(0, 365 - 0.01, 50))
            swap = random.sample(range(d), k=2)
            out_temp[swap[0]], out_temp[swap[1]] = out_temp[swap[1]], out_temp[swap[0]]

        last = [1] * 26
        sat_temp = 0
        for day in range(d):
            cur = out_temp[day]
            sat_temp += s[day][cur]
            last[cur] = 1
            for cid in range(26):
                if cid != cur:
                    sat_temp -= last[cid] * c[cid]
                    last[cid] += 1
        if sat_temp > sat_best:
            #print(i, ":", sat_temp)
            out_best = out_temp
            sat_best = sat_temp

    for x in out_best:
        print(x + 1)

    #write_output(out_best)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81796
def main():
    N, Q = map( int, input().split())
    A = list( map( int, input().split()))
    bit = [0]*N
    def add(bit,a,w):#リストに値を追加する関数
        x = a
        while x <= N:
            bit[x-1] += w
            x += x&(-x)

    def sums(bit,a):#k番目までの和
        x = a
        S = 0
        while x > 0:
            S += bit[x-1]
            x -= x&(-x)
        return S

    for i, a in enumerate(A):
        add(bit,i+1,a)
    Q = [ tuple( map( int, input().split())) for _ in range(Q)]
    ANS = []
    for q,p,x in Q:
        if q == 0:
            add(bit,p+1,x)
        else:
            ANS.append( sums(bit,x)-sums(bit,p))
    print( "\n".join( map( str, ANS)))
if __name__ == '__main__':
    main()


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


int main()
{ 
  string str ;
  cin >> str ;
 string tmp = "";
 for(int i = 0 ; i < str.size() ; i++)
 {
  if(i%2 == 0) 
  {
    tmp += str[i] ;
  }
 }
 cout << tmp << endl;
return 0 ;
}

Measured memory_bytes: 512