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

int main(){
  int D, M=26;
  cin >> D;
  vector<long long> c(M);
  for(int i=0; i<M; i++){
    cin >> c[i];
  }
  vector<vector<long long>> s(D,vector<long long>(M));
  for(int i=0; i<D; i++){
    for(int j=0; j<M; j++){
      cin >> s[i][j];
    }
  }
  long long la,onelos=0;
  for(int j=0; j<M; j++){
    onelos += c[j];
  }
  long long num = 10;
  vector<long long> sat(num,0), los(num,0), nlos(num,0);
  vector<pair<long long, long long>> tmpsat(num*M);
  vector<vector<long long>> last(num,vector<long long>(M,-1)), nlast(num,vector<long long>(M,-1));
  vector<vector<long long>> t(num,vector<long long>(D)), nt(num,vector<long long>(D));
  for(int i=0; i<D; i++){
    for(int j=0; j<num; j++){
      for(int k=0; k<M; k++){
        la = (long long)i - last[j][k];
    	tmpsat[j*M+k].first = sat[j] + s[i][k] - los[j] - onelos + la*c[k];
        tmpsat[j*M+k].first -= los[j]*8; //mahou
        tmpsat[j*M+k].second = j*M+k;
      }
    }
    sort(tmpsat.begin(), tmpsat.end(), greater());
    for(int j=0; j<num; j++){
      sat[j] = tmpsat[j].first;
      long long ty = tmpsat[j].second%M;
      long long prenum = tmpsat[j].second/M;
      sat[j] += los[prenum]*8; //mahoumo
      nlast[j] = last[prenum];
      nlast[j][ty] = (long long)i;
      nlos[j] = los[prenum] + onelos - ((long long)i - last[prenum][ty])*c[ty];
      nt[j] = t[prenum];
      nt[j][i] = ty;
    }
    for(int j=0; j<num; j++){
      last[j] = nlast[j]; los[j] = nlos[j]; t[j] = nt[j];
    }
  }
  //cout << sat[0] << endl;
  for(int i=0; i<D; i++){
    cout << t[0][i]+1 << endl;
  }
  return 0;
}

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

int main() {
  double xA,yA,xB,yB,xC,yC,xD,yD;
  double inner,vecAB[2],vecCD[2];
  while (cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD) {
    vecAB[0] = xB - xA;
    vecAB[1] = yB - yA;
    vecCD[0] = xD - xC;
    vecCD[1] = yD - yC;
    inner = vecAB[0] * vecCD[0] + vecAB[1] * vecCD[1];
    if(inner == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  long long a=0;
  cin >> n;
  for(long long i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
    a+=i;
    }
  }
  cout << a <<endl;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = ReadLine();
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == '1')
            {
                Write(9);
            }
            else if (S[i] == '9')
            {
                Write(1);
            }
            else
            {
                Write(S[i]);
            }
        }
        WriteLine();
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
typedef vector<vi> vvi;
typedef vector<vll> vvll;

//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
    return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

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

    sort(all(A));

    if (A[0] == A[N-1]) {
        if (N >= 2*A[0] || N == (A[0] + 1)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (A[N-1] == A[0] + 1) {
        int num_small = 0;
        for (int i=0;i<N;i++) if (A[i] == A[0]) num_small++;

        int num_big = N - num_small;

        if (A[N-1] > num_small && num_small + num_big/2 >= A[N-1]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N ()
#define ll long long
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP2-&MOP1)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
string a,b;
bool MOP2;
int main(){
	int cnt=0;
	cin>>a>>b;
	for(int i=0;i<3;i++)if(a[i]==b[i])cnt++;
	printf("%d\n",cnt);
	return 0;
}






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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(ll (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

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

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

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// Xの辺をa回、Yの辺をb回通ったときのS->Tの(整数が書いてある辺の重みのみを考慮した)最短距離をf(ab)とすると
// X=x,Y=yのときの最短距離は Dx,y = min(xa+yb+f(a,b)) となる
// dがたかだか100だからa・bの範囲は[0,100]で十分
// 頂点0〜100をXの辺で、101〜201をYの辺でつなぎ、
// S(0〜100)とT(101〜201)をコストfabの辺で繋ぐと総コストSX+(T-101)Y+fabのパスができる
// fabは任意の1<=x<=A, 1<=y<=Bに対しdxy<=xa+yb+fabを満たす条件の中で最も小さくするのが最善
// ∴ fab = max( 0, max(dxy-xa-yb) ) (0<=a,b<=100)
// これに従って辺を伸ばした後にちゃんとdを満たしているか確認すればok

int A, B, d[11][11], f[101][101];

signed main() {
	cin >> A >> B;
	repst(i,1,A) repst(j,1,B) {
		cin >> d[i][j];
		rept(a,100) rept(b,100) chmax(f[a][b], d[i][j]-i*a-j*b);
	}
	repst(i,1,A) repst(j,1,B) {
		int m = inf;
		rept(a,100) rept(b,100) chmin(m, i*a+j*b+f[a][b]);
		if (m!=d[i][j]) return cout << "Impossible" << ln, 0;
	}
	cout << "Possible" << ln << "202 10401" << ln;
	repst(i,1,100) cout << i << ' ' << i+1 << " X" << ln;
	repst(i,1,100) cout << i+101 << ' ' << i+102 << " Y" << ln;
	rept(a,100) rept(b,100) cout << a+1 << ' ' << b+102 << ' ' << f[a][100-b] << ln;
	cout << "1 202" << ln;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int a,b,c;cin>>a>>b>>c;
    int d=(a+b-1)/b;
    cout<<d*c<<endl;
}


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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int next=1;
	rep(i,n) if(a[i]==next) next++;

	printf("%d\n",next==1?-1:n-(next-1));

	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int cant[1000] = {};
int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	REP(i, k) {
		int a;
		cin >> a;
		cant[a] = true;
	}
	int ans = n;
	while (true) {
		int pre_ans = ans;
		while (pre_ans != 0) {
			int hoge = pre_ans % 10;
			pre_ans /= 10;
			if (cant[hoge] == true) goto failed;
		}
		cout << ans << endl;
		return 0;
	failed:;
		ans++;
	}
}

Measured memory_bytes: 256
import collections
n, k = map(int, input().split())
a_lst = list(map(int, input().split()))

c = collections.Counter(a_lst)
res = 0
sorted_c = sorted(c.items(), key=lambda x:x[1])
if len(c) <= k:
  print(res)
  quit()
else:
  for k, v in sorted_c[:(len(c) - k)]:
    res += v
print(res)


Measured memory_bytes: 43236
def main 
while n = gets.chomp.to_i and n != 0
    nums = gets.chomp.split(/\s/).collect { |x| x.to_f}
    avg = nums.inject(0) { |s, e| s + e} / nums.size
    ans = 0.0
    nums.each do |num|
      ans += (num - avg) ** 2
    end
    puts ("%.6f" %  Math.sqrt((ans / nums.size)))
  end
end

main


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

int main() {
  string S,T,ans="Yes";
  cin >> S >> T;

  for(int i=0;i<S.size();i++){
    if(S.at(i) != T.at(i)){
      ans="No";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  //input
  int N;
  cin >> N;
  //calc
  int answer = -1;
  int min = (int)ceil(N / 1.08);
  int max = (int)floor((N+1)/1.08);
  if ( min <= max ) {
    int cand = min;
    int calc = floor(((double)cand)*1.08);
    if ( calc == N ) {
      answer = cand;
    }
  }
  //output
  if ( answer > 0 ) {
    cout << answer << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

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

void Main()
{
    int n;
    cin >> n;
    vector<long> l(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            for (int k = j+1; k < n; k++)
            {
                if(l[i] < l[j] + l[k] && l[i] != l[j] && l[j] != l[k]){
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3652
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

ll q[maxn];
void solve()
{
	repp(i,1,4)
	{
		scanf("%lld",&q[i]);
	}
	ll n;
	cin>>n;

	ll ans=2e18;
	repp(i,1,4)
	{
		if(i==1)
		{
			ans=min(ans,4*q[i]*n);
		}
		else if(i==2)
		{
			ans=min(ans,2*q[i]*n);
		}
		else if(i==3)
		{
			ans=min(ans,q[i]*n);
		}
		else
		{
			if(n%2==0)
				ans=min(ans,q[i]*(n/2));
			else
			{
				ans=min(ans,q[i]*(n/2)+q[3]);
				ans=min(ans,q[i]*(n/2)+q[2]*2);
				ans=min(ans,q[i]*(n/2)+q[1]*4);
			}
		}

	}
	printf("%lld\n", ans);
}

int main()
{
	solve();
	// system("pause");
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> sum(n + 1, 0);
    map<ll,ll> mp;
    set<ll> st;
    mp[0] = 1;
    st.insert(0);
    for(ll i = 0; i < n; i++){
        sum[i + 1] = sum[i] + a[i];
        st.insert(sum[i + 1]);
        mp[sum[i + 1]]++;
    }
    for(auto v : st){
        ans += mp[v] * (mp[v] - 1) / 2;
    }
    cout << ans << endl;
}

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

void find(double s) 
{ 
	double length = s / 3.0; 
	s -= length; 
	double breadth = s / 2.0; 
	double height = s - breadth; 
	double ans = length * breadth * height;
	cout << fixed << setprecision(8) << ans << "\n"; 
} 
int main() 
{ 
	double s; cin >> s;
	find(s);
	return 0; 
} 


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 1e5 + 5;

vi gr[MAXN];
int p[MAXN];

void dfs(int u) {
    for (auto v : gr[u]) {
        if (v == p[u]) continue;
        p[v] = u;
        dfs(v);
    }
}

ii bad;

int calc(int u, int par = -1) {
    int res = 1;
    for (auto v : gr[u]) {
        if (v == par) continue;
        if (mp(u, v) == bad || mp(v, u) == bad)
            continue;
        res += calc(v, u);
    }
    return res;
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        gr[u].pb(v);
        gr[v].pb(u);
    }
    memset(p, -1, sizeof p);
    dfs(1);
    vi path;
    int u = n;
    while (u != -1) {
        path.pb(u);
        u = p[u];
    }
    reverse(all(path));
#if 0
    fprintf(stderr, "path:");
    for (auto it : path) fprintf(stderr, " %d", it);
    fprintf(stderr, "\n");
#endif
    int sz = (int)path.size();
    int i = 0, j = sz - 1, last = 1;
    while (i < j) {
        if (i + 1 < j) {
            i++;
            last = 0;
        } else
            break;
        if (i < j - 1) {
            j--;
            last = 1;
        } else
            break;
    }
    bad = mp(path[i], path[j]);
#if 0
    fprintf(stderr, "i = %d, j = %d\n", i, j);
    fprintf(stderr, "bad edge: (%d, %d)\n", bad.fi, bad.se);
#endif
    int cnt[2] = {calc(1), calc(n)};
    //fprintf(stderr, "bef %d, %d\n", cnt[0], cnt[1]);
    cnt[0] -= (i + 1);
    cnt[1] -= (sz - j);
    fprintf(stderr, "aft %d, %d\n", cnt[0], cnt[1]);
    assert(cnt[0] >= 0 && cnt[1] >= 0);
    last ^= 1;
    while (cnt[0] && cnt[1]) {
        cnt[last]--;
        last ^= 1;
    }
    if (cnt[0] == 0 && cnt[1] == 0)
        puts(last == 1 ? "Fennec" : "Snuke");
    else
        puts(cnt[1] == 0 ? "Fennec" : "Snuke");
    return 0;
}



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

using namespace std;

int main()
{
    int a,b,c,x,y,z;
    cin>>x>>y>>z;
    a=y;
    b=x;
    c=a;
    a=z;
    cout<<a<<' '<<b<<' '<<c;

    return 0;
}


Measured memory_bytes: 256
### constant

MAX_INT = (1 << 30)

### global variables

$mccache = []
$hmoves = []

### subroutines

def hmoves(x0, x1)
  hmvs = []

  for xi in (0...$w)
    hmv0 =
      (x0 == xi) ? [] :
      (x0 > xi) ? x0.downto(xi + 1).to_a : x0.upto(xi - 1).to_a
    hmv1 =
      (xi == x1) ? [x1] :
      (xi > x1) ? xi.downto(x1).to_a : xi.upto(x1).to_a

    hmv = hmv0 + hmv1
    hmvs << hmv if ! hmvs.include? hmv
  end

  hmvs.sort
end

def min_cost(x, y, o)
  return 0 if y >= $h
  return $mccache[x][y][o] if ! $mccache[x][y][o].nil?
  return ($mccache[x][y][0] = MAX_INT) if o <= 1

  min_cost = MAX_INT

  for xn in (0...$w)
    for hmv in $hmoves[x][xn]
      cost0 = 0
      o0 = o
      visited = $w.times.map{false}
      ok = true

      for x1 in hmv
        o0 -= 1
        if o0 <= 0
          ok = false
          break
        end

        if ! visited[x1]
          l = $layers[y][x1]

          if l > 0
            o0 += l
            o0 = $m if o0 > $m
          else
            cost0 += -l
          end

          visited[x] = true
        end
      end

      if ok && o0 > 0
        cost = cost0 + min_cost(x1, y + 1, o0)
        min_cost = cost if min_cost > cost
      end
    end
  end

  $mccache[x][y][o] = min_cost
end

### main

while true
  $w, $h = gets.strip.split(' ').map{|s| s.to_i}
  break if $w == 0 && $h == 0

  f, $m, o = gets.strip.split(' ').map{|s| s.to_i}

  $layers = []

  $h.times do
    $layers << gets.strip.split(' ').map{|s| s.to_i}
  end
  #p $layers

  $mccache= $w.times.map{$h.times.map{[]}}
  $hmoves = (0...$w).map{|x0| (0...$w).map{|x1| hmoves(x0, x1)}}
  #p $hmoves

  min_cost = MAX_INT

  for x in (0...$w)
    cost = min_cost(x, 0, o)
    min_cost = cost if min_cost > cost
  end

  puts (min_cost >= MAX_INT ? 'NA' : min_cost)
end

Measured memory_bytes: 6460
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll gcd(ll, ll);

int main()
{
	int N;
	cin >> N;
	int g = 0;
	rep(i, N)
	{
		int tmp;
		cin >> tmp;
		g = gcd(g, tmp);
	}
	co(g);
	return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc178/abc178_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = max(a * c, a * d);
  ans = max(max(ans, b * c), b * d);

  cout << ans << endl;
}

Measured memory_bytes: 3612
s=[]
a=[]
gets.size.times{|i|c=$_[i]
if$*!=s&&c[?/]
x=s.pop
y=i-x
y+=a.pop[1]while a[-1]&&x<a[-1][0]
a.push [x,y]
end
s.push i if c[?\\]}
p(0,0)|exit if !A=a.transpose[1]
p A.reduce :+
puts [A.size,A]*" "

Measured memory_bytes: 6280
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    bool flag=0;
    if(b-a==c-b)
    {
        flag=1;
    }
    if(flag)
    {
        cout << "YES" << endl;
    }
    else
        cout << "NO" <<endl;
   // cout << "Hello world!" << endl;
    return 0;
}

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

int main(){
  long long a,b;
  cin >> a >> b;
  long long ans,c;
  for(long long i=0; i<b; i++){
    c=a*(b-i);
    if(c%b==0){
      ans=c;
    }
  }
  cout << ans << endl;
}

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

bool valid(int n, int a, int b){
	int sum = 0;
	while(n){
		sum += n%10;
		n /= 10;
	}
	return (sum >= a && sum <= b);
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	for(int i = 1 ; i <= N ; i++)
		if(valid(i, A, B)) ans += i;
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int ans = 0;
	int height = 0;
	for(int i=0;i<N;++i){
		int dh;
		cin>>dh;
		if(dh >= height){
			height = dh;
			++ans;
		}	
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
const int INF=1e9+5;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> vec(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    vector<int>dp(n,INF);
    dp[0]=0;
    //long long int ans=vec[0];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
            if(j<n)
            dp[j]=min(dp[i]+abs(vec[i]-vec[j]),dp[j]);
        //res=res+dp[i];
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
int main() {
	int N;
   cin>>N;
   vector<ll> mozi(26,1);
   string S;
   cin>>S;
   ll count=1;
   
   for(int i=0;i<N;i++){
      mozi.at(S.at(i)-'a')++;
   }
 for(int i=0;i<26;i++){
    count*=mozi.at(i);
    if(count>=mod){
      count%=mod;
    }
 }
 count--;
 cout<<count<<endl;
}


Measured memory_bytes: 512
import itertools

n = int(input())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))

result = list(itertools.permutations([i for i in range(1, n+1)], n))
# 中身がtuppleなのでlistに変換
result = list(map(lambda x: list(x), result))
a = result.index(p_list)
b = result.index(q_list)
print(abs(a-b))


Measured memory_bytes: 15092
//Created by apsp1234

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<string>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define ct continue
#define PI 3.14159265358979323846
#define maxn 100005
#define L length()
#define B begin()
#define T front()
#define E end()
#define Z size()
#define RB rbegin()
#define RE rend()
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i, j, q, t, n, y, k, x, m;
    string s;
    cin >> s;
    n = s.L;
    x = 0;
    for (j = 0; j < n; j++) {
        char c = s[j];
        m = c - 48;
        x = x + (m);
    }
    if (x % 9 == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

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

int main(){
	int n, a, b, c, d, t;
	while( cin >> n){
		t = 0;
		for(a = 0; a < 10; ++a){
			if( a > n ) break;
			for(b = 0; b < 10; ++b){
				if (a + b > n) break;
				for(c = 0; c < 10; ++c){
					if (a + b + c > n) break;
					d = n - ( a + b + c );
					if( 0 <= d && d <= 9)
						++t;
				}
			}
		}
		cout << t << "\n";
	}
	return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

ll n;

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

    cin >> n;
    vector<char> v;
    // cout << 26 * 26 << el;
    while (n > 26){
        ll dig = (n - 1LL) % 26LL;
        v.pb(char((int)dig + 'a'));
        n = (n - 1LL) / 26LL;
    }
    ll dig = (n - 1LL) % 26LL;
    v.pb(char((int)dig + 'a'));
    reverse(v.begin(), v.end());
    for (auto x : v) cout << x;
    cout << el;

    return 0;
}

Measured memory_bytes: 3652
using System;
using System.IO;

namespace problem
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            //int a = int.Parse(line);
            // 半角スペースで文字列を分割して、各々を配列の要素として入れる
            //string[] strs = line.Split(' ');
            //int b = int.Parse(strs[0]);

            if (line == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else 
            {
                Console.WriteLine("ABC");
            }            
        }
    }
}


Measured memory_bytes: 25660
l = input().split()
s = input()
 
n = int(l[0])
a = int(l[1])
b = int(l[2])
 
count = 0
countt = 0
for i in s:
    if i == 'a':
        if count < a+b:
            count = count + 1
            print('Yes')
        else:
            print('No')
    if i == 'b':
        if (count < a+b) and (countt < b):
            count = count + 1
            countt = countt + 1
            print('Yes')
        else:
            print('No')
    if i == 'c':
        print('No')

Measured memory_bytes: 4040
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int s = sc.nextInt();
        if (k > 0){
            System.out.print(s);
        }else{
            if (s < 1000000000){
                System.out.print(s+1);
            }else{
                System.out.print(s-1);
            }
        }
        for (int i=1; i<n; i++){
            if (i < k){
                System.out.print(" " + s);
            }else{
                if (s < 1000000000){
                System.out.print(" " + (s+1));
                }else{
                System.out.print(" " + (s-1));
                }
            }
        }
	}
}

Measured memory_bytes: 52688
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=100010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
double aa,bb;
vl v1,v2,v3;
vp vp1,vp2;
string s1[100000];
ll solve(void){
    for(ll i=1;i<sqrt(n)+1;i++){
        if(n%i==0){
            if(n/i>i){
            v1.push_back(i);
            v1.push_back(n/i);
            }
            if(n/i==i){
                v1.push_back(i);
            }
        }
    }

    rep(i,v1.size()){
        m=n/v1[i]-1;
        if(m>v1[i])ans+=m;
    }

    return ans;
}
int main(){
    cin>>n;
    
    cout<<solve()<<endl;
}

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

int main() {
  
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B) {
    cout << C << endl;
  }
  else if (B == C) {
    cout << A << endl;
  }
  else if (C == A) {
    cout << B << endl;
  }
  
return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int m=55;
vector<vector<char>> s(m,vector<char>(m));
vector<vector<int>> t(m,vector<int>(m));
queue<pair<int,int>> q;

void bfs(int x,int y){
  q.push(make_pair(0,0));
  t[0][0]=1;
  while(q.size()){
    pair<int,int> f=q.front();
    int u=f.first,v=f.second;
    if(u!=0&&s[u-1][v]=='.'&&t[u-1][v]==0){
      q.push(make_pair(u-1,v));
      t[u-1][v]=t[u][v]+1;
    }
    if(u!=x-1&&s[u+1][v]=='.'&&t[u+1][v]==0){
      q.push(make_pair(u+1,v));
      t[u+1][v]=t[u][v]+1;
    }
    if(v!=0&&s[u][v-1]=='.'&&t[u][v-1]==0){
      q.push(make_pair(u,v-1));
      t[u][v-1]=t[u][v]+1;
    }
    if(v!=y-1&&s[u][v+1]=='.'&&t[u][v+1]==0){
      q.push(make_pair(u,v+1));
      t[u][v+1]=t[u][v]+1;
    }
    q.pop();
  }
}

int main(){
  int h,w;
  cin >> h >> w;
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
      if(s[i][j]=='.'){
        cnt++;
      }
    }
  }
  bfs(h,w);
  if(t[h-1][w-1]==0){
    cout << -1 << endl;
  }
  else{
    cout << cnt-t[h-1][w-1] << endl;
  }
}


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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int K, X;
    cin >> K >> X;
    if (500 * K >= X){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		char[] ans=new char[n];
		String[] s=new String[n];
		for(int i=0; i<n; i++){
			s[i]=sc.next();
		}
		if(a+b+c==2){
			ArrayList<State> list=new ArrayList<>();
			String tmp=s[0];
			for(int i=0; i<n; i++){
				if(!tmp.equals(s[i])){
					list.add(new State(i-1,tmp));
					tmp=s[i];
				}
			}
			list.add(new State(n-1,tmp));
			int li=0;
			for(int i=0; i<n; i++){
				if(i-1==list.get(li).count){
					li++;
				}
				if(s[i].equals("AB")){
				if(a>b){
					a--;
					b++;
					ans[i]='B';
				}else if(a<b){
					b--;
					a++;
					ans[i]='A';
				}else{
					if(list.get(li).count==i){
						if(list.get(Math.min(list.size()-1,li+1)).idx.equals("BC")){
							b++;
							a--;
							ans[i]='B';
						}else{
							a++;
							b--;
							ans[i]='A';
						}
					}else{
						b--;
						a++;
						ans[i]='A';
					}
				}
			}else if(s[i].equals("BC")){
				if(c>b){
					c--;
					b++;
					ans[i]='B';
				}else if(c<b){
					b--;
					c++;
					ans[i]='C';
				}else{
					if(list.get(li).count==i){
						if(list.get(Math.min(list.size()-1,li+1)).idx.equals("AB")){
							b++;
							c--;
							ans[i]='B';
						}else{
							c++;
							b--;
							ans[i]='C';
						}
					}else{
						b--;
						c++;
						ans[i]='C';
					}
				}
			}else{
				if(a>c){
					a--;
					c++;
					ans[i]='C';
				}else if(a<c){
					c--;
					a++;
					ans[i]='A';
				}else{
					if(list.get(li).count==i){
						if(list.get(Math.min(list.size()-1,li+1)).idx.equals("BC")){
							c++;
							a--;
							ans[i]='C';
						}else{
							a++;
							c--;
							ans[i]='A';
						}
					}else{
						c--;
						a++;
						ans[i]='A';
					}
				}
			}
			if(a<0 || b<0 || c<0){
				System.out.println("No");
				return;
			}
			}
		}else{
		for(int i=0; i<n; i++){
			if(s[i].equals("AB")){
				if(a>b){
					a--;
					b++;
					ans[i]='B';
				}else{
					b--;
					a++;
					ans[i]='A';
				}
			}else if(s[i].equals("BC")){
				if(c>b){
					c--;
					b++;
					ans[i]='B';
				}else{
					b--;
					c++;
					ans[i]='C';
				}
			}else{
				if(a>c){
					a--;
					c++;
					ans[i]='C';
				}else{
					c--;
					a++;
					ans[i]='A';
				}
			}
			if(a<0 || b<0 || c<0){
				System.out.println("No");
				return;
			}
		}
		}
		System.out.println("Yes");
		for(int i=0; i<n; i++){
			System.out.println(ans[i]);
		}
	}
	static class State{
		int count;
		String idx;
		State(int count,String idx){
			this.count=count;
			this.idx=idx;
		}
	}
}


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

int main() {
    string s1,s2;
    cin>>s1>>s2;
    int count=0;
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s2[i]){
            count++;
        }
    }
    cout<<count;
	return 0;
}

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

int main(){
  long long int N ,ans = 0 ;
  string S ;
  cin >> N >> S;
  if(N % 2 == 0 && S.substr(0,N / 2) == S.substr(N / 2)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  long N, M;
  cin >> N >> M;
  vector<long> A(M);
  long sum =0;
  for(int i=0; i<M; i++){
    cin >> A[i];
    sum+=A[i];
  }
  long ans = N-sum >=0? N-sum: -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  a.append(input())
for i in range(m):
  b.append(input())
for i in range(n-m+1):
  for j in range(n-m+1):
    f=True
    for k in range(m):
      for l in range(m):
        if b[k][l]!=a[i+k][j+l]:
          f=False
    if f:
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	string s;
	cin >> s;
	int z=0,o=0;
	cu(i,0,s.length()){
		if(s[i] == '0')++z;
		else if(s[i] == '1')++o;
	}
	cout << 2 * min(z,o) << endl;
}


Measured memory_bytes: 636
import java.util.Scanner;

class Main{
	public static void main(String[] aegs) {
		Scanner sc=new Scanner(System.in);
		int kosu=0;
		while(true) {
			kosu=sc.nextInt();
			if(kosu==0) {
				System.exit(0);
			}
			String[] ko=new String[kosu];
			int[] mjs=new int[kosu];
			for(int i=0; i<kosu; i++) {
				ko[i]=sc.next();
				mjs[i]=ko[i].length();
			}

			boolean[] tanka= {false,false,false,false,false};
			int[] tnkmjs= {5,12,17,24,31};
			int sum=0;
			boolean pf=true;
			boolean end=false;

			for(int start=0; start<kosu; start++) {
				pf=false;
				sum=0;
				for(int j=start; j<kosu; j++) {
					if(end==true) {
						break;
					}
					sum+=mjs[j];
					for(int i=0; i<5; i++) {
						if(sum==tnkmjs[i]) {
							tanka[i]=true;
						}
					}
					if(sum>31) {
						for(int k=0; k<5; k++) {
							tanka[k]=false;
						}
						break;
					}
					if(sum==31) {
						pf=true;
						for(int i=0; i<5; i++) {
							if(tanka[i]==false) {
								pf=false;
							}
						}
						if(pf==true) {
							System.out.println(start+1);
							end=true;
							break;
						}
						else if(pf==false) {
							for(int k=0; k<5; k++) {
								tanka[k]=false;
							}
							break;
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 34024
#include <iostream>
#include <stdio.h>
#include <stack>
using namespace std;

int main()
{
    stack<int> S;
    int a, b;
    char c[100];
    
    while( scanf("%s", c) == 1) {
        if (c[0] == '+') {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a + b);
        } else if (c[0] == '-') {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a - b);
        } else if (c[0] == '*') {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a * b);
        } else {
            S.push(atoi(c));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3248
M, D = map(int, input().split(" "))
counter = 0
for i in range(1, M+1):
    for j in range(11, D+1):
        if int(str(j)[0])>=2 and int(str(j)[1])>=2:
            if i == int(str(j)[0]) * int(str(j)[1]):
                counter += 1
            else:
                counter += 0
print(counter)

Measured memory_bytes: 3188
#include<stdio.h>

int main(void)

{

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0) { printf("Yes\n");}else{ printf("No\n");} return 0;}

Measured memory_bytes: 1012
/*
auhtor:hbohra98
chandigarh univeristy
*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define VP vector < pair < ll , ll > >
#define VI vector< ll >
#define VS vector< string >
#define mk make_pair

using namespace std;
int main(){
 ll n;cin>>n;
 vector<ll>aa,kk;
 for(ll i=0;i<n;i++){
  ll io;cin>>io;
  aa.pb(io);
  kk.pb(io);
 }
 ll c=1;
 sort(kk.begin(),kk.end());
 for(ll i=n-2;i>=0;i--){
    if(kk[i]==kk[n-1])c++;
 }
  for(ll i=0;i<n;i++){
      if(aa[i]==kk[n-1] && c>1)cout<<kk[n-1]<<endl;
      else if(aa[i]==kk[n-1] && c==1)cout<<kk[n-2]<<endl;
      else cout<<kk[n-1]<<endl;
}
}

Measured memory_bytes: 4964
isPrime=[1 for i in range(0,55556)]
Primes=[]
isPrime[0]=0
isPrime[1]=0
for i in range(2,55556):
  if isPrime[i]==1:
    Primes.append(i)
    for j in range(2,int(55556/i)):
      isPrime[j*i]=0

li=[]
for i in Primes:
  if i%5==1:
    li.append(i)
ans=''
for i in range(0,int(input())):
  if i==0:
    ans+=str(li[i])
  else:
    ans+=' '+str(li[i])
  
print(ans)


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Maxn=310;
int N; LL A[Maxn][Maxn];
int main()
{

  scanf("%d",&N); for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) scanf("%lld",&A[i][j]);
  LL ans=0;
  for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) for(int k=1;k<=N;k++) if(A[i][j]>A[i][k]+A[k][j]){printf("-1\n"); return 0;}
  for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) if(i!=j)
  {
    bool bk=false;
    for(int k=1;k<=N;k++) if(i!=k && j!=k)
      if(A[i][j]==A[i][k]+A[k][j]) bk=1;
    if(!bk) ans+=A[i][j];
  }
  return printf("%lld\n",ans/2),0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B, C, D = MI()
t = -(-C // B)
a = -(-A // D)
print('Yes' if t <= a else 'No')


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

int main()
{
  vector<int> a(3);
  for (auto &e : a)
    cin >> e;
  sort(a.begin(), a.end());
  cout << a[1] - a[0] + a[2] - a[1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int n, m;
	cin >> n;
	vint d(n);
	rep(i, 0, n)
		cin >> d[i];
	cin >> m;
	vint t(m);
	rep(i, 0, m)
		cin >> t[i];
	map<int, int> a;
	rep(i, 0, n) {
		a[d[i]] = a[d[i]] + 1;
	}
	int flag = 0;
	rep(i, 0, m) {
		a[t[i]] = a[t[i]] - 1;
		if (a[t[i]] == -1) {
			flag = 1;
			break;
		}
	}
	if (flag == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate nPm
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int a, b, c; cin >> a >> b >> c;
    if (a == b && b == c) puts("1");
    else if (a == b || b == c || c == a) puts("2");
    else puts("3");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b;
    cin >> a >> b;
    
    cout << a*b - a - b + 1 << endl;
    
    return 0;

}

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

#define MAX_N (100)
#define MAX_M (100)
#define MAX_L (100)

using namespace std;

int main()
{ 
    int n, m, l;

    do {
        cin >> n >> m >> l;
    } while ((n < 1 || n > MAX_N) || (m < 1 || m > MAX_M) || (l < 1 || l > MAX_L));

    long** A = new long*[n];
    long** B = new long*[m];
  
    for (int i = 0; i < n; i++) {
         A[i] = new long[m];
    }

    for (int i = 0; i < m; i++) {
         B[i] = new long[l];
    }
  
    for (int i = 0; i < n; i++) {
         for (int j = 0; j < m; j++) {
	      do {
	          cin >> A[i][j];
              } while (A[i][j] < 0 || A[i][j] > 10000);
         }
    }

    for (int i = 0; i < m; i++) {
         for (int j = 0; j < l; j++) {
              do {
                  cin >> B[i][j];
              } while (B[i][j] < 0 || B[i][j] > 10000);
         }
    }

    long** C = new long*[n];

    for (int i = 0; i < n; i++) {
         C[i] = new long[l];
    }  

    for (int i = 0; i < n; i++) {
         for (int j = 0; j < l; j++) {
	      C[i][j] = 0;
         }
    }

    for (int i = 0; i < n; i++) {
         for (int j = 0; j < l; j++) {	      
	      for (int k = 0; k < m; k++) {
	           C[i][j] += A[i][k] * B[k][j];
	      }
         }
    }
      
    for (int i = 0; i < n; i++) {
         for (int j = 0; j < l; j++) {
              if (j != l - 1) {
                  cout << fixed << C[i][j] << " ";
              } else {
                  cout << fixed << C[i][j] << endl;
              }	 
         }
    }

    for (int i = 0; i < n; i++) {
         delete[] A[i];
    }

    delete[] A;
           
    for (int i = 0; i < m; i++) {
         delete[] B[i];
    }

    delete[] B;

    for (int i = 0; i < n; i++) {
         delete[] C[i];
    }

    delete[] C;
        
    return (0);
}

Measured memory_bytes: 1324