akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read() {
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

ll mod;

struct M { ll a[3][3]; };
M operator * (const M &a, const M &b) {
	M c;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			c.a[i][j] = 0;
			for (int k = 0; k < 3; k++) {
				c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % mod) % mod;
			}
		}
	}
	return c;
}

M qp(M a, ll b) {
	M c;
	for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) c.a[i][j] = i == j;
	while (b) {
		if (b & 1) c = c * a;
		a = a * a;
		b >>= 1;
	}
	return c;
}

int main() {
	ll n = read(), a0 = read(), d = read(); mod = read();
	ll bit = 10, ans = 0;
	ll st = 0;
	for (int i = 1; i <= 19; i++) {
		ll l = st, r = n, p = -1;
		while (l + 1 < r) {
			ll mid = l + r >> 1;
			if (mid * d + a0 < bit) l = mid , p = mid;
			else r = mid;
		}
		if (l * d + a0 < bit) p = l;
		if (p != -1) {
			M a;
			a.a[0][0] = bit % mod; a.a[0][1] = a.a[1][1] = a.a[2][2] = 1LL;
			a.a[0][2] = a.a[1][0] = a.a[2][0] = a.a[2][1] = 0LL;
			a.a[1][2] = d % mod;
			a = qp(a, p - st + 1);
			ll ast = a0 % mod + d % mod * st % mod; ast %= mod; 
			ans = (ans * a.a[0][0] % mod + ast * a.a[0][1] % mod + a.a[0][2] % mod) % mod;
			st = p + 1;
		}
		if (st >= n) break;
		bit *= 10;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        int out;
        if(N % K == 0)
            out = 0;
        else 
            out = 1;
        System.out.println(out);
    }
}


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

int main(void){
int n,t,s,f,sum;
  while(cin >> t&&t){
    cin >> n;
    sum = 0;
    for(int i=0;i<n;i++){
      cin >> s >> f;
      sum += (f-s);
    }
    if(sum >= t){
      cout << "OK" << endl;
    }else{
      cout << t-sum << endl;
    }
  }
  return 0;
}


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

int main() {
    int w,h,n,l,r,u,d;
    cin>>w>>h>>n;
    l=d=0;
    r=w;
    u=h;
    int x,y,a;
    while (n--) {
        cin>>x>>y>>a;
        if (a==1)
            l=max(l,x);
        else if (a==2)
            r=min(r,x);
        else if (a==3)
            d=max(d,y);
        else
            u=min(u,y);
    }
    cout<<max(0,r-l)*max(0,u-d)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	long long n, ans = 0,min;
	cin >> n;
	vector<long long> p(n);
	for (long long i = 0; i < n; i++)
		cin >> p[i];

	for (long long i = 0; i < n; i++)
	{
		if (i == 0)
			min = p[i];
		else if (min < p[i])
		{
			continue;
		}

		min = p[i];

		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
function main(a){
	a=a.replace(/,/g," ");
	console.log(a);
	}
function op(a){
	console.log(a);
}
function stn(a){
		return a.map(function(x){return parseInt(x,10);});
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    long long int N,t1=0,t2=0;
    cin >> N;
    vector<long long int>   x(N),y;
    for(long long int i=0;i<N;i++)  cin >> x[i];
    copy(x.begin(),x.end(),back_inserter(y));
    sort(y.begin(),y.end());
    t1 = y[N/2-1];
    t2 = y[N/2];
    for(long long int i=0;i<N;i++){
        if(x[i]<=t1)    cout << t2 << endl;
        else   cout << t1 << endl;
    }
    return 0;
} 

Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1416
long long int t,i;
string s ,s1;

int main()
{cin>>t;
   cin>>s;
   if(t%2!=0)
   {
       cout<<"No"<<endl;
       return 0;
   }

for(i=0;i<s.size()/2;i++)
{
    if(s[i]!=s[s.size()/2+i])
    {cout<<"No"<<endl;
    return 0;}

}
cout<<"Yes"<<endl;
return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
    long long int N, D;
    long long int ans = 0;
    long long int X, Y;

    cin >> N >> D;
    
    for (long long int i = 0; i < N; i++) {
        cin >> X >> Y;
        if (X*X + Y*Y <= D*D) { 
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
A=input().split()
B=[]
for i in A:
 if i.isdigit():
  B.append(int(i))
 else:
  if i=="+":
   B[-1]=B[-2]+B[-1]
   del B[-2]
  elif i=="-":
   B[-1]=B[-2]-B[-1]
   del B[-2]
  elif i=="*":
   B[-1]=B[-2]*B[-1]
   del B[-2]
print(B[0])

Measured memory_bytes: 7704
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);

    vector<int> units(13, 0);
    units[0] = 1;

    for (int i = 1; i <= 6; i++) {
        units[2 * i - 1] = pow(6, i);
        units[2 * i - 0] = pow(9, i);
    }
    sort(units.begin(),units.end());


    vector<int> money(N + 1);
    int ans = 0;

    money[0] = 0;
    
    for (int i = 1; i <= N; i++) { // 1
        money[i] = money[i - 1] + 1;
    }

    for (int j = 1; j < 12; j++) {
        int unit = units[j];
        for (int i = unit; i <= N; i++) {
            money[i] = min(money[i], money[i - unit] + 1);
        }
    }

    cout << money[N] << "\n";

    return 0;
}

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

int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d and abs(b-c)<=d))
        cout<<"Yes";
    else
        cout<<"No";
}


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

ll N, V[30], C[30];

void solve() {
  ll res = 0;
  for (int i = 0; i < N; i++) {
    if (V[i] - C[i] > 0) {
      res += V[i] - C[i];
    }
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }

  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
def solve(n, s):
    l = {s[i]: i for i in range(n-1, -1, -1)}
    r = {s[i]: i for i in range(n)}
    S = set()
    for j in range(n):
        y = s[j]
        for x, i in l.items():
            for z, k in r.items():
                if i < j < k:
                    S.add(x+y+z)
    return len(S)

n = int(input())
s = input()
print(solve(n, s))

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


void solve(long long N, long long X, long long T){
  cout << (((N/X)+((N%X==0) ? 0 : 1)) * T) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long X;
  scanf("%lld",&X);
  long long T;
  scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3760
def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    A, B = [], []
    diff_progression = False
    min_B = float('INF')
    for i in range(N):
        a, b = get_next_ints()
        A.append(a)
        B.append(b)
        if a != b:
            diff_progression = True
        if a > b:
            min_B = min(min_B, b)
    if not diff_progression:
        print(0)
    else:
        ans = sum(A) - min_B
        print(ans)

solve()

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

int main() {
  string S; cin>>S;
  char a;
  bool flag = true;
  for(int i=0;i<S.length();i++){
    cin>>a;
    if(S[i]!=a){
      flag = false;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
	int X,ans=0,i=1,kai=0;
	
	scanf("%d",&X);
	
	while(kai<X){
		kai=kai+i;
		++i;
	}
	ans=i-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=1000010,mod=1000000007;
int n,f[N],sum=0,tmp=0;

inline int pls(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int mns(int a,int b){return a<b?a-b+mod:a-b;}
inline int mul(int a,int b){return (ll)a*b%mod;}

int main()
{
	n=rd();
	if(n<=2)return printf("%d\n",n*n),0;
	int ans=0;
	f[n]=1;sum=0;ans=pls(mul(f[n], mul(n-1, n-1)), mul(f[n], 2));
	of(i,n-1,1){
		f[i]=sum;
		f[i]=pls(f[i],f[i+1]);
		sum=pls(sum,f[i+2]);
		if(i>1)ans=pls(ans,pls(mul(f[i],mul(n-1,n-1)),mul(f[i],min(n-i+2,n-1))));
	}
	ans=pls(ans,mul(f[1],n));
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
int dp[100000][3],n,arr[100000][3];

int solve(int i,int j)
{
	if(j<0 || j>=3)
	{
		return 0;
	}
	if(i==n-1)
	{
		return arr[i][j];
	}
	if(dp[i][j]!=-1)return dp[i][j];
	

	dp[i][j]=max(solve(i+1,j-1),max(max(solve(i+1,j+1),solve(i+1,j+2)),solve(i+1,j-2)))+arr[i][j];
	
	return dp[i][j];
}

int main()
{

ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

cin>>n;
for(int i=0;i<n;i++)
{
	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
}

int l=INT_MIN;
for(int i=0;i<3;i++)
{
memset(dp,-1,sizeof(dp));
l=max(l,solve(0,i));
}

cout<<l;


}

Measured memory_bytes: 10368
N, M = map(int, input().split())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

div_list = make_divisors(M)
div_list = div_list[::-1]
for div in div_list:
    if N * div <= M:
        print(div)
        exit()


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

typedef long long ll;

const int MAXN = 2.1e5;
int N;
int A[MAXN];

const int MAXB = 4.2e5;
int bit[MAXB];

void reset() {
	memset(bit, 0, sizeof(bit));
}

void add(int a) {
	for (a += MAXN; a < MAXB; a += (a & -a)) {
		assert(a > 0);
		bit[a]++;
	}
}

int sum(int a) {
	int r = 0;
	for (a += MAXN; a; a -= (a & -a)) {
		assert(a > 0);
		r += bit[a];
	}
	return r;
}

ll S;

bool is_good(ll v) {
	reset();
	add(0);
	ll cnt = 0;
	int pref = 0;
	for (int i = 1; i <= N; i++) {
		if (A[i-1] <= v) pref++;
		ll val = 2 * pref - i;
		cnt += sum(val-1);
		add(val);
	}
	return cnt >= S;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	vector<int> sorted;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sorted.push_back(A[i]);
	}

	sort(sorted.begin(), sorted.end());
	sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end());
	S = ll(N) * (N+1) / 4 + 1;
	int mi = -1, ma = int(sorted.size()) - 1;
	while (ma - mi > 1) {
		int md = (mi + ma) / 2;
		if (is_good(sorted[md])) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << sorted[ma] << endl;

	return 0;
}

Measured memory_bytes: 2808
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem065a(x, a, b))
}

fun problem065a(x: Int, a: Int, b: Int): String {
    return when {
        b - a > x -> "dangerous"
        b - a > 0 -> "safe"
        else -> "delicious"
    }
}

Measured memory_bytes: 29348
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    
    vl v(k+1);  // v[x] : GCDがxになる組み合わせの数
    for(ll x = k; x >= 1; x--) {
        ll u = 0;
        for(ll i = 2*x; i <= k; i += x) {
            u += v[i];
            u %= mod;
        }
        v[x] = (modpow(k/x, n) + mod - u)%mod;
    }

    ll ans = 0;
    exrep(x, 1, k) {
        ans += x*v[x];
        ans %= mod;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int X;

void input() {
    cin >> X;
}

bool solve() {
    return X == 7 or X == 5 or X == 3;
}


int main() {
    input();
    cout << (solve() ? "YES" : "NO") << endl;;
    
    return 0;
}



Measured memory_bytes: 256
#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

typedef long long cat;

#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;
	int X[2];
	cin >> S >> X[0] >> X[1];
	vector<int> D[2];
	int dir =0, l =0;
	bool stX =(S[0] == 'F');
	for(int i =0; i < (int)S.length(); i++) {
		if(S[i] == 'F') l++;
		else {
			if(l) D[dir].push_back(l);
			l =0;
			dir ^=1;
		}
	}
	if(l) D[dir].push_back(l);
	
	for(int k =0; k < 2; k++) {
		vector<int> reach(2*S.length()+1,0);
		reach[S.length()] =1;
		for(int i =0; i < (int)D[k].size(); i++) {
			vector<int> reach_nw(2*S.length()+1,0);
			for(int j =0; j < 2*(int)S.length()+1; j++) if(reach[j]) {
				reach_nw[j+D[k][i]] =1;
				if(k == 0 && stX && i == 0) continue;
				reach_nw[j-D[k][i]] =1;
			}
			reach =reach_nw;
		}
		if(reach[X[k]+(int)S.length()] == 0) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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


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

using namespace std;

int main(){
    int N; long long C;
    while(cin >> N >> C){
        vector<long long> x(N), v(N);
        for(int i=0;i<N;i++) cin >> x[i] >> v[i];
        vector<long long> c1(N+1, 0), c2(N+1, 0);
        long long cur = 0;
        long long best = 0;
        long long prePos = 0;
        for(int i=0;i<N;i++){
            cur += v[i] - (x[i] - prePos);
            best = max(best, cur);
            c1[i+1] = best;
            prePos = x[i];
        }
        c2[0] = 0;
        cur = best = 0;
        prePos = C;
        for(int i=N-1;i>=0;i--){
            cur += v[i] - (prePos - x[i]);
            best = max(best, cur);
            c2[N-i] = best;
            prePos = x[i];
        }
        long long res = 0;
        for(int i=0;i<N;i++){
            res = max(res, c1[i+1]);
            res = max(res, c2[i+1]);
            res = max(res, c1[i+1] + c2[N-1-i] - x[i]);
            res = max(res, c2[i+1] + c1[N-1-i] - (C - x[N-1-i]));
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3328
N = int(input())
S = input()

flag = 1

if N%2==0:
    for i in range(int(N/2)):
        if S[i] != S[int(i+N/2)]:
            flag = 0
            break
    if flag == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
while true
	a,b = gets.chomp.split(" ").map &:to_i
	break if a == 0 and b == 0

	c = 0
	a.times { |i|
	    i += 1
		next if i >= b
		a.times { |j|
		    j += 1
			break if i+j >= b
			next if j <= i
			a.times { |k|
			    k += 1
				break if i+j+k > b
				next if k <= j or i+j+k < b
				#puts "i:#{i} j:#{j} k:#{k}"
				c += 1
			}
		}
	}

	puts c
end

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

map<lint, lint> cnt;

int main(){
    lint n, k; cin >> n >> k;
    for(lint i=0;i<n;i++){
        lint a, b; cin >> a >> b;
        cnt[a] += b;
    }

    for(auto it : cnt){
        k -= it.second;
        if(k<=0){
            cout << it.first << endl;
            return 0;
        }
    }
}


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

#define INF 900000000
#define LINF 9000000000000000000

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


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

	string s;
	cin >> s;
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


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

namespace ABC132B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int count = 0;
            //調べる対象はp[1]～p[n-2]
            for (int i = 1; i < n-1; i++)
            {
                if ((p[i-1]>p[i]&&p[i+1]<p[i])||(p[i-1]<p[i]&&p[i+1]>p[i]))
                {
                    count++;
                }
            }
            Console.WriteLine(count);

        }

    }
}


Measured memory_bytes: 13268
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;
  
  auto s=readln.chomp.to!(char[]);

  char[] t;
  foreach(c; s)if(c!='x') t~=c;
  bool ok=true;
  foreach(i; 0..(t.length/2)) ok&=(t[i]==t[$-i-1]);
  if(!ok){writeln(-1); return;}

  int cnt=0;
  int[] y;
  foreach(c; s){
    if(c=='x') cnt++;
    else y~=cnt, cnt=0;
  }
  y~=cnt;
  int sum=0;
  foreach(i; 0..(y.length/2)) sum+=(y[i]-y[$-i-1]).abs;
  writeln(sum);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 2840
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  while (cin>>N, N!=0) {
    if (N < 3) {
      cout << 1 << endl;
      continue;
    }

    int dp[N];
    dp[0] = 1;
    dp[1] = dp[0]+1;
    dp[2] = dp[1]+dp[0]+1; 
    for (int i = 3; i < N; i++) {
      dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
    }
    cout << ceil((dp[N-1]/10.0)/365.0) << endl;
  }  
}



Measured memory_bytes: 3184
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int dice[24][6] = {
	{0, 1, 2, 4, 3, 5}, {0, 2, 4, 3, 1, 5}, {0, 4, 3, 1, 2, 5}, {0, 3, 1, 2, 4, 5},
	{1, 5, 2, 0, 3, 4}, {1, 2, 0, 3, 5, 4}, {1, 0, 3, 5, 2, 4}, {1, 3, 5, 2, 0, 4},
	{2, 1, 5, 4, 0, 3}, {2, 5, 4, 0, 1, 3}, {2, 4, 0, 1, 5, 3}, {2, 0, 1, 5, 4, 3},
	{3, 1, 0, 4, 5, 2}, {3, 0, 4, 5, 1, 2}, {3, 4, 5, 1, 0, 2}, {3, 5, 1, 0, 4, 2},
	{4, 0, 2, 5, 3, 1}, {4, 2, 5, 3, 0, 1}, {4, 5, 3, 0, 2, 1}, {4, 3, 0, 2, 5, 1},
	{5, 1, 3, 4, 2, 0}, {5, 3, 4, 2, 1, 0}, {5, 4, 2, 1, 3, 0}, {5, 2, 1, 3, 4, 0}
};

map<vector<string>, bool> used;


int main(){
	vector<string> vs(6, "");
	vector<string> cs(6, "");
	int n, res;
	while(cin >> n && n ){
		res = 0;
		used.clear();
		rep(i, n){
			rep(j, 6) cin >> cs[j];
			rep(j, 24){
				rep(k, 6){
					vs[k] = cs[dice[j][k]];
				}
				if(used[vs]) res++;
				used[vs] = true;
			}
		}
		cout << res / 24 << endl;
	}
	return 0;
}

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

int main() {
   int p, q, r;
   cin >> p >> q >> r;

   cout << min({p+q, q+r, r+p}) << endl;
}

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

int main(){
  long n,m;cin>>n>>m;
  long st[n+5];
  vec a(m);
  rep(i,m)cin>>a[i];
  st[0]=1;

  for(int i=0;i<n;i++)st[i+1]=1;
  
  for(auto x:a)st[x]=0;
  
  for(int i=0;i<n;i++){
    if(st[i+2]==0)continue;
    st[i+2]=(st[i+1]+st[i])%1000000007;
  }

  
  cout<<st[n]<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
map<string,int> m;
int main() {
	int n; string s;
	long long ans=0;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin>> s;
		sort(s.begin(), s.end());
		m[s]++;
		ans+=m[s]-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
from sys import stdin
N=int(stdin.readline().rstrip())

data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

t=0
x=0
y=0
flag=True

for j in data:
    dist = abs(x-j[1]) + abs(y-j[2])
    if dist > j[0] - t:
        flag = False
    if dist == 0:
        flag = False
    if dist % 2 != (j[0] - t) % 2:
        flag = False
        
    t = j[0]
    x = j[1]
    y = j[2]
    
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21052
from itertools import product

N,M = map(int,input().split())

ABC = [list(map(int,input().split())) for i in range(N)]
ans = 0
for a,b,c in product([-1,1],repeat=3):
    score = []
    for x,y,z in ABC:
        score.append(x * a + y * b + z * c)
    score.sort(reverse=True)
    ans = max(ans,sum(score[:M]))

print(ans)


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

#define int long long

int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;

	if((n==1 && a!=b) || (a>b)){
		cout << 0 << endl;
		return 0;
	}	
	
	if(n==1 || n==2){
		cout << 1 << endl;
		return 0;
	}
	
	int mini=(n-2)*a;
	int maxi=(n-2)*b;
	
	cout << maxi-mini+1 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int H = sc.nextInt();
      int W = sc.nextInt();
      if (H == 0 && W == 0) {
        break;
      }
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
             if(i == 0 || i == H-1){
               System.out.print("#");
               }else{
                 if(j == 0 || j == W-1){
                   System.out.print("#");
                   }else{
                     System.out.print(".");
                     }
                     }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}



Measured memory_bytes: 32388
N = int(input())
s = []
c=[]
for i in range(N):
    s.append(int(input()))
d=sum(s)
if sum(s)%10!=0:
    print(sum(s))
else:
    for i in range(len(s)):
        if s[i]%10>0:
            c.append(s[i])
    if c==[]:
        print(0)
    else:
        print(d-min(c))


Measured memory_bytes: 3060
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
	"container/heap"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()
	j := make(jobs, n)

	for i := 0; i < n; i++ {
		j[i] = job{scanInt(),scanInt()}
	}

	sort.Sort(j)

	ans := 0
	h := &intHeap{}
	heap.Init(h)

	p := 0
	for i := 1; i < m+1; i++ {
		for p != n && j[p].a <= i{
			heap.Push(h, j[p].b)
			p++
		}
		// fmt.Println(h)
		if h.Len() != 0 {
			ans += heap.Pop(h).(int)
		}
	}

	fmt.Println(ans)
	
}

type job struct {
	a int 
	b int
}

type jobs []job

func (a jobs) Len() int           { return len(a) }
func (a jobs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a jobs) Less(i, j int) bool { return a[i].a < a[j].a }

type intHeap []int

func (a intHeap) Len() int           { return len(a) }
func (a intHeap) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a intHeap) Less(i, j int) bool { return a[i] > a[j] }

func (a *intHeap) Push(x interface{}) {
	*a = append(*a, x.(int))
}

func (a *intHeap) Pop() interface{} {
	old := *a
	n := len(old)
	x := old[n-1]
	*a = old[0:n-1]

	return x
}


Measured memory_bytes: 7168
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
LL n,a[MaxN + 5],b[MaxN + 5],c[MaxN + 5],cnt1[MaxN + 5], cnt2[MaxN + 5];

bool cmp(LL x, LL y){
	return x < y;
}

int main()
{
	scanf("%lld",&n);
	for(LL i = 1; i <= n; i++){
		scanf("%lld",&a[i]);
	}
	for(LL i = 1; i <= n; i++){
		scanf("%lld",&b[i]);
	}
	for(LL i = 1; i <= n; i++){
		scanf("%lld",&c[i]);
	}
	sort(a + 1, a + n + 1,cmp);
	sort(b + 1, b + n + 1,cmp);
	sort(c + 1, c + n + 1,cmp);
	LL l = 1, r = n;
	LL mid;
	for(LL i = 1; i <= n; i++){
		cnt1[i] = lower_bound(a + 1, a + n + 1,b[i]) - (a + 1);
	}
	for(int i = 1;i <= n; i++){
		cnt2[i] = n - (upper_bound(c + 1, c + n + 1,b[i]) - (c + 1));
	}
	LL sum = 0;
    for(int i = 1; i <= n; i++){
    	sum += cnt1[i] * cnt2[i];
	}
	printf("%lld\n",sum);
	return 0;
}






Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <utility>
#include <cctype>
using namespace std;


typedef map<vector<int>,int> expr_t;

void normalize(expr_t &e){
	expr_t::iterator it;
	for(it = e.begin(); it != e.end();){
		if( it->second ){
			++it;
		}
		else{
			e.erase(it++);
		}
	}
}


stringstream ss;


void mul(expr_t &e1, expr_t &e2){
	expr_t e3;
	expr_t::iterator it1, it2;

	for(it1 = e1.begin(); it1 != e1.end(); ++it1)
	for(it2 = e2.begin(); it2 != e2.end(); ++it2){
		vector<int> v = it1->first;
		for(int i = 0; i < 26; ++i){
			v[i] += it2->first[i];
		}
		
		e3[v] += it1->second * it2->second;
	}
	
	e1.swap(e3);
}


expr_t expr();
expr_t term();
expr_t power();
expr_t factor();

expr_t expr(){
	expr_t::iterator it;

	expr_t t = term();

	while(true){
		char ch = 0;
		ss >> ch;
		if( ch == '+' ){
			expr_t t2 = term();
			for(it = t2.begin(); it != t2.end(); ++it){
				t[it->first] += it->second;
			}
		}
		else if( ch == '-' ){
			expr_t t2 = term();
			for(it = t2.begin(); it != t2.end(); ++it){
				t[it->first] -= it->second;
			}
		}
		else{
			ss.unget();
			break;
		}
	}

	normalize(t);
	return t;
}

expr_t term(){
	expr_t::iterator it1, it2;

	expr_t p = power();

	while(true){
		char ch = 0;
		ss >> ch;

		if( ch == '(' || isalnum(ch) ){
			ss.unget();
			expr_t p2 = power();

			mul(p, p2);
		}
		else{
			ss.unget();
			break;
		}
	}
	
	normalize(p);
	return p;
}

expr_t power(){
	expr_t f = factor();
	
	while(true){
		char ch = 0;
		ss >> ch;

		if( ch == '^' ){
			int x;
			ss >> x;
			
			expr_t f2;
			f2.insert( make_pair(vector<int>(26), 1) );

			while( x-- ){
				mul(f2, f);
			}
			f.swap(f2);
		}
		else{
			ss.unget();
			break;
		}
	}
	
	return f;
}

expr_t factor(){
	char ch = 0;
	ss >> ch;

	expr_t ret;
	vector<int> v(26);
	
	if( ch == '(' ){
		ret = expr();
		ss >> ch;
	}
	else if( isdigit(ch) ){
		ss.unget();
		int x;
		ss >> x;
		if( x != 0 ) ret[v] = x;
	}
	else{
		v[ch - 'a'] = 1;
		ret[v] = 1;
	}
	
	return ret;
}


int main(){
	string str;
	
	while( getline(cin, str), str[0] != '.' ){
		ss.str(str);
		ss.clear();
		expr_t e1 = expr();

		while( getline(cin, str), str[0] != '.' ){
			ss.str(str);
			ss.clear();
			expr_t e2 = expr();

			if( e1 == e2 ){	cout << "yes\n";	}
			else{	cout << "no\n";	}
		}
		
		cout << ".\n";
	}
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[6];
int main()
{
	for(int i=0;i<3;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+3);
	if(a[0]==a[1]) printf("%d",a[2]);
	else printf("%d",a[0]);
	return 0;
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: VU.Vector Int -> VU.Vector Int
calc as = do
  let n = VU.length as
  let base = VU.generate (n + 1) (\x -> 0)
  let ds = VU.imap (\i a -> (maximum [0, i - a], 1)) as VU.++ VU.imap (\i a -> (minimum [n, i + a + 1], -1)) as
  VU.postscanl' (+) 0 (VU.init (VU.accumulate (+) base ds))

judge :: VU.Vector Int -> Int -> Int -> VU.Vector Int
judge as n 0 = as
judge as n k
  | VU.all (== n) as = as
  | otherwise = judge (calc as) n (k -1)

main = do
  [n, k] <- getIntList
  as <- getIntList
  let as' = VU.fromList as
  let as'' = judge as' n k
  mapM_ putStr (map (\x -> show x ++ " ") (VU.toList as''))


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

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println(Math.max(reader.nextInt() - reader.nextInt(), 0));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> A(N), B(N);
    int max_a = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        A[i] = a; B[i] = b;
        max_a = max(max_a, a);
    }

    sort(B.begin(), B.end(), greater<int>());

    int res = 0;
    for (int i = 0; i < N; i++) {
        if (B[i] < max_a) break;
        res++;
        H -= B[i];
        if (H <= 0) break;
    }

    if (H > 0) {
        res += (H + max_a - 1) / max_a;
    }
    
    cout << res << endl;
    return 0;
}

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

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = long long;

int main() {
  int n; cin >> n;
  vector<int> a(n), b(n), c(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  REP(i,n) cin >> c[i];
  whole(sort,a);
  whole(sort,c);
  ll ans = 0;
  REP(j,n) {
    auto itea = whole(lower_bound, a, b[j]);
    auto itec = whole(upper_bound, c, b[j]);
    ll ia = distance(a.begin(), itea);
    ll ic = distance(itec, c.end());
    ans += ia*ic;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;


int main() {
    ll N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int m,f,r;

	

	while (1) {
		scanf("%d %d %d", &m, &f, &r);

		if(m==-1&&f==-1&&r==-1) break;

		if (m == -1 || f == -1) {
			printf("F\n");
		}else if (m+f>=80) {
			printf("A\n");
		}else if (m+f>=65) {
			printf("B\n");
		}else if (m+f>=50||r>=50) {
			printf("C\n");
		}else if (m+f>=30) {
			printf("D\n");
		}else{
			printf("F\n");
		}

	}

	return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

LL W, H;
vector<pair<LL, char>> pqs;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> W >> H;
	rep (i, W) {
		LL w;
		cin >> w;
		pqs.pb(mp(w, 'w'));
	}
	rep (i, H) {
		LL h;
		cin >> h;
		pqs.pb(mp(h, 'h'));
	}
	sort(all(pqs));
	LL w = H + 1, h = W + 1;
	LL ans = 0;
	rep (i, pqs.size()) {
		pair<LL, char> pq = pqs[i];
		if (pq.second == 'w') {
			ans += pq.first * w;
			h--;
		} else {
			ans += pq.first * h;
			w--;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4464
#include "iostream"
#define endl '\n'

using namespace std;

int main() {
  int a, b, c, d = 0;
  int flag = 0;

  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;

  while (true) {
    c -= b;
    if (c <= 0) {
      flag = 1;
      break;
    }

    a -= d;
    if (a <= 0) {
      flag = -1;
      break;
    }
  }

  cout << (flag == 1 ? "Yes" : "No");

  return 0;
}

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

int n, q;
vector<int> a;

int main() {
	cin >> n >> q;
	string s;
	cin >> s;
	a = vector<int> (n, 0);
	for(int i = 1; i < n; i++){
		int x = 0;
		if(s[i] == 'C' && s[i - 1] == 'A') x = 1;
		a[i] = a[i - 1] + x;
	}
	for(int i = 0; i < q; i++){
		int x, y;
		cin >> x >> y;
		cout << abs(a[x - 1] - a[y - 1]) << "\n";
	}
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using lint = int64_t;
using namespace std;

#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define Rep(i, n) for (lint i = (n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

using P = pair<int, int>;
using D = pair<double, double>;
//constexpr lint mod = 998'244'353LL;
constexpr lint mod = 1000'000'007LL;
constexpr lint inf = 3LL * mod * mod;
const double Pi = 2.0 * acos(0.0);

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second << "\n"; }

constexpr bool pri(lint x) { for (lint i = 2; i * i <= x; ++i) if (x % i == 0) return false; return 1 < x; }

double dis(D a, D b) { return hypot(a.first - b.first, a.second - b.second); }

lint fact[3000000];
void fact_init(lint n) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
}

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

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod * modpow(fact[r], mod - 2, mod) % mod;
	return res < 0 ? res + mod : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

lint n;
unordered_map<lint, lint>mp;
int main() {
	cin >> n;
	for (lint i = 1; i * i <= n; i++) {
		for (lint j = 1; j * j <= n; j++) {
			for (lint k = 1; k * k <= n; k++) {
				mp[i * i + j * j + k * k + i * j + j * k + k * i]++;
			}
		}
	}
	rep(i, n) {
		cout << mp[i + 1] << endl;
	}
}

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

#define ll long long
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(v) (v).begin(),(v).end()

typedef pair<ll,ll> pi;

void solve()
{
    ll n,i,j,k,x,y,z;
    ll ac=0,wa=0,tle=0,re=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	if(s=="AC")
    	{
    		ac++;
		}
		else if(s=="WA")
		{
			wa++;
		}
		else if(s=="TLE")
		{
			tle++;
		}
		else
		{
			re++;
		}
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	
}

int main() {
	// your code goes here
	int t=1;
	//cin>>t;
	while(t--)
	{
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int flag=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			flag=1;
			break;
		}
		else if(i<s.size()-2&&s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3<<endl;
			flag=1;
			break;
		}
	}
	if(!flag)
	cout<<-1<<" "<<-1<<endl;
	return 0;	
} 

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

int main(){
    using namespace std;
  
    int a = 0;
    int b = 0;
    cin >> a >> b;

    int   d = a / b;
    int   r = a % b;
    double f = static_cast<double>(a) / static_cast<double>(b);

    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;

    return 0;
}

Measured memory_bytes: 1244
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector> 
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
vector<int> G[N],E[N];
int n,m,vis[N];
int d[N];
void dfs1(int u,int last) {
	vis[u]=1;
	for(int i=0;i<G[u].size();++i) {
		int v=G[u][i]; if(v==last) continue;
		if(vis[v]) {
			if(u>v) {
				printf("%d %d\n",u,v);
				d[u]^=1;
			}
		}
		else {
			dfs1(v,u);
			E[u].PB(v);
		}
	}
}
void dfs2(int u,int last) {	
	for(int i=0;i<E[u].size();++i) dfs2(E[u][i],u);
	if(last) {
		if(d[u]) printf("%d %d\n",u,last);
		else printf("%d %d\n",last,u),d[last]^=1;
	}
}
int main() {
	rd(n),rd(m);
	for(int x,y,i=1;i<=m;++i) rd(x),rd(y),G[x].PB(y),G[y].PB(x);
	if(m&1) { printf("-1"); exit(0); }
	dfs1(1,0);
	dfs2(1,0);
	return 0;
}

Measured memory_bytes: 22528
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    char c; cin >> c;
    if(c >= 'A' && c <= 'Z')cout << "A" << ln;
    else cout << "a" << ln;
}

Measured memory_bytes: 3632
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest-
#  Atcoder_Grand_Contest-
#  TODO https://atcoder.jp/contests/abc/tasks/abc_
import time
from contextlib import contextmanager
# from time import sleep
@contextmanager
def timer(title):
	t0 = time.time()
	yield
	print("{} - done in {:.0f}s".format(title,time.time()-t0) )

def  maxLevel(memberNumber,orgMemberLevelList):
	maxLevelSortedList = sorted(orgMemberLevelList,reverse=True)
	maxLevelScore = 0
	checkMemberCountRange = range(0,memberNumber,+1)
	for i in checkMemberCountRange:
		maxLevelScore = maxLevelScore+maxLevelSortedList[2*i+1]
	answer = maxLevelScore
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	levelNoSortList = list(map(int,input().strip().split(' ')))
	solution=maxLevel(N,levelNoSortList)
	print("{}".format(solution))

Measured memory_bytes: 37796
import heapq
x,y,z,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = []

hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    hqi,ai,bi,ci = heapq.heappop(hq)
    print(-hqi)
    if ai+1 < x and not (ai+1,bi,ci) in al:
        heapq.heappush(hq,(-(a[ai+1]+b[bi]+c[ci]),ai+1,bi,ci))
        al.append((ai+1,bi,ci))
    if bi+1 < y and not (ai,bi+1,ci) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi+1]+c[ci]),ai,bi+1,ci))
        al.append((ai,bi+1,ci))
    if ci+1 < z and not (ai,bi,ci+1) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi]+c[ci+1]),ai,bi,ci+1))
        al.append((ai,bi,ci+1))


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    cout << ((n-m)*100+m*1900)*(1<<m) << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
    def main(args: Array[String]): Unit = {
        val N = StdIn.readLine().split("")
        def modify(stringArray: List[String], string: String = ""): String = {
            stringArray match {
                case Nil => string
                case str :: tail => modify(tail, string + (str match {
                    case "1" => "9"
                    case "9" => "1"
                    case _ => str
                }))
            }
        }

        println(modify(N.toList))
    }
}


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

long long a[200000];
int compareInt(const void* a, const void* b)
{
	int aNum = *(int*)a;
	int bNum = *(int*)b;

	return aNum - bNum;
}

int main()
{
	int n;
	bool b;
	scanf("%d", &n);
	for (int i = 0; i != n; i++) {
		scanf("%lld", &a[i]);
	}
	qsort(a, n, sizeof(long long), compareInt);
	long long tmp = a[0];

	for (int i = 1; i != n; i++) {
		if (tmp == a[i]) {
			b = true;
			break;
		}
		else {
			tmp = a[i];
			b = false;
		}
	}
	if (b) {
		printf("NO");
	}
	else {
		printf("YES");
	}


	return 0;
}

Measured memory_bytes: 3324
def cal_digit_sum(x):
    res = 0
    for digit_val in str(x):
        res += int(digit_val)
    return res


def main():
    n, A, B = map(int, input().split())
    res = 0
    for i in range(1, n+1):
        res = res + (i if cal_digit_sum(i) >= A and cal_digit_sum(i) <= B else 0)
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060