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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    var(i64, N);
    var(string, s);
    s.erase(unique(all(s)), s.end());
    outl(s.length());
    return 0;
}


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

using namespace std;

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

  int n, m, p;
  cin >> n >> m >> p;
  vector<int> a(n), b(m);
  int A = 1e9, B = 1e9;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    A = min(A, a[i]);
  }
  for (int j = 0; j < m; ++j) {
    cin >> b[j];
    B = min(B, b[j]);
  }
  int ans = A + B;
  while (p--) {
    int c, x, y;
    cin >> x >> y >> c;
    --x, --y;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 1024
#include<vector>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define pb push_back
using namespace std;
inline char nc() {
	static char b[100000],*s=b,*t=b;
	return s==t&&(t=(s=b)+fread(b,1,100000,stdin),s==t)?-1:*s++;
}
inline void read(int &x) {
	char b = nc(); x = 0;
	for (; !isdigit(b); b = nc());
	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';
}
struct Node {
	int x, y, id;	
	inline bool operator<(const Node &o) const {
		return x < o.x || (x == o.x && y < o.y);
	}
} a[100005];
int n, s, t, D, f[100005], fa[100005], rk[100005];
int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
long long ans;
bitset < 100005 > vis;
inline int ABS(int x) {return x > 0 ? x : -x;}
inline void ae(int u, int v) {
	if ((u = find(u)) != (v = find(v))) {
		if (rk[u] < rk[v]) swap(u, v);
		rk[u] += rk[u] == rk[v]; fa[v] = u;
	}
}
void build(int k) {
	sort(a + 1, a + 1 + n); int i, j, l, r;
	for (i = j = l = r = 1; i <= n; ++i) {
		while (a[l].x < a[i].x - D || (a[l].x == a[i].x - D && a[i].y - a[l].y > k)) ++l;
		while (a[r].x < a[i].x - D || (a[r].x == a[i].x - D && a[r].y - a[i].y <= k)) ++r;
		f[a[i].id] += r - l; j = max(j, l); if (j < r) ae(a[i].id, a[j].id);
		for (; j + 1 < r; ++j) ae(a[j].id, a[j+1].id);
	}
}
int main() {
	read(n); read(s); read(t);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int x, y, i = 1; i <= n; ++i)
		read(x), read(y), a[i] = (Node){x + y, x - y, i};
	D = max(ABS(a[s].x - a[t].x), ABS(a[s].y - a[t].y));
	build(D);
	for (int i = 1; i <= n; ++i) swap(a[i].x, a[i].y);
	build(D-1);
	for (int i = 1; i <= n; ++i)
		if (find(i) == find(s)) ans += f[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main(){
	int n; std::cin >> n;
	std::map<std::string, long long int> counter;
	for (auto i = 0; i < n; ++i) {
		std::string str; std::cin >> str;
		std::sort(str.begin(), str.end());
		counter[str]++;
	}
	long long int result = 0;
	for (const auto p : counter) {
		result += p.second * (p.second - 1) / 2;
	}
	std::cout << result << std::endl;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int x, y, z, K; cin >> x >> y >> z >> K;
	vector<ll> a(x), b(y), c(z);
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	sort(a.begin(), a.end()); reverse(a.begin(), a.end());
	sort(b.begin(), b.end()); reverse(b.begin(), b.end());
	sort(c.begin(), c.end()); reverse(c.begin(), c.end());


	if (x * y * z < 3000) {
		vector<ll> cost(x * y * z);
		int idx = 0;
		rep(i, x)rep(j, y)rep(k, z) cost[idx++] = a[i] + b[j] + c[k];
		sort(cost.begin(), cost.end()); reverse(cost.begin(), cost.end());
		rep(i, K) printf("%lld\n", cost[i]);
	} else {
		vector<ll> cost(x * y);
		int idx = 0;
		rep(i, x)rep(j, y) cost[idx++] = a[i] + b [j];
		sort(cost.begin(), cost.end()); reverse(cost.begin(), cost.end());
		vector<ll> cost2(K * z);
		idx = 0;
		rep(i, K)rep(j, z) cost2[idx++] = cost[i] + c[j];
		sort(cost2.begin(), cost2.end()); reverse(cost2.begin(), cost2.end());
		rep(i, K) printf("%lld\n", cost2[i]);
	}

	return 0;
}

Measured memory_bytes: 31616
#include <iostream>

using namespace std;
 
int main()
{
    int t, n, s, f, total;

    while (cin >> t, t) {
        total = 0;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> s >> f;
            total += f - s;
        }

        if (total >= t) {
            cout << "OK" << endl;
        } else {
            cout << t - total << endl;
        }
    }   
    return 0;
}

Measured memory_bytes: 3084
fun main(args: Array<String>) {
    val x = readLine()!!.toInt()
    if (x == 2) {
        println(2)
        return
    }
    var list: MutableList<Int> = mutableListOf()
    val primes: MutableSet<Int> = mutableSetOf()
    for (i in 2 until x) {
       list.add(i)
    }

    do {
        val head = list.removeAt(0)
        primes.add(head)
        list = list.filter { it%head!=0 }.toMutableList()
    } while (head >= x)

    list.forEach { primes.add(it) }

    fun checkPrime(n: Int): Boolean {
        for (i in primes) {
            if (n%i==0) return false
        }
        return true
    }

    var res = x
    while (!checkPrime(res)) {
        res++
    }
    println(res)
}


Measured memory_bytes: 44016
// Created By Jefferson Samuel on 23/08/20 at 2:47 PM

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

class Main {

    static void solve() throws Exception {

       long a = scanLong();
       long b = scanLong();
       long c = scanLong();
       long d = scanLong();
        long aa[] = {a,b};
        long bb[] = {c,d};

        long ans = Long.MIN_VALUE;
       for(long t : aa)
       {
           for(long q : bb)
           {
               ans = Math.max(ans,t*q);
           }
       }
       out.println(ans);
    }




    // dont touch this side
    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	int now = 0;
	b[0]++;
	for(int i=1; i < n; i++) {
		if(a[i] != a[i-1])
			now++;
		b[now]++;
		if(b[now] >= 3)
			b[now] -=2;
	}
	int hi=0,hu=0;
	for(int i= 0; i< n;i++) {
		if(b[i] == 1)
			hi++;
		else if(b[i] == 2)
			hu++;
	}
	if(hu % 2 == 0)
		hi += hu;
	else
		hi += hu - 1;
	cout << hi << endl;
}

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

int n,a,b,q,k,x,y;
long long c;
vector<int> adjl[100001];
long long D[100001];
map<string, long long> C;
bool visited[100001];

void dfs(int i,long long dt){
	//cout<<i<<" "<<dt<<endl;
	visited[i]=true;
	for(int j : adjl[i]){
		if(!visited[j]){
			D[j]=C[to_string(i)+" "+to_string(j)]+dt;
			dfs(j, D[j]);
		}
	}
}

int main(){
	cin>>n;
	D[n]=0;
	for(int i=0;i<n-1;i++){
		D[i+1]=0;
		cin>>a>>b>>c;
		C[to_string(a)+" "+to_string(b)]=c;
		C[to_string(b)+" "+to_string(a)]=c;
		adjl[a].push_back(b);
		adjl[b].push_back(a);
	}
	cin>>q>>k;
	dfs(k,0);
	while(q--){
		cin>>x>>y;
		cout<<D[x]+D[y]<<endl;
	}
}

Measured memory_bytes: 53376
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll n, sum = 0, d = 10;
  cin >> n;
  if(n % 2 == 0) {
    while(d <= n) {
      sum += n / d;
      d *= 5;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    vector<int> monsters(n + 1), heros(n);
    for(int i = 0; i < n + 1; i++)
        cin >> monsters[i];
    for(int i = 0; i < n; i++)
        cin >> heros[i];
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        int monstersOppMe = monsters[i];
        int mini = min(monstersOppMe, heros[i]);
        heros[i] -= mini;
        monsters[i] -= mini;
        ans += mini;
        monstersOppMe = monsters[i + 1];
        mini = min(monstersOppMe, heros[i]);
        heros[i] -= mini;
        monsters[i + 1] -= mini;
        ans += mini;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 1010000
ll MOD=1e9+7;
vector<vec> G;
vector<int> ans;

struct point{
    int x,y,z,num;
};


ll gcd(ll x,ll y){
    if(!x)return y;
    else return gcd(y%x,x);
}
int main(){
    ll a,b;cin>>a>>b;
    ll g=gcd(a,b);
    ll ans=1;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0)g/=i;
        }
    }
    if(g>1)ans++;
    cout<<ans<<endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int ans=0, tmp;
    char p = s[0], s0 = s[0];
    int mode;
    FOR(i,1,n) {
        if(p==s[i]){
            ans += 1;
        }
        else if (s[i] == s0 && k != 0)
        {
            k = k - 1;
            ans += 2;
        }
        p = s[i];
    }
    if (s[n-1] != s0 && k != 0){
        ans += 1;
    }

        cout << ans << "\n";

    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod=1e9+7;
const ll inf=1001001001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}

int main(){
    int n,m;cin>>n>>m;
    string s;cin>>s;
    vector<char> t(m);
    vi v(m,1);
    rep(i,m){
        char c;cin>>t[i]>>c;
        if(c=='L')v[i]=-1;
    }
    int ok=n,ng=-1;
    while(ok-ng>1){
        int md=(ok+ng)/2;
        bool fall=false;
        int w=md;
        rep(i,m){
            if(s[w]==t[i])w+=v[i];
            if(w>=n)break;
            if(w<0){
                fall=true;
                break;
            }
        }
        if(fall)ng=md;
        else ok=md;
    }
    int l=ok;
    ok=-1,ng=n;
    while(ng-ok>1){
        int md=(ok+ng)/2;
        bool fall=false;
        int w=md;
        rep(i,m){
            if(s[w]==t[i])w+=v[i];
            if(w<0)break;
            if(w>=n){
                fall=true;
                break;
            }
        }
        if(fall)ng=md;
        else ok=md;
    }
    out(ok-l+1);
}

Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
   int N,T,A,c;
   double a;
   c = 1;
   cin >> N >> T >> A;
   vector<int> vec(N);
   for(int i = 0;i < N; i++){
       cin >> vec[i];
   }

   vector<double> temperature(N);
   for(int i = 0; i < N; i++){
       temperature[i] = abs(A - (T - vec[i] * 0.006));
   }
   double b = temperature[0];
   for(int i = 0; i < N; i++){
       a = temperature[i];
       if(a < b){
           b = temperature[i];
           c = i + 1;
       }
   }
   cout << c << endl;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool valid(int h,int m,int)
{
	return h%5==m/12;
}

int main()
{
	for(int n;cin>>n && n;){
		vvi ts(n);
		rep(i,n){
			vi a(3);
			rep(j,3) cin>>a[j];
			sort(all(a));
			do{
				int &h=a[0],&m=a[1],&s=a[2];
				rep(j,60){
					if(valid(h,m,s))
						ts[i].push_back(h/5*3600+m*60+s);
					rep(k,3) (++a[k])%=60;
				}
			}while(next_permutation(all(a)));
			sort(all(ts[i]));
		}
		
		int mn=0,mx=86400;
		rep(i,n) rep(j,ts[i].size()){
			int x=ts[i][j];
			rep(k,n) if(k!=i){
				auto it=lower_bound(all(ts[k]),ts[i][j]);
				if(it==end(ts[k])){
					x=INF;
					break;
				}
				x=max(x,*it);
			}
			if(x-ts[i][j]<mx-mn || x-ts[i][j]==mx-mn && ts[i][j]<mn)
				mn=ts[i][j],mx=x;
		}
		printf("%02d:%02d:%02d %02d:%02d:%02d\n",mn/3600,mn/60%60,mn%60,mx/3600,mx/60%60,mx%60);
	}
}

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

using namespace std;

void solve()
{
	int N, M;
	while (cin >> N >> M, N || M)
	{
		vector<int> height(1500001);
		vector<int> width(1500001);
		vector<int> h(N);
		vector<int> w(M);
		for (int i = 0; i < N; ++i)
		{
			cin >> h[i];
		}
		for (int i = 0; i < M; ++i)
		{
			cin >> w[i];
		}
		int ans = 0;
		int sum = 0;
		for (int i = 0; i < N; ++i)
		{
			sum = 0;
			for (int j = i; j < N; ++j)
			{
				sum += h[j];
				height[sum]++;
			}
		}
		for (int i = 0; i < M; ++i)
		{
			sum = 0;
			for (int j = i; j < M; ++j)
			{
				sum += w[j];
				width[sum]++;
			}
		}
		for (int i = 0; i < height.size(); ++i)
		{
			ans += height[i] * width[i];
		}
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 12876
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    vector<int> border_rl(0);
    vector<int> border_lr(0);
    border_lr.push_back(-1);
    int len = S.size();
    vector<int> ans(len,0);
    rep(i,len - 1){
        if (S[i] == 'R' && S[i + 1] == 'L') border_rl.push_back(i);
        if (S[i] == 'L' && S[i + 1] == 'R') border_lr.push_back(i);
    }
    border_lr.push_back(len - 1);
    rep(i,border_rl.size()){
        if ((border_rl[i] - border_lr[i]) % 2 == 0){
            ans[border_rl[i]] += ((border_rl[i] - border_lr[i]) / 2);
            ans[border_rl[i] + 1] += ((border_rl[i] - border_lr[i]) / 2);
        }
        else{
            ans[border_rl[i]] += ((border_rl[i] - border_lr[i]) / 2 + 1);
            ans[border_rl[i] + 1] += ((border_rl[i] - border_lr[i]) / 2);
        }
        
        if ((border_lr[i + 1] - border_rl[i]) % 2 == 0){
            ans[border_rl[i]] += ((border_lr[i + 1] - border_rl[i]) / 2);
            ans[border_rl[i] + 1] += ((border_lr[i + 1] - border_rl[i]) / 2);
        }
        else{
            ans[border_rl[i]] += ((border_lr[i + 1] - border_rl[i]) / 2);
            ans[border_rl[i] + 1] += ((border_lr[i + 1] - border_rl[i]) / 2 + 1);
        }
    }
    rep(i,len){
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    string s,t;
    cin >> s >> t;
    bool flag=1;
    if (s.size()==t.size()-1) {
        rep(i,s.size()) {
            if (s[i]!=t[i]) flag=0;
        }
    } else {
        flag=0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;   
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int a,b,c,d,h,w,e=0,f=0;
	char space;
	while(scanf("%d%d",&h,&w)!=EOF)
	{
		getchar();
		char pic[10000][10000];
		int n,m;
		n=h;m=w;
		while(n--)
		{
			scanf("%s",pic[f]);
			f++;
		}
		f=0;
	    for(a=0;a<w+2;a++)
		{
			printf("#");
		}
		printf("\n#");
		e=0;
		for(b=0;b<h;b++)
		{
			printf("%s",pic[e]);
			printf("#\n#");
			e++;
		}
		for(c=0;c<w;c++)
		{
			printf("#");
		}
		printf("#\n");
	}
	
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cstdio>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int m,ans = 0;
    vector<pair<int,pair<int,int> > > P;
    bool done[100]={false};
    cin >>m;
    for(int i=0,a,b,c; i<m; i++){
      scanf("%d,%d,%d",&a,&b,&c);
      P.push_back(make_pair(c,make_pair(a,b)));
    }
    sort(P.begin(),P.end());
    ans+=(P[0].first/100)-1;
    done[P[0].second.first] = done[P[0].second.second] = true;
    for(int i=0; i<n-1; i++){
      for(int j=0; j<m; j++){
	if(done[P[j].second.first]^done[P[j].second.second]){
	  ans+=(P[j].first/100)-1;
	  done[P[j].second.first] = done[P[j].second.second] = true;
	  break;
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

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

int main(){
int W,H,N;
  cin>>W>>H>>N;
  vector<int>x(N), y(N), a(N);
  for(int i=0; i<N; i++){
   cin>>x[i]>>y[i]>>a[i]; }
  
  int x1=0, x2=W, y1=0, y2=H;
  for(int i=0; i<N; i++){
   if(a[i]==1){x1=max(x1, x[i]);} // 最大のx[i]を算出 
   if(a[i]==2){x2=min(x2, x[i]);} // 最小のx[i]を算出  
   if(a[i]==3){y1=max(y1, y[i]);} // 最大のy[i]を算出
   if(a[i]==4){y2=min(y2, y[i]);} // 最小のy[i]を算出
  }
  
  if(x1>x2){x2=x1;} // x2-x1=0の場合、答えが0になるようにする
  if(y1>y2){y2=y1;}
  
  cout<<(x2-x1)*(y2-y1); // 白い部分の面積
 }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC162B
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long count = 0;
            for(long i = 1; i < N+1; i++)
            {
                if (i % 3 != 0 & i % 5 != 0)
                {
                    count += i;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27460
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[100001];
int main(void)
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
    sort(a,a+n);
    cout<<a[n-1]-a[0];
    return 0;
} 

Measured memory_bytes: 256
def fact(n):
    global mod
    if n==0:
        return 1
    else:
        res=1
        for i in range(1,n+1):
            res=(res*i)%mod
        return res

def inv(n):
    global mod
    res=1
    prod=n%mod
    a=mod-2
    while a>0:
        if a%2==1:
            res=(res*prod)%mod
        a//=2
        prod=(prod**2)%mod
    return res

def combi(n,r):
    return (fact(n)*inv(fact(r))*inv(fact(n-r)))%mod

def ord(n,p):
    res=0
    while n%p==0:
        res+=1
        n//=p
    return res

mod=10**9+7
N,M=map(int,input().split())
l=[]

if ord(M,2)>0:
    l.append(ord(M,2))
    M//=2**ord(M,2)

p=3
while M>1 and p<=int(10**4.5):
    if ord(M,p)>0:
        l.append(ord(M,p))
        M//=p**ord(M,p)
    p+=2
if M>1:
    l.append(1)
    M=1

ans=1
for e in l:
    ans=(ans*combi(e+N-1,N-1))%mod

print(ans)

Measured memory_bytes: 39408
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const W = parseInt(args[0][1], 10)
	const w = new Array()
	const v = new Array()

	for (let i = 1; i <= N; i++) {
		w.push(parseInt(args[i][0], 10))
		v.push(parseInt(args[i][1], 10))
	}

	const dp = new Array(N + 1)

	for (let i = 0; i < dp.length; i++) {
		dp[i] = new Array(W + 1).fill(0)
	}

	for (let i = 0; i < N; i++) {
		for (let j = 0; j <= W; j++) {
			if (j - w[i] >= 0) {
				dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
			}

			dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j])
		}
	}

	console.log(dp[N][W])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 196752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int n = sc.nextInt();
            long[] a = sc.nextLongArray(n);

            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans ^= a[i];
            }

            for (int i = 0; i < n; i++) {
                System.out.print((ans ^ a[i]) + " ");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


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

using namespace std;

typedef pair<string, int> P;
typedef vector<P> V;

class Queue {
public:
    void enqueue(P p) {
        v[tail] = p;
        if (tail + 1 == v.size()) {
            tail = 0;
        } else {
            tail++;
        }
    }

    P dequeue() {
        P p = v[head];
        if (head + 1 == v.size()) {
            head = 0;
        } else {
            head++;
        }
        return p;
    }

    bool is_empty() {
        return head == tail;
    }

private:
    V v = V(100000);
    int head = 0;
    int tail = 0;
};

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

    int n, q;
    cin >> n >> q;
    Queue qu = Queue();
    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time;
        qu.enqueue(P(name, time));
    }
    int time = 0;
    while (!qu.is_empty()) {
        P c = qu.dequeue();
        if (c.second <= q) {
            time += c.second;
            cout << c.first << " " << time << "\n";
        } else {
            c.second -= q;
            time += q;
            qu.enqueue(c);
        }
    }
}


Measured memory_bytes: 6676
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
my @args;

while (<>) {
    push @args, $_;
}

my $N = $args[0];

for my $i (1 .. 9) {
    my $n = $i * 100 + $i * 10 + $i;
    if ($n >= $N) {
        say $n;
        last;
    }
}


Measured memory_bytes: 640
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "+++ test ++++" << endl;	// 動作確認テスト
using ll = long long;
using namespace std;
const int MOD = 1e9 + 7; // 10^9 + 7

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int> & vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
ll sumVec(vector<ll> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// ------------------ 最大公約数関数 ------------------ //
int GCD(int x, int y) {
	if (x == 0) return y;
	else GCD(y % x, x);
}


// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A) {
	
	// スコアの計算
	if (A.size() == n+1) {
		int now = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
		}		
		ans = max(ans, now);
		return;
	}

	// 全探索
	A.push_back(A.back());
	while (A.back() <= m) {
		dfs(A);
		A.back()++;
	}
}

int main(void) {

	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vector<int>(1,1));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
// C - 怪文書 / Dubious Document
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n;
	vector<int> a(26, 50);
	for(int i=0; i<n; i++){
		string s; cin>>s;
		vector<int> b(26);
		for(char e:s) b[e-'a']++;
		for(int j=0; j<26; j++) if(a[j]>b[j]) a[j] = b[j];
	}
	for(int i=0; i<26; i++) while(a[i]--) cout<<(char)(i+'a');
	cout<<"\n";
}

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

int main() {
    int n;
    while (cin >> n) {
        vector<int> v(n);
        for (int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        int result = 0, timeFromBeginning = 0;
        for (int i = 0; i < n; i++) {
            result += v[i] + timeFromBeginning;
            timeFromBeginning += v[i];
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt(); 
		int ans = (r-l)/d;
		if(l%d==0 || r%d==0) {
			ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  vector<P> A(n); 
  rep(i,n) {
    ll x, l;
    cin >> x >> l;
    A[i].second = max(0LL,x-l);
    A[i].first = min(1000000000LL, x+l);
  }
  sort(all(A));
  int ans = 1;
  int preid = 0;
  for (int i = 1; i < n; ++i) {
    if (A[preid].first <= A[i].second) {
      ans++;
      preid = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	var as []int
	for i := 0; i < n; i++ {
		var a int
		if _, err := fmt.Scan(&a); err != nil {
			panic(err)
		}

		as = append(as, a)
	}

	for i := 0; i < len(as); i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(as[len(as)-i-1])
	}
	fmt.Println()
}



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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll n;
	cin>>n;
	cout<<(1000-n%1000)%1000;	
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    if(s[0]==t[0])ans++;
    if(s[1]==t[1])ans++;
    if(s[2]==t[2])ans++;
    cout<<ans;
    return 0;
}

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

void top(vector<vector<int>> &A,vector<int> &order)
{
	queue<int> q;
	int n=A.size()-1;
	vector<int> ind(n+1,0);
	for(int i=1;i<=n;i++)for(int x:A[i])ind[x]++;
	for(int i=1;i<=n;i++)if(ind[i]==0)q.push(i);
	while(!q.empty())
	{
		int cur=q.front();
		q.pop();
		order.push_back(cur);
		for(int x:A[cur])
		{
			if(--ind[x]==0)q.push(x);
		}
		
	}
	
	
}
int main() {
	
	int n,m;
	cin>>n>>m;
	vector<vector<int>> A(n+1);
	while(m--)
	{
		int a,b;
		cin>>a>>b;
		A[a].push_back(b);
	}
	
	vector<int> order;
	top(A,order);
	
	vector<int> dp(n+1,0);
	for(int i=n-1;i>=0;i--)
	{
		int x=order[i];
		for(int y:A[x])dp[x]=max(dp[x],1+dp[y]);
		
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	
	
}

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

int main() {
  double a, b;
  char op;

  cin >> a >> op >> b;
  
  int x;
  if ( op == '+' ) {
    x = a + b;
  } else {  // op == '-'
    x = a - b;
  }
  
  cout << x << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int a[200020];

int main(){
  cin.sync_with_stdio(false);
  int n, k, t;
  cin >> n >> k;
  set<int> s;
  rep(i, n + 1) a[i] = INF;
  rep(i, n) {
    cin >> t;
    if (!s.count(t)) a[t] = 0;
    s.insert(t);
    a[t]++;
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  rep(i, s.size() - k) ans += a[i + 1];
  cout << ans << endl;
  return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, K;
    cin >> N >> K;
    cout << (N - 1 + K - 1 - 1) / (K - 1) << endl;
}

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

int main()
{
	string s;
	
	
	cin>>s;
	
	cout<<"2018";
	int t = s.size();
	for( int i=4 ; i<t ; i++ )
		cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int ans=0;
  int N,K;
  cin>>N>>K;
  vector<int> p(N);
  REP(i,N){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  REP(i,K){
    ans+=p.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
c = list(map(int, input().split()))

dp = [0] + [float('inf')] * N
for m in range(M):
    ci = c[m]
    for n in range(N + 1):
        if n - ci >= 0:
            dp[n] = min(dp[n], dp[n - ci] + 1)

print(dp[N])


Measured memory_bytes: 7524
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

ll mpow(ll n, ll p) {
	ll res = 1LL;
	while( p ) {
		if( p & 1 ) res *= n;
		
		n *= n;
		p >>= 1;
	}
	
	return res;
}

int main(void) {
	int n, m;
	cin >> n >> m;
	
	ll ans = mpow(2LL, m) * (1900 * m + (n - m) * 100);
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  int x=0;
  ll ans=0;
  rep(i,n){
    if(i==0){x=a[0];}
    if(x>a[i]){
      ans+=x-a[i];
    }else{x=a[i];}
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

bool solve(int one, int two, int four, vector<int> &ans){
    int N = ans.size();
    for(int i=1; i<N; i++){
        if(ans[i-1] == 1){
            if(four > 0){
                ans[i] = 4;
                four--;
            }else return false;
        }
        else if(ans[i-1] == 2){
            if(two > 0){
                ans[i] = 2;
                two--;
            }else if(four > 0){
                ans[i] = 4;
                four--;
            }
            else return false;
        }else{
            if(one > 0){
                ans[i] = 1;
                one--;
            }else if(two > 0){
                ans[i] = 2;
                two--;
            }else{
                ans[i] = 4;
                four--;
            }
        }
    }
    return true;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    int two = 0, four = 0;
    for(int i=0; i<N; i++)
        if(a[i] % 4 == 0)
            four++;
        else if(a[i] % 2 == 0)
            two++;
    int one = N - two - four;

    vector<int> ans(N, 0);

    if(one > 0){
        ans[0] = 1;
        if(solve(one-1, two, four, ans)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(two > 0){
        ans[0] = 2;
        if(solve(one, two-1, four, ans)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(four > 0){
        ans[0] = 4;
        if(solve(one, two, four-1, ans)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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

int main()
{
    IOS;
    ll a[5];
    ll x=0,mn=10;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]%10<=mn&& a[i]%10!=0)
        {
            mn=min(mn,a[i]%10);
            x=a[i];
        }
    }
    ll ans=0;
    int flag=0;
    for(int i=0;i<5;i++)
    {
        if(a[i]==x&&flag==0)
        {
            flag=1;
            continue;
        }
        else
        {
            ll y=a[i]/10;
            ans+=y*10;
            if(a[i]%10) ans+=10;
        }
    }
    ans+=x;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int result = k * (int)Math.pow(k - 1, n - 1);
        System.out.println(result);
    }
}

Measured memory_bytes: 35876
#include <stdio.h>

int main(void)
{
	int a[5];
	int i,j,temp;

	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);

	for(i=0; i<5; i++){
	  for(j=i+1; j<5; j++){
	    if(a[i] < a[j]){
	      temp = a[i];
	      a[i] = a[j];
	      a[j] = temp;
	    }
	  }
	}

	for(i=0; i<5; i++){
	  if(i<4)printf("%d ",a[i]);
	  else
	    printf("%d\n",a[i]);
        }


	return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int a = sc.nextInt();
		String str = sc.next();
		String r = a>=3200? str : "red";


		System.out.println(r);

	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
long flg[9], N, M, R, r[8], d[200 + 1][200 + 1], mn;
void func(int p, long cost){
	int f = 1;
	for(int i = 0; i < R; i++){
		if(flg[i] != 1){
			f = 0;
			break;
		}
	}
	if(f == 1) mn = min(mn, cost);
	else {
		for(int i = 0; i < R; i++){
			if(flg[i] != 1){
				flg[i] = 1;
				func(r[i], cost + d[p][r[i]]);
				flg[i] = 0;
			}
		}
	}
}
int main(void){
	cin >> N >> M >> R;
	for(int i = 0; i < R; i++) cin >> r[i];
	fill(d[0], d[N + 1], INT_MAX);
	for(int i = 0; i < M; i++){
		long a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c; d[b][a] = c;
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			for(int k = 1; k <= N; k++) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
		}
	}
	mn = INT_MAX;
	for(int i = 0; i < R; i++){
		fill(flg, flg + R, 0);
		flg[i] = 1;
		func(r[i], 0);
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int a, b, x;
    scanf("%d %d %d", &a, &b, &x);
    printf(x - a >= 0 && (x - a) <= b ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    V(string) S(N);
    cout << 0 << endl;
    string t;
    cin >> t;
    S[0] = t;
    if(t=="Vacant") return 0;
    int l=0, r=N;
    rep(i, 19) {
        int mid = (l+r)/2;
        cout << mid << endl;
        string s;
        cin >> s;
        if(s=="Vacant") return 0;
        S[mid] = s;
        if(abs(mid-l)%2 && S[l]==s) r = mid;
        else if(abs(mid-l)%2==0 && S[l]!=s) r = mid;
        else if(abs(mid-r)%2 && S[r%N]==s) l = mid;
        else if(abs(mid-r)%2==0 && S[r%N]!=s) l = mid;
    }

    return 0;
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

typedef long long ll;

ll mod=1000000000+7;


int main(void){
    double N;
    int x1,x2;

    scanf("%lf", &N);
    x1=(int)(N/1.08);
    x2=(int)(N/1.08)+1;
    if((int)(x1*1.08)==(int)N){
        printf("%d", x1);
    }else if((int)(x2*1.08)==(int)N){
        printf("%d", x2);
    }else{
        printf(":(");
    }
    
    return 0;
}

Measured memory_bytes: 128
import math

A = [0] * 5
amari = [0] * 5
jikann = [0] * 5

for i in range(5):
    A[i] = int(input())
    amari[i] = A[i] % 10
    jikann[i] = math.ceil(A[i] / 10)
# print(A)
# print(amari)
# print(jikann)

if 0 in amari:
    amari.remove(0)
min_index = amari.index(min(amari))

jikann.pop(min_index)
print(sum(jikann) * 10 + A[min_index])

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t a;  
  cin >> a;
  
  cout << a+a*a+a*a*a << endl;
  
  
  return 0;
}

Measured memory_bytes: 3652