akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
	int i;cin>>i;
	if(i>=400 and i<=599) cout<<"8";
	else if(i>599 and i<=799) cout<<"7";
	else if(i>799 and i<=999) cout<<"6";
	else if(i>999 and i<=1199) cout<<"5";
	else if(i>1199 and i<=1399) cout<<"4";
	else if(i>1399 and i<=1599) cout<<3;
	else if(i>1599 and i<=1799) cout<<2;
	else if(i>1799 and i<=1999) cout<<1;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long e = sc.nextLong();

        long aBottoleNeck = (long)Math.ceil((double)n/(double)a);
        long bBottoleNeck = (long)Math.ceil((double)n/(double)b);
        long cBottoleNeck = (long)Math.ceil((double)n/(double)c);
        long dBottoleNeck = (long)Math.ceil((double)n/(double)d);
        long eBottoleNeck = (long)Math.ceil((double)n/(double)e);

        long maxBottoleNeck = Math.max(aBottoleNeck, Math.max(bBottoleNeck, Math.max(cBottoleNeck, Math.max(dBottoleNeck, eBottoleNeck))));
        System.out.println(maxBottoleNeck + 4);
    }
}

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

const int N=1e6+5;
int n,k,tl;
pair<int,int> lis[N];
char s[N];

void init()
{
	scanf("%d%d",&n,&k);int i;
	scanf("%s",s+1);lis[++tl]=make_pair(0,0);
	for(i=1;i<=n;++i)
	{
		if(s[i]=='1') continue;
		int r=i;
		while(s[r]==s[i]&&r<=n) ++r;--r;
		lis[++tl]=make_pair(i,r);
		i=r;
	}
	lis[++tl]=make_pair(n+1,n+1);
}

void work()
{
	if(tl-2<=k)
	{
		printf("%d\n",n);
		exit(0);
	}
	int i,ans=0;
	for(i=2;i<=tl-k;++i) ans=max(ans,lis[i+k].first-lis[i-1].second-1);
	printf("%d\n",ans);
}

int main()
{
	init();work();
	return 0;
}

Measured memory_bytes: 768
require 'matrix'


n, m,l= gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb


mc.row_vectors.each {|row| puts row.to_a.join("\s")}


Measured memory_bytes: 9184
from collections import deque
S = deque(input())
N = int(input())
Q = []
gyaku = 0
for i in range(N):
    q = input()
    if len(q)>1:
        q = q.split()
    else:
        q = [q]
    Q.append(q)
#print(Q)
for i in range(N):
    if len(Q[i])==1:
        gyaku +=1
        #print(S)
    if len(Q[i])>1:
        if Q[i][1]=='1'and gyaku%2==0:
            S.appendleft(Q[i][2])
        elif Q[i][1]=='1'and gyaku%2==1:
            S.append(Q[i][2])
            #print(S)
        elif Q[i][1]=='2'and gyaku%2==0:
            S.append(Q[i][2])
        else:
            S.appendleft(Q[i][2])
            #print(S)
if gyaku%2==0:
    #print(S)
    print(''.join(S))
else:
    S = list(S)
    print(''.join(S[::-1]))

Measured memory_bytes: 119700
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = [rr() for _ in range(n)]
a = 0
b = 0
c = 0
d = 0
for i in li:
  if i == 'AC':
    a += 1
  elif i == 'TLE':
    b += 1
  elif i == 'RE':
    c += 1
  else:
    d += 1
print(f'AC x {a}')
print(f'WA x {d}')
print(f'TLE x {b}')
print(f'RE x {c}')







Measured memory_bytes: 34196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    string s;
    cin >> s;
    cout << s;
    if (s[s.size() - 1] == 's')cout << "es" << endl;
    else cout << "s" << endl;
}

Measured memory_bytes: 3632
/* 162-D.cpp
 *     Created on : Apr 12, 2020 
 *     Time       : 6:42:31 PM
 *     Author     : null_ptr
 */
#include<iostream>
#include<cstring>
#include<vector>

using namespace std;

struct point{
	int r,g,b;
};
int main()
{
	int n;
	string str;
	cin>>n>>str;

	vector<point> nums(n+1);

	for(int i=n-1;i>=0;--i)
	{
		nums[i].r+=nums[i+1].r;
		nums[i].g+=nums[i+1].g;
		nums[i].b+=nums[i+1].b;

		nums[i].r+=(str[i]=='R'?1:0);
		nums[i].g+=(str[i]=='G'?1:0);
		nums[i].b+=(str[i]=='B'?1:0);
	}
	long long ans=0;
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
		{
			if(str[i]==str[j])continue;

			int k=j+(j-i);

			char ch=('R'+'G'+'B')-(str[i]+str[j]);

			if(ch=='R')ans+=(nums[j].r);
			else if(ch=='G')ans+=(nums[j].g);
			else ans+=(nums[j].b);

			if(k<n && str[i]!=str[k] && str[j]!=str[k])
			{
				ans--;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3624
from collections import deque

def f(k,edge,n):
    root = [[] for _ in range(n)]
    for i in range(n-1):
        a,b,c = edge[i][0],edge[i][1],edge[i][2]
        root[a-1].append([b-1,c])
        root[b-1].append([a-1,c])
    
    que = deque()
    for l in root[k]:
        que.append(l)
    
    dist = [float("inf")]*n
    dist[k] = 0
    visited = [False]*n
    que = deque([k])

    while que:
        pos = que.popleft()
        if not visited[pos]:
            visited[pos] = True
        for x,y in root[pos]:
            if not visited[x]:
                dist[x] = dist[pos] + y
                visited[x] = True
                que.append(x)
    return dist

n = int(input())
edge = [list(map(int,input().split())) for _ in range(n-1)]

q,k = map(int,input().split())

ans = []
d = f(k-1,edge,n)
for i in range(q):
    x,y = map(int,input().split())
    ans.append(d[x-1] + d[y-1])

print(*ans , sep = "\n")


Measured memory_bytes: 69912
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string S;
int res, ans;

int main()
{
	in >> S;

	char now = 'J', next = 'O';
	int J = 0, O = 0, I = 0;
	for (auto c : S)
	{
		if (c == next)
		{
			if ((next == 'O' && J > 0)
				|| (next == 'I' && O > 0)
				|| (next == 'J' && I > 0))
			{
				now = next;
				if (next == 'J')
				{
					if (std::min(J, std::min(O, I)) == O) { ans = std::max(ans, O); }
					J = O = I = 0;
					next = 'O';
				}
				else if (next == 'O') { next = 'I'; }
				else { next = 'J'; }
			}
			else
			{
				J = O = I = 0;
				now = 'J';
				next = 'O';
			}
		}
		if (c != now&&c != next)
		{
			if (now == 'I')
			{
				if (std::min(J, std::min(O, I)) == O) { ans = std::max(ans, O); }
			}
			J = O = I = 0;
			now = 'J';
			next = 'O';
		}
		if (c == now)
		{
			if (now == 'J') { ++J; }
			if (now == 'O') { ++O; }
			if (now == 'I') { ++I; }
		}
	}
	if (next == 'J' && I > 0)
	{
		if (std::min(J, std::min(O, I)) == O) { ans = std::max(ans, O); }
	}

	out << ans << std::endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int L, R, D;
    cin >> L >> R >> D;

    int ans = 0;
    for(int i = L; i <= R; ++i) {
        if(i % D == 0) {
            ans++;
        }
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	int k;
	cin >> k;
	int x;
	cin >> x;
	ff(i, x - k + 1, x + k) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)




int main() {
	string s;
	int k;
	cin >> k;
	cin >> s;
	if (s.size() <= k) cout << s << endl;
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M, Nl, Nh;
	cin >> M >> Nl >> Nh;
	while (M != 0) {
		vi P(M);
		REP(i, M) {
			cin >> P[i];
		}
		so(P); rev(P);
		int ans = 0;
		int cur = -1;
		FOR(i, Nl, Nh + 1) {//i人合格
			// 高　0,1,2, ... i-1|i,i+1, ...　低
			if (P[i - 1] - P[i] >= cur) {
				cur = P[i - 1] - P[i];
				ans = i;
			}
		}
		cout << ans << endl;
		cin >> M >> Nl >> Nh;
	}
	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+100;
const int inf=0x3f3f3f;

vector<string> vc;
map<string,int>mp;
int goal[N];
int main(){
    int n;
    scanf("%d",&n);
    string s;
    for(int i=0;i<n;i++)
        cin>>s,vc.push_back(s),mp[s]++;
    sort(vc.begin(),vc.end());
    vc.erase(unique(vc.begin(),vc.end()),vc.end());
    int maxe=-1;
    for(int i=0;i<vc.size();i++)
        goal[i]=mp[vc[i]],maxe=max(goal[i],maxe);
    for(int i=0;i<vc.size();i++)
        if(maxe==goal[i])
        cout<<vc[i]<<endl;
    return 0;
}
/*
87
13
4
*/


Measured memory_bytes: 27504
#include<bits/stdc++.h>
using namespace std;
int a[105],sum[105];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a[i]);
	}
	int ans=0;
	sort(a+1,a+1+n);
	for(int i=n;i>=n+1-k;--i) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


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

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	
	if (s.size() < 26) {
		bool used[26] = {};
		for (int i = 0; i < s.size(); i++) {
			used[s[i] - 'a'] = true;
		}

		char ans;
		bool exist = false;
		for (int i = 0; i < 26; i++) {
			if (!used[i]) {
				ans = (char)('a' + i);
				exist = true;
				break;
			}
		}

		if (!exist) {
			cout << -1 << endl;
			return 0;
		}

		cout << s + ans << endl;
		return 0;
	}
	else {
		for (int i = 25; i >= 0; i--) {
			for (int j = 25; j > i; j--) {
				if (s[i] < s[j]) {
					for (int k = 0; k < i; k++) {
						cout << s[k];
					}
					cout << s[j] << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    yakusuu = make_divisors(N)
    
    ans = INF
    for i,val in enumerate(yakusuu):
        for j,vol in enumerate(yakusuu):
            if val*vol == N:
                tmp = max(val,vol)
                tmptmp = len(str(tmp))
                
                if ans > tmptmp:
                    ans = tmptmp
                    
    print(ans)
    
    
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    # divisors.sort()
    return divisors
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 42972
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>P(N);
	rep(i, N) {
		cin >> P[i];
	}
	int cnt = 0;
	int ans = 0;
	rep(i, N) {
		if (P[i] == i + 1) {
			cnt++;
		}
		else {
			ans += (cnt / 2 + cnt % 2);
			cnt = 0;
		}
	}
	ans += (cnt / 2 + cnt % 2);
	cout << ans << endl;
}

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

using namespace std;

int main() {
  int x;
  cin >> x;
  
  vector<int> pow5(1, 0);
  int i = 1;
  for ( ; ; ) {
    int tmp = i * i * i * i * i;
    if (x < tmp - pow5[i - 1]) break;
    pow5.push_back(tmp);
    for (int j = i - 1; -i <= j; --j) {
      int sgn = (j > 0) - (0 > j);
      int dif = tmp - sgn * pow5[sgn * j];
      if (x <= dif) {
        if (x == dif) {
          cout << i << ' ' << j << endl;
          return 0;
        }
        break;
      }
    }
    ++i;
  }
  return 0;
}


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

#define FOR(i, x, n) for(int i = x; i < n; i++)

using namespace std;
typedef long long int ll;


long long int binPow(long long int a, long long int b, long long int m){
    a = a%m;
    long long int res = 1;
    while(b){
        if(b&1)res = res*a%m;
        a = a*a;
    }
    return res;
}

long long int binPow(long long int a, long long int b){
    a = a;
    long long int res = 1;
    while(b){
        if(b&1)res = res*a;
        a = a*a;
    }
    return res;
}

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

int main(){
    int n;
    cin >> n;
    int c = 0;
    FOR(i, 1, n+1){
        if(i&1)c++;
    }
    cout << c*1.0/n;
}


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

int main() {
  int a,w,x,y,z;
  cin >> a;
  
  w = a/1000;
  x = (a/100)%10;
  y = (a/10)%10;
  z = a%10;
  
  if(x==y && y==z){
    cout << "Yes" << endl;
  }
  else if(w==x && x==y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = [input() for _ in [0] * N]

    cnt = Counter(S).most_common()
    j = cnt[0][1]
    ans = []
    for v, i in cnt:
        if i == j:
            ans.append(v)
    ans.sort()
    print(*ans, sep='\n')


main()


Measured memory_bytes: 45016
#include <stdio.h>

int main(void){
	while(1){
		//input
		int b;
		scanf("%d", &b);
		//scanf("%d", &b) // AOJではscanf_s()が使えないことに注意
		if(!b) break;

		//processing
		//できるだけ多くのフロアを借りたい -> 安い部屋から順。
		int high=1; //借りるフロアの中での最上階
		int low=1;  //借りるフロアの中での最下層
		int sum=1;  //lowからhighまでの和
		while(1){
			if(sum == b) break; //予算通りになる借り方を発見。ループを抜け出力へ
			else if(sum < b){
				//予算に余裕がありそうなので、さらに上の部屋を借りてみる。
				high++;
				sum += high;
			} else{
				//予算をオーバーしているので、最下層を諦める。
				sum -= low;
				low++;
			}
		}

		//output
		int ans1 = low; //借りるフロアの中での最下層
		int ans2 = high - low + 1; //借りるフロアの総数
		printf("%d %d\n", ans1, ans2);
	}
	return 0;
}


Measured memory_bytes: 2104
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,k,s; cin>>n>>k>>s; 
    for (int i=0;i<k;i++) cout << s << " ";
    s =  ((s==1000000000)? 1 : s+1) ; 
    for ( ; k<n;k++) cout << s << " ";
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using Cost = int;

const Cost INF = 2e9;
using P = pair<Cost, int>;

struct Edge {
	int from, to;
	Cost cost;
	Edge() {}
	Edge(int f, int t, Cost c) : from(f), to(t), cost(c) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

vector<Cost> Dijkstra(const Graph& G, int s) {
	int n = G.size();
	vector<Cost> d(n, INF);
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.emplace(0, s);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		if (d[p.second] != INF) continue;
		d[p.second] = p.first;
		for (const auto& e : G[p.second]) if (d[e.to] > p.first + e.cost) {
			pq.emplace(p.first + e.cost, e.to);
		}
	}
	return d;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int V, E, r;
	cin >> V >> E >> r;
	Graph G(V);
	for (int i = 0, s, t, d; i < E; i++) {
		cin >> s >> t >> d;
		G[s].emplace_back(s, t, d);
	}
	auto res = Dijkstra(G, r);
	for (auto ans : res) {
		if (ans == INF) puts("INF");
		else printf("%d\n", (int)ans);
	}
	return 0;
}

Measured memory_bytes: 16328
def nCr(n, r): 
	return (fact(n) // (fact(r) 
				* fact(n - r))) 

def fact(n): 
	res = 1
	for i in range(2, n+1): 
		res = res * i 		
	return res 

n,m=map(int,input().split())
if(n==1 and m!=1):
  print(nCr(m,2))
elif(n!=1 and m==1):
  print(nCr(n,2))
elif(n==1 and m==1):
  print("0")
else:
  print(int(nCr(n,2)+nCr(m,2)))


Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long M;
        static long S;
        static long T;
        static Node[] Nodes;
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            N = NM[0];
            M = NM[1];
            Nodes = new Node[3 * N + 1];

            for (int i = 0; i < 3 * N + 1; i++)
            {
                Nodes[i] = new Node();
            }

            for (int i = 0; i < M; i++)
            {
                var UV = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var U = UV[0];
                var V = UV[1];

                Nodes[3 * U].adj.Add(3 * V - 1);
                Nodes[3 * U - 1].adj.Add(3 * V - 2);
                Nodes[3 * U - 2].adj.Add(3 * V);
            }
            var ST = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            S = ST[0];
            T = ST[1];

            Console.WriteLine(WFS());
        }

        static long WFS()
        {
            var que = new Queue<long>();
            que.Enqueue(3 * S);
            Nodes[3 * S].dis = 0;
            while(que.Count > 0)
            {
                var top = que.Dequeue();
                var now = Nodes[top];
                foreach (var item in now.adj)
                {
                    if(Nodes[item].dis == -1)
                    {
                        Nodes[item].dis = now.dis + 1;
                        que.Enqueue(item);
                    }
                }
            }
            return Nodes[3*T].dis%3 == 0 ? Nodes[3*T].dis/3 : -1;
        }
    }

    class Node
    {
        public List<long> adj;
        public long dis = -1;

        public Node()
        {
            adj = new List<long>();
        }
    }
}


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

int main( void ) {
    
    int a, b;
    cin >> a >> b;
    
    if( a <= 0 && 0 <= b )
        cout << "Zero\n";
    else
    if( b < 0 )
        cout << ( ((b - a + 1) % 2 == 0) ? "Positive\n" : "Negative\n" );
    else
        cout << "Positive\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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

using ll=long long;

using vb=vector<bool>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

const int INF=INT_MAX;

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

  int N; cin >>N;
	string S; cin >>S;
	vi west(N+1);
  vi east(N+1);
	rep(i,0,N) {
		west[i+1]+=west[i]+(S[i]=='W' ? 1:0);
		east[i+1]+=east[i]+(S[i]=='E' ? 1:0);
	}

	int ans=INF;
	rep(i,0,N+1) {
		chmin(ans,west[i]+east[N]-east[i]);
	}

  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 6064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int x;
	cin >> x;
	const int y = x / 100;
	const int z = x % 100;
	cout << ((z + 4) / 5 > y ? "0" : "1") << endl;
	return 0;
}


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

int main() {

    int X; cin >> X;
    bool flag = false;

    for (int i=0; i<=X/100; i++) {
        for (int j=0; j<=X/101; j++) {
            for (int k=0; k<=X/102; k++) {
                for (int l=0; l<=X/103; l++) {
                    for (int m=0; m<=X/104; m++) {
                        for (int n=0; n<=X/105; n++) {
                            int sum = 100*i + 101*j + 102*k + 103*l + 104*m + 105*n;
                            if (sum == X) {
                                cout << '1' << endl;
                                flag = true;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    if (!flag) cout << '0' << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n;
	cin>>n;
	ll dp[47];
	dp[0] = 1; dp[1] = 1;
	for(int i = 2; i<=n; ++i){
		dp[i] = dp[i-1]+dp[i-2];
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cstring>

typedef struct node {
  int key;
  node *prev, *next;
} N;

N *nil;

void init() {
  nil = (N *)malloc(sizeof(N));
  nil->next = nil;
  nil->prev = nil;
}

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

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

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

void insert(int key) {
  N *x = (N *)malloc(sizeof(N));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

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

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

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

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

  printList();

  return 0;
}

Measured memory_bytes: 33800
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

vi Solve(int n, int a, int b) {
  vi result;
  b ^= a;
  vi x, y;
  for (int i = 0; i < n; ++i) if (b & (1 << i)) x.push_back(i); else y.push_back(i);
  //cerr << " x: "; for (int t : x) cerr << t << " "; cerr << endl;
  //cerr << " y: "; for (int t : y) cerr << t << " "; cerr << endl;
  if (x.size() % 2 == 0) return vi();
  if (y.empty()) {
    if (x.size() == 1) {
      result = {0, 1};
    } else {
      int l = 1 << (n - 1);
      int m = l - 2;
      vi v1 = Solve(n - 1, 0, m);
      vi v2 = Solve(n - 1, m, m + 1);
      assert(!v1.empty() && !v2.empty());
      for (int t : v1) result.push_back(t);
      for (int t : v2) result.push_back(l | t);
    }
  } else {
    int l = 1 << (n - 1);    
    int m = 0;
    for (int i = 0; i < x.size() - 1; ++i) m |= 1 << (n - 2 - i);
    vi v1 = Solve(n - 1, 0, m + 1);
    vi v2 = Solve(n - 1, m + 1, m);
    assert(!v1.empty() && !v2.empty());
    for (int t : v1) result.push_back(t);
    for (int t : v2) result.push_back(l | t);
    for (int& t : result) {
      int cur = 0;
      for (int j = 0; j < n; ++j) if (t & (1 << j)) {
        int i = n - 1 - j;
        if (i < x.size()) cur |= 1 << x[i]; else cur |= 1 << y[i - x.size()];
      }
      t = cur;
    }
  }
  for (int& t : result) t ^= a;
  return result;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  vi ans = Solve(n, a, b);
  if (ans.empty()) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int x : ans) cout << x << " ";
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1620
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main() {
    string s;
    int    ans = 0;
    cin >> s;
    if (s[0] == '1')
        ans++;
    if (s[1] == '1')
        ans++;
    if (s[2] == '1')
        ans++;
    cout << ans << "\n";
}


Measured memory_bytes: 3544
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int64_t W, H;
	cin >> W >> H;
	vector<int64_t> P;
	P.reserve(W + H);
	int64_t x;
	for (int i = 0; i < W + H; i++)
		cin >> x, P.push_back((x << 1) | (i < W));
	sort(P.begin(), P.end());
	W++, H++;
	int64_t r = 0;
	for (auto p : P) {
		int64_t t = p & 1;
		r += (p >> 1) * ((-t & H) + (~(-t) & W));
		H -= !t;
		W -= t;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,p;
int main(void){
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    n--;
    for(ll i=0;i<n;i+=2){
        if((a-p-(n-i)*d<=b&&b<=a+p-(n-i)*c)||(a-p+(n-i)*c<=b&&b<=a+p+(n-i)*d)){
            printf("YES\n");
            return 0;
        }
        p+=(d-c);
    }
    printf("NO\n");
}


Measured memory_bytes: 256
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


struct TV{
    int s,t,c;
    bool operator<(const TV &o) const{
        return t < o.t;
    }
};

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

    vector<vector<int>> tv(C+1,vector<int>(100100,0));

    REP(i,N){
        int s,t,c; cin >> s >> t >> c;
        tv[c][s] += 1;
        tv[c][t+1] -= 1;
    }

    REP(i,C+1){
        REP(j,100010){
            tv[i][j+1] += tv[i][j];
        }
    }

    int ans = 0;
    REP(j,100010){
        int cnt = 0;
        REP(i,C+1){
            if(tv[i][j]>0)cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;

    // vector<TV> T(N);
    // REP(i,N) cin >> T[i].s >> T[i].t >> T[i].c;
    
    // sort(ALL(T));

    // int ans = 0;
    
    // //チェック済みならc = -1
    // while(1){
    //     int before = 0;
    //     int before_c = 0;
    //     int cnt = 0;
    //     REP(i,N){
    //         if(T[i].c==-1){
    //             cnt++;
    //             continue;
    //         }

    //         if(before < T[i].s){
    //             before = T[i].t;
    //             before_c = T[i].c;
    //             T[i].c = -1;
    //         }else if(before==T[i].s && before_c==T[i].c){
    //             before = T[i].t;
    //             before_c = T[i].c;
    //             T[i].c = -1;
    //         }else{
    //             cnt++;
    //         }
    //     }
    //     if(cnt == N) break;
    //     ans++;
    // }

    // cout << ans << endl;


    return 0;
}

Measured memory_bytes: 15904
#include <stdio.h>

int main()
{
int width;
int height;
int x,y;
scanf("%d",&width);
scanf("%d",&height);
scanf("%d",&x);
scanf("%d",&y);

double max = (double)width* height/2;
printf("%f",max);
printf(" ");
if(x*2 == width && y*2 == height){
printf("%d",1);
}else{
    printf("%d",0);
}

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string S;
    cin >> S;
    cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


def main():
    import sys

    read = sys.stdin.buffer.read

    N, Q, *TUV = map(int, read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 144976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;

int main() {
  int r,D,x;
  cin>>r>>D>>x;
  
  for(int i=0;i<10;++i){
    x=r*x-D;
    cout<<x<<endl;
  }
  
}

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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int ans=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] == '1') ans++;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;

  ll t = max(A, max(B, C));
  ll ans = A + B + C - t;

  REP(i, K) { t *= 2; }

  cout << ans + t;

  return 0;
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int a, b, c; cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust\n";
  else cout << "win\n";

  return 0;
}



Measured memory_bytes: 256
import sys

n = int(input())

if n == 0:
    print(0)
    sys.exit()

cur = n
S = ""

while cur != 0:
    if cur % 2 == 0:
        S = "0" + S
        cur /= -2
    else:
        S = "1" + S
        cur -= 1
        cur /= -2
print(S)


Measured memory_bytes: 2940
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		public static void Compute(TextReader reader, TextWriter writer)
		{
//			string line = null;
//			while (null != (line = reader.ReadLine()))

			reader.ReadLine();
			var line = reader.ReadLine();
			
			
			var e = line.Split(' ').Reverse();
			
			var stringBuilder = new StringBuilder();
			foreach (var v in e)
			{
				stringBuilder.Append(v);
				stringBuilder.Append(' ');
			}
			stringBuilder.Remove(stringBuilder.Length - 1, 1);
			writer.WriteLine(stringBuilder.ToString());
		}
	}
}

Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin>>a.at(i).at(j);
  vector<vector<int>> c(2,vector<int>(n,0));
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      c[i][j]=(j==0?a.at(i).at(j):c[i][j-1]+a.at(i).at(j));
      if(i>0)
        c[i][j]=max(c[i][j],c[i-1][j]+a.at(i).at(j));
    }
  }
  cout<<c[1][n-1]<<endl;
}


Measured memory_bytes: 3504
n,m=map(int,input().split())
a=sorted(map(int,input().split()))
b=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])[::-1]
i=0
for num,v in b:
	for j in range(num):
		if i<n and a[i]<v:
			a[i]=v
			i+=1
		else:
			print(sum(a))
			exit()
else:
	print(sum(a))

Measured memory_bytes: 33736
#include <iostream>
#include <vector>

struct DJSet {
  int n;
  std::vector<int> upper;

  DJSet(int n) : upper(n) {
    for (int i=0;i<n;++i) upper[i]=-1;
  }

  int root(int x) {
    return upper[x]<0?x:(upper[x]=root(upper[x]));
  }

  bool equiv(int x, int y) {
    return root(x)==root(y);
  }

  void setUnion(int x, int y) {
    x=root(x);
    y=root(y);
    if (x==y) return;
    if (upper[x]>upper[y]) {
      x^=y;
      y^=x;
      x^=y;
    }
    upper[x]+=upper[y];
    upper[y]=x;
  }
};

int main() {
  long long N, M, Q;
  std::cin >> N >> M >> Q;
  DJSet ds(N);
  std::vector<int> A(Q);
  std::vector<int> B(Q);
  std::vector<int> C(Q);
  for (int i=0;i<Q;++i) {
    std::cin >> A[i] >> B[i] >> C[i];
    if (C[i]==0) {
      ds.setUnion(A[i], B[i]);
    }
  }
  bool flag = false;
  for (int i=0;i<Q;++i) {
    if (C[i]==1) {
      flag = true;
      if (ds.equiv(A[i], B[i])) {
	std::cout << "No" << std::endl;
	return 0;
      }
    }
  }
  long long num=0;
  for (int i=0;i<N;++i) {
    if (ds.upper[i]<0) ++num;
  }
  if (num==1) {
    std::cout << (M==N-1?"Yes":"No") << std::endl;
    return 0;
  } else if (num==2) {
    if (flag) 
      std::cout << "No" << std::endl;
    else {
      if (M==N-1) {
	std::cout << "Yes" << std::endl;
      } else {
	std::cout << "No" << std::endl;
      }
    }
    return 0;
  } else {
    if (N-(flag?0:1)<=M && M<=N+(num-3)*num/2) {
      std::cout << "Yes" << std::endl;
    } else {
      std::cout << "No" << std::endl;
    }
    return 0;
  }
}


Measured memory_bytes: 1792
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from collections import deque

    h, w, k = map(int, readline().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, readline().split())
    dict = [[-1] * w for _ in range(h)]
    move = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    for i in range(h):
        c = readline().rstrip().decode()
        for j, cc in enumerate(c):
            if cc == '@':
                dict[i][j] = 0
    q = deque()
    q.append((x1, y1))
    dict[x1][y1] = 0
    while q:
        x, y = q.popleft()
        if x == x2 and y == y2:
            exit(print(dict[x][y]))
        for dx, dy in move:
            for i in range(1, k + 1):
                xx = x + dx * i
                yy = y + dy * i
                if 0 > xx or xx >= h or 0 > yy or yy >= w:
                    break
                if 0 <= dict[xx][yy] <= dict[x][y]:
                    break
                if dict[xx][yy] == -1:
                    q.append((xx, yy))
                dict[xx][yy] = dict[x][y] + 1
    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95988
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(){

    int A, B;
    int i;
    int ans = 0;
    string str1, str2;

    cin >> A >> B;

    for(i =A; i <= B; ++i){
        str1 = to_string( i );
        str2 = to_string( i );
        reverse(str2.begin(), str2.end());
        if(str1 == str2){
            ++ans;
        }
    }

    cout << ans << endl;

}

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

int main(){
   int A,B,C; cin>>A>>B>>C;
   int i=0;
   int K; cin>>K;
   for(i=0; i<K; ++i){
    if(A>=B){
      B*=2;
    }
    else if(B>=C){
      C*=2;
    }
  }
    if (B > A && C >B){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int n;
int p[25];


int main(void) {
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  int count=0;
  
  for(int i=1; i<n-1; i++){
    if(p[i-1] < p[i] && p[i] < p[i+1]) count++;
    else if(p[i-1] > p[i] && p[i] > p[i+1]) count++;
  }
 
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	rep(i, 3) {
		string str;
		cin >> str;
		char s = ('A' - 'a' + str[0]);
		cout << s;
	}
	cout << endl;

}



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

int main(){
int n;
  cin >>n;
string s;
  cin >>s;
if(n>=3200) cout <<s<<endl;
  else cout <<"red"<<endl;
}

Measured memory_bytes: 256