akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e6+2;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,k;
	cin>>n>>k;
	int s=0;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i],s+=a[i];
	k=min(k,n);
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<k;i++) s-=a[i];
	cout<<s;
}
// I never lose. I either win or I learn

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;string S;cin >> N >> S;
    int cnt = 0, ans = 0;
    REP(i,N){
        if(S[i]=='I') ++cnt;
        else --cnt;
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
       
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define inf 1000000007
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n;
	cin>>n;
	ll arr[n];
	ll dp[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)
	{
		dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	cout<<dp[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

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

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
struct BIT {
	vector< int > container;
	BIT(int n) {
		container = vector< int >(n + 1, 0);
	}
	void add(int i, int x) {
		if (i > container.size())
			return;
		container[i] += x;
		add(i + (i & -i), x);
	}
	int sum(int i) { //[1,i]
		if (i == 0)
			return 0;
		return container[i] + sum(i - (i & -i));
	}
	int sum(int l, int r) { //[l,r)
		return sum(r - 1) - sum(l - 1);
	}
};
int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	N = S.size();
	vector< BIT > bts(26, BIT(N));
	rep(i, N) {
		bts[S[i] - 'a'].add(i + 1, 1);
	}
	int ans = 1;
	rep(i, N) {
		int tmp = N - i;
		tmp -= bts[S[i] - 'a'].sum(i + 1, N + 1);
		//cout << tmp << endl;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 42756
N=input()

E=[ [ "" for j in range(N+1) ] for i in range(N+1) ]

for K in range(10):
	if N<=2**K:
		break

for i in range(1,N+1):
	for j in range(i+1,N+1):
			for k in range(K):
				if (i>>k)&1!=(j>>k)&1:
						E[i][j]=str(k+1)
						break
	
for i in range(1,N):
		print " ".join(E[i][i+1:])

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

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
	ninja
	int t; 
	int n; cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];

	if(n&1){
		cout<<0; return 0;
	}
	sort(all(v));
	cout<<v[n/2]-v[n/2 -1];
}



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

int main() {
  int K;
  string S;
  cin >> S >> K;
  rep(i, S.size()){
    if(S.at(i)!='1'){
      cout << S.at(i) << endl;
      break;
    }
    else if(K==i+1){
      cout << 1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N, K; cin >> N >> K;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	int ans = 0;
	sort(all(vec), greater<int>());
	rep(i, 0, K)ans += vec[i];
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
from math import ceil
N = int(input())
A = [int(a) for a in input().split()]

DP = 1
for a in A:
    DP |= DP << a

Shalf = ceil(sum(A)/2)
DP >>= Shalf
for i in range(N * max(A)):
    if DP & 1:
        print(Shalf + i)
        break
    DP >>= 1


Measured memory_bytes: 5432
def examA():
    N = I()
    L = LI()
    L.sort()
    if sum(L)<=L[-1]*2:
        print("No")
    else:
        print("Yes")
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int y;
  int m;
  int d;
 char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
 
  if (m >= 5 || m == 4 && d >= 31) {
    cout << "TBD" << endl;
  }
  else {
  cout << "Heisei" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S=="RRR") cout << 3;
  else if(S=="SSS") cout << 0;
  else if(S=="RRS"||S=="SRR") cout << 2;
  else cout << 1;
}

Measured memory_bytes: 3620
s = input()
q = int(input())
for i in range(q):
    c = list(input().split())
    a = int(c[1])
    b = int(c[2])
    if c[0]=='print':
        print(s[a:b+1])
    elif c[0]=='reverse':
        s = s[:a]+s[a:b+1][::-1]+s[b+1:]
    else:
        s = s[:a]+c[3]+s[b+1:]


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 500+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int n,m;
int a[maxn],b[maxn];
bool check(int x){
	for(register int i=1;i<=n;i++){
		b[i]=a[i]%x;
		//cout<<i<<" "<<b[i]<<endl;
	}
	sort(b+1,b+n+1);
	int num=0,l=1,r=n;
	while(l<r){
		//cout<<l<<" "<<r<<" "<<b[l]<<" "<<b[r]<<endl;
		int minn=min(b[l],x-b[r]);
		b[l]-=minn;
		(b[r]+=minn)%=x;
		num+=minn;
		if(num>m)return false;
		if(!b[l])l++;
		if(!b[r])r--;
	}
	//cout<<x<<" "<<num<<" "<<m<<endl;
	if(l==r && b[l])return false;
	return true;
}
int main(){
	int k,num=0,ans=0;
	n=read();m=read();
	for(register int i=1;i<=n;i++){a[i]=read();num+=a[i];}
	for(register int i=1;i*i<=num;i++){
		if(num%i==0){
			if(check(i))ans=max(ans,i);
			if(check(num/i))ans=max(ans,num/i);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//to set precision use fixed,setprecision(number_of_points_after_decimal
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define mod 1000000007
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
void solution(){
    int n;cin>>n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)
        cout<<"hon"<<endl;
    else if(n==3)
        cout<<"bon"<<endl;
    else
        cout<<"pon"<<endl;
}



int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    solution();
    return 0;
}

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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

void dfs(vi adj[], int x, int colour[], int c)
{
    colour[x] = c;
    for(auto i: adj[x])
    {
        if(colour[i] == -1)
            dfs(adj, i, colour, c);
    }
}


int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n, k, l;
    TI(n, k, l);
    vi adj[n];
    vi adj2[n];
    F(i, 0, k)
    {
        int x, y;
        DI(x, y);
        --x; --y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    F(i, 0, l)
    {
        int x, y;
        DI(x, y);
        --x; --y;
        adj2[x].pb(y);
        adj2[y].pb(x);
    }
    int colour1[n];
    memset(colour1, -1, sizeof(colour1));
    int c = 0;
    int d = 0;
    int colour2[n];
    memset(colour2, -1, sizeof(colour2));
    F(i, 0, n)
    {
        if(colour1[i] == -1)
        {    
            dfs(adj, i, colour1, c);
            ++c;
        }
        if(colour2[i] == -1)
        {
            dfs(adj2, i, colour2, d);
            ++d;
        }
    }
    map<ii, vi> mp;
    F(i, 0, n)
        mp[{colour1[i], colour2[i]}].pb(i);
    int ans[n];
    for(auto i: mp)
    {
        int p = i.second.size();
        for(auto j: i.second)
        {
            ans[j] = p;
        }
    }
    F(i, 0, n)
        cout << ans[i] << " ";
    cout << "\n";
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans += (s[i] != t[i] ? 1 : 0);
    }
    cout << ans;
}


Measured memory_bytes: 3864
N, Y = map(int, input().split())
for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 66352
#include <stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1];
int main(){
    int i, k, n;
    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i;k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    while(scanf("%d", &n) != EOF){
        if(n==0) break;
        for(i = n; i >=2; i--){
            if(prime[i - 2]&& prime[i]/*&&p1<i*/){
                printf("%d %d\n", i - 2, i);
                break;
            }
        }
    }
    return 0;
}

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

void runrun_gen ( ll num, vector<ll> &runrun_num, int keta_num, int end_num ) {
//    cout << keta_num << endl;
    if ( keta_num == end_num ) return;
    if ( num != 0 ) {
        runrun_num.push_back(num);
    }
    rep(i, 10) {
        if ( num == 0 ) {
            if ( i == 0 ) continue;
            runrun_gen(num*10+i, runrun_num, keta_num+1, end_num);
        }
        else {
            if ( num % 10 - 1 >= 0 && i == num % 10 - 1 ) {
                runrun_gen(num*10+i, runrun_num, keta_num+1, end_num);
            } 
            if ( num % 10 + 1 <= 9 && i == num % 10 + 1 ) {
                runrun_gen(num*10+i, runrun_num, keta_num+1, end_num);
            }
            if ( num % 10 == i ) {
                runrun_gen(num*10+i, runrun_num, keta_num+1, end_num);
            }
        }
    }
    return;
} 

int main(){
    ll k;
    cin >> k;
    ll now_num = 1;
    vector<ll> runrun_num;
    runrun_gen(0, runrun_num, 0, 11);
    sort(runrun_num.begin(), runrun_num.end());
//    for ( auto tmp_num : runrun_num ) {
//        cout << tmp_num << endl;
//    }
//    cout << runrun_num.size() << endl;
    cout << runrun_num[k-1] << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    for (int a : A) {
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";
    return 0;
}


Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// solution 
//
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        v: [usize; N],
    }

    let mut num_odd = vec![0_usize; 100_001];
    let mut num_even = vec![0_usize; 100_001]; 
    
    for (ind, &num) in v.iter().enumerate() {
        if ind % 2 == 0 {
            num_even[num] += 1;
        } else {
            num_odd[num] += 1;
        }
    }

    let mut num_odd: Vec<(_, _)> = num_odd.iter().enumerate().collect();
    let mut num_even: Vec<(_, _)> = num_even.iter().enumerate().collect();
    num_odd.sort_by(|a, b| b.1.cmp(a.1));
    num_even.sort_by(|a, b| b.1.cmp(a.1));

    let no_change = 
        if num_odd[0].0 != num_even[0].0 {
            num_odd[0].1 + num_even[0].1
        } else {
            std::cmp::max(num_odd[0].1 + num_even[1].1,
                          num_odd[1].1 + num_even[0].1)
        };

    println!("{}", N - no_change);
}


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

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

	int N;
	cin >> N;

	vector<int> a( N );
	for( auto& v: a ) { cin >> v; }

	int result = 0;
	for( bool f = true; f; ) {
		f = false;
		for( int i = 0; i < N; ++i ) {
			if( a[i] % 2 == 0 ) {
				a[i] /= 2;
				result += 1;
				f = true;

				break;
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int inf = 0x3f3f3f3f;
const int mxn = 100000;
int n, m;
int a[mxn], b[mxn], c[mxn];
int cc[mxn], d[mxn], dd[mxn], p[mxn], vis[mxn];
vector<int> f(1, 0), g(1, 0);
ll sum, cnt, cyc;
int ret, ret2;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		d[a[i]]++, dd[b[i]]++, p[b[i]] = a[i], cc[a[i]] = c[i];
		if(a[i] != b[i]) ret++, sum += c[i] - 1;
	}
	
	for(int i = 0; i < m; i++){
		if(a[i] == b[i]){
			if((d[a[i]] > 1 || dd[a[i]] > 1) && c[i] > 1){
				f.push_back(c[i] - 1);
			}else if(c[i] > 2){
				g.push_back(c[i] - 2);
			}
		}else if(!~-d[a[i]] && !~-dd[a[i]] && !vis[a[i]]){
			ll j, s;
			for(j = a[i], s = 0; !~-d[j] && !~-dd[j] && !vis[j]; j = p[j]) vis[j] = 1, s += cc[j] - 1;
			if(j == a[i]) cnt++, cyc += s;
		}
	}
	
	sort(f.begin() + 1, f.end(), greater<int>());
	sort(g.begin() + 1, g.end(), greater<int>());
	
	ret += cnt;
	ret2 = !!cnt * inf;
	for(int i = sum == cyc, j = 0; i < f.size(); i++){
		sum += f[i];
		while(j < g.size() - 1 && sum < cnt) sum += g[++j];
		while(j && sum - g[j] >= cnt) sum -= g[j--];
		if(sum >= cnt) ret2 = min(ret2, i + 2 * j);
	}
	
	cout << (ret2 == inf ? -1 : ret + ret2) << endl;

	return 0;
}


Measured memory_bytes: 6800
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

double Tok,Kak=1;
int K;

double solve(int Tok){
    if(Tok >= K) return Kak;
    Kak *= 0.5;
    solve(Tok*2);
}

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

    double N;
    cin >> N >> K;
    double ans = 0;
    if(N>=K){
        for(int i = 1; i <= K-1;i++){
            Tok = i;
            solve(i);
            ans += (1/N)*Kak;
            Kak = 1;
        }
        ans += (N-K+1)/N;
    }
    else if(N < K){
        for(int i = 1; i <= N; i++){
            Tok = i;
            solve(Tok);
            ans += (1/N)*Kak;
            Kak = 1;
        }
    }

    printf("%.16f", ans);
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
score = float("inf")
for index, i in enumerate(H):
    x = T - i * 0.006
    if abs(A - x) < score:
        score = abs(A - x)
        ans = index + 1

print(ans)


Measured memory_bytes: 3060
module kkk
  sub main()
    
    dim ab() as integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse) 
    dim a as long = ab(0)
    dim b as long = ab(1)
    
    dim ia as long
    dim ib as long
    
    dim i as long
    
    for i = 1 to b
    ia = ia * 10 + a
  next
  
  for i = 1 to a
  ib = ib * 10 + b
next

if a >= b then
  console.writeline(ib)
else
  console.writeline(ia)
end if

end sub
end module
    

Measured memory_bytes: 13140
#include<stdio.h>

#define MAX 101
#define MAX_VAL 1000000

int n,g[MAX],a[MAX][MAX],d[MAX],p[MAX],v[MAX],color[MAX]; 
int mincost;

int main(void) {
  
  
  int i,j,u,v;
  
  // color WHITE:0, GRAY:1, BLACK:2
  
  // 入力
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  
  // 初期化
  
  for(i=0;i<n;i++){
    d[i] = MAX_VAL;
    p[i] = -1;
    color[i] = 0;
  }
  
  d[0] = 0 ;
  
  while(1){
    
    mincost = MAX_VAL;
    
    for(i=0;i<n;i++){
      if(color[i] != 2 && d[i] < mincost){ // 現在の全ノードの中で最も小さい辺とその頂点を保持
	mincost = d[i];
	u = i ;
      }
    }
    
    if(mincost == MAX_VAL) // みつからなかった場合終わり
      break;
    
    // 最短のノードを黒に
    color[u] = 2; //BLACK
    
    for(v = 0 ; v < n ; v++) {
      if(color[v] != 2 && a[u][v] < d[v] && a[u][v] != -1) {
	  d[v] = a[u][v];
	  p[v] = u;
	
      }
    }
    
  }
  /*
  printf("\nd[]\n");
  for(i=0;i<n;i++)
    printf(" %d",d);
  printf("\n");
  */
  int sum = 0;
  for(i=0;i<n;i++){
    if(p[i] != -1){
      sum += a[i][ p[i] ];
    }
  }
  
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) emplace_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 998244353;
class mint {
public:
	ll x;
	mint(ll x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const { 
	  return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

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

ll dp[3010][3010] = {0};

void Main(){

	string s, t;
	cin >> s >> t;
	
	ll lens = s.size();
	ll lent = t.size();
	rep(i, lens) rep(j, lent){
		if(s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
		chmax(dp[i + 1][j + 1], max(dp[i][j + 1], dp[i + 1][j]));
	}

	ll i = lens;
	ll j = lent;
	string lcs = "";

	while(i > 0 && j > 0){
		if(dp[i][j] == dp[i - 1][j]) i--;
		else if(dp[i][j] == dp[i][j - 1]) j--;
		else{
			lcs += s[i - 1];
			i--; j--;
		}
	}

	REV(lcs);
	print(lcs);	

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





Measured memory_bytes: 74156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	int N;
	cin >> N;
	N = N%1000;

	if(N != 0){
		N = 1000 - N;
	}
	cout << N;

	cin >> N;
	
	return 0;	
}


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

int main()
{
	int w, n = 1;
	cin >> w;
	vector<int> vec(w);
	for (auto& x : vec) x = n++;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp = vec[a - 1];
		vec[a - 1] = vec[b - 1];
		vec[b - 1] = tmp;
	}
	for (auto x : vec) cout << x << "\n";
	cout.flush();
}

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

using namespace std;

int INF=1e9;

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

    long long n;
    cin>>n;

    vector<long long> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    
    sort(b.begin(),b.end());

    long long mid1=b[n/2-1],mid2=b[n/2];

    for(int i=0;i<n;i++){
        if(a[i]<=mid1)cout<<mid2<<endl;
        else if(mid2<=a[i])cout<<mid1<<endl;
    }
}

Measured memory_bytes: 5376
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    A, B = map(int, input().split())

    if (A+B)%2:
        print("IMPOSSIBLE")
    else:
        print((A+B)//2)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc135","a",main)

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

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
		if (w >= (x + r) && h >= (y + r) && !(x <0) && !(y < 0))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;
	return 0;
}

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

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

  ll s = 0;
  ll a = n;
  while (true) {
    ll b = a % 10;
    s += b;
    if (a < 10) break;
    a -= b;
    a /= 10;
  }
  if (n % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
   ll n,i,ans=0,j;
   cin>>n;
   vector<ll>v;
   for(i=2;i*i<=n;i++)
   {
       if(n%i==0)
       {
           ll a=0;
           while(n%i==0)
           {
               n/=i;a++;
           }
           v.push_back(a);
       }
   }
   if(n>=2)
   {
       v.push_back(1);
   }
   for(i=0;i<v.size();i++)
   {
       for(j=1;;j++)
       {
           if(v[i]>=j*(j+1)/2)
           {
               ans++;
           }
           else
           {
               break;
           }
       }
   }
   printf("%lld\n",ans);
}



Measured memory_bytes: 3728
import java.util.Scanner;

class Main
{
    public static void main(String[]args) {
        int H,A,n;
        n=0;
        Scanner sc=new Scanner(System.in);
        H=sc.nextInt();
        A=sc.nextInt();
        
        while(H>0){
            H-=A;
            n++;
        }
        System.out.println(n);
        sc.close();
    }
}

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

using namespace std;
const int N = 207;
const int M = 1024;
const int inf = (int)1E8;
int sea[N][N],land[N][N],dp[M][N],n,m,z[M];
#define REP(i,j,k) for(int i = j;i <= k;i ++)
int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int a,b,c;
    char ch;
    while(cin >> n >> m && (n + m)) {
        REP(i,1,n) REP(j,1,n) sea[i][j] = land[i][j] = i == j ? 0 : inf;
        REP(i,1,m) {
            cin >> a >> b >> c >> ch;
            if(ch == 'L') land[a][b] = land[b][a] = min(land[a][b], c);
            else sea[a][b] = sea[b][a] = min(sea[a][b], c);
        }
        REP(k,1,n) REP(i,1,n) REP(j,1,n) {
            sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);
            land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
        }
        int R;
        cin >> R;
        REP(i,1,R) cin >> z[i];
        REP(i,1,R) REP(j,1,n) dp[i][j] = inf;
        REP(i,1,n) dp[1][i] = sea[z[1]][i] + land[i][z[1]];
        REP(i,2,R) {
            REP(j,1,n) {
                REP(k,1,n) {
                    if(k != j)
                    dp[i][j] = min(dp[i][j], dp[i - 1][k] + sea[k][j] + land[z[i - 1]][k] + land[j][z[i]]);
                    else
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + land[z[i - 1]][z[i]]);
                }
            }
        }
        cout << *min_element(dp[R] + 1, dp[R] + 1 + n) << endl;
    }
    return 0;
}

Measured memory_bytes: 4252
n=int(input())
s=list(input())

nr=s.count('R')
ng=s.count('G')
nb=s.count('B')
ans=nr*ng*nb
cnt=0

for i in range(n-1):
  for j in range(i+1,n):
    k=2*j-i
    if k>=n or k<=j:
      continue
    if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
      cnt+=1
print(ans-cnt)

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

const int NR = 60;
int n,m,a[NR][NR];
bool flag[NR][NR];
char s[NR];

int check(int x,int y){
	int ret = 0;
	if(flag[x - 1][y])++ret;
	if(flag[x][y - 1])++ret;
	if(flag[x - 1][y - 1])++ret;
	if(flag[x + 1][y])++ret;
	if(flag[x][y + 1])++ret;
	if(flag[x + 1][y + 1])++ret;
	if(flag[x - 1][y + 1])++ret;
	if(flag[x + 1][y - 1])++ret;
	return ret;
}

int main()
{
	cin>>n>>m;
	for(int i = 1;i <= n;++i){
		scanf("%s",s);
		for(int j = 0;j <= m;++j)
			flag[i][j + 1] |= s[j] == '#';
	}
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= m;++j)
			if(flag[i][j])
				putchar('#');
			else
				cout<<check(i,j);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char [] S = in.next().toCharArray();
        char [] T = in.next().toCharArray();
        int iguales = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i] == T[i]){
                iguales++;
            }
        }
        System.out.println(iguales);
        
    }
    
}

Measured memory_bytes: 21716
import bisect

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i*(n-j)
print(ans)

Measured memory_bytes: 23360
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N;
	cin >> N;

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

		if( i != 0 ) {
			a[i] += a[i-1];
		}
	}

	long ans = LLONG_MAX;
	for( int i = 0; i < N-1; ++i ) {
		ans = min( ans, abs( a[i] - (a[N-1] - a[i]) ) );
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

int calc(const vector<int> &a) {
	int out = 0;
	for(auto &x: a) {
		out += out % 10 != 0 ? 10 - (out % 10) : 0;
		out += x;
	}
	return out;
}
int main() {

	vector<int> a(5);
	for(auto &x: a) cin >> x;

	sort(a.begin(), a.end());
	int out = 114514;
	for(bool f = true; f; f = next_permutation(a.begin(), a.end())) {
		out = min(out, calc(a));
	}

	cout << out << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int n=0;
  if(S.at(0)==S.at(1)){
    n++;
  }
  if(S.at(0)==S.at(2)){
    n++;
  }
  if(S.at(0)==S.at(3)){
    n++;
  }
  if(S.at(1)==S.at(2)){
    n++;
  }
  if(S.at(1)==S.at(3)){
    n++;
  }
  if(S.at(2)==S.at(3)){
    n++;
  }
  
  if(n==2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC126
{
    class Dist
    {
        public long nextvertex { get; set; }
        public long distance { get; set; }

        public Dist(long v, long d)
        {
            nextvertex = v;
            distance = d;
        }
    }

    class D
    {
        static bool[] Res;
        static List<Dist>[] list;

        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            Res = new bool[N];
            list = new List<Dist>[N];

            long[] input;
            long u = 0;
            long v = 0;
            long w = 0;
            for (long i = 0; i < N - 1; i++)
            {
                input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                u = input[0] - 1;
                v = input[1] - 1;
                if (input[2] % 2 == 0) w = 0;
                else if (input[2] % 2 == 1) w = 1;

                if (list[u] == null) list[u] = new List<Dist>();
                if (list[v] == null) list[v] = new List<Dist>();
                list[u].Add(new Dist(v, w));
                list[v].Add(new Dist(u, w));
            }

            DFS(0, 0, false);

            foreach (var item in Res)
            {
                Console.WriteLine(item ? "1" : "0");
            }
        }

        static void DFS(long now, long previous, bool check)
        {

            Res[now] = check;
            if (list[now] == null) return;

            foreach (var item in list[now])
            {
                if (item.nextvertex != previous) DFS(item.nextvertex, now, item.distance % 2 == 0 ? check : !check);
            }
        }
    }
}


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

using namespace std;

int solve(int n,int k){
	int cnt = 0;
	while(n/(int)pow(k,cnt)>0){
	 cnt++;
	}
	return cnt;
}


int main(){
  int n,k;
  cin>>n>>k;
  cout<<solve(n,k)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  int a[8];
  int year, moon, day;
  int j=0;
  for(int i=0; i<10; i++){
    if(i != 4 && i != 7){
      a[j] = s[i] - '0';
      j++;
    }
  }
  year = a[0]*1000 + a[1]*100 + a[2]*10 + a[3];
  moon = a[4]*10 + a[5];
  day = a[6]*10 + a[7];
  //if(year < 2019) cout << "Heisei" <<endl;
  //else if(year > 2019) cout << "TBD" <<endl;
  //else{
  if(moon <= 4) cout << "Heisei" <<endl;
  else cout << "TBD" <<endl;
  //}
  return 0;
}

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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD 998244353
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

long c[400100];

long inv(long a, long b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}

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

  long n, a, b, k;
  cin >> n >> a >> b >> k;

  c[0] = 1;
  FOR (i, 1, n+1) {
    c[i] = (((c[i-1] * (n-i+1)) % MOD) * inv(i, MOD)) % MOD;
  }
  long total = 0;
  for (long i = 0; i <= n; i++) {
    long soma = i * a;
    long aux = k - soma;
    if (aux < 0) continue;
    long x = c[i];
    if (aux % b == 0) {
      long j = aux / b;
      if (j > n) continue;
      x = (x * c[j]) % MOD;
      total = (total + x) % MOD;
    }
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	string s;
	int cnt = 0;
	cin >> s;
	Vi ans(s.size(), 0);
	VVi sum(s.size() + 2, Vi(2, 0));
	rep(i, s.size()) {
		// sum[i + 1][0] += sum[i][0];
		if (s[i] == 'R') {
			// sum[i + 1][0]++;
			cnt++;
		} else {
			// sum[i + 1][0] = 0;
			sum[i][0] = cnt;
			cnt       = 0;
		}
	}
	cnt = 0;
	rrep(i, s.size()) {
		// sum[i + 1][1] += sum[i + 2][1];
		if (s[i] == 'L') {
			// sum[i + 1][1]++;
			cnt++;
		} else {
			// sum[i + 1][1] = 0;
			sum[i + 2][1] = cnt;
			cnt           = 0;
		}
	}
	//rep(i, s.size() + 2) { clog << sum[i][0] << " " << sum[i][1] << endl; }
	rep(i, s.size() + 2) {
		if (sum[i][0] != 0) {
			ans[i - 1] += (sum[i][0] + 1) / 2;
			ans[i] += sum[i][0] / 2;
		}
		if (sum[i][1] != 0) {
			ans[i - 1] += (sum[i][1] + 1) / 2;
			ans[i - 2] += sum[i][1] / 2;
		}
	}
	rep(i, ans.size()) {
		cout << ans[i];
		if (i != ans.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 9260
#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, j, n) for(int i=j;i<n;i++)
#define COUT(n) cout<<(n)<<"\n"

typedef long long ll;
const int INF = 1e9;

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

    int r; cin >> r;
    COUT(3*r*r);

    return 0;
} 

Measured memory_bytes: 256
use std::io::Read;

const MAX: i64 = 100_001;
const MOD: i64 = 1_000_000_007;

fn rec(i: usize, n: usize, x: i64, s: &Vec<i64>, dp: &mut Vec<Vec<i64>>) -> i64 {
    if i == n {
        return x;
    }

    if dp[i][x as usize] < 0 {
        dp[i][x as usize] = rec(i + 1, n, x % s[i], s, dp) as i64;
        dp[i][x as usize] += (rec(i + 1, n, x, s, dp) * (n - i - 1) as i64) % MOD as i64;
        dp[i][x as usize] %= MOD;
        return dp[i][x as usize];
    }
    return dp[i][x as usize];
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();
    let x = iter.next().unwrap().parse().unwrap();
    let mut s: Vec<i64> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    s.sort_by_key(|&value| -value);

    let mut dp: Vec<Vec<i64>> = vec![vec![-1; MAX as usize]; n + 1];
    println!("{}", rec(0, n, x, &s, &mut dp));
}


Measured memory_bytes: 209148
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
    //system("chcp 65001");

    int a;
    string s;
    cin >> a >> s;

    if(a >= 3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    int ans;
    int realans = 2147483647;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    for (int i = 0; i <= x.at(x.size() - 1); i++) {
        ans = 0;
        for (int j = 0; j < n; j++) {
            ans += (x.at(j) - i) * (x.at(j) - i);
        }
        realans = min(realans, ans);
    }
    cout << realans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int n; cin >> n;
  vector<int> A(n), B(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];

  ll tmp = 0;
  rep(i, n) {
    int a = A[i], b = B[i];
    if(a == b) continue;

    if(a > b) {
      tmp += a - b;
    } else {
      tmp -= (b - a) / 2;
    }
  }

  if(tmp <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
  int n;
  cin>>n;
  int x[n];
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=n-1;i>=0;i--){
    if(i!=n-1)cout<<" ";
    cout<<x[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3068
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
 
        static void Main(string[] args)
        {
            var N = Slist()[0];
            var H = Slist();
            var dp = new int[N];
            
            dp[0] = 0;
            dp[1] = Abs(H[1] - H[0]);
            for (var i = 2; i < N; ++i)
                dp[i] = Min(Abs(H[i] - H[i - 1]) + dp[i - 1], Abs(H[i] - H[i - 2]) + dp[i - 2]);
            WriteLine(dp[N - 1]);
        }
    }
}


Measured memory_bytes: 19680
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <cstring>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int nx,ny,nr;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int a[100][100];
bool plot(int x, int y, int r, int n){
  int count = 0;
  bool flag = true;
  if((x+2*dx[r]>=0&&x+2*dx[r]<n)&&
      y+2*dy[r]>=0&&y+2*dy[r]<n&&a[x+2*dx[r]][y+2*dy[r]]==1)
    return false;
  x+=dx[r]; y+=dy[r];
  while((x>=0&&x<n)&&(y>=0&&y<n)){
    if((x+2*dx[r]>=0&&x+2*dx[r]<n)&&y+2*dy[r]>=0&&y+2*dy[r]<n&&a[x+2*dx[r]][y+2*dy[r]]==1) flag = false;
    a[x][y] = 1;
    x+=dx[r]; y+=dy[r];
    count++;
    if(!flag) break;
  }
  x-=dx[r];y-=dy[r]; nx=x; ny=y; nr=(r+1)%4;
  if(count<2) return false;
  return true;
}
int main(void){
  int d;
  cin>>d;
  while(d--){
    int n;
    cin>>n;
    memset(a,0,sizeof(a));
    a[0][n-1]=1;
    nx=0; ny=n-1; nr=3;
    while(plot(nx,ny,nr,n));
    if(n==2) a[1][0]=1;
    REP(i,n){
      REP(j,n)
        printf("%c",(a[j][i]==1)?'#':' ');
      cout << endl;
    }
    if(d)cout << endl;
  }
  return 0;
}

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

typedef long long ll;
const ll INF=1e16;
const ll MAX=11;
ll dist[MAX][MAX];

void init(int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            dist[i][j]=INF;
            dist[i][i]=0;
        }
    }
}

void warshall_floyd(int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
            }
        }
    }
}

int main(){
    int H,W;
    cin >> H >> W;
    init(10);
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            int c; cin >> c;
            dist[i][j]=c;
        }
    }
    warshall_floyd(10);
    ll res;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int a;
            cin >> a;
            if(a!=1&&a!=-1){
                res+=dist[a][1];
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
ans = 0
A, B, C, N = gets.split.map(&:to_i)
3001.times{|a|
  next if A * a > N
  3001.times{|b|
    next if A * a + B * b > N
    rest = N - A * a - B * b
    c = rest / C
    next if c * C != rest
    ans += 1
  }
}
p ans


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.answer"

int main() {
	ld a;
	while (cin >> a) {
		ld ans = a*7.81481481;
		cout << setprecision(22)<<fixed<<ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3256