akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	int A,B,C,D;cin>>A>>B>>C>>D;
	if(B <= C || D <= A)cout<<0;
	else if(A <= C && C <= B && B <= D)cout<<B - C;
	else if(A <= C && D <= B)cout<<D - C;
	else if(C <= A && A <= D && D <= B)cout<<D - A;
	else if(C <= A && B <= D)cout<<B - A;
	
}


Measured memory_bytes: 256
# include <stdio.h>
#include <stdlib.h>
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a+b==c)
	{
		printf("Yes\n");
	}
	else 
	{
		if (b+c==a)
		{
			printf("Yes\n");
		}
		else 
		{
			if (c+a==b)
			{
				printf("Yes\n");
			}
			else 
			{ 
				printf("No\n");
			}
		}
	}
	system("pause");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main()
{
  for(int i=1; i<=3; i++)
  {
    cin>>a[i];
  }
  sort(a+1,a+4);
  cout<<a[1]+a[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

int main()
{
    int n,g=0;
    double d;
    cin>>n>>d;
    while(n--)
    {
        double x,y,s;
        cin>>x>>y;
        s=sqrt(x*x+y*y);
        if(s<=d)
        {
            g++;
        }
    }
    cout<<g<<endl;
}


Measured memory_bytes: 3764
#include<cstdio>
#include<cstring>

using namespace std;

int main(){
	char num[1001];
	
	while(1){
		scanf("%s",num);
		if(num[0] == '0') break;
		int sum=0;
		for(int i=0;i<strlen(num);i++){
			sum+=num[i]-'0';
			}
		printf("%d\n",sum);
		}
	return 0;
	}

			

Measured memory_bytes: 964
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int n;  cin >> n;
  vector<double> A(n);
  REP(i, n) cin >> A[i];
  double sum = 0.0;
  REP(i, n) sum += (1/A[i]);
  double ans = 1.0 / sum;
  cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int k;
	int n;
	cin >> k >> n;
	
	int first;
	int last;
	
	int maxdist = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (i == 0) {
			first = a;
		}
		
		maxdist = max(maxdist, a-last);
		last = a;
	}
	
	maxdist = max(maxdist, first+(k-last));
	
	cout << k-maxdist << endl;
  return 0;
}

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

int main() {
    int n, k;
    array<int, 1000> p;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> p[i];
    sort(p.begin(), p.begin() + n);
    cout << accumulate(p.begin(), p.begin() + k, 0) << endl;
}



Measured memory_bytes: 3580
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    for (int i=0;i<n;i++){
      s[i] = sc.next();
    }
    Map<Character,Integer> a = new HashMap<>();
    for (char i:s[0].toCharArray()){
      a.put(i,a.getOrDefault(i,0)+1);
    }
    Map<Character,Integer> da = new HashMap<>();
    for (int i=1;i<n;i++){
      da.clear();
      for (char j:s[i].toCharArray()){
        da.put(j,da.getOrDefault(j,0)+1);
      }
      List<Character> ac = new ArrayList<>(a.keySet());
      for (char k:ac){
        if (da.containsKey(k)){
          a.put(k,Math.min(a.get(k),da.get(k)));
        }else{
          a.remove(k);
        }
      }
      if (a.size() == 0) break;
    }
    List<Character> ac = new ArrayList<>(a.keySet());
    Collections.sort(ac);
    StringBuilder ans = new StringBuilder();
    for (char i:ac){
      for (int j=0;j<a.get(i);j++){
        ans.append(String.valueOf(i));
      }
    }
    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 23764
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
dis = []
for i in range(1, M):
  dis.append(abs(X[i] - X[i - 1]))

dis.sort()
if N >= M:
  print(0)
else:
  ans = 0
  for i in range(M - N):
    ans += dis[i]
  print(ans)

Measured memory_bytes: 13968
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define PI 3.14159265358979323846264338327950288
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

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

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

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

const int M = 1000005;

int main(void) {

	int N, ans = 0;
	cin >> N;
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	vector<int> ok(M);

	for (int x : A) {
		if (ok[x] != 0) {
			ok[x] = 2;
			continue;
		}
		for (int i = x; i < M; i += x) ok[i]++;
	}

	rep(i, N) {
		ans = (ok[A[i]]==1 ? ans + 1 : ans);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> a(H);
	for(auto &i:a)cin >> i;
	
	vector<string> r(H);
	vector<string> b(H);
	
	for(int i=0;i<H;i++){
		r[i]=b[i]=a[i];
		if(i%2==0){
			for(int j=0;j<W-1;j++)r[i][j]='#';
			b[i][W-1]='#';
		}
		else{
			for(int j=W-1;j>0;j--)b[i][j]='#';
			r[i][0]='#';
		}
	}
	for(int i=0;i<H;i++)cout << r[i] << endl;
	cout << endl;
	for(int i=0;i<H;i++)cout << b[i] << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll sum(ll l, ll r){
  return (l+r)*(r-l+1)/2;
}

int main() {
  int n,k;
  cin >> n >> k;
  mint ans = 0;
  for(int i = k;i<=n+1;i++){
    ll l = sum(0,i-1);
    ll r = sum(n-i+1,n);
    ans+=r-l+1;
  }
  cout<<ans.x<<endl;
  return 0;
}

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

int h,w;

int main(){
    while(true){
        cin>>h>>w;
        if(h==0&&w==0)return 0;
        else{
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((i+j)%2==0)cout<<"#";
                    else cout<<".";
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC151E solver = new ABC151E();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC151E {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      ModInt res = new ModInt(0);
      ModInt max = new ModInt(0);
      ModInt min = new ModInt(0);
      ModComb mc = new ModComb(100005);
      mc.makeFac();
      int n = in.nextInt();
      int k = in.nextInt();
      int[] ar = new int[n];
      for (int i = 0; i < n; i++) {
        ar[i] = in.nextInt();
      }
      Arrays.sort(ar);
      // ar[i]がminとなる集合はiより大きいn-1-iCk
      // ar[i]がmaxとなる集合はiより小さいiCk
      for (int i = 0; i < n; i++) {
        // out.println(mc.combFac(i, k - 1) + " " + mc.combFac(n - 1 - i, k - 1));
        max = max.add(new ModInt(ar[i]).mul(mc.combFac(i, k - 1)));
        min = min.add(new ModInt(ar[i]).mul(mc.combFac(n - 1 - i, k - 1)));
        // out.println(max + " " + min);
      }
      res = max.sub(min);
      out.println(res);
    }

  }

  static class ModInt {

    private static int MOD = 1000000007;
    long x;

    ModInt(int i) {
      this.x = i % MOD;
    }

    ModInt(long l) {
      this.x = l % MOD;
    }

    ModInt add(ModInt mi) {
      return new ModInt(this.x + mi.x);
    }

    ModInt sub(ModInt mi) {
      return new ModInt(this.x + MOD - mi.x);
    }

    ModInt mul(long i) {
      return new ModInt(this.x * i);
    }

    ModInt mul(ModInt mi) {
      return new ModInt(this.x * mi.x);
    }

    ModInt pow(int p) {
      ModInt res = new ModInt(1);
      ModInt tmp = this;
      while (p > 0) {
        if ((p & 1) == 1) {
          res = res.mul(tmp);
        }
        tmp = tmp.mul(tmp);
        p /= 2;
      }
      return res;
    }

    ModInt inv() {
      return this.pow(MOD - 2);
    }

    public String toString() {
      return Integer.toString((int) this.x);
    }

  }

  static class ModComb {

    int size;
    ModInt[] fac;
    ModInt[] inv;

    ModComb(int n) {
      size = n;
      fac = new ModInt[n + 1];
      inv = new ModInt[n + 1];
    }

    void makeFac() {
      for (int i = 0; i <= size; i++) {
        if (i == 0) {
          fac[i] = new ModInt(1);
        } else {
          fac[i] = fac[i - 1].mul(i);
        }
        inv[i] = fac[i].inv();
      }


    }

    ModInt combFac(int n, int k) {
      if (n < k) {
        return new ModInt(0);
      }
      return fac[n].mul(inv[k]).mul(inv[n - k]);
    }

  }
}



Measured memory_bytes: 96632
h, w = map(int, input().split())
lst = [input() for i in range(h)]

for i in range(h):
  for j in range(w):
    if lst[i][j] == "#":
      if lst[max(0, i-1)][j] == lst[min(h-1, i+1)][j] == lst[i][max(0, j-1)] == lst[i][min(w-1, j+1)] == ".":
        print("No")
        exit()
        
print("Yes")



Measured memory_bytes: 39280
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  int n; cin >> n;
  vi v(n);

  int sum = 0;
  int maxv = 0;

  rep(i, n){
    cin >> v[i];
    chmax(maxv, v[i]);
    sum += v[i];
  }

  if(sum - maxv > maxv)
    pr("Yes");
  else
    pr("No");
  
  return 0;
}


Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=200005;
const int maxm=30;
const int H=31;
ll l,r;
int n,len,len2; 
string s;
int cnt[maxn][maxm];
int hsh[maxn],power[maxn],z[maxn];
ll ans[maxm];

void Z_algorithm(){
	z[0]=0;
	int L=0,R=0;
	REP(i,n-1){
		if(R<=i){
			for(int j=0;i+j<n;j++)
			if(s[j]==s[i+j])z[i]++;
			else break;
			if(z[i])L=i,R=i+z[i]-1; 
		} 
		else{
			if(i>L&&i<R&&z[i-l]<=r-i)z[i]=z[i-l];
			else{
				z[i]=r-i;
				for(int j=r-i;i+j<n;j++)
				if(s[j]==s[i+j])z[i]++;
				else break;
				if(z[i])L=i,R=i+z[i]-1;
			}
		}
	}
}


bool same(int pos){
	int k1=hsh[pos-1],k2=hsh[n-1]-hsh[n-1-pos]*power[pos];
	return k1==k2;
}

inline vector<ll>add_vector(vector<ll>a,vector<ll>b){
	rep(i,26)b[i]+=a[i];
	return b;
}

ll solve(ll l_len,vector<ll>L,ll r_len,vector<ll>R,ll rest,vector<ll>&Ans){
	if(l_len+r_len<=rest){
		vector<ll>sum=add_vector(L,R);
		ll x=solve(l_len+r_len,sum,l_len,L,rest,Ans);
		rest=x;
	}
	if(l_len<=rest){
		Ans=add_vector(Ans,L);
		rest-=l_len;
	}
	return rest;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>s>>l>>r;
	l--;r--;
	s=s.substr(0,s.size()/2);
	n=s.size();
	
	rep(i,n){
		rep(j,26){
			if(s[i]-'a'==j)cnt[i][j]=!i?1:cnt[i-1][j]+1;
			else cnt[i][j]=!i?0:cnt[i-1][j];
		}
	}
	
	hsh[0]=s[0]-'a';power[0]=1;
	REP(i,n-1)hsh[i]=hsh[i-1]*H+s[i]-'a',power[i]=power[i-1]*H;
	REP(i,n-1)if(same(i))len=max(len,i);
	
//	Z_algorithm();
//	REP(i,n-1)if(z[i]+i==n)len2=max(len2,i);

	if(len==0){
		rep(j,26){
			ans[j]+=(ll)cnt[n-1][j]*(r/(ll)n)+(ll)cnt[r%(ll)n][j];
			if(l-1>=0)ans[j]-=(ll)cnt[n-1][j]*((l-1)/(ll)n)+(ll)cnt[(l-1)%(ll)n][j];
		}
		rep(j,26)cout<<ans[j]<<' ';
		return 0;
	}
	
	else{
		len=n-len;
		vector<ll>L(maxm),R(maxm);
		rep(i,26)L[i]=cnt[len-1][i];
		rep(i,26)R[i]=cnt[n-1][i]-cnt[len-1][i];
		vector<ll>Ans1(maxm),Ans2(maxm);
		ll x1=solve(len,L,n-len,R,r+1,Ans1);
		ll x2=solve(len,L,n-len,R,l,Ans2);
		rep(i,26){
			ans[i]+=Ans1[i]-Ans2[i];
			if(x1>=1)ans[i]+=(ll)cnt[x1-1][i];
			if(x2>=1)ans[i]-=(ll)cnt[x2-1][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	}
}

Measured memory_bytes: 13520
import math
a,b,n=map(int, input().split())
x=n%b
if n==0:
    print(0)
else:
    if x==0 or n>=b:
        x=b-1
    num1=math.floor((a*x)/b)
    num2=a*math.floor(x/b)
    print(num1-num2)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  int n;
  scanf("%d", &n);

  vector<pair<int, int>> works(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    works[i] = make_pair(b, a);
  }

  sort(works.begin(), works.end());

  bool r = true;
  int time = 0;
  for (int i = 0; i < n; i++) {
    // cout << works[i].first << "," << works[i].second << endl;

    int dl = works[i].first;
    int tm = works[i].second;

    time += tm;

    if (time > dl) {
      r = false;
      break;
    }
  }

  cout << (r ? "Yes" : "No") << endl;
}



Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int x,y;

while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) break;
        if(x > y){
         printf("%d %d\n",y,x);
        }else{
            printf("%d %d\n",x,y);
        }
    }
}



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

#define pb push_back
#define fst first
#define scd second
#define all(x) x.begin(), x.end()
#define N int(1e6+10)
#define mkp make_pair

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef list<int> li;
typedef list<ll> llong;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

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

ll lcm(ll a, ll b){
	ll g=gcd(a,b);
	return (a/g)*b;
}

ll inv_mod(ll a, ll b){
	ll x=0, y=1, r, q, ta=a;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=ta;
	return x%ta;
}

int main(){
	string s;
	cin>>s;
	int j=s.length()-1, i=0;
	int ans=0;
	while(i<j){
		if(s[i]!=s[j]){
			if(s[i]=='x'){
				ans++;
				i++;
			}else if(s[j]=='x'){
				ans++;
				j--;
			}else{
				ans=-1;
				break;
			}
		}else{
			i++;
			j--;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int, input().split()))
ans=0
hight=a[0]
if n==1:
  print(0)
  exit()
for i in range(1,n):
  if a[i]<hight:
    ans+=hight-a[i]
  else:
    hight=a[i]
print(ans)

Measured memory_bytes: 32364
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 1e4+5;
const int MOD = 1e9+7;


string S;
int D;
ll dp[MSIZE][2][105];

ll solve(int i,int bd,int sum) {
    if(i==S.length())   return sum%D==0;
    if(dp[i][bd][sum]!=-1)  return dp[i][bd][sum];
    ll ans = 0;
    f(j,0,(bd?(S[i]-'0'):9)) {
        ans+=solve(i+1,bd and j==(S[i]-'0'),(sum+j)%D);
        ans%=MOD;
    }
    return dp[i][bd][sum] = ans;
}
int main(){

    FIO
    cin>>S>>D;
    memset(dp,-1,sizeof(dp));
    cout<<(solve(0,true,0)-1+MOD)%MOD<<endl;

    return 0;

}
    


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}

int main()
{
	fio
	string s;
	cin>>s;
	int d;
	cin>>d;
	int n=s.size();
	vector<vector<ll int>>D(n,vector<ll int>(d,0));
	for(int i=0;i<int(s[0])-48;++i)
	{
		D[0][(i)%d]+=1;
	}
	int cr=(int(s[0])-48)%d;
	for(int i=0;i<n-1;++i)
	{
		for(int j=0;j<d;++j)
		{
			for(int x=0;x<10;++x)
			{
				D[i+1][(x+j)%d]=(D[i+1][(x+j)%d]+D[i][j])%md;
			}
		}
		for(int j=0;j<int(s[i+1])-48;++j)
		{
			D[i+1][(cr+j)%d]=(D[i+1][(cr+j)%d]+1)%md;
		}
		cr=(cr+int(s[i+1])-48)%d;
	}
	D[n-1][cr%d]=(D[n-1][cr%d]+1)%md;
	cout<<((D[n-1][0]-1)%md +md)%md<<"\n";
	return 0;
}

Measured memory_bytes: 11384
#include <iostream>
    #include <cstdlib>
    #include <algorithm>
    #include <cmath>
    #include <vector>
    #include <set>
    #include <map>
    #include <unordered_set>
    #include <unordered_map>
    #include <queue>
    #include <cstring>
    #include <climits>
    using namespace std;
    #define ll long long
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define sz(x) (int)(x.size())
    #define all(x) (x).begin(),(x).end()
    template<typename tp> void read(tp &x) {cin >> x;}
    template<typename tp, typename... Args> void read(tp& x, Args&... args) {read(x);read(args...);}
    const int mxN = (int)1e5,INF = (int)1e9,MOD = 998244353;
     
    ll rnge(ll l,ll r,vector<ll> &sum)
    {
    	return sum[r]-sum[l-1];
    }
    bool comp(pair<ll,ll> &a,pair<ll,ll> &b)
    {
    		if(a.first == b.first)return a.second < b.second;
    		return a.first<b.first;
    }
    void solve()
    {
    	ll n,k;
    	read(n,k);
    	vector<pair<ll,ll>> segm(k);
    	FOR(i,k) read(segm[i].first,segm[i].second);
    	sort(all(segm),comp);
    	vector<pair<ll,ll>> S;
    	for(int i=0;i<k;i++)
    	{
    		if(S.empty())
    		{
    			S.push_back(segm[i]);
    			continue;
    		}
    		pair<int,int> a = S.back(),b = segm[i];
    		if(a.first == b.first)
    			S.back() = b;
    		else if(b.first<=a.second)
    			S.back().second = b.second;
    		else S.push_back(b);	
    	}
    	vector<ll> dp(n+1),sum(n+1);
    	dp[1] = 1;
    	sum[1] = 1;
    	for(int i=2;i<=n;i++)
    	{
    		dp[i] = 0;
    		FOR(j,sz(S))
    		{
    			if(i-S[j].first<1LL)break;
    			ll temp;
    			if(i-S[j].second>0)
    				temp = (sum[i-S[j].first]-sum[i-S[j].second-1]+MOD)%MOD;
    			else
    			temp = sum[i-S[j].first];
    			dp[i] = (dp[i]%MOD+temp%MOD)%MOD;
    		}
    		sum[i] = (dp[i]%MOD+sum[i-1]%MOD)%MOD;
    	}
    	cout << dp[n] << '\n';
    }
     
    int main()
    {
    	ios_base::sync_with_stdio(0);
    	cin.tie(0);
    	int test = 1;
    	//read(test);
    	while(test--)
    		solve();
    	return 0;
    }


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define go(i,s) for(int i = head[s]; i; i = e[i].next)
#define pb push_back
#define mp make_pair

int x, l, r, mid, ans;

int main()
{
	cin >> x;
	l = 1; r = x;
	while(l <= r)
	{
		mid = l+r >> 1;
		if((long long)(mid+1)*mid/2ll>=x) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
      Scanner scan = new Scanner(System.in);
//      scan = new Scanner("4 3\n" +
//              "1 2 3 4\n" +
//              "1 3\n" +
//              "2 3\n" +
//              "2 4");
//
//        scan = new Scanner("6 5\n" +
//                "8 6 9 1 2 1\n" +
//                "1 3\n" +
//                "4 2\n" +
//                "4 3\n" +
//                "4 6\n" +
//                "4 6");

      int N = scan.nextInt();
      int M = scan.nextInt();
      int []heights = new int[N];
      boolean[]peaks = new boolean[N];
      for(int i=0; i<N;i++){
          peaks[i]= true;
      }

      for(int i=0;i<N;i++){
          heights[i] = scan.nextInt();
      }

      for(int i=0;i<M;i++){
          int a = scan.nextInt()-1;
          int b = scan.nextInt()-1;

          if(heights[a] <= heights[b]){
              peaks[a] = false;
          }
          if(heights[b] <= heights[a]){
              peaks[b] = false;
          }
      }

      int count = 0;
        for(boolean b: peaks){
            if(b){
                count++;
            }
        }

        System.out.println(count);


    }
}

Measured memory_bytes: 61048
n = gets.to_i
words = []

n.times do 
  words.push(gets.chomp)
end

success_flag = true

(n-1).times do |i|
  if words[i][-1] != words[i+1][0]
    success_flag = false
  end
end

if success_flag && n == words.uniq.length
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std; 

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
template <typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;


typedef     long long                            ll; 
typedef     long double                          ld; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;
 
#define FOR(a, b, c) for (int(a) = (b); a < c; a++) 
#define FORD(a, b, c) for (int(a) = (b); a >= c; a--)  
 
#define rep(i, n) FOR(i, 0, n) 
#define repN(i, n) FOR(i, 1, n+1) 
#define repD(i, n) FORD(i, n-1, 0)
#define trav(i, a) for(auto i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define pe pop_back
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i, sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

int main(){
	int n; cin>>n;
	vl h(n); get(h);
	vl dp(n,1e9); dp[0]=0; 
	rep(i,n-1){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		if(i+2<n)dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    int c = count(s.begin(), s.end(), 'o');

    cout << 700 + 100 * c << endl;

    return 0;
}

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

int main(){
    int n,a; cin >> n;long int sum = 0; int max = -1000000; int min = 1000000;
    
    for(int i = 0; i < n; ++i){
        cin >> a;
        sum = sum + a;
        if(a > max){
            max = a;
        }
        if(a < min){
            min = a;
        }
    }
    
    cout << min << " " << max << " " << sum << endl;
    return 0;
}

Measured memory_bytes: 3096
def f(n):
    if n <= 0:
        return 1
    return 2**(n-1)

s = input()

score = 0
for blocksize in range(1,len(s)+1):
    for startpoint in range(len(s)):
        if startpoint+blocksize >= (len(s)+1): continue
        block = s[startpoint:startpoint+blocksize]  
        ss = int(block) * f(startpoint) * f(len(s) - (startpoint+blocksize))
        # print("{} ({}, {}): {}".format(block, startpoint, len(s) - (startpoint + blocksize), ss))
        score += ss
print(score)
exit()

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,ans=1;
ll a[nmax],dp[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<n;i++)
	{
		dp[i]+=dp[i-1]+a[i];
		if(a[i+1]>2*dp[i])ans=i+1;
	}
	cout<<n-ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008





#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll n,k,m,s=0;
    cin>>n;
    m=MAX;
    for(int i=0; i<n; i++){
        cin>>k;
        s+=k;
        if(k%10){
            m=min(m,k);
        }
    }
    if(s%10==0)
        cout<<max(0ll,s-m);
    else cout<<s;

    return 0;
}


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

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0}, dj[4] = {0, 1, 0, -1};

typedef struct {int to, w;} Edge;
typedef struct {Edge *elem; int cap, size;} VecEdge;
typedef struct {int num, d;} PNumDis;

VecEdge adj[3600];
PNumDis heap[14400];
int hsize;
int d[3600];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;
	int w, h;

	while (scanf("%d %d", &w, &h), w) {
		int s[30][30];
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", s[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);
		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == s[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));

		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1036
s = input()
t = input()
n_t = len(t)
n_s = len(s)
ans = n_s
for i in range(n_s):
    if i+n_t <= n_s:
        time = 0
        for j in range(n_t):
            if s[i+j] != t[j]:
                time+= 1
        ans = min(ans,time)
print(ans)


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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] time = new int[n];
        for(int i=0;i<n;i++){
        	time[i] = sc.nextInt();
        }

        long now = 0;
        long ans = 0;
        for(int i=0;i<n;i++){
        	if(now>time[i]){
        		ans +=  t - (now - (long)time[i]);
        		now = t + time[i];
        	}
        	else{
        		ans += t;
        		now = t + time[i];
        	}
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 66840
#include<iostream>
#define MAXN 200100
using namespace std;
int n,p[MAXN],t[MAXN],f[MAXN],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]),t[p[i]]=i;
	for(int i=1;i<=n;i++)
		if(t[p[i]-1]<t[p[i]])f[p[i]]=f[p[i]-1]+1;
		else f[p[i]]=1;
	for(int i=1;i<=n;i++)ans=max(ans,f[i]);
	cout<<n-ans;
	return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int W, H;
int sx, sy;
int ans;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
vector<vector<char>>  field;

bool is_out_of_range(int x, int y) {
    return x < 0 || x >= W || y < 0 || y >= H;
}

void dfs(int x, int y) {
    if (is_out_of_range(x, y)) return;
    if (field[y][x] == '#') return;

    field[y][x] = '#';
    ans++;

    for (int i = 0; i < 4; ++i) {
        dfs(x + dx[i], y + dy[i]);
    }
    return;
}

int main() {
	while(cin >> W >> H, W) {
        ans = 0;
        field.assign(H, vector<char>(W));
        for (int y = 0; y < H; ++y) {
            for (int x = 0; x < W; ++x) {
                cin >> field[y][x];
                if (field[y][x] == '@') {
                    sx = x; sy = y;
                }
            }
        }
    
        dfs(sx, sy);
        cout << ans << endl; 
	}
	return 0;
}

Measured memory_bytes: 3056
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


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

const int N = (int) 1e5 + 10;
const int inf = (int) 2e9 + 10;

long long arr[N];

int main() {
//    freopen("in.txt", "r", stdin);
    int n; scanf("%d", &n);
    string s; cin >> s;
    char last = '@';
    int ans = 0;
    for (char c: s) {
        if (c != last) {
            ans += 1;
        }
        last = c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()

    while "B" in s:
        index = s.index("B")
        if index == 0:
            s = s.replace("B","",1)
        else:
            before = s[index-1]
            delete = before+"B"
            s = s.replace(delete,"",1)
    print(s)
main()            


Measured memory_bytes: 74556
yohou = list(input())
jissai = list(input())
ans = 0

if yohou[0] == jissai[0]:
  ans = ans + 1
if yohou[1] == jissai[1]:
  ans = ans + 1
if yohou[2] == jissai[2]:
  ans = ans + 1
  
print(ans)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int INF=1e9;
//const int MOD=1e9+7;
const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"-1"<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N),ans(N,0);
  for(int i=0;i<N;i++)cin>>v[i];
  int ma=0;
  std::vector<int> w;
  for(int i=0;i<N;i++){
    if(v[i]>ma){
      ma=v[i];
      w.push_back(i);
    }
  }
  int K=w.size();
  int now=0;
  std::vector<int> sumv(K,0),sumn(K,0);
  //sumv[i]はans[w[i]]にのみ迷惑のかかる値の合計 (v[w[i-1]],v[w[i]]]が対象
  //sumn[i]はans[w[i]]にのみ迷惑のかかる場所の合計
  //cout<<w[0]<<endl;
  int nnow=K-1;
  for(int i=N-1;i>=0;i--){
    if(v[i]<=v[w[0]])continue;
    if(i==w[nnow]){
      sumn[nnow]++;
      sumv[nnow]+=v[w[nnow]]-v[w[nnow-1]];
      nnow--;
      continue;
    }
    int l=0,h=K;
    while(h-l>1){
      int m=(h+l)/2;
      if(v[i]>v[w[m]])l=m;
      else h=m;
    }
    //cout<<i<<" "<<l<<endl;
    sumv[h]+=v[i]-v[w[l]];
    sumn[h]++;
  }
  int num=0;
  //cout<<"-------"<<endl;
  //for(int i=0;i<K;i++)cout<<sumv[i]<<" "<<sumn[i]<<endl;
  //cout<<"-------"<<endl;
  for(int i=K-1;i>0;i--){
    ans[w[i]]=sumv[i];
    if(i!=K-1)ans[w[i]]+=num*(v[w[i]]-v[w[i-1]]);
    num+=sumn[i];
  }
  int sum=0;
  for(int i=0;i<N;i++)sum+=v[i];
  for(int i=0;i<N;i++)sum-=ans[i];
  ans[w[0]]=sum;
  for(int p:ans)cout<<p<<endl;
}


Measured memory_bytes: 5108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=81e4,M=N<<1;

int la[N],ne[M],lb[M];
int B[M];

int n,k,oo;

int f1[N],f2[N];
int X[N];
int ans[N],y[N];

int r1,r2,R,ok=1;

inline void llb(int a,int b)
{ne[++oo]=la[a]; la[a]=oo; lb[oo]=b;}

inline void dg1(int o)
{
	X[o]=0;
	for(int y=la[o];y;y=ne[y])
	if(f1[lb[y]]==o){
		dg1(lb[y]);
		++X[o];
	}
	X[o]=(X[o]+1)%2;
}

inline void dg2(int o)
{
	for(int y=la[o];y;y=ne[y])
	if(f2[lb[y]-n]==o-n)dg2(lb[y]);
	int k=0;
	for(int y=la[o];y;y=ne[y])
	if(f2[lb[y]-n]==o-n)k++;
	if((k+1)%2!=X[o-n])
	ok=0;
}

inline void dfs(int o)
{
	for(y[o]=la[o];y[o];y[o]=ne[y[o]])
	if(!B[y[o]>>1]){
		B[y[o]>>1]=1;
		k=lb[y[o]];
		if(k==n+o||o==k+n){
			if(o>n)ans[k]=-1;
			else ans[o]=1;
		}
		la[o]=ne[la[o]];
		dfs(k);
	}else la[o]=ne[la[o]];
}

int main()
{
	scanf("%d",&n); R=n+n+n+1;
	fo(i,1,n)scanf("%d",&f1[i]);
	fo(i,1,n)scanf("%d",&f2[i]);
	oo=1;
 	fo(i,1,n)if(f1[i]!=-1)llb(f1[i],i),llb(i,f1[i]);
 	else r1=i;
 	dg1(r1);
 	fo(i,1,n)if(f2[i]!=-1)llb(f2[i]+n,i+n),llb(i+n,f2[i]+n);
 	else r2=i+n;
 	dg2(r2);
 	if(!ok){
 		puts("IMPOSSIBLE");
 		return 0;
	}
	fo(i,1,n)if(X[i]==1)llb(i+n,i),llb(i,i+n);
 	llb(R,r2); llb(r2,R); llb(r1,R); llb(R,r1);
 	dfs(R);
 	puts("POSSIBLE");
 	fo(i,1,n)printf("%d ",ans[i]);
}

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

int main(){
  using namespace std;

  string n;
  cin >> n;
  for(int i=0; i<n.size(); i++){
    if(n[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  string s;
  cin>>s;
  cout<<s.substr(0, 4) + " " + s.substr(4)<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc102/tasks/arc100_a

int main() {
    int N; cin >> N;
    ll A[N];
    REP(i, N) {
        ll a; cin >> a;
        A[i] = a-(i+1);
    }
    sort(A, A+N);
    ll m = A[N/2];
    ll ans = 0;
    REP(i, N) {
        ans += abs(m-A[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    vector<pair<double, string>> ef(N);
    for (int i = 0; i < N; i++){
      string L;
      int P, A, B, C, D, E, F, S, M;
      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
      int c = P - F * S * M;
      int t = A + B + C + (D + E) * M;
      ef[i] = make_pair((double) c / t, L);
    }
    sort(ef.begin(), ef.end());
    for (int i = 0; i < N; i++){
      cout << ef[i].second << endl;
    }
    cout << '#' << endl;
  }
}


Measured memory_bytes: 3004