akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	int N = S.length();
	vector< vector<int> > ans(N+1, vector<int>(4, 0));
	for(int i = 1; i <= min(3, N); i++) ans[i][i] = 1;
	for(int i = 1; i <= N; i++) for(int l = 1; l <= 3; l++) {
		if(l > i) continue;
		string sl = S.substr(i-l, l);
		for(int k = 1; k <= 3; k++) {
			if(i+k > N) break;
			if(k == l) {
				if(S.substr(i, k) == sl) continue;
			}
			ans[i+k][k] = max(ans[i+k][k], ans[i][l] + 1);
		}
	}
	cout << max(ans[N][1], max(ans[N][2], ans[N][3])) << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 11412
from collections import Counter


def comb(n, r):
    ans = 1
    for i in range(1, r+1):
        ans = ans * ((n + 1 - i) / i)

    return int(ans)


n = int(input())

a = list(map(int, input().split()))

d = [0]

for i in range(n):
    d.append(d[i]+a[i])

d.sort()

cd = Counter(d)
ans = 0
for k in cd.keys():
    if cd[k] >= 2:
        ans += comb(cd[k], 2)

print(ans)


Measured memory_bytes: 44192
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int X;cin >> X;
    if(X >= 400 && X <= 599) cout << 8 << endl;
    if(X >= 600 && X <= 799) cout << 7 << endl;
    if(X >= 800 && X <= 999) cout << 6 << endl;
    if(X >= 1000 && X <= 1199) cout << 5 << endl;
    if(X >= 1200 && X <= 1399) cout << 4 << endl;
    if(X >= 1400 && X <= 1599) cout << 3 << endl;
    if(X >= 1600 && X <= 1799) cout << 2 << endl;
    if(X >= 1800 && X <= 1999) cout << 1 << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);
    int a[m],i,sum=0;;
    for(i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++)
    {
        sum = sum + a[i];
    }

    if(n >= sum)
    printf("%d",n-sum);
    else
    printf("-1");
    return 0;
}

Measured memory_bytes: 1764
abcd = input()


for bit in range(1<<3):
  f = abcd[0]
  sum = int(f)
  for i in range(3):
    if bit & 1<<i:
      f += '+' + abcd[i+1]
      sum += int(abcd[i+1])
    else:
      f += '-' + abcd[i+1]
      sum -= int(abcd[i+1])
  
  if sum == 7:
    print(f + '=7')
    exit()

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

using i64 = long long;
using P = pair<i64, i64>;


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    vector<i64> pat(N);
    for(int i = 1; i <= N; ++i) pat[i - 1] = i;
    i64 a, b, cnt;
    cnt = 0;
    do{ 
        bool f1 = true, f2 = true;
        for(int i = 0; i < N; ++i){
            f1 &= P[i] == pat[i];
            f2 &= Q[i] == pat[i];
        }
        if(f1) a = cnt;
        if(f2) b = cnt;
        cnt++;
    }while(next_permutation(pat.begin(), pat.end()));
    cout << abs(a - b) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int** mat;
int M, N;

void display()
{
    for(int i = 0; i < M+1; i++)
    {
        for(int j = 0; j < N+1; j++)
        {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
}
void lcs(string s1, string s2)
{
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());

    M = s1.size();
    N = s2.size();

    mat = new int*[M+1];
    for(int i = 0; i < M+1; i++)
    {
        mat[i] = new int[N+1];
        for(int j = 0; j < N+1; j++)
        {
            mat[i][j] = 0;
        }
    }

    // length of s1
    for(int i = 0; i < M; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if(s1[i] == s2[j])
            {
                //increment
                mat[i+1][j+1] = mat[i][j] + 1;
            }
            else
            {
                mat[i+1][j+1] = max(mat[i+1][j], mat[i][j+1]);
            }
        }
    }
    // display();

    int lcs_len = mat[M][N];
    // cout << "lcs len: " << lcs_len << endl;
    
    if(lcs_len == 0)
    {
        cout << ' ' << endl;
        return;
    }

    //proceed to printing of word
    char word[lcs_len+1] = "";
    int end =  lcs_len-1;
    // word[end] = '\0';
    // end--;
    // cout << "end: " << end << endl;
    int i = M;
    int j = N;
    while(end >= 0)
    {
        if(mat[i][j-1] != mat[i][j] && mat[i-1][j] != mat[i][j])
        {
            word[end] = s1[i-1];
            cout << s1[i-1];
            i = i - 1;
            j = j - 1;
            end--;
        }
        else if(mat[i][j-1] == mat[i][j])
        {
            j--;
        }
        else if(mat[i-1][j] == mat[i][j])
        {
            i--;
        }
    }
    cout << endl;
    

} 

int main()
{
    string s1, s2;

    cin >> s1 >> s2;

    lcs(s1, s2);
}

Measured memory_bytes: 38792
n = input()
left = int(n[:2])
right = int(n[2:])

if 1 <= left <= 12:
    left_jd = 1
else:
    left_jd = 0

if 1 <= right <= 12:
    right_jd = 1
else:
    right_jd = 0

if left_jd == 1 and right_jd == 1:
    print('AMBIGUOUS')
elif left_jd == 1 and right_jd == 0:
    print('MMYY')
elif left_jd == 0 and right_jd == 1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
// Vicfred
// https://atcoder.jp/contests/abc175/tasks/abc175_e
// 
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long R, C, K;
    readf("%s %s %s", &R, &C, &K);
    readln;

    long[][] v = new long[][](R+1, C+1);
    long[][][] dp = new long[][][](R+1, C+1, 4);

    for(int i = 0; i < K; ++i) {
        int x, y, w;
        readf("%s %s %s", &x, &y, &w);
        readln;
        v[x][y] = w;
    }

    for(int i = 1; i <= R; ++i) {
        for(int j = 1; j <= C; ++j) {
            long newrow = max(
                    max(dp[i-1][j][0], dp[i-1][j][1]),
                    max(dp[i-1][j][2], dp[i-1][j][3]),
                    );
            dp[i][j][0] = max(dp[i][j-1][0], newrow);
            dp[i][j][1] = max(dp[i][j-1][1], max(newrow, dp[i][j-1][0]) + v[i][j]);
            dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + v[i][j]);
            dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + v[i][j]);
        }
    }

    long ans = long.min;
    for(int i = 0; i <= 3; ++i)
        ans = max(ans, dp[R][C][i]);

    ans.writeln;
}



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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());

    int res = 0;
    while(a[0]+2 <= a[2]) {a[0]+=2; res++;}
    while(a[1]+2 <= a[2]) {a[1]+=2; res++;}

    if(!(a[0]%2 == a[2]%2) || !(a[1]%2 == a[2]%2)) {
        if(a[0]%2 == a[1]%2) res++;
        else res += 2;
    }

    cout << res << endl;
    return 0;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ans = 1e18;
	for (int i = 1; i * 1LL * i <= n; i++) {
		if (n%i == 0) {
			ans = min(ans, i + n / i);
		}
	}
	cout << ans - 2 << E;
	//system("pause");
	return 0;
}

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

int main(){
    int n; cin >> n;
    bool f = true;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a%2 == 0){
            if(a%3 != 0 && a%5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
def lackSatisfaction(c, d, last):
    lack = 0
    max = 0
    mindex = 0
    for i in range(len(c)):
        tmp = c[i] * (d - last[i])
        lack += tmp
        if (max < tmp):
            max = tmp
            mindex = i
    return max, mindex

#365
D = int(input())
c = list(map(int, input().split()))

d = []
last = {}
for i in range(26):
    last[i] = 0

score = 0
for i in range(D):
    s = list(map(int, input().split()))
    rate = 0
    type = 0
    maxLack, mindex = lackSatisfaction(c, i + 1, last)
    for j in range(len(s)):
        if (rate < s[j]):
            rate = s[j]
            type = j + 1
    if (maxLack < rate):
        d.append(type)
    else:
        d.append(mindex + 1)
    last[d[i] - 1] = i + 1

for i in range(len(d)):
    print(d[i])


Measured memory_bytes: 9276
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

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

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s;
    cin >> s;

    int g = 0, p = 0;
    rep(i, s.size()){
      if(s[i] == 'g')++g;
      else ++p;
    }

    pri((g - p) / 2);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ld = long double;
const ld pi = acos(-1.0L);
int main(){
    ld a,b,x; cin >> a >> b >> x;
    if(a * a * b >  2 * x){
        // In this condition, watter bottle can rotate
        // It indicate that V can be Triangular prism.
        // so that 1/2 * a^2 * b is enought to rotate.
        ld rad = (pi / 2) - atan((2 * x) / (a * b * b) );
        ld res = (rad * 180) / pi;
        printf("%.10Lf\n", res);
    } else {
        //In this conditon, it can not be Triangular Prism.
        ld rad = atan((-2 * x  / (a * a * a) + (2 * b) / a));
        ld res = (rad * 180) / pi;
        printf("%.10Lf\n", res);
    }
}



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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

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

    int dp[n];
    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        int m = dp[i-1] + abs(h[i] - h[i-1]);
        for(int j = 2; j <= k; j++) {
            if(i-j < 0) break;
            m = min(m, dp[i-j] + abs(h[i] - h[i-j]));
        }
        dp[i] = m;
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;

const int V_MAX = 100000;

struct Edge {
	int v;
	int w;
};

int solve(vector<Edge> graph[],int v,int prev, int n,int& m) {
	int first = 0;
	int second = 0;

	for (int i = 0; i < graph[v].size(); i++) {
		if (graph[v][i].v == prev)continue;
		int res = solve(graph, graph[v][i].v, v, n + graph[v][i].w, m) + graph[v][i].w;

		if (second < res) {
			if (first < res) {
				second = first;
				first = res;
			}
			else {
				second = res;
			}
		}
	}

	m = max(m, first + max(n, second));

	return first;
}

int main() {
	int n;
	vector<Edge> graph[V_MAX];

	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int s, t, w;
		Edge e1, e2;
		scanf("%d%d%d", &s, &t, &w);
		
		e1.v = t; e1.w = w;
		e2.v = s; e2.w = w;

		graph[s].push_back(e1);
		graph[t].push_back(e2);
	}

	int m = 0;
	solve(graph, 0,0, 0,m);

	printf("%d\n", m);

	return 0;
}

Measured memory_bytes: 17476
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位


int main(void){
    ll n;
    cin >> n;
    ll a[n], b[n];
    for(ll i = 0; i < n; i++)   cin >> a[i];
    for(ll i = 0; i < n; i++)   cin >> b[i];
    ll check = 0;
    vector<ll> c;
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(a[i]<b[i]) {
            check += abs(a[i]-b[i]);
            ans++;
        }
        else c.push_back(a[i]-b[i]);
    }
    sort(c.begin(), c.end(), greater<ll>());
    ll sum = 0;
    //cout << check << endl;
    //cout << c.size() << endl;
    if(check>0){
        for(ll i = 0; i < c.size(); i++){
            sum+=c[i];
            if(sum>=check){
                ans+=(i+1);
                break;
            }
        }
    }
    //cout << sum << " " << check << endl;
    if(sum < check) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2808
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
long x[1<<17];
struct UF{
	int n;
	vector<int>parent,rank,cnt;
	vector<long>w;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0),w(n_),cnt(n_,0)
	{
		for(int i=0;i<n_;i++)
		{
			parent[i]=i;
			w[i]=x[i];
		}
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			w[b]+=w[a];
			cnt[b]+=cnt[a];
		}
		else
		{
			parent[b]=a;
			w[a]+=w[b];
			cnt[a]+=cnt[b];
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
};
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>x[i];
	UF uf(n);
	vector<pair<long,pair<int,int> > >G;
	for(int i=0;i<m;i++)
	{
		long y;int u,v;cin>>u>>v>>y;
		G.push_back(make_pair(y,make_pair(u-1,v-1)));
	}
	sort(G.begin(),G.end());
	for(int i=0;i<m;i++)
	{
		uf.unite(G[i].second.first,G[i].second.second);
		int u=uf.find(G[i].second.first);
		if(uf.w[u]<G[i].first)uf.cnt[u]++;
		else uf.cnt[u]=0;
	}
	int ans=0;
	for(int i=0;i<n;i++)if(i==uf.find(i))ans+=uf.cnt[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 5108
n, m ,c = map(int, input().split())
b = list(map(int, input().split()))

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

ans = 0
for i in range(n):
    t = 0
    for j in range(m):
        t += a[i][j] * b[j]

    if t + c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;
    if(s[i]!=s[i-1]) return g(i-1)+1;
    if(s[i]==s[i-1]) return g(i-3)+2;
}


int main(){
    ll  a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    cout<<min(a+b,2*c)*min(x,y)+min(a*max(0LL,x-y)+b*max(0LL,y-x),2*c*abs(y-x))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
 
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int s, b; cin>>s>>b;
	
	vector<int> bulb[b];
	for(int i=0; i<b; i++)
	{
		int k; cin>>k;
		while(k--)
		{
			int x; cin>>x; x--;
			bulb[i].push_back(x);
		}
	}
	vector<int> p(b);
	for(int &i : p) cin>>i;
	
	int nos = 1<<s;
	int ans = 0;
	for(int i=0; i<nos; i++)
	{
		vector<int> state(s, 0), bulb_ON(b, 0);
		int temp = i, j = 0;
		for(int j=0; j<s; j++)
		{
			if( 1<<j & i)
				state[j] = 1;
		}
		int cnt = 0;
		for(int j=0; j<b; j++)
		{
			int on = 0;
			for(int swich: bulb[j])
				on += state[swich];
			cnt += (on%2 == p[j]);
		}
		ans += cnt == b;
	}
	
	cout<<ans<<"\n";
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int c = 0;
    rep3(i, 1, n + 1) {
        if (SZ(to_string(i)) % 2 != 0) c++;
    }
    out(c);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    s = input()
    result = ''

    for si in s:
        if si == '0' or si == '1':
            result += si
        elif si == 'B':
            if len(result) != 0:
                result = result[:len(result) - 1]

    print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int mxn=6e5+5,mxm=2e5+5;
int n,m,c=1;string s;
int a[mxn],b[mxn],v[mxn];
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>s;m=s.size(),s=" "+s;
	for(int i=1;i<=n;++i,c*=3){
		int rev=0;
		for(int j=0;j<c;++j)for(int f=0;f<3;++f)b[j+f*c]=f;
		for(int j=1;j<=m;++j){
			if(s[j]=='R'){
				int lst=v[j];
				for(int f=0;f<3;++f){
					int p=lst+f*c;
					if(b[p]+rev==2)v[j]=p;
					(b[p]+=rev+1)%=3;
				}
			}else rev^=1;
		}
		for(int j=0;j<c;++j){
			int t=a[j];
			for(int f=0;f<3;++f){
				int p=j+f*c;
				a[p]=t+(rev?3-b[p]:b[p])%3*c;
			}
		}
	}
	for(int i=0;i<c;++i)cout<<a[i]<<' ';
}

Measured memory_bytes: 9276
n = int(input())
a,b = map(int,input().split())

res = a/n

count = 0
for i in range(a,b+1):
  if int(res)*n == i or int(res+1)*(n) == i:
    print("OK")
    exit()
  else:
    count += 1

if count == (b-a+1):
  print("NG")

Measured memory_bytes: 9192
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int D = in.i() * 2;
        int A = in.i();

        int[][] m = new int[N + 1][];
        for (int i = 0; i < N; i++) {
            m[i] = new int[]{in.i(), in.i()};
        }
        m[N] = new int[]{1 << 30, 0};
        Arrays.sort(m, (m1, m2) -> m1[0] - m2[0]);

        int[][] bomb = new int[N][];
        int pop = 0;
        int push = 0;

        long ans = 0;
        long extra = 0;

        for (int i = 0; i < N; i++) {
            int x = m[i][0];
            int h = m[i][1];

            while (pop < push) {
                int x2 = bomb[pop][0];
                int h2 = bomb[pop][1];
                if (x <= x2) break;
                extra -= h2;
                pop++;
            }
            h -= extra;

            if (h > 0) {
                int num = (h + A - 1) / A;
                ans += num;
                int attack = A * num;
                extra += attack;
                bomb[push++] = new int[]{x + D, attack};
            }
        }
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 50284
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  int n;
  if (100 <= N && N <= 999) {
    n = N % 10 % 10;
  }
  if (0 <= N && N <= 9) {
    n = N;
  }
  if (10 <= N && N <= 99) {
    n = N % 10;
  }
  switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
      break;
  }
  return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
struct Point { long double px, py; };
struct Segment { Point p1, p2; };
Point Minus(Point a, Point b) { return Point{ a.px - b.px,a.py - b.py }; }
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double dst(const Segment& a, const Point& b) {
	return dot(Minus(a.p2, a.p1), Minus(b, a.p1)) < 0.0 ? abs(Minus(b, a.p1)) : (dot(Minus(a.p1, a.p2), Minus(b, a.p2)) < 0.0 ? abs(Minus(b, a.p2)) : abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / abs(Minus(a.p2, a.p1))));
}
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = Minus(v[i], p), b = Minus(v[(i + 1) % v.size()], p);
		if (a.py > b.py) swap(a, b);
		if (a.py <= 0 && 0 < b.py)
			if (crs(a, b) < 0) in = !in;
		if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
vector<Point>x; int n;
long double solve(long double S) {
	long double L1 = -100000.0l, R1 = 100000.0l, d1, d2, maxn2 = -1000000000.0l;
	for (int i = 0; i < 200; i++) {
		d1 = (L1 + L1 + R1) / 3;
		d2 = (L1 + R1 + R1) / 3;
		long double cnt1 = 1000000000.0l, cnt2 = 1000000000.0l;
		Point P1 = Point{ S,d1 }, P2 = Point{ S,d2 };
		if (contain(x, P1) >= 1) {
			for (int j = 0; j < n; j++) {
				Segment L1 = Segment{ x[j],x[(j + 1) % n] };
				long double W3 = dst(L1, P1);
				cnt1 = min(cnt1, W3);
			}
		}
		else {
			cnt1 = -1000000000.0l;
			for (int j = 0; j < n; j++) {
				Segment L1 = Segment{ x[j],x[(j + 1) % n] };
				long double W3 = dst(L1, P1);
				cnt1 = max(cnt1, -1.0l*W3);
			}
		}
		if (contain(x, P2) >= 1) {
			for (int j = 0; j < n; j++) {
				Segment L1 = Segment{ x[j],x[(j + 1) % n] };
				long double W4 = dst(L1, P2);
				cnt2 = min(cnt2, W4);
			}
		}
		else {
			cnt2 = -1000000000.0l;
			for (int j = 0; j < n; j++) {
				Segment L1 = Segment{ x[j],x[(j + 1) % n] };
				long double W4 = dst(L1, P2);
				cnt2 = max(cnt2, -1.0l*W4);
			}
		}
		if (cnt1 < cnt2)L1 = d1;
		if (cnt1 > cnt2)R1 = d2;
		maxn2 = max(maxn2, max(cnt1, cnt2));
	}
	return maxn2;
}
int main() {
	while (true) {
		cin >> n; x.clear(); if (n == 0)break;
		for (int i = 0; i < n; i++) { Point AA; cin >> AA.px >> AA.py; x.push_back(AA); }
		long double L = -100000.0l, R = 100000.0l, c1, c2, maxn = 0.0l;
		for (int i = 0; i < 150; i++) {
			c1 = (L + L + R) / 3;
			c2 = (L + R + R) / 3;
			long double W1 = solve(c1), W2 = solve(c2);
			if (W1 < W2)L = c1;
			if (W1 > W2)R = c2;
			maxn = max(maxn, max(W1, W2));
		}
		printf("%.16Lf\n", maxn);
	}
	return 0;
}

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

const int64_t INF = 1e18;

int64_t calc(int64_t b, int64_t c, int64_t d, int64_t e){
  int64_t ret = max({b,c,d,e}) - min({b,c,d,e});
  if(b == 0 || c == 0 || d == 0 || e == 0){
    ret = INF;
  }
  return ret;
}


int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  int64_t ans = INF;
  
  vector<int64_t> sum(N);
  for(int i=0; i<N; i++){
    if(i == 0){
      sum[i] = vec[i];
    }
    else{
      sum[i] = sum[i-1] + vec[i];
    }
  }
  
  vector<int64_t>::iterator pos;
  for(int i=1; i<N-1; i++){ //どこの右側に仕切りを入れるか？
    int64_t B, C, D, E;
    int idx1, idx2;
    //左側
    int64_t L = (sum[i]+1)/2;
    pos = lower_bound(sum.begin(),sum.end(),L);
    idx1 = distance(sum.begin(),pos);
    //右側
    int64_t R = (sum[N-1] - sum[i]+1)/2;
    pos = lower_bound(sum.begin(),sum.end(),R + sum[i]);
    idx2 = distance(sum.begin(),pos);
    
    //0にならなければいい、パターン列挙
    B = sum[idx1];
    C = sum[i] - sum[idx1];
    D = sum[idx2] - sum[i];
    E = sum[N-1] - sum[idx2];
    ans = min(ans,calc(B,C,D,E));
    
    B = sum[max(0,idx1-1)];
    C = sum[i] - sum[max(0,idx1-1)];
    D = sum[idx2] - sum[i];
    E = sum[N-1] - sum[idx2];
    ans = min(ans,calc(B,C,D,E));
    
    B = sum[max(0,idx1-1)];
    C = sum[i] - sum[max(0,idx1-1)];
    D = sum[idx2-1] - sum[i];
    E = sum[N-1] - sum[idx2-1];
    ans = min(ans,calc(B,C,D,E));
    
    B = sum[idx1];
    C = sum[i] - sum[idx1];
    D = sum[idx2-1] - sum[i];
    E = sum[N-1] - sum[idx2-1];
    ans = min(ans,calc(B,C,D,E));
  }
  cout << ans << endl;
}

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

int n, p;
long long dp[2] = {1, 0};

int main() {
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x&1) {
            long long v = dp[0];
            dp[0] += dp[1];
            dp[1] += v;
        } else dp[0] += dp[0], dp[1] += dp[1];
    }
    cout << dp[p];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rp(a,b,c) for(long long a=b;a<=c;++a)
using namespace std;
ll v[100];
ll c[100];

int main()
{
	ll n;
	ll ans=0;
	cin>>n;
	rp(i,1,n)
		cin>>v[i];
	rp(i,1,n)
		cin>>c[i];
	rp(i,1,n)
		ans+=max(v[i]-c[i],1ll*0);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

#define N 3000
#define S 5001
int px[N], py[N];
int n;
char pillar[S][S];

void init(){
	int i, j;
	for( i = 0; i < S; i++ ){
		for( j = 0; j < S; j++ ){
			pillar[i][j] = 0;
		}
	}
	return;
}

int input(){
	int i, x, y;
	init();
	std::cin >> n;
	for( i = 0; i < n; i++ ){
		std::cin >> x >> y;
		pillar[x][y] = 1;
		px[i] = x;
		py[i] = y;
	}
	return n;
}

int func(){
	int area = 0, i, j, dx, dy, p3x, p3y, p4x, p4y;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < n; j++ ){
			if( i == j ){ continue; }
			//std::cout << i << "," << j << std::endl;
			dx = px[i] - px[j];
			dy = py[i] - py[j];
			p3x = px[j] + dy;
			p3y = py[j] - dx;
			p4x = px[i] + dy;
			p4y = py[i] - dx;
			//std::cout << px[i] << "," << py[i] << ":" << px[j] << "," << py[j] << ":";
			//std::cout << p3x << "," << p3y << ":" << p4x << "," << p4y << std::endl;
			if( p3x < 0 || p3y < 0 || p4x < 0 || p4y < 0 ){ continue; }
			if( p3x >= S || p3y >= S || p4x >= S || p4y >= S ){ continue; }
			if( pillar[p3x][p3y] == 1 && pillar[p4x][p4y] == 1 ){
				int s = dx*dx + dy*dy;
				area = (s>area?s:area);
			}
		}
	}
	return area;
}

int main(){
	while( input() > 0 ){ std::cout << func() << std::endl; }
	return 0;
}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int h,w,n;
	int x[101],y[101],a[101];
	int c[101][101]={};

	cin>>w>>h>>n;

	for(int i=1; i<n+1; i++){
		cin>>x[i]>>y[i]>>a[i];
	}
	for(int i=1; i<n+1; i++){
		if(a[i]==1){
			for(int j=1; j<h+1; j++){
				for(int k=1; k<x[i]+1; k++){
					c[k][j]=1;
				}
			}
		}else if(a[i]==2){
			for(int j=1; j<h+1; j++){
				for(int k=x[i]+1; k<w+1; k++){
					c[k][j]=1;
				}
			}
		}else if(a[i]==3){
			for(int j=1; j<y[i]+1; j++){
				for(int k=1; k<w+1; k++){
					c[k][j]=1;
				}
			}
		}else if(a[i]==4){
			for(int j=y[i]+1; j<h+1; j++){
				for(int k=1; k<w+1; k++){
					c[k][j]=1;
				}
			}
		}

	}
	int total=0;
	for(int j=1; j<h+1; j++){
		for(int k=1; k<w+1; k++){
			if(c[k][j]==0){
				total++;
			}
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

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

def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*(10**5)+2
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if k>n:
    k=n

ans=0
for i in range(k+1):
    ans+=cmb(n,i)*cmb(n-1,n-i-1)
    # print(ans)
    ans%=mod
print(ans%mod)

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

int main() {
  long long N;
  cin >> N ;
  long long count = 0;
  for (long long i=1; i<N+1; i++){
    if (i % 3 == 0 || i % 5 == 0){
      //cout << i << endl;
      continue;
    }
    else{
      count += i;
    }
  }
  cout << count << endl;
    
}


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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer Search(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

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

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = Search(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

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

  printList();

  return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  cout << (n-1)*(k-1) << endl;
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmin (T &a, T b) {return a > b ? a = b, 1 : 0; }
template <typename T> inline int Chkmax (T &a, T b) {return a < b ? a = b, 1 : 0; }
inline int read ()
{
	int sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 100 + 10;

int N, A[Maxn];

inline void Solve ()
{
	int sum = 0, ans = 0;
	for (int i = 1; i <= N + 1; ++i)
		if (A[i] == A[i - 1]) ++sum;
		else 
		{
			ans += sum / 2;
			sum = 1;
		}
	cout<<ans<<endl;
}

inline void Input ()
{
	N = read();
	for (int i = 1; i <= N; ++i) A[i] = read();
}

int main()
{
#ifdef hk_cnyali
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


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

int vectormax(vector<int> vec){
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    return vec.at(0);
}

int vectorsecond(vector<int> vec){
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    return vec.at(1);
}


int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for (int i=0;i<N;i++){
        cin>>A.at(i);
    }

    vector<int> answer(N);
    int uno;
    uno=vectormax(A);
    int due;
    due=vectorsecond(A);
    for(int i=0;i<N;i++){
        if(A.at(i)==uno){
            cout<<due<<endl;
        }
        else{
            cout<<uno<<endl;
        }
    }
}

Measured memory_bytes: 3952
#include <iostream>
#include<cstdio>
using namespace std;
int main(void){
   
   int n,b,f,r,v;
   int count[4][3][10];
   
    for(int i=0;i<4;i++){
       for(int j=0;j<3;j++){
          for(int k=0;k<10;k++){
            count[i][j][k]=0;
          }
        }
    }
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b>>f>>r>>v;
        count[b-1][f-1][r-1]+=v;
    }
     for(int i=0;i<4;i++){
       for(int j=0;j<3;j++){
          for(int k=0;k<10;k++){
            cout<<" "<<count[i][j][k];
          }
          cout<<endl;
        }
        if(i<3){
            cout<<"####################\n";
        }
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,ans;
int main(){
	n=read();m=read();
	if(m>=n)puts("unsafe");
	else puts("safe");
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, r, b;
string s;

signed main() {
	cin >> n >> s;
	each(i,s) (i=='R' ? r : b)++;
	cout << (r>b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (s.length() == 2) {
            System.out.println(s);
        }
        else {
            System.out.println(new StringBuilder(s).reverse().toString());
        }
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=205;
const long long ONE=1;
int N,K,Ans,vis[MAXN],Ok;
char c[MAXN];
int main(){
	scanf("%s%d",c+1,&K);
	N=strlen(c+1);
	if(N==1){
		printf("%d\n",K/2);
		return 0;
	}
	for(int i=2;i<=N;i++)
		if(c[i]!=c[i-1]){
			Ok=1;break;
		}
	if(!Ok){
		printf("%lld\n",ONE*N*K/2);
		return 0;
	}
	for(int i=1;i<=N;i++){
		if(vis[i])continue;
		if(c[i]==c[i+1]){
			vis[i+1]=1;
			Ans++;
		}
	}
	if(K==1){
		printf("%d\n",Ans);
		return 0;
	}
	if(vis[N]||c[N]!=c[1]){
		printf("%lld\n",ONE*Ans*K);
		return 0;
	}
	int cnt0=1,cnt1=1;
	for(int i=2;i<=N;i++)
		if(c[i]==c[i-1])cnt0++;
		else break;
	for(int i=N;i>=1;i--)
		if(c[i]==c[i-1])cnt1++;
		else break;
	int tr=K-1;
	if((cnt0+cnt1)%2==1)Ans--,tr++;
	printf("%lld\n",ONE*Ans*K+tr);
}
/*
ssiisssiis

ssiis 2

*/

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    vector<int> a(5);
    int k;
    REP(i, 5) {
        std::cin >> a[i];
    }
    std::cin >> k;

    std::cout << ((k < a.back() - a.front()) ? ":(" : "Yay!") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n,  A[100];

int solve(int i, int m){
    if(m == 0) return 1;
    else if(i >= n) return 0;

    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

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


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

    for(int i = 0; i < q;i++){
        if(solve(0, m[i]) == 1){
            printf("%s\n", "yes");
        } else{
            printf("%s\n", "no");
        }
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
std::vector<ll> ans;
ll arr[MAX];
map <ll,ll> cnt;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		cnt[arr[i]]++;
	}
	sort(arr,arr+n);
	for(int i=n-1;i>=0;i--)
	{
		if(cnt[arr[i]]>1)
		{
			cnt[arr[i]]-=2;
			ans.pb(arr[i]);
		}
		if(ans.size()>1)
			break;
	}
	if(ans.size()<2)
		cout<<0<<endl;
	else
		cout<<ans[0]*ans[1]<<endl;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int l,r;    // child
}node;
void Preorder(int);
void Inorder(int);
void Postorder(int);
node *T;
int main(){
  int n, i, x, root;
  scanf("%d",&n);
  T = (node *)malloc(sizeof(node) * n);
  for(i=0; i<n; i++) T[i].parent = -1;
  for(i=0; i<n; i++){
    scanf("%d",&x);
    scanf("%d%d",&T[x].l,&T[x].r);
    T[T[x].l].parent = T[T[x].r].parent = x;
  }
  for(i=0; i<n; i++){
    if(T[i].parent == -1){
      root = i;
      break;
    }
  }
  printf("Preorder\n");
  Preorder(root);
  printf("\nInorder\n");
  Inorder(root);
  printf("\nPostorder\n");
  Postorder(root);
  printf("\n");
  free(T);
  return 0;
}

void Preorder(int x){
  if(x != -1){
    printf(" %d",x);
    Preorder(T[x].l);
    Preorder(T[x].r);
  }
  return;
}

void Inorder(int x){
  if(x != -1){
    Inorder(T[x].l);
    printf(" %d",x);
    Inorder(T[x].r);
  }
  return;
}

void Postorder(int x){
  if(x != -1){
    Postorder(T[x].l);
    Postorder(T[x].r);
    printf(" %d",x);
  }
  return;
}

Measured memory_bytes: 616
import math
list1=list(map(int,input().split(" ")))
ln1=[1,2,3,4,5]
i=0
eee=0
for n in list1:
    if n-ln1[i]<0:
        eee=i
    i+=1
#print(eee)
if eee<4 and eee>0:
    print(int((list1[eee-1]+list1[eee+1])/2))
elif eee==4:
    print(list1[eee-1]+list1[eee-1]-list1[eee-2])
elif eee==0:
    print(list1[eee+1]-list1[eee+2]+list1[eee+1])

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

typedef long long int ll;

int main()
  
{
	ll n,min=1000000000000,ans=0;cin>>n;
  	vector<ll> a(n);
  for(auto &v : a)
    cin>>v;
  	for(int i=1;i<=100;i++)
    {
    	ll min1=0;
      	for(int j=0;j<n;j++)
        {
        	min1+=pow((i-a[j]),2);
        }
      if(min>min1)
      	min=min1;
    }
  cout<<min;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char s[105];
int main()
{
	scanf("%s",s);
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;

void main()
{
    foreach(line; stdin.byLine)
    {
        auto hw = line.chomp.split.map!(to!int);
        auto h = hw[0], w = hw[1];
        if(h == 0 && w == 0) return;

        foreach(i; 0 .. h){
            foreach(j; 0 .. w)
                write('#');
            writeln();
        }
        writeln();
    }
}

Measured memory_bytes: 1056
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
#define EPS 1e-10

double entropy(int s,int a,int c,vector<int> v){
	int freq[256]={};
	for(int i=0;i<v.size();i++){
		s = (a*s+c)&255;
		freq[(s+v[i])&255]++;
	}
	double res=0,n=v.size();
	for(int i=0;i<256;i++){
		if(!freq[i])continue;
		res -= freq[i]/n*log(freq[i]/n);
	}
	return res;
}

int main(){
	int n;
	while(cin>>n&&n){
		vector<int> v(n);
		for(int i=0;i<n;i++)cin>>v[i];
		double maxe=1e10;
		int anss,ansa,ansc;
		for(int s=0;s<=15;s++){
			for(int a=0;a<=15;a++){
				for(int c=0;c<=15;c++){
					double e=entropy(s,a,c,v);
					if(e+EPS<maxe){
						maxe=e;
						anss=s;
						ansa=a;
						ansc=c;
					}
				}
			}
		}
		cout<<anss<<' '<<ansa<<' '<<ansc<<endl;
	}
	return 0;
}

Measured memory_bytes: 1260