akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
int c[10005] = {0},d[10005] = {0};
using namespace std;
int func(int s,int t){
    int x = 0;
    while(c[s] == c[t] && d[s]+d[t] >= 4){
        x += d[s]+d[t];
        s = s-d[s];
        t += d[t];
    }
    return x;
}
int main(){
    int n;
    while(scanf("%d",&n),n){
        c[0] = 5;
        c[n+1] = 6;
        d[0] = d[n+1] = 0;
        scanf("%d",&c[1]);
        int x;
        x = c[1];
        int y = 1;
        for(int i = 2;i <= n+1; i++){
            if(i < n+1)scanf("%d",&c[i]);
            if(c[i] != x){
                for(int j = 1;j <= y; j++)d[i-j] = y;
                y = 1;
                x = c[i];
            }
            else y++;
        }
        int ans = 0;
        int s = 0,t = 0;
        for(int i = 1;i <= n; i++){
            if(c[i-1] == c[i+1]){
                if(c[i-1]!= c[i] && d[i-1] + d[i+1] >= 3){
                    s = (i-1) - d[i-1];
                    t = (i+1) + d[i+1];
                    ans = max(ans,d[i-1]+d[i+1]+1+func(s,t));
                }
            }
            else {
                if(c[i-1] != c[i] && d[i-1] >= 3){
                    s = (i-1) - d[i-1];
                    if(c[i] == c[i+1]){
                        t = i;
                        x = 0;
                    }
                    else {
                        t = i + 1;
                        x = 1;
                    }
                    ans = max(ans,d[i-1]+x+func(s,t));
                }
                if(c[i+1] != c[i] && d[i+1] >= 3){
                    t = (i+1) + d[i+1];
                    if(c[i] == c[i-1]){
                        s = i;
                        x = 0;
                    }
                    else {
                        s = i-1;
                        x = 1;
                    }
                    ans = max(ans,d[i+1]+x+func(s,t));
                }
            }
        }
        //printf("%d\n",ans);
        printf("%d\n",n-ans);
    }
    return 0;
}

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

string days(int i) {
  if(i == 0) return "SUN";
  else if(i == 1) return "MON";
  else if(i == 2) return "TUE";
  else if(i == 3) return "WED";
  else if(i == 4) return "THU";
  else if(i == 5) return "FRI";
  else return "SAT";
}

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 7; i++) {
    if (S == days(i)) {
      cout << 7 - i << endl;
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll INF = (1LL << 60);

int main(){
    int N; ll X, D;
    cin >> N >> X >> D;

    if (D == 0){
        if (X == 0) cout << 1 << endl;
        else cout << (N + 1) << endl;
        return 0;
    }

    if (D < 0)
        X *= -1, D *= -1;

    map<ll, vector<pair<ll, ll>>> LR;
    set<ll> keys;
    for (int k = 0; k <= N; ++k){
        ll key = (k * X % D + D) % D;
        keys.insert(key);

        ll base = k * X;
        if (base % D != 0 && base < 0){
            base /= D; --base;
        }
        else base /= D;

        ll l = base + k * (k - 1LL) / 2;
        ll r = base + k * (2 * (N - 1LL) - k + 1) / 2;

        LR[key].emplace_back(l, r);
    }

    ll res = 0;
    for (auto k : keys){
        sort(LR[k].begin(), LR[k].end());
        ll lst_added = -INF;
        for (auto pll : LR[k]){
            if (lst_added >= pll.second)
                continue;
            res += pll.second - max(lst_added, pll.first - 1);
            lst_added = pll.second;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 31488
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  long long m,s,n,i;
  m=pow(10,9)+7;
  while(~scanf("%ld",&n))
  {
      s=1;
      for(i=1;i<=n;i++)
      {
          s*=i;
          s%=m;
      }
      printf("%I64d\n",s);
  }
}

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

#define REP(i, N) for(int (i) = 0; (i) < (N); i++)
#define MAX 1 << 20

int main(){
    int h, w;
    char c[105][105];
    scanf("%d %d", &h, &w);
    REP(i, h){
        scanf("%s", c[i]);
    }
    REP(i, h) printf("%s\n%s\n", c[i], c[i]);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
  string S,T;
  cin >> S >> T;
  int i;
  for(i=0;i<S.length();i++) {
    if(S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
  int N,A;
  cin >> N >> A;
  
  int change = N%500;
  
  if(0<=change && change <= A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int d,n;cin>>d>>n;
    
    ll root = pow(100,d);
    
    if(n!=100){
        cout << root * n<<endl;
    }else{
        cout<<root*n + root<<endl;
    }
    return 0;
}





Measured memory_bytes: 384
/*input
16
0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7
5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9
-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9
-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1
-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3
-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2
7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5
2 -7 1 -1 9 1 -2 0 -6 0 -6 6 4 -1 -7 8
-4 2 4 9 1 -2 -2 -6 0 8 -6 -2 -4 8 7 7
0 -7 9 -3 -9 2 -9 0 8 0 0 1 -3 3 -6 -6
7 0 6 -5 -6 0 -3 -6 -6 0 0 5 7 -1 -5 3
0 -1 6 0 -3 -5 9 6 -2 1 5 0 -2 7 -8 0
2 -4 -6 1 -8 -2 -2 4 -4 -3 7 -2 0 -9 7 1
-3 1 1 2 3 3 9 -1 8 3 -1 7 -9 0 -6 -8
7 -1 8 -4 4 1 2 -7 7 -6 -5 -8 7 -6 0 -9
7 9 9 1 3 2 -5 8 7 -6 3 0 1 -8 -9 0
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 17;
int g[N][N];
long int prof[1<<N];
long int dp[1<<N];

int bit(int mask,int b)
{
	return (mask>>b)&1;
}

int main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>g[i][j];
	
	int MASK = (1<<n);
	for(int mask=0;mask<MASK;mask++) for(int a=0;a<n;a++) for(int b=a+1;b<n;b++) if(bit(mask,a) && bit(mask,b) ) prof[mask]+=(long int)g[a][b];

	// for(int mask=0;mask<MASK;mask++) cout<<prof[mask]<<"\n";

	dp[0]=prof[0];
	for(int curMask=1;curMask<MASK;curMask++)
	{
		dp[curMask]=prof[curMask];
		for(int mask = (curMask-1)&curMask;mask>0;mask=(mask-1)&curMask)
		{
			assert(mask<curMask);
			dp[curMask]=max(dp[curMask],dp[mask]+prof[curMask^mask]);
			// cout<<mask<<"\n";
		}

		// cout<<curMask<<" "<<dp[curMask]<<"\n";

	}

	cout<<dp[MASK-1]<<"\n";




	return 0;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n;cin >> n;
    vector<ll> height(n+3,0);
    rep(i,n)cin >> height[i];
    vector<ll> dp(n+3,INF);
    dp[0] = 0;
    rep(i,n){
        dp[i+1] = min(dp[i+1],dp[i] + abs(height[i] - height[i+1]));
        dp[i+2] = min(dp[i+2],dp[i] + abs(height[i] - height[i+2]));
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
    using namespace std;

    bool ar[105];
    int main() {
       int a,b,c;
       memset(ar,1,sizeof(ar));
       cin>>a>>b;
       int m = 0;
       int mm = 0;
       for(int i =1;i<=b;i++){
        cin>>c;
        m = max(m,c);
        mm = min(mm,c);
        ar[c] = 0;
       }

       if(ar[a]){
        cout<<a<<endl;
        return 0;
       }

       int sl =101;
       int sr = 101;
       for(int i = 0;i<=102;i++){
        if(ar[i] && i<a){
            sl = min(sl,abs(i-a));
        }
        if(ar[i] && i>a){
           sr  = min(sr,abs(i-a));
        }

       }
       //cout<<sl<<" "<<sr<<endl;
       if(sl>sr)cout<<a+sr<<endl;
       else cout<<a-sl<<endl;

        return 0;
    }


Measured memory_bytes: 3636
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   vector<int>w(n);
   rep(i,n) cin >> w[i];

   int mind = 1000000;
   int delt = 0;
   for(int i=1;i<=n;i++){
      int suml = 0;
      int sumh = 0;
      for(int j=0;j<n;j++){
         if(j+1<=i){
            suml += w[j];
         }else{
            sumh += w[j];
         }
      }
      delt = abs(sumh-suml);
      mind = min(delt,mind); 
   }
   cout << mind << endl;



   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,stor,peo;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>stor>>peo;
        if(stor%peo==0)cout<<peo<<endl;
        else cout<<stor%peo<<endl;
    }
}

Measured memory_bytes: 1160
import itertools

books_num, alg_num, goal = map(int, input().split())
book = [[None]*(alg_num + 1) for _ in range(books_num)]

for i in range(books_num):
    book[i] = list(map(int, input().split()))
# print(book)

ans = float('inf')
seq = [i for i in range(books_num)]
flag = True
for i in range(books_num, 0, -1):
    if(not flag):
        break
    flag = False
    for seq_tmp in itertools.combinations(seq, i):
        skill = [0]*alg_num
        ans_tmp = 0
        for j in seq_tmp:
            for k in range(alg_num):
                skill[k] += book[j][k+1]
            ans_tmp += book[j][0]
            # print(skill, ans_tmp, ans, seq_tmp)
            for k in range(alg_num):
                if skill[k] < goal:
                    break
            else:
                ans = min(ans, ans_tmp)
                flag = True
print(ans if ans != float('inf') else -1)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    string str; cin >> str;
    int sz = str.size(); str.clear();
    str.append(sz,'x');
    cout << str << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>


using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const set<A>& s) {
    for(auto it = s.begin(); it != s.end(); ++it) {
        output << *it << endl;
    }
    return output;
}

template<class A, class B>
ostream& operator << (ostream& output, const map<A, B>& m) {
    for(auto it = m.begin(); it != m.end(); ++it) {
        output << "[" << it->first << ", " << it->second << "]" << endl;
    }
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    unordered_map<string, int> umap;
    long long ans = 0;
    for(int i = 0; i < n; ++i) {
    	string str;
    	cin >> str;
    	sort(str.begin(), str.end());
    	ans += umap[str];
    	umap[str]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  //int A, B, C, D;
  //cin >> A >> B >> C >> D;
  int a[8];
  for (int i=0; i < 4; ++i) cin >>a[i];
  int res=0;

  if (a[2] >= a[1] || a[0] >= a[3]) { //時間がかぶっていなければ
    res=0;
    } else {
    sort(a, a+4); //真ん中の２つの値の差を取る
    res = a[2]-a[1];
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;


std::vector<bool> UpFlags(int n, int size) {
  std::vector<bool> up_flags(size);
  for (int i = 0; i < size; ++i) {
    if (n & (1<<i)) up_flags[i] = true;
    else            up_flags[i] = false;
  }
  return up_flags;
}

int main() {
  string A; cin >> A;
  for (int i = 0; i < (1 << 3); ++i) {
    auto flags = UpFlags(i, 3);
    int sum = A[0] - '0';
    string S;
    S = A[0];
    for (int i = 0; i < 3; ++i) {
      if (flags[i]) {
        sum += A[i+1] - '0';
        S = S + "+" + A[i+1];
      } else {
        sum -= A[i+1] - '0';
        S = S + "-" + A[i+1];
      }
    }
    if (sum == 7) {
      cout << S << "=7" << endl;
      return 0;
    }
  }
}


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

using namespace std;

int a[11][10001], r, c, flag[12];

int dfs (int depth, int f)
{
    if (depth<r)
    {
        flag[depth]=f;
        return max(dfs(depth+1, 0), dfs(depth+1, 1));
    }
    flag[depth]=f;
    int best=0, sum, cpy[11][10001];
    for (int i=1; i<=r; i++)
    {
        if (flag[i]==1)
        {
            for (int j=1; j<=c; j++)
            {
                if (a[i][j]==0) cpy[i][j]=1;
                else cpy[i][j]=0;
            }
        }
        else for (int j=1; j<=c; j++) cpy[i][j]=a[i][j];
    }
    for (int i=1; i<=c; i++)
    {
        sum=0;
        for (int j=1; j<=r; j++)
        {
            if (cpy[j][i]==1) sum++;
        }
        best+=max(sum, r-sum);
    }
    return best;
}

int main()
{
    while (1)
    {
        cin>>r>>c;
        if (r==0 && c==0) break;
        for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) cin>>a[i][j];
        cout<<dfs(0,0)<<'\n';
    }
    return 0;
}



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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d,t,s;cin >> d >> t >> s;
    if(t<(double)d/s) cout << "No" ENDL;
    else cout << "Yes" ENDL;
    
    return 0;
}

Measured memory_bytes: 5988
#include <stdio.h>

int magic[20][20] = {0};
int a, b, n;

void select(int i){
  if (a > n) {
    a = 1;
    if (magic[a][b] == 0 && a <= n && b <= n) {
      magic[a][b] = i;
      a++;
      b++;
    }
    else {
      select(i);
    }
  }
  else if (b > n) {
    b = 1;
    if (magic[a][b] == 0 && a <= n && b <= n) {
      magic[a][b] = i;
      a++;
      b++;
    }
    else {
      select(i);
    }
  }
  else if (b < 1) {
    b = n;
    if (magic[a][b] == 0 && a <= n && b <= n) {
      magic[a][b] = i;
      a++;
      b++;
    }
    else {
      select(i);
    }
  }
  else if (a <= n && b <= n) {
    if (magic[a][b] == 0) {
      magic[a][b] = i;
      a++;
      b++;
    }
    else {
      a++;
      b--;
      select(i);
    }
  }
  else {
    select(i);
  }
}

void func(){
  int i;

  a = (n + 1) / 2;
  b = (n + 1) / 2;
  a++;
  magic[a][b] = 1;
  a++;
  b++;
  for (i = 2; i <= n*n; i++) {
    select(i);
  }
}

int main(){
  int i, j;

  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        magic[i][j] = 0;
      }
    }
    func();
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        printf("%4d", magic[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            double r = double.Parse(line);

            Console.WriteLine("{0:0.000000} {1:0.000000}", Math.PI * r * r, 2 * Math.PI * r);

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9272
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var a, b, c int
	fmt.Sscan(getNextLine(scanner), &a, &b, &c)

	if a < b {
		if a < c && c < b {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		if b < c && c < a {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <set>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int64_t> a;
	for (int i = 0; i < n; ++i) {
		int64_t ai;
		cin >> ai;
		a.push_back(ai);
	}
	const int64_t inf = 1ULL << 62;
	vector<vector<int64_t>> dp(n + 1, vector<int64_t>(3,-inf));
	dp[0][0] = 0;
	// 0 : not carry
	// 1 : carry
	for (int i = 0; i < n; ++i) {
		int64_t v1 = dp[i][0] + a[i];
		int64_t v2 = dp[i][1] - a[i];
		dp[i + 1][0] = max(max(v1, v2), -inf);

		int64_t v3 = dp[i][0] - a[i];
		int64_t v4 = dp[i][1] + a[i];
		dp[i + 1][1] = max(max(v3, v4), -inf);
	}
	cout << dp[n][0] << endl;
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t count_i(int64_t k, int64_t p) {
    int64_t t = 0;
    while (k % p == 0) {
        ++t;
        k /= p;
    }

    return min(t, 9L);
}

int main() {
    int64_t n;
    cin >> n;

    vector<pair<int64_t, int64_t>> a(n);
    for (auto&& aa : a) {
        double d;
        cin >> d;

        int64_t dd = llround(d * 1000000000L);
        int64_t g = gcd(dd, 1000000000L);

        aa = {dd / g, 1000000000L / g};
    }

    vector m(10, vector(10, vector(10, vector(10, 0L))));
    for (auto aa : a) {
        auto b2 = count_i(aa.first, 2);
        auto b5 = count_i(aa.first, 5);
        auto c2 = count_i(aa.second, 2);
        auto c5 = count_i(aa.second, 5);

        ++m[b2][b5][c2][c5];
    }

    for (auto i : irange(0L, 10L)) {
        for (auto j : irange(0L, 10L)) {
            for (auto k : irange(0L, 10L)) {
                for (auto k2 : irange(1L, 10L)) {
                    m[i][j][k][k2] += m[i][j][k][k2 - 1];
                }
            }
            for (auto k : irange(1L, 10L)) {
                for (auto k2 : irange(0L, 10L)) {
                    m[i][j][k][k2] += m[i][j][k - 1][k2];
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto aa : a) {
        auto b2 = count_i(aa.first, 2);
        auto b5 = count_i(aa.first, 5);
        auto c2 = count_i(aa.second, 2);
        auto c5 = count_i(aa.second, 5);

        for (auto i2 : irange(c2, 10L)) {
            for (auto i5 : irange(c5, 10L)) {
                ans += m[i2][i5][b2][b5];
            }
        }

        if (aa.second == 1) {
            --ans;
        }
    }

    assert(ans % 2 == 0);
    cout << ans / 2 << endl;
}


Measured memory_bytes: 6236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
  cin >> t;

  int N;
  N = t.size();
  
  for (int i = 0; i < N; i++ ) {
    if (t.at(i) == '?') {
      t.at(i) = 'D';
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll n, x, t; cin >> n >> x >> t;
	ll res = ceil(n * 1.0 / x);
	cout << res*t;
	cout << "\n";
	return ;
}


Measured memory_bytes: 3756
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;
	t--;
	vector<vector<ll>> adj(n);
	REP(i,m) {
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	vector<ll> froms(n,INF);
	vector<ll> fromt(n,INF);
	froms[s]=0;
	fromt[t]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty()) {
		ll p=q.front();
		q.pop();
		REP(i,adj[p].size()) {
			if(froms[adj[p][i]]>froms[p]+1) {
				froms[adj[p][i]]=froms[p]+1;
				q.push(adj[p][i]);
			}
		}
	}
	q.push(t);
	while(!q.empty()) {
		ll p=q.front();
		q.pop();
		REP(i,adj[p].size()) {
			if(fromt[adj[p][i]]>fromt[p]+1) {
				fromt[adj[p][i]]=fromt[p]+1;
				q.push(adj[p][i]);
			}
		}
	}
	vector<ll> cnt1(n,0);
	vector<ll> cnt2(n,0);
	REP(i,n) if(froms[i]!=INF) cnt1[froms[i]]++;
	REP(i,n) if(fromt[i]!=INF) cnt2[fromt[i]]++;
	ll ans=0;
	REP(i,n) {
		if(froms[t]-i-2>=0) ans+=cnt1[i]*cnt2[froms[t]-i-2];
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 13640
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    for i in 1..n + 1 {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            continue;
        }
        'include3: while x > 0 {
            if x % 10 == 3 {
                print!(" {}", i);
                break 'include3;
            }
            x /= 10;
        }
    }
    println!();
}


Measured memory_bytes: 5036
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;




    ll dp[51][510][510];
int main()
{
    
    int n, m, p;
    cin >> n >> m >> p;
    vector<int>a(n), b(n),c(n);

    for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];


    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 510; j++) {
            for (int k = 0; k < 510; k++) {
                dp[i][j][k] = 99999999999999999;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 500; j++) {
            for (int k = 0; k < 500; k++) {
                if (dp[i][j][k] == 1000000000)continue;
                dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    ll ans = 99999999999999999;
    for (int i = 1; i < 500; i++) {
        for (int j = 1; j < 500; j++) {
            if (m * j != i * p)continue;
            ans = min(ans, dp[n][i][j]);
        }
    }
    if (ans == 99999999999999999)cout << -1 << endl;
    else cout << ans << endl;

    return 0;

}

Measured memory_bytes: 105240
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long x, xx, y, yy, N, M, ans, A[100000], AA[100000];
string S, s;
bool h, k[101];

int main() {
	cin >> x >> y >> xx >> yy;
	if (y > yy) {
		if (x > xx) {
			cout << xx + (y - yy) << " " << yy - (x - xx) << " " << x + (y - yy) << " " << y - (x - xx) << endl;
		}
		else {
			cout << xx + (y - yy) << " " << yy + (xx - x) << " " << x + (y - yy) << " " << y + (xx - x) << endl;
		}
	}
	else {
		if (x > xx) {
			cout << xx - (yy - y) << " " << yy - (x - xx) << " " << x - (yy - y) << " " << y - (x - xx) << endl;
		}
		else {

			cout << xx - (yy - y) << " " << yy + (xx - x) << " " << x - (yy - y) << " " << y + (xx - x) << endl;
		}
	}

	return 0;

}





Measured memory_bytes: 256
n, m = list(map(int, input().split()))
k = [list(map(int, input().split())) for _ in range(n)]
ser = min(k)[1:]
ans = 0
for i in ser:
    for j in range(n):
        if i in k[j][1:]:
            pass
        else:
            break
    else:
        ans += 1
print(ans)

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

int parent(int num)
{
	return num / 2;
}
int left(int num)
{
	return num * 2;
}
int right(int num)
{
	return num * 2 + 1;
}
int main()
{
	int A[100000];
	int N;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
	for (int i = 1; i <= N; i++) {
		printf("node %d: key = %d, ", i, A[i]);
		if (parent(i) > 0)printf("parent key = %d, ", A[parent(i)]);
		if (left(i) <= N)printf("left key = %d, ", A[left(i)]);
		if (right(i) <= N)printf("right key = %d, ", A[right(i)]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3208
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <typeinfo>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;
  char s[] = {'M', 'A', 'R', 'C', 'H'};

  map<char, llong> mp;
  REP(i,n){
    string tmp;
    cin >> tmp;
    mp[tmp[0]]++;
  }

  llong ans = 0;

  REP(i,5){
    FOR(j,i+1,5){
      FOR(k,j+1,5){
        if(mp[s[i]] != 0 && mp[s[j]] != 0 && mp[s[k]] != 0){
          ans += mp[s[i]] * mp[s[j]] * mp[s[k]];
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}



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

int main ()
{
    int n;
    int r=0,w=0;
    int ans=0;
    char s[200010];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        (s[i]=='R')?r++:w++;
    }
    for(int i=0;i<r;i++)
    {
        if(s[i]=='W') ans++;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string a;
   int k=0;
   cin>>a;
   for(int i=0;i<a.size();i++)
   {
      if(a[i]=='C')k=1;
      if(a[i]=='F'&&k)k=2;
   }
   if(k==2)puts("Yes");
   else puts("No");
   return 0;
}

Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
lis=list(reversed(lis))
st=lis[0]
for i in range(n-1):
    if lis[i+1]>lis[i]+1:
        print("No")
        sys.exit()
    elif lis[i+1]==lis[i]+1:
        lis[i+1]-=1
    else:
        continue
print("Yes")

Measured memory_bytes: 21052
//abc123 b 最後に注文するものを決める
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

//10分単位で合わせる
int maxtime(int x){
    return (x+9)/10*10;
}
//最後に提供するものを決める
int mintime(int x){
    return maxtime(x)-x;
}
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int sum;
    sum=maxtime(a)+maxtime(b)+maxtime(c)+maxtime(d)+maxtime(e);
    int de= max({mintime(a),mintime(b),mintime(c),mintime(d),mintime(e)});
    //cout<<sum<<endl;
    //cout<<de<<endl;
    sum=sum-de;
    cout<<sum<<endl;
    return 0;
}

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

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


// struct second_order {
//   bool operator()(const value_type& x, const value_type& y) const {
//     return x.second < y.second;
//   }
// };

void solve() {
    int N; cin >> N;
    map<string, int> mp;
    rep(i, N){
        string s; cin >> s;
        ++mp[s];
    }

    int M; cin >> M;
    rep(i, M){
        string t; cin >> t;
        --mp[t];
    }

    auto greater = [](const P& x, const P& y){
        return x.second < y.second;
    };
    priority_queue< P, vector<P>, decltype(greater) > que(greater);
    for(auto & m : mp){
        que.push(m);
    }
    if(que.top().second > 0){
        cout << que.top().second << "\n";
    }else{
        cout << 0 << "\n";
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define dist(a,b) max(a-b,b-a)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
// void print(list<pair<int,int>>& que){
//   for(auto x:que) printf("(%d %d)",x.first,x.second);
//   printf("\n");
// }
void print(vector<int>& v){
  for(auto x: v) printf("%2d",x);
  printf("\n");
}
void print(vector<vector<int>>& s){
  for(auto x: s) print(x);
}

template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int order(int n){
  int cnt=0;
  while(n%2==0) {cnt++; n/=2;}
  return cnt;
}

int main(){
  int n; cin >>n;
  string s; cin >>s;
  vector<int> v(n),d(n);
  int flag=1;
  rep(i,n) {
    v[i]=s[i]-'1';
    d[i]=v[i];
    if(v[i]==1)flag=0;
  }
  if(df)print(v);
  if(flag){
    rep(i,n) v[i]/=2;
  }else{
    rep(i,n) v[i]%=2;
  }
  if(df)print(v);
  int ans=v[0],ord=0;
  n--;
  rep(i,n){
    int a=order(n-i);
    if(df) print(n-i,":",a);
    ord+=a;
    a=order(i+1);
    if(df) print(i+1,":",a);
    ord-=a;
    if(ord==0) ans^=v[i+1];
    if(df) print(n,"C",i+1,":",ord,"->",ans);
  }

  flag++;
  print(ans*flag);


  if(df){
    print(d);
    rep(i,n){
      int m=d.size();
      rep(j,m-1){
        d[j]=dist(d[j],d[j+1]);
      }
      d.pop_back();
      rep(j,i+1) printf(" ");
      print(d);
    }
  }
}


Measured memory_bytes: 9220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,T,S;
  cin>>D>>T>>S;
  if(S*T>=D){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
vector<bool>is_prime(100005, true);

int main()
{
    fastio;
    string ar[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin>>s;
    for(ll i=0;i<7;++i){
        if(ar[i]==s){
            cout<<7-i;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

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

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}

int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,b=0,c=0,w;
    cin>>n>>w;
    ll dp[w+1][n+1];
    memset(dp,0,sizeof(dp));
    vi v1,v2;
    v1.pb(0),v2.pb(0);
    r(i,0,n)
    {
      cin>>k>>l;
      v1.pb(k);
      v2.pb(l);
    }
    for(i=1;i<=n;i++)
    {
      for(j=1;j<=w;j++)
      {
        if(v1[i]>j)
        dp[j][i]=dp[j][i-1];
        else
        dp[j][i]=max(dp[j][i-1],dp[j-v1[i]][i-1]+v2[i]);
      }
    }
    cout<<dp[w][n];
}

Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
  ll h;
  cin >> h;
  ll ans = h;
  ll count = 0;
  ll aa = 1;
  if (h==1) {cout << 1 << endl; return 0;}
  while (ans != 1)  {
    ans = ans/2;
    count += aa;
    aa *= 2;
    if(ans ==1) {
      count +=  aa;
      break;
    }
  }
  cout << count << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(n);
	makev(a, n);
	sort(all(a));
	int ai = a.back();
	cout << ai << " ";
	auto it = lower_bound(all(a), ai / 2.);
	int aj = abs(*it - ai / 2.) < abs(*(it - 1) - ai / 2.) ? *it : *(it - 1);
	say(aj);
}

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

string s;
int k;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	cin>>k;
	int n=s.size();
	
	for(int i=0;i<n;i++)
	{
		if(s[i]=='a')
			continue;
		int req=(('z'-s[i])+1);
		if(req<=k)
		{
			s[i]='a';
			k-=req;
		}
	}
	//k is left
	
	//s[n-1]=(char)(s[n-1]+k);
	s[n-1]=(char)('a'+((s[n-1]-'a')+k)%26);
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<valarray>
#include<cmath>

using namespace std;

double dist(valarray<double> a,valarray<double> b){
  double s=0;
  for(int i=0;i<3;i++){
    s+=(a[i]-b[i])*(a[i]-b[i]);
  }
  return sqrt(s);
}

int main(){
  for(int n;cin>>n,n;){
    valarray<double> p[30];
    for(int i=0;i<n;i++){
      p[i].resize(3);
      cin>>p[i][0]>>p[i][1]>>p[i][2];
    }
    valarray<double> c(50,3);
    double w=1;
    double ld;
    for(int i=0;i<100000;i++,w*=.999){
      double m=-1;
      int x;
      for(int j=0;j<n;j++){
	auto d=dist(p[j],c);
	if(d>m){
	  m=d;
	  x=j;
	}
      }
      ld=m;
      valarray<double> v=p[x]-c;
      c+=v*w;
    }
    cout.precision(5);
    cout<<fixed<<ld<<endl;
  }
}

Measured memory_bytes: 1292
#include <stdio.h>
#define max 2000000
int a[max+1], b[max+1], c[max+1];

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

  for(i = 0; i < n; i++){
    scanf("%d",&a[i+1]);
  }
   
  for(i = 0; i < n; i++){ //iの出現回数をカウント
    c[a[i+1]]++;
  }
  for(i = 0; i < max; i++){ //i以下の出現回数カウント
    c[i+1] = c[i+1] + c[i];
  }
  for(i = n; i > 0; i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
  for(i = 0; i < n-1; i++){
    printf("%d ",b[i+1]);
  }
  printf("%d\n",b[n]);

  return 0;
}


Measured memory_bytes: 25148
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
//$s = trim(fgets(STDIN));
list($A,$B,$C,$D) = explode(" ",trim(fgets(STDIN)));
if ($A+$B == $C+$D) {
  printf("Balanced\n");
  exit;
}
if ($A+$B > $C+$D) {
  printf("Left\n");
}
else {
  printf("Right\n");
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

ll sumOfDigit(ll x)
{
  ll ret = 0;
  while (x) {
    ret += x % 10;
    x /= 10;
  }
  return ret;
}
ll f(ll N)
{
  vector<pair<double, ll>> v;
  string S = to_string(N);
  for (int i = 0; i <= S.size(); i++) {
    string T(S);
    for (int j = 0; j < i; j++) {
      T[T.size() - j - 1] = '9';
    }
    ll num = stoll(T);
    v.push_back(make_pair((double)num/sumOfDigit(num), num));
  }
  return min_element(v.begin(), v.end())->second;
}

int main()
{
  ll K;
  cin >> K;

  ll N = 1;
  for (int i = 0; i < K; i++) {
    cout << N << endl;
    N = f(N + 1);
  }
  return 0;
}

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

int main() {
  int c11,c12,c13,c21,c22,c23,c31,c32,c33;
  cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
  for(int a1=0; a1<=100; a1++) {
    for(int a2=0; a2<=100; a2++) {
      for(int a3=0; a3<=100; a3++) {
        int b1 = c11 - a1;
        int b2 = c12 - a1;
        int b3 = c13 - a1;
        if(b1==c21-a2 && b1==c31-a3 && b2==c22-a2 && b2==c32-a3 && b3==c23-a2 && b3==c33-a3) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3672
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

const W: usize = 100_000;
// const W: usize = 10;

#[fastout]
fn main() {
    input! {
        n: usize,
        item: [(i64, usize); n],
        q: usize,
        query: [(Usize1, usize); q],
    }
    let m = cmp::min(n, 1024) as usize;
    let mut max_val = vec![vec![0i64; W + 1]; m + 1];
    for (i, &(a, b)) in item.iter().take(m).enumerate() {
        for w in 0..=W {
            max_val[i + 1][w] =
                cmp::max(max_val[(i + 1) / 2][w], max_val[i + 1][w.saturating_sub(1)]);
            if let Some(pw) = w.checked_sub(b) {
                max_val[i + 1][w] = cmp::max(max_val[i + 1][w], max_val[(i + 1) / 2][pw] + a);
            }
        }
    }
    for &(v, l) in &query {
        if v < m {
            println!("{}", max_val[v + 1][l]);
        } else {
            let mut vs = vec![item[v]];
            let mut v = v;
            loop {
                v = (v - 1) / 2;
                if v < m {
                    break;
                }
                vs.push(item[v]);
            }
            let last_v = v;
            let mut ret = 0i64;
            for pat in 0..1 << vs.len() {
                let mut value = 0i64;
                let mut w = 0usize;
                for (i, &(a, b)) in vs.iter().enumerate() {
                    if (pat >> i) & 1 != 0 {
                        value += a;
                        w += b;
                    }
                }

                if let Some(pw) = l.checked_sub(w) {
                    ret = cmp::max(ret, value + max_val[last_v + 1][pw]);
                }
            }
            println!("{}", ret);
        }
    }
}


Measured memory_bytes: 816320
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define mod 1000000007;
#define my_mod 2019;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s;
    cin >> s;
    rep(i,s.size()) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 256
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    S_count = Counter(S)
    cnt = len(S) - abs(S_count['0']-S_count['1'])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 39792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
using ll = long long ;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int a[N];
int nxt[N];
int main(){

  int n;  cin >> n;

  for(int i = 0; i < n; i++)
    cin >> a[i];
  nxt[n-1] = n;
  for(int i = n-2; i >= 0; --i){
    if(a[i+1] == 0)nxt[i] = nxt[i+1];
    else nxt[i] = i + 1;
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    int cur1 = 0, cur2 = 0;

    for(int j = i; j < n && (cur1 == cur2); j = nxt[j]){
      cur1 += a[j];
      cur2 ^= a[j];
      ans += (cur1 == cur2) * (nxt[j] - j);
    }

  }

  cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 1792