akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll N,K;cin>>N>>K;
  ll ans =0;
  for(ll b=K+1; b<=N;b++){
    ans += (N/b)*max(b-K,0LL);
    if(K!=0)ans+=max(0LL,(N%b)-K+1);
    else ans+=N%b;
  }
  cout<<ans<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(2e5+5)
#define MOD (ll)(998244353)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;

ll mult (ll a, ll b) {
	return (a * b) % MOD;
}

ll add (ll a, ll b) {
	return (a + b) % MOD;
}

ll pw (ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) {
			res = mult (res, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return res;
}

int main () {
	ll n;
	cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
	}
	if (ar[0]) {
		cout << "0\n";
		return 0;
	}
	sort (ar, ar + n);
	ll cc = 1, pr = 1, ii = 1;
	ll ans = 1;
	for (ll i = 1; i < n;) {
		if (ar[i] != cc) {
			cout << "0\n";
			return 0;
		}
		ll co = 0;
		while (i < n && ar[i] == cc) {
			co++;
			i++;
		}
		ans = mult (ans, pw (pr, co));
		pr = co;
		cc++;
	}	
	cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define ck(n,a,b) (a<=(n)&&(n)<=b)
using namespace std;

int snW,snH;
char snC[75][75];
string sndp[75][75];

string snrec(int x,int y){
	if(!ck(x,0,snW-1)||!ck(y,0,snH-1)||!ck(snC[y][x],'0','9')) return "";
	if(sndp[y][x]!="") return sndp[y][x];

	string ns1=snC[y][x]+snrec(x+1,y);
	string ns2=snC[y][x]+snrec(x,y+1);

	if(sndp[y][x].size()==ns1.size()){
		REP(k,0,(int)ns1.size()){
			if(sndp[y][x][k]==ns1[k]) continue;
			else if(sndp[y][x][k]<ns1[k])	sndp[y][x]=ns1;
			break;
		}
	}else if(sndp[y][x].size()<ns1.size()) sndp[y][x]=ns1;

	if(sndp[y][x].size()==ns2.size()){
		REP(k,0,(int)ns2.size()){
			if(sndp[y][x][k]==ns2[k]) continue;
			else if(sndp[y][x][k]<ns2[k])	sndp[y][x]=ns2;
			break;
		}
	}else if(sndp[y][x].size()<ns2.size()) sndp[y][x]=ns2;

	return sndp[y][x];
}

int main(){
	while(cin>>snW>>snH,snW){
		REP(i,0,snH){
			REP(j,0,snW){
				cin>>snC[i][j];
				sndp[i][j]="";
			}
		}
		string ans="";
		REP(i,0,snH){
			REP(j,0,snW){
				if(ck(snC[i][j],'1','9')){
					string ns=snrec(j,i);
					if(ans.size()==ns.size()){
						REP(k,0,(int)ns.size()){
							if(ans[k]==ns[k]) continue;
							else if(ans[k]<ns[k])	ans=ns;
							break;
						}
					}else if(ans.size()<ns.size()) ans=ns;
				}

			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n,k;
cin>>n>>k;
string s;
cin>>s;
char c='?';
int cnt=1;
V<P> dat;
for(int i=0;i<n;i++){
	if(c==s[i]){
		cnt++;
		if(i==n-1)dat.push_back(P(cnt,c-'0'));
	}
	else if(c=='?'){
		c=s[i];
		if(i==n-1)dat.push_back(P(cnt,c-'0'));
	}
	else{
		dat.push_back(P(cnt,c-'0'));
		cnt=1;
		c=s[i];
		if(i==n-1)dat.push_back(P(cnt,c-'0'));
	}
 }
 int r=0;
 cnt=0;
 ll sum=0,ans=0;
 n=dat.size();
 for(int l=0;l<n;l++){
	 while(r<n&&cnt+(dat[r].se?0:1)<=k){
		  cnt+=(dat[r].se?0:1);
		 sum+=dat[r].fi;r++;
	 }
	 chmax(ans,sum);
	 sum-=dat[l].fi;
	  cnt-=(dat[l].se?0:1);
 }
 cout<<ans<<endl;
}



Measured memory_bytes: 2548
n,k,*v=map(int,open(0).read().split())
m=0
r=range
for i in r(n+1):
 for j in r(min(k-i,n-i)+1):
  t=sorted(v[:i]+v[-j:]*(j>0))[::-1];c=k-i-j
  while t and c*t[-1]<0:t.pop();c-=1
  m=max(m,sum(t))
print(m)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N,C,K; cin>>N>>C>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  int sum=1;
  int ans=1;
  int memo=A[0]+K;
  rep(i,1,N){
    if(memo<A[i]){
      ans++;
      memo=A[i]+K;
      sum=1;
    }
    else{
      sum++;
      if(sum>C){
        ans++;
        memo=A[i]+K;
        sum=1;
      }
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> table(10, false);
    for(int i = 0; i < k; i++) {
        int d;
        cin >> d;
        table[d] = true;
    }
    auto check = [&](ll num) {
        string s = to_string(num);
        for(auto c : s) {
            if(table[c - '0']) {
                return false;
            }
        }
        return true;
    };
    for(ll i = n;; i++) {
        if(check(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  
  for (int i = a; i <= b;i++){
    string s = to_string(i);
    if (s[0] != s[4]) continue;
    if (s[1] != s[3]) continue;
    
    ans++;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int X;
    cin >>X;
    
    int a = 1800;
    rep(i,9){
        if(X >= a){
            cout << i+1 << endl;
            return 0;
        }
        a -= 200;
    }
    
    

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdlib>

using namespace std;

void printSort(int A[], int N) {
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if(i!=N-1)cout << " ";
	}
	cout << endl;
}

void insertionSort(int A[], int N) {
	int j;
	for (int i = 1; i<N; i++) {
		int v = A[i];
		j = i - 1;
		while (j >= 0 && A[j]>v) {
			A[j + 1] = A[j];
			j--;
			
		}
		A[j+1] = v;
		printSort(A, N);
	}
}



int main() {
	int N;
	int A[1000];

	cin >> N;
	for (int i = 0; i<N; i++) cin >> A[i];
	printSort(A, N);
	insertionSort(A, N);
	

	return 0;
}



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

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

int main()
{
    int k;
    cin >> k;
    ll sum = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int l = 1; l <= k; l++)
            {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>
#include<queue>

typedef long long ll;
#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define pqi_ priority_queue<int, vector<int>, greater<int>>
#define pqll_ priority_queue<ll, vector<ll>, greater<ll>>

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  rep(i, N) {
    int a;
    cin >> a;
    mp[a] = i + 1;
  }

  for(auto itr = mp.begin(); itr != mp.end(); itr++) {
    cout << itr->second << " ";
  }

  return 0;
}

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

struct Pos {
	double x, y;
}a, b, c, d;

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++ ) {
		cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
		Pos e;
		e.x = b.x - a.x;
		e.y = b.y - a.y;
		Pos f;
		f.x = d.x - c.x;
		f.y = d.y - c.y;
		
		double men = e.x * f.y - e.y * f.x;
		double eps = 1e-11;
		if(-eps <= men && men <= eps)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
using namespace std;
void solve() {
	int a[10], r[20], g[20], b[20];
	for (int i = 0; i < 9; i++)cin >> a[i];
	for (int i = 0; i <= 9; i++) {
		r[i] = 0; g[i] = 0; b[i] = 0;
	}
	for (int i = 0; i < 9; i++) {
		char c; cin >> c;
		if (c == 'R') { r[0]++; r[a[i]]++; }
		if (c == 'G') { g[0]++; g[a[i]]++; }
		if (c == 'B') { b[0]++; b[a[i]]++; }
	}
	if (r[0] % 3 + g[0] % 3 + b[0] % 3 != 0) { cout << "0\n"; return; }
	for (int i = 0; i < r[0] / 3; i++) {
		for (int j = 1; j <= 9; j++) {
			if (r[j] >= 3) {
				r[j] -= 3;
				goto heaven_r;
			}
			else if (r[j] > 0) {
				r[j]--;
				r[j + 1]--;
				r[j + 2]--;
				if (r[j + 1] < 0 || r[j + 2] < 0) { cout << "0\n"; return; }
				goto heaven_r;
			}
		}
		heaven_r:;
	}
	for (int i = 0; i < g[0] / 3; i++) {
		for (int j = 1; j <= 9; j++) {
			if (g[j] >= 3) {
				g[j] -= 3;
				goto heaven_g;
			}
			else if (g[j] > 0) {
				g[j]--;
				g[j + 1]--;
				g[j + 2]--;
				if (g[j + 1] < 0 || g[j + 2] < 0) { cout << "0\n"; return; }
				goto heaven_g;
			}
		}
	heaven_g:;
	}
	for (int i = 0; i < b[0] / 3; i++) {
		for (int j = 1; j <= 9; j++) {
			if (b[j] >= 3) {
				b[j] -= 3;
				goto heaven_b;
			}
			else if (b[j] > 0) {
				b[j]--;
				b[j + 1]--;
				b[j + 2]--;
				if (b[j + 1] < 0 || b[j + 2] < 0) { cout << "0\n"; return; }
				goto heaven_b;
			}
		}
	heaven_b:;
	}
	cout << "1\n"; return;
}
signed main() {
	int n; cin >> n; for (int i = 0; i < n; i++)solve();
}


Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[405][405];
int n;
vector<ll> a;
 
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	a.resize(n); 
  	ll sum[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
     	if(i>0) sum[i]=sum[i-1]+a[i];
     	else sum[i]=a[i];
	}
  	for(int i=n-1; i>=0; i--){
      for(int j=i; j<n; j++){
        if(i==j) dp[i][j]=0;
        else{
          ll s;
          dp[i][j]=1e18;
          if(i>0) s=sum[j]-sum[i-1];
          else s=sum[j];
          for(int k=i; k<j; k++){
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
          }
        }
      }
    }
  	cout<<dp[0][n-1]<<endl;
  	
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <utility>
#include <stack>
using namespace std;


using P = pair<int, int>;


int h, w;
char sq[500][500];
int dp[500][501];
stack<P> hist;


void clear(stack<P> s){
	stack<P> emp;
	swap(s, emp);
}


int histMax(P r){
	int m = 0;
	P prev;
	while(!hist.empty() && hist.top().first >= r.first){
		prev = hist.top();
		hist.pop();
		m = max(m, prev.first * (r.second - prev.second));
	}
	hist.push({ r.first, prev.second });
	return m;
}


int histProcess(P r){
	if(hist.empty()){ hist.push(r); return 0; }
	if(hist.top().first == r.first) return 0;
	if(hist.top().first < r.first){ hist.push(r); return 0; }
	if(hist.top().first > r.first) return histMax(r);
	return 0;
}


int solve(){
	int m = 0;
	for (int y = 0; y < h; y++){
		for (int x = 0; x < w + 1; x++){
			if(x == w) dp[y][x] = 0;
			else if(sq[y][x] == '*') dp[y][x] = 0;
			else if(y == 0) dp[y][x] = 1;
			else dp[y][x] = dp[y-1][x] + 1;
			m = max(m, histProcess({ dp[y][x], x }));
		}
		clear(hist);
	}
	return m;
}


int main(){
	while(cin >> h >> w, h | w){
		for(int y = 0;y < h;y++){
			for(int x = 0;x < w;x++){
				cin >> sq[y][x];
			}
		}

		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
n = int(input())
x = list(map(int,input().split()))
answer = 0

for i in range(min(x),max(x)+1):
	result = 0
	for j in range(n):
		result += (x[j] - i) ** 2
	if answer == 0 or answer > result:
		answer = result
		number = i

print(answer)

Measured memory_bytes: 63872
#include<iostream>
using namespace std;
int n;
int r[200000];
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>r[i];
}
int i=0;
for(int j=i+1;j<n;j++){
r[j]-=r[i];
}
r[0]=-1400000000;
i++;
while(i<n-1){
if(r[i]<0){
for(int j=i+1;j<n;j++){
r[j]-=r[i];
}
}
++i;
}
//int max=*max_element(r,r+n*sizeof(r[0]));
int max=-1400000000;
for(int j=0;j<n;j++){
if(max<r[j])max=r[j];
}
cout<<max<<endl;

}



Measured memory_bytes: 3880
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
 
using namespace std;
 
#define INF (1 << 30)
 
struct Route
{
    int x, y, z;
};
 
struct Path
{
    int mask;
    int city;
    vector<int> pathCost;
};
 
bool solve()
{
    int n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
 
    if( (n | m | p | a | b) == 0 )return false;
 
    //fix to zero index
    a--;
    b--;
 
    vector<int> t(n);
 
    for(auto& _t : t)
    {
        cin >> _t;
    }
 
    //dummy data
    t.push_back(-10);
 
    sort(t.begin(), t.end(), std::greater<int>());
 
    vector<Route> route(p);
    vector<Route> bin[30];
 
    for(auto& r : route)
    {
        cin >> r.x;
        cin >> r.y;
        cin >> r.z;
 
        //fix to zero index
        r.x--;
        r.y--;
 
        //bin sort
        bin[r.x].push_back(r);
        bin[r.y].push_back(Route{ r.y, r.x, r.z }); 
    }
  
    queue<Path> que;
    queue<Path> ansPath;
 
    Path tmp{ 1 << a, a };
    tmp.pathCost.push_back(0);
 
    que.push(tmp);
 
    double minCost[30] = {};
    for(auto &mc : minCost)
    {
        mc = INF;
    }
    minCost[a] = 0.0;
 
    //n is number of max path
    for(int i = 0; i < n; i++)
    {
        while(que.front().pathCost.size() == (i + 1))
        {
            //que.front() is the now city
            int nowCity = que.front().city;
            for(int j = 0; j < bin[nowCity].size(); j++)
            {
                //if already come
                if(que.front().mask & 1 << bin[nowCity][j].y)        
                {
                    continue;
                }

                //go to next city
                Path next = que.front();
                next.mask |= 1 << bin[nowCity][j].y;
                next.city = bin[nowCity][j].y;
                next.pathCost.push_back(bin[nowCity][j].z);
 
                sort(next.pathCost.begin(), next.pathCost.end(), std::greater<int>());
 
                double cost_tmp = 0.0;
                for(int i = 0; i < next.pathCost.size(); i++)
                {
                    cost_tmp += (double)next.pathCost[i] / (double)t[i];
                }
 
                if(cost_tmp < minCost[next.city]) minCost[next.city] = cost_tmp;
                else continue;
             
                //if come at terminate, push to ansPath
                if(next.city == b) ansPath.push(next);
                else que.push(next);
            }
            que.pop();
        }
    }
 
 
    if(minCost[b] >= INF - 1){
        cout << "Impossible\n";
        return true;
    }
 
    cout << minCost[b] << endl;
 
    return true;
 
}
 
int main()
{   
    while( solve() );
 
    return 0;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <string>
#include <utility>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string s=std::move(buf);

  int K;
  scanf("%d", &K);

  for (size_t i=0; i<s.length(); ++i) {
    if (s[i] == 'a') continue;

    int num='z'+1-s[i];
    if (K < num) continue;  // todo

    K -= num;
    s[i] = 'a';
  }

  if (K > 0) {
    K %= 26;
    s.back() += K;
    if (s.back() > 'z')
      s.back() -= 26;
  }

  printf("%s\n", s.c_str());
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int h, w;
    cin >> h >> w;
    char C[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> C[i][j];
        }
    }

    rep(i, h)
    {
        rep(j, w)
        {
            cout << C[i][j];
        }
        cout << endl;
        rep(j, w)
        {
            cout << C[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

typedef long long ll;

int main(){
    string a,b,c,d;

    cin >>a >> b >> c ;
    d = a[0]-'a'+'A' ;
    d += b[0]-'a'+'A';
    d += c[0]-'a'+'A';
    cout << d;
}

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

int main (){
	int n, t, k, l, h;
	cin >> n >> t;
	h = n * t;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		if(i > 0){
			int s = a[i] - a[i - 1];
			if(s < t){
				h -= (t - s);
			}
		}
	}
	cout << h << endl;
	return 0;
} 

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
K, A, B = map(int, input().split())
if A >= B:
  print(K + 1)
  exit(0)
if K <= A:
  print(K + 1)
  exit(0)
print(max(K + 1, ((K - A + 1) // 2) * (B - A) + A * (((K - A + 1) // 2) > 0) + (((K - A + 1) % 2))))

Measured memory_bytes: 38256
#include <iostream>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
            long long int a,b,c,d;
            cin>>a>>b>>c>>d;
            
            long long int ans=-2e18;
            
            ans=max(ans,a*c);
            ans=max(ans,a*d);
            ans=max(b*c,ans);
            ans=max(ans,b*d);
            
            cout<<ans<<endl;
            
            
	   
	}
	   
	   
	return 0;
}

Measured memory_bytes: 3584
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, M;
vector<int> graph[10];

char visited[10];
int dfs(int v, int depth) {
    if (depth >= N) return 1;
    int ret = 0;
    for (int w : graph[v]) {
        if (visited[w]) continue;
        visited[w] = true;
        ret += dfs(w, depth+1);
        visited[w] = false;
    }
    return ret;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    visited[0] = true;
    cout << dfs(0, 1) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	r := nextInt(sc)
	c := nextInt(sc)

	rowSum := make([]int64, r)
	colSum := make([]int64, c)
	var sum int64
	t := make([][]int64, r)

	for i := int64(0); i < r; i++ {
		t[i] = make([]int64, c)
		for j := int64(0); j < c; j++ {
			t[i][j] = nextInt(sc)
			rowSum[i] += t[i][j]
			colSum[j] += t[i][j]
		}
		sum += rowSum[i]
	}

	for i, tr := range t {
		vStr := make([]string, c+1)
		vStr[c] = strconv.FormatInt(rowSum[i], 10)
		for j, v := range tr {
			vStr[j] = strconv.FormatInt(v, 10)
		}
		fmt.Println(strings.Join(vStr, " "))
	}
	vStr := make([]string, c+1)
	vStr[c] = strconv.FormatInt(sum, 10)
	for i, v := range colSum {
		vStr[i] = strconv.FormatInt(v, 10)
	}
	fmt.Println(strings.Join(vStr, " "))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1492
#light "off"

open System
open System.Linq
open System.Collections.Generic

let INF64 = 100000000000L

let readInt () =
    let s = stdin.ReadLine() in
    int s

let readInt64 () =
    let s = stdin.ReadLine() in
    int64 s

let readIntArray () =
    stdin.ReadLine().Split(' ') |>
    Array.map int

(*
let readIntList () =
    stdin.ReadLine().Split(' ') |>
    Array.map int |>
    Array.toList
*)
(*
let readIntList () =
    stdin.ReadToEnd()
        .Split('\n')
        .Select(fun s -> s.Replace("\r", ""))
        .Where(fun s -> s.Length > 0)
        .Select(fun e -> int e)
        .ToArray() |>
    Array.toList
*)

type Edge = {NodeA: int; NodeB: int}

let parseProblem () =
    let ar = readIntArray () in
    let N, M = ar.[0], ar.[1] in
    let bridges = Array.create M {NodeA = 0; NodeB = 0} in
    for i in 0 .. M - 1 do
        let ar2 = readIntArray () in
        bridges.[i] <- {NodeA = ar2.[0] - 1; NodeB = ar2.[1] - 1}
    done;
    N, M, bridges

let createParents N =
    Array.create N -1

let rec findRoot (p: int []) (a: int) =
    let x = p.[a] in
    if x >= 0 then
        findRoot p x
    else
        a

let findThenUnion p a b =
    let x = findRoot p a in
    let y = findRoot p b in
    let same = x = y in
    let size_a, size_b = -p.[x], -p.[y] in
    begin
        if not same then
            let xx, yy = if size_a >= size_b then x, y else y, x in
            p.[xx] <- p.[xx] + p.[yy];
            p.[yy] <- xx;
    end;
    same, (int64)size_a, (int64)size_b

[<EntryPoint>]
let main argv =
    let N, M, bridges = parseProblem () in
    let parents = createParents N in
    let ans = Array.create M -1L in
    for i = M downto 1 do
        if i = M then
            ans.[i - 1] <- (int64)N * ((int64)N - 1L) / 2L
        else
            let a, b = bridges.[i].NodeA, bridges.[i].NodeB in
            let same, size_a, size_b = findThenUnion parents a b in
            if same then
                ans.[i - 1] <- ans.[i]
            else
                ans.[i - 1] <- ans.[i] - size_a * size_b;
    done;
    for i in 0 .. M - 1 do
        printfn "%d" <| ans.[i]
    done;
    0

Measured memory_bytes: 25508
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int K, A, B;  cin >> K >> A >> B;
    for(int i = A ; i <= B ; i++)
      if(i % K == 0){  cout << "OK" << endl;  return 0;  }

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


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int n, k; cin >> n >> k;
  vecint h(n, 0), dp(n,1e9);
  REP(i,n) cin >> h[i];
  dp[0] = 0;
  for(int i = 1; i < n; i ++){
    // cout << "i = " << i << endl;
    for(int j = max(0,i - k); j < i; j ++ ){
      // cout << "j = " << j << endl;
      dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i]);
    }
  }
  // cout << dp[0] << endl;
  // cout << dp[1] << endl;
  cout << dp[n - 1] << endl;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    int t, f, cnt = 0;
    char c;
    string front, end;
    rep(i, 0, q){
        cin >> t;
        if(t == 1){
            cnt++;
        }else{
            cin >> f >> c;
            if(cnt % 2 == 0){
                if(f == 1){
                    front.push_back(c);
                }else{
                    s.push_back(c);
                }
            }else{
                if(f == 1){
                    s.push_back(c);
                }else{
                    front.push_back(c);
                }
            }
        }
    }
    if(cnt % 2 == 0){
        reverse(all(front));
        cout << front + s << endl;
    }else{
        reverse(all(s));
        cout << s + front << endl;
    }
}


Measured memory_bytes: 1248
while True:
  h_list=[]
  card_list=[]
  card = str(input())
  if card == '-':
    break
  n = int(input())
  card_list=list(card)
  
  while n>0:
    h = int(input())
    h_list.append(h)
    n = n - 1
    
  for i in h_list:
    for j in range(i):
      card_list.append(card_list.pop(0))
  
  print(''.join(card_list))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
    cin>>a;
    cin>>b;
    int x=a.size(),y=b.size();
    for(int i=0;i<y;i++) cout<<a[i]<<b[i];
    if(x>y) cout<<a[x-1];
    return 0;
}

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

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)
from itertools import product

N = int(input())
A = [0] * N
x = []

for i in range(N):
    A[i] = int(input())
    d = []
    for j in range(A[i]):
        d.append(tuple(map(int, input().split())))
    x.append(d)

# print(x)

ans = 0
for case in list(product([0,1], repeat=N)):
    # print(case)

    flg = [-1] * N
    cond = True
    for i in range(N):
        if not cond:
            continue
        if case[i] == 0:
            continue

        for a in range(A[i]):
            c, d = x[i][a]
            c = c-1

            # print(c, d)
            if case[c] != d:
                cond = False
                # print('矛盾')
    if cond:
        ans = max(ans, sum(case))

print(ans)


Measured memory_bytes: 48876
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i-1)*(ll)(s[i]-'0');
	}
	return ans;
}

int main() {
	string s; cin >> s;
	int gu = 0, pa = 0;
	int N = s.length();
	REP(i, N) {
		if (s[i] == 'g')gu++;
		else pa++;
	}
	if (gu <= pa) {
		cout << 0 << endl;
		return 0;
	}
	else {
		p(N / 2 - pa);
	}
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long lint;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    double ans = 0.0;
    const string JPY = "JPY";
    const string BTC = "BTC";
    const double btoy = 380000.0;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    for (int i=0; i<n; ++i){
        cin >> x[i] >> u[i];
    }
    for (int i=0; i<n; ++i){
        if(u[i] == JPY){
            ans += x[i];
        }
        else if(u[i] == BTC){
            ans += x[i] * btoy;
        }
    }
    printf("%.10f", ans);
    cout << endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int A, B;
  cin >> A >> B;
  
  string U;
  cin >> U;
  
  if (U == S) {
    cout << A - 1 << " " << B;
  } else {
    cout << A << " " << B - 1;
  }
}

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

int main() {
  int h1,h2,m1,m2,s1,s2;
  while(cin>>h1>>m1>>s1>>h2>>m2>>s2) {
    if(s2 >= s1) s2 -= s1;
    else {
      if(m2 > 0) {
	m2--;
	s2 += 60;
	s2 -= s1;
      }else{
	h2--;
	m2 += 59;
	s2 += 60;
	s2 -= s1;
      }
    }

    if(m2 >= m1) m2 -= m1;
    else {
      h2--;
      m2 += 60;
      m2 -= m1;
    }
    h2 -= h1;
    cout<<h2<<" "<<m2<<" "<<s2<<endl;
  }
}

Measured memory_bytes: 0
s=input()
list=[0 for i in range(len(s))]
a=0
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    list[a]+=1
  else:
    a+=1
print(max(list))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<string>
#include <vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

int main(){
	int N, Y[200000];
	vector<int> X;

	scanf("%d", &N);
	int i;
	REP(i, N){
		cin >> Y[i];
		X.push_back(Y[i]);
	}

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

	REP(i, N){
		if (Y[i]<=X[(N-1)/2]){
			cout << X[(N-1) / 2 + 1] << endl;
		}
		else{
			cout << X[(N -1)/ 2] << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3828
s = str(input())

if s[0] == s[1]:
    if s[2] == s[3] and s[0] != s[2]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[2]:
    if s[1] == s[3] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[3]:
    if s[1] == s[2] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] cl = sc.next().toCharArray();
        int zero = 0;
        int one = 0;
        for(char c : cl){
            if(c == '0'){
                zero++;
            }else{
                one++;
            }
        }
        System.out.println(Math.min(zero,one)*2);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#define llint unsigned long long
#define B 1000000007
#define C 9973

using namespace std;

int w, h, p;
llint image[1005][1005];
int pat[105][105];
llint hash[1005][1005];
llint bmod[105], cmod[105];
vector<llint> vec;

void rotate()
{
	int tmp[105][105];
	for(int x = 0; x < p; x++){
		for(int y = 0; y < p; y++){
			tmp[x][y] = pat[y][p-1-x];
		}
	}
	for(int x = 0; x < p; x++){
		for(int y = 0; y < p; y++){
			pat[x][y] = tmp[x][y];
		}
	}
}

llint calc()
{
	llint ret = 0;
	llint tmp[105];
	
	for(int y = 0; y < p; y++){
		llint hs = 0;
		for(int x = 0; x < p; x++){
			hs += pat[x][y] * bmod[p-1-x];
		}
		tmp[y] = hs;
	}
	
	for(int y = 0; y < p; y++){
		ret += tmp[y] * cmod[p-1-y];
	}
	return ret;
}

int main(void)
{
	llint val = 1;
	for(int i = 0; i < 105; i++){
		bmod[i] = val;
		val *= B;
	}
	val = 1;
	for(int i = 0; i < 105; i++){
		cmod[i] = val;
		val *= C;
	}
		
	while(1){
		cin >> w >> h >> p;
		if(w == 0 && h == 0 && p == 0) break;
		
		for(int y = 0; y < h; y++){
			char c; int v;
			for(int x = 0; x < w; x++){
				if(x % 6 == 0){
					cin >> c;
					if(c >= 'A' && c <= 'Z') v = (int)(c - 'A');
					if(c >= 'a' && c <= 'z') v = (int)(c - 'a') + 26;
					if(c >= '0' && c <= '9') v = (int)(c - '0') + 52;
					if(c == '+') v = 62;
					if(c == '/') v = 63;
				}
				image[x][y] = !!(v & (1<<(5-x%6)));
			}
		}
		for(int y = 0; y < p; y++){
			char c; int v;
			for(int x = 0; x < p; x++){
				if(x % 6 == 0){
					cin >> c;
					if(c >= 'A' && c <= 'Z') v = (int)(c - 'A');
					if(c >= 'a' && c <= 'z') v = (int)(c - 'a') + 26;
					if(c >= '0' && c <= '9') v = (int)(c - '0') + 52;
					if(c == '+') v = 62;
					if(c == '/') v = 63;
				}
				pat[x][y] = !!(v & (1<<(5-x%6)));
			}
		}
		
		if(p > w || p > h){
			cout << 0 << endl;
			continue;
		}
		
		vec.clear();
		for(int i = 0; i < 4; i++){
			rotate();
			vec.push_back(calc());
		}
		int tmp[105][105];
		for(int x = 0; x < p; x++){
			for(int y = 0; y < p; y++){
				tmp[x][y] = pat[y][x];
			}
		}
		for(int x = 0; x < p; x++){
			for(int y = 0; y < p; y++){
				pat[x][y] = tmp[x][y];
			}
		}
		for(int i = 0; i < 4; i++){
			rotate();
			vec.push_back(calc());
		}
		
		for(int y = 0; y < h; y++){
			llint hs = 0;
			for(int x = 0; x < p; x++){
				hs += image[x][y] * bmod[p-1-x];
			}
			hash[0][y] = hs;
			for(int x = p; x < w; x++){
				hs = hs * B - image[x-p][y] * bmod[p] + image[x][y];
				hash[x-p+1][y] = hs;
			}
		}
		for(int x = 0; x < w; x++){
			llint hs = 0;
			for(int y = 0; y < p; y++){
				hs += hash[x][y] * cmod[p-1-y];
			}
			image[x][0] = hs;
			for(int y = p; y < h; y++){
				hs = hs * C - hash[x][y-p] * cmod[p] + hash[x][y];
				image[x][y-p+1] = hs;
			}
		}
		
		llint ans = 0;
		for(int x = 0; x < w-p+1; x++){
			for(int y = 0; y < h-p+1; y++){
				for(int k = 0; k < vec.size(); k++){
					if(vec[k] == image[x][y]){
						ans++;
						break;
					}
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 18532
# include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
# define pb push_back
# define pii pair < int, int >
# define F first
# define S second
# pragma GCC optimize("unroll-loops")
# pragma GCC optimize("Ofast")
# define int long long int
# define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2e5+100,inf=1e15,mod=998244353 ;

int32_t main(){
    string s;
    cin >> s;
    if (s=="SUN"){
        cout << 7;
    }
    if (s=="MON"){
        cout << 6;
    }
    if (s=="TUE"){
        cout << 5;
    }
    if (s=="WED"){
        cout << 4;
    }
    if (s=="THU"){
        cout << 3;
    }
    if (s=="FRI"){
        cout << 2;
    }
    if (s=="SAT"){
        cout << 1;
    }
}


Measured memory_bytes: 256
k, n = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
max_l = a[0] + k - a[-1]
for i in range(n-1):
  if a[i+1] - a[i] >= max_l:
    max_l = a[i+1] - a[i]
print(k - max_l)

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    k--;

    string ans = "";
    for (int i = 0; i < n; ++i) {
        if (s[k] == s[i]) {
            ans += s[i];
        } else {
            ans += "*";
        }
    }

    cout << ans << endl;
    return 0;
}


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

ll gcd(ll m, ll n) {
	if(n == 0) return m;
	else return gcd(n, m % n);
}

int main() {
	int t;
	cin >> t;
	ll a, b, c, d;
	while (t--) {
		cin >>a>>b>>c>>d;
		if (a < b || d < b) {
			cout << "No\n";
		} else if (c >= b - 1){
			cout << "Yes\n";
		} else {
			a %= b;
			if (a > c) {
				cout << "No\n";
				continue;
			}
			d %= b;
			if (d == 0) {
				cout << "Yes\n";
				continue;
			}
			d = gcd(b, d);
			a %= d;
			cout << (b + a - d > c ? "No\n" : "Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
def main2():
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]

    if sum(A) < sum(B):
        print(-1)
    else:
        S = sum(A) - sum(B)
        C = [[a, b, b, a - b] for a, b in zip(A, B)] 
        C = sorted(C, key=lambda x:x[3])

        ans = 0
        for i in C:
            a, b, c, d = i

            if d == 0:
                pass
            
            elif d > 0:
                if d <= S:
                    S -= d
                else:
                    ans += 1
            else:
                ans += 1

        print(ans)

if __name__ == "__main__":
    main2()

Measured memory_bytes: 32980
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+11,INF=1e9+11;
int n,z,w,f[N][2],a[N],ans;
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d%d%d",&n,&z,&w);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	if(n==1){
		printf("%d",abs(a[n]-w));
		return 0;
	}
	printf("%d",max(abs(a[n]-a[n-1]),abs(a[n]-w)));
	return 0;
}

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

string a(string s,string t,string u) {
	string::size_type pos = s.find(t);
	while (pos != string::npos) {
		s.replace(pos, t.size(), u);
		pos = s.find(t, pos + u.size());
	}
	return s;
}

int main() {
	string s;
	getline(cin, s);
	s = a(s, "apple", "PEACH");
	s = a(s, "peach", "apple");
	s = a(s, "PEACH", "peach");
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1192