akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  string s;
  cin >> s;
  int ans = 0, n = s.size();
  rep(i, n / 2){
    if(s[i] != s[n - i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	switch(n){
		case 111:
			printf("999\n");
			break;
		case 119:
			printf("991\n");
			break;
		case 191:
			printf("919\n");
			break;
		case 199:
			printf("911\n");
			break;
		case 911:
			printf("199\n");
			break;
		case 919:
			printf("191\n");
			break;
		case 991:
			printf("119\n");
			break;
		case 999:
			printf("111\n");
			break;
	}
	return 0;
}



Measured memory_bytes: 128
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl; return 0;
#define NO_ cout<<"No"<<endl; return 0;

int main(){
    
    
    int n;
    char a;
    cin>>n;
    REP(i,n){
        cin>>a;
        if(a=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }

    cout<<"Three"<<endl;
            return 0;


}


Measured memory_bytes: 256
#d
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x: x[1])
a, b = [list(i) for i in zip(*ab)]
import sys
time_sum=0
limit_sum =0

for i in ab:
    time_sum += i[0]
    limit_sum = i[1]
    if time_sum > limit_sum:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 70912
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a * b % 2 == 1 || a * b * 3 % 2 == 1)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


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

int main()
{
  long long n,k;cin>>n>>k;
  vector<long long> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  vector<long long> sum(n+1,0);
  for(i=0;i<n;i++)
  {
    a.at(i)--;
    sum.at(i+1)=(sum.at(i)+a.at(i))%k;
  }
  map<long long,long long> m;
  m.insert(make_pair(0,1));
  long long ans=0;
  for(i=0;i<n;i++)
  {
    if(i>=k-1)
    {
      if(m.at(sum.at(i-k+1))>1)
      {
        long long num=m.at(sum.at(i-k+1));
        m.erase(sum.at(i-k+1));
        m.insert(make_pair(sum.at(i-k+1),num-1));
      }
      else
      {
        m.erase(sum.at(i-k+1));
      }
    }
    if(m.count(sum.at(i+1))==1)
    {
      ans+=m.at(sum.at(i+1));
      long long num=m.at(sum.at(i+1));
      m.erase(sum.at(i+1));
      m.insert(make_pair(sum.at(i+1),num+1));
    }
    else
    {
      m.insert(make_pair(sum.at(i+1),1));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
s = gets.chomp
n = s.size
num = Array.new(n+1,0)

j = 0
k = 0
k += 1 while k < n && s[k] == ">"
(n+1).times do |i|

    if k == 0
        k += 1 while i + k < n && s[i+k] == ">"
    end

    num[i] = j > k ? j : k

    k -= 1 if k > 0
    j += s[i] == "<" ? 1 : -j
end

#p num
puts num.inject(:+)

Measured memory_bytes: 6796
#pragma once

#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
/*
 * @see https://snuke.hatenablog.com/entry/2017/07/18/101026
 */
//BEGIN CUT HERE
// longest prefix suffix matching of [0, i)
vector<int> knuth_morris_pratt(const string &s){
  int n=s.size();
  vector<int> kmp(n+1,-1);
  for(int i=0,j=-1;i<n;i++){
    while(~j&&s[i]!=s[j]) j=kmp[j];
    kmp[i+1]=++j;
    if(i+1<n&&s[i+1]==s[j]) kmp[i+1]=kmp[j];
  }
  return kmp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const string &s){
  auto kmp=knuth_morris_pratt(s);
  for(int i=1;i<(int)kmp.size();i++) kmp[i]=i-kmp[i];
  return kmp;
}
// positions for t that match s
vector<int> pattern_match(string s,string t){
  int n=s.size(),m=t.size();
  vector<int> kmp=knuth_morris_pratt(s);

  vector<int> res;
  int i=0,j=0;
  while(i+j<m){
    if(s[j]==t[i+j]){
      if(++j!=n) continue;
      res.emplace_back(i);
    }
    i+=j-kmp[j];
    j=max(kmp[j],0);
  }
  return res;
}
//END CUT HERE
#ifndef call_from_test

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE

// test knuth_morris_pratt
signed ABC135_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s,t;
  cin>>s>>t;

  int n=s.size(),m=t.size();

  string b;
  while(b.size()<t.size()) b+=s;
  auto kmp=knuth_morris_pratt(t+'$'+b+b);

  vector<int> match(n);
  for(int i=m+1;i<=m+n;i++)
    match[i-(m+1)]=kmp[i+m]==m;

  vector< vector<int> > G(n);
  for(int i=0;i<n;i++)
    if(match[i]) G[i].emplace_back((i+m)%n);

  vector<int> indeg(n,0);
  for(int i=0;i<n;i++)
    for(int j:G[i]) indeg[j]++;

  queue<int> que;
  for(int i=0;i<n;i++)
    if(indeg[i]==0) que.emplace(i);

  vector<int> dp(n,0);
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int u:G[v]){
      chmax(dp[u],dp[v]+1);
      indeg[u]--;
      if(indeg[u]==0) que.emplace(u);
    }
  }

  for(int i=0;i<n;i++){
    if(indeg[i]!=0){
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}
/*
  verified on 2019/08/21
  https://atcoder.jp/contests/abc135/tasks/abc135_f
*/

// test minimum_period
signed ARC060_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string w;
  cin>>w;

  int n=w.size();
  if(w==string(n,w[0])){
    cout<<n<<endl<<1<<endl;
    return 0;
  }

  auto kmp=minimum_period(w);
  if(n%kmp[n]!=0||n==kmp[n]){
    cout<<1<<endl<<1<<endl;
    return 0;
  }

  string w_rev=w;
  reverse(w_rev.begin(),w_rev.end());
  auto kmp_rev=minimum_period(w_rev);

  int cnt=0;
  for(int i=1;i<n;i++){
    int j=n-i;
    if(i%kmp[i]==0&&i>kmp[i]) continue;
    if(j%kmp_rev[j]==0&&j>kmp_rev[j]) continue;
    cnt++;
  }
  cout<<2<<endl<<cnt<<endl;
  return 0;
}
/*
  verified on 2019/08/21
  https://atcoder.jp/contests/arc060/tasks/arc060_d
*/

signed main(){
  ABC135_F();
  //ARC060_F();
  return 0;
}
#endif


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


int main(){
    long long A, B, K;
    cin >> A >> B >>K;
    bool t = true;
    rep(i, K){
        if(t){
            if(A % 2 == 1){
                A--;
            }
            A /= 2;
            B += A;
            t = false;
        }
        else{
            if(B % 2 == 1){
                B--;
            }
            B /= 2;
            A += B;
            t = true;
        }
    }
    cout << A << " " << B << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, a[109], ord[109]; bool isprime[109];
int solve(int depth, int cur) {
	if (depth == c) return (cur == 1 ? 1 : 0);
	int ans = 0;
	for (int i = 1; i <= ord[depth] + 1; ++i) {
		if (cur % i == 0) {
			ans += solve(depth + 1, cur / i);
		}
	}
	return ans;
}
int main() {
	cin >> n;
	if (n != 0) fill(isprime + 2, isprime + n + 1, true);
	for (int i = 2; i <= n; ++i) {
		if (!isprime[i]) continue;
		for (int j = i * i; j <= n; j += i) {
			isprime[j] = false;
		}
	}
	for (int i = 2; i <= n; ++i) {
		if (isprime[i]) {
			a[c] = i;
			int x = n;
			while (x > 0) {
				x /= i;
				ord[c] += x;
			}
			++c;
		}
	}
	int ans = solve(0, 75);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
  vector<vector<bool>>d(5001,vector<bool>(5001));
int main(){
  ll a,c=7,ans=0;cin>>a;
  vector<bool>b(a,false);
  rep(i,a){
    if(c%a==0){
      cout<<i+1;
      return 0;
    }
    if(b[c%a]){
      break;
    }
    b[c%a]=true;
    c=(c%a)*10+7;
  }
  cout<<-1;
}



Measured memory_bytes: 30320
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e6 + 7;
int ans[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == '<') {
            ans[i + 1] = max(ans[i + 1], ans[i] + 1);
        }   
    }
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '>') {
            ans[i] = max(ans[i], ans[i + 1] + 1);
        }   
    }   
    int sum = 0;
    for (int i = 0; i <= n; ++i)
        sum += ans[i];
    cout << sum << endl;
}

Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+100;
const int mod = 1e9+7;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
inline bool read(ll &num) {
    char in;bool IsN=false;
    in=getchar();
    if(in==EOF) return false;
    while(in!='-'&&(in<'0'||in>'9')) in=getchar();
    if(in=='-'){ IsN=true;num=0;}
    else num=in-'0';
    while(in=getchar(),in>='0'&&in<='9'){
            num*=10,num+=in-'0';
    } 
    if(IsN) num=-num;
    return true;
}
int main(){
    //freopen("1.in", "r", stdin);
    string s;
    cin>>s;
    if(s=="Sunny"){
        puts("Cloudy");
    }
    if(s=="Cloudy"){
        puts("Rainy");
    }
    if(s=="Rainy"){
        puts("Sunny");
    }
    return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int N, M, L, R;

int64_t calc(int x, int total){
    int64_t ans = 0;
    for(int i=M; i<=min(N, total/x); i++){
        int64_t res = comb_mod(N, i);
        mul(res, comb_mod(total - i*x + N, N));
        mul(res, comb_mod(i, M));
        add(ans, (i-M)%2 ? MOD-res : res);
    }
    return ans;
}

int64_t solve(int total){
    int64_t ans = comb_mod(total+N, N);
    for(int x=1; x<=total; x++){
        add(ans, MOD - calc(x, total));
        add(ans, calc(x, total - M));
    }
    return ans;
}

int main(){
    create_mod_tables(600000);
    cin >> N >> M >> L >> R;
    int64_t ans = solve(R);
    add(ans, MOD - solve(L-1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n;
  cin >> n;

  vector<int> f(n);
  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = 0; j < 10; j++) {
      t *= 2;
      int k;
      cin >> k;
      if (k == 1) t++;
    }
    f[i] = t;
  }

  vector<vector<ll>> p(n, vector<ll>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }

  ll max_get = -LLINF;
  for (int i = 1; i < (1<<10); i++) {
    ll get = 0;
    for (int j = 0; j < n; j++) {
      int store = f[j];
      int cnt = 0;
      for (int time = 0; time < 10; time++) {
        if ((store >> time) & (i >> time) & 1) cnt++;
      }
      get += p[j][cnt];
    }
    max_get = max(max_get, get);
  }

  cout << max_get << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
a = inpl()
g = 1
res = 0
for i in a:
    g = i*g//fractions.gcd(i,g)
for i in a:
    res += g//i
print(res%mod)


Measured memory_bytes: 6176
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	string in;
	string ans;

	cin >> in;

	for (int i = 0; i < in.size(); i++) {
		if (in[i] == '0')ans += '0';
		else if (in[i] == '1')ans += '1';
		else if (in[i] == 'B'&&ans.empty() == 0) {
			ans.pop_back();
		}
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    map<char, int> cnt;
    rep(i, 0, n) {
      cnt[s[i]]++;
    }
    for (char c = 'a'; c <= 'z'; c++) {
      if (cnt[c] == 0) {
        cout << c << endl;
        return 0;
      }
    }
    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
    #include<algorithm>
    #include<cmath>
    #include<climits>
    using namespace std;
    typedef long long int lli;
    typedef vector<int> vi;
    typedef vector<long long int> vlli;
    typedef pair<int,int> pii;
    typedef pair<long long int,long long int> plli;
    typedef vector< vi > vvi ;
    typedef vector< vlli > vvlli  ;
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define flli(i,a,b) for(long long int i=a;i<=b;i++)
    #define bi(i,a,b) for(int i=a;i>=b;i--)
    #define blli(i,a,b) for(long long int i=a;i>=b;i--)
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define all(x) x.begin(),x.end()
    #define sz(x) x.size()
    #define pi 2*acos(0.0)
    #define pb push_back
    #define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
    #define present(v,num) (v.find(num)!=v.end())
    #define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
    #define pq priority_queue
    #define mp make_pair
    const int inf=INT_MAX;
    const lli INF =LLONG_MAX;
    const lli mod = 1e9+7;
    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        fast;	
        lli n,m,k;cin>>n>>m>>k;
        vlli a(n);
        vlli b(m);
        flli(i,0,n-1)
        {
        	cin>>a[i];
        	if(i!=0)
        	{
        		a[i]=a[i-1]+a[i];
        	}
        }
        flli(i,0,m-1)
        {
        	cin>>b[i];
        	if(i!=0)
        	{
        		b[i]=b[i-1]+b[i];
        	}
        }        
        lli ans=0;
        flli(i,0,n-1)//assuming we read i books from a and remaining from b
        {
        	if(a[i]>k)break;
        	lli var=k-a[i];
        	if(var>=b[m-1])
        	{
        		ans=max(ans,i+1+m);
        		continue;
        	}
        	auto temp=lower_bound(all(b),var);
        	lli curr=temp-b.begin();
        	if(var>=b[curr])ans=max(ans,i+1+curr+1);
        	else ans=max(ans,i+1+curr);
        }
        flli(i,0,m-1)
        {
        	if(b[i]>k)break;
        	lli var=k-b[i];
        	if(var>=a[n-1])
        	{
        		ans=max(ans,i+1+n);
        		continue;
        	}
        	auto temp=lower_bound(all(a),var);
        	lli curr=temp-a.begin();
        	if(var>=a[curr])ans=max(ans,i+1+curr+1);
        	else ans=max(ans,i+1+curr);
        }
        cout<<ans<<endl;
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
        return 0;
    }

Measured memory_bytes: 6348
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<pair<int,int>> vp;
  for(auto&& i:irange(0,n)) {
    int x,l;
    cin>>x>>l;
    vp.emplace_back(x+l, x-l);
  }
  boost::sort(vp);
  int cnt=0;
  int last=-1e9 - 1;
  auto itr = begin(vp);
  while (itr != end(vp)) {
    int s,t;
    tie(t,s) = *itr;
    if (s >= last) {
      ++cnt;
      last = t;
    }
    ++itr;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,a,b;
    ll sum=0;
    cin>>h>>w>>a>>b;
    ll ans[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if((i+1)%a==0 && (j+1)%b==0){
                ans[i][j]=-1e3*(a*b-1)-1;
            }
            else{
                ans[i][j]=1e3;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            sum+=ans[i][j];
        }
    }
    if(sum<=0){
        cout <<"No"<<endl;
        return 0;
    }
    cout <<"Yes"<<endl;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}



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

int main(){
  int n; cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  int ans = 0;
  for (int i = 0; i < (1<<n); i++){
    bitset<20> b(i);
    int x = 0, y = 0;
    for (int j = 0; j < n; j++){
      if (b.test(j)){
        x += v.at(j); y += c.at(j);
      }
    }
    ans = max(ans, x-y);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.29 20:38:20
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, p[100];
    scanf("%d", &n);
    rep(i, n) scanf("%d", &p[i]);

    int ret = 0;
    rep(i, n - 2) {
        if ((p[i] < p[i + 1] && p[i + 1] <= p[i + 2]) ||
            (p[i + 2] < p[i + 1] && p[i + 1] <= p[i])) {
            ret++;
        }
    }

    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++) {
        int val=x-i;
        if(i*2+val*4==y) {
            cout<<"Yes"<<endl;
            return 0;

        }
    }
    cout<<"No"<<endl;




}


Measured memory_bytes: 3564
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = [int(input()) for _ in range(N)]
aa.sort()

if N%2 == 0:
    ans = (sum(aa[N//2:]) - sum(aa[:N//2]))*2 - (aa[N//2]-aa[N//2-1])
    print(ans)
else:
    ans1 = (sum(aa[N//2:]) - sum(aa[:N//2]))*2 - (aa[N//2]+aa[N//2+1])
    ans2 = (sum(aa[(N//2+1):]) - sum(aa[:(N//2+1)]))*2 + (aa[N//2]+aa[N//2-1])
    print(max(ans1,ans2))


Measured memory_bytes: 9736
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



signed main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

//----------------------------------------------------------
//Macro
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define maxn int(1e6+10)
//----------------------------------------------------------
//TypeDef
typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef vector<int> vi;
//----------------------------------------------------------
//Variables
int n, n3, n2, a[maxn];
priority_queue <ll> quMax;
priority_queue <ll, vector <ll>, greater <ll>> quMin;
long long dpMax[maxn], dpMin [maxn];
//----------------------------------------------------------
void Input ()
{
	cin >> n;
	n3 = 3 * n;
	n2 = 2 * n;
	for (int i = 1; i <= n3; i++) cin >> a[i];
}
void Solve ()
{
	for (int i = n3; i > n2; i--) 
	{
		quMax.push (a[i]);
		dpMin[n2 + 1] += a[i];
	}
	for (int i = n2; i > 0; i--)
	{
		dpMin[i] = dpMin[i+1];
		int t = quMax.top ();
		if (a[i] >= t) continue;
		quMax.pop ();
		quMax.push (a[i]);
		dpMin [i] = dpMin [i] + a[i] - t;
	}
	for (int i = 1; i <= n; i++) 
	{
		quMin.push (a[i]);
		dpMax[n] += a[i];
	}
	for (int i = n + 1; i <= n3; i++)
	{
		dpMax[i] = dpMax[i-1];
		int t = quMin.top ();
		if (a[i] <= t) continue;
		quMin.pop ();
		quMin.push (a[i]);
		dpMax [i] += a[i] - t;
	}
	long long res = -1e18;
	for (int i = n; i <= n2; i++)
		res = max (res, dpMax[i] - dpMin [i+1]);
	cout << res;
}
//----------------------------------------------------------
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie (NULL);
    cout.tie (NULL);
    //freopen ("tnnum.inp","r",stdin);
    //freopen ("tnnum.out","w",stdout);
    Input ();
    Solve ();
}

Measured memory_bytes: 10356
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */
 
#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 //~ cin >> T;
	 for(int t = 1; t <= T; t++) {
		 int n;
		 cin >> n;
		 int input[n + 1];
		 map<int,int> count;
		 int max_number = -1,second_max = -1;
		 for(int i = 1;i <= n; i++){
			 cin >> input[i];
			 count[input[i]] += 1;
			 if(max_number < input[i]){
				 second_max = max(second_max,max_number);
				 max_number = input[i];
			 }
			 if(input[i] < max_number){
				 second_max = max(second_max,input[i]);
			 }
		 }
		 if(count[max_number] > 1){
			 second_max = max_number;
		 }
		 for(int i = 1; i <= n; i++){
			 if(input[i] == max_number){
				 if(count[input[i]] > 1){
					 cout << max_number << "\n";
				 }else{
					 cout << second_max << "\n";
				 }
			 }else{
				 cout << max_number << "\n";
			 }
		 }
	 }
}


Measured memory_bytes: 9820
#include<stdio.h>
int main(){

char s[100];

	scanf("%[^\n]", s);
	
	for(int i=0; s[i]!='\0';i++){
		if (s[i] == ','){
			printf(" ", s[i]);
		}
		else{
			printf("%c", s[i]);
		}
	}
	
return 0;
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;
const int minf = (-1)*(1e9+7);

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}

ll n;
bool check(ll ans, ll a[], ll k){

    for(ll i=0 ; i<n ; i++){
        if((ll)(a[i]/ans) > 0)
            k -= ceil(a[i]/(ans+0.0))-1;
    }
    // deg(ans);
    // deg(k);
    if(k<0)return false;
    return true;
}


void solve(int test){

    ll k;
    cin >> n >> k;
    ll a[n];

    for(ll i=0 ; i<n ; i++){
        cin >> a[i];
    }

    ll l = 1;
    ll r = 1e9+10;

    while(l<r){
        ll mid = (l+r)/2;
        // deg(mid);
        if(check(mid,a,k)){
            r = mid;
        }
        else{
            l = mid+1;
        }
    }

    cout << r;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> d, m, c;
    vector<ll> a(n);
    rep(i, 0, n) {
        if (s[i] == 'D') d.emplace_back(i);
        if (s[i] == 'M') m.emplace_back(i), a[i]++;
        if (s[i] == 'C') c.emplace_back(i);
    }
    rep(i, 1, n) a[i] += a[i - 1];
    int q;
    cin >> q;
    while (q--) {
        int k, j = -1, l = -1;
        cin >> k;
        ll ans = 0, sum = 0;
        rep(i, 0, d.size()) {
            while (c[j + 1] - d[i] < k && j + 1 < c.size()) {
                j++;
                sum += a[c[j]];
            }
            while (c[l + 1] - d[i] < 0 && l + 1 < c.size()) {
                l++;
                sum -= a[c[l]];
            }
            if (j != -1) {
                ans += sum - a[d[i]] * (j - l);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 22284
from collections import deque
input()
A = [*map(int, input().split())]
A.sort(reverse=True)
q = deque([A[0]])
P = []
for a in A[1:]:
    p = q.popleft()
    P.append(p)
    q.append(a); q.append(a)
print(sum(P))


Measured memory_bytes: 32596
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	char comb[5] = {'M','A','R','C','H'};
	vector<ll> name(30,0LL);
	rep(i,N){
		string s;
		cin>>s;
		name[s[0]-'A']++;
	}
	ll ans = 0LL;
	for(int i = 0; i<5; ++i){
		for(int j = i+1; j<5; ++j){
			for(int k = j+1; k<5; ++k){
				ans += name[comb[i]-'A'] * name[comb[j]-'A'] * name[comb[k]-'A'];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);
    long long ans=0ll;
    for(int i=0;i<n;i++){
        ans+=abs(a[i]-a[n/2]+0ll);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a / b << endl;
    cout << a % b << endl;
    double c = a;
    double d = b;
    cout << fixed << setprecision(10) << c / d << endl;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vd = vector<ld>;
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)

#define DBG 1
#define TR(X) ({if(DBG) cerr << "TR: " << (#X) << " = " << (X) << endl; })

#define MOD (1000000007ll)


int main(){
  cin.sync_with_stdio(0);

	ll N;
	cin >> N;

	string s;
	cin >> s;

	vl ol, ne;
	ol.pb (1);

	FOR (i, 0, N - 1)
	{
		if (s[i] == '<')
		{
			ne.pb (0);
			FOR (j, 0, i + 1)
			{
				ll n = ne[j];
				n += ol[j];
				n %= MOD;
				ne.pb (n);
			}
		}
		else
		{
			ne.pb (0);
			FOR (j, 0, i + 1)
			{
				ll n = ne[j];
				n += ol[i - j];
				n %= MOD;
				ne.pb (n);
			}
			reverse (all (ne));
		}
		ol = ne;
		ne.clear ();
	}

	cout << accumulate (all (ol), 0ll, [](ll a, ll b) { return (a + b) % MOD; }) << endl;

  return 0;

} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 384
// AOJ 2214: Warp Hall
// 2018.1.7 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1000000007

typedef struct { int a, b, c, d; } T;
T warp[1002];
int dp[1002];
int fact[200001], inv[200001], factinv[200001];

int cmp(T *a, T *b) { if (a->a - b->a) return a->a - b->a; return a->b - b->b; }

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int comb(int n, int k)
{
	if (n < 0 || k < 0) return 0;
	return (int)((long long)fact[n] * factinv[k] % M * factinv[n-k] % M);
}

int calc(int a, int b, int c, int d)
{
	if (c < a || d < b) return 0;
	return comb(c-a + d-b, c-a);
}
     
int main()
{
	int n, m, k, i, j, a, b;
	T *p, *q;

	fact[0] = 1; for (i = 1; i <= 200000; i++)
		fact[i] = (long long)fact[i-1] * i % M;
	inv[1] = 1; for (i = 2; i <= 200000; i++)
		inv[i] = M - (M / i) * (long long)inv[M % i] % M;
	factinv[0] = 1; for (i = 1; i <= 200000; i++)
		factinv[i] = (long long)factinv[i-1] * inv[i] % M;

	while (n = in()) {
		n--, m = in()-1, k = in();

		for (p = warp, i = 0; i < k; i++, p++)
			p->a = in()-1, p->b = in()-1, p->c = in()-1, p->d = in()-1;
		p->a = n, p->b = m, p->c = n+1, p->d = m+1;
		qsort(warp, k, sizeof(T), cmp);

		memset(dp, 0, sizeof(dp));
        for (p = warp, i = 0; i <= k; i++, p++) {
            dp[i] = comb(p->a + p->b, p->b);
            for (q = warp, j = 0; j < i; j++, q++) {
				a = calc(q->c, q->d, p->a, p->b);
				b = calc(q->a, q->b, p->a, p->b);
				a -= b; if (a < 0) a += M;
				a = (long long)a * dp[j] % M;
				dp[i] += a; if (dp[i] >= M) dp[i] -= M;
			}
		}
		printf("%d\n", dp[k]);
	}
	return 0;
}


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1,2,4,3);}
  void roll_y(){roll(0,2,5,3);}
  void roll_x(){roll(0,1,5,4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

bool eq(Cube c1, Cube c2){
  for(int i=0;i<6;i++){
    if(c1.f[i] != c2.f[i]) return false;
  }
  return true;
}

bool equal(Cube c1, Cube c2){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if(eq(c1, c2)) return true;
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return false;
}

int main(){
  Cube c1, c2;

  for(int i=0;i<6;i++) cin >> c1.f[i];
  for(int i=0;i<6;i++) cin >> c2.f[i];

  if(equal(c1, c2)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



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

int main(){
	ll a,b; cin >> a >> b;
	if(a <= 5)cout << 0 << endl;
	else if(a >= 13)cout << b << endl;
	else cout << b/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100001] = {};
ll s[100001] = {};
int main() {
	ll n, k; cin >> n >> k;
	repe(i, 1, n) cin >> a[i];
	sort(a + 1, a + n + 1);
	ll minV = MAX_L;

	repe(i, k, n) {
		s[i] = a[i] - a[i - k + 1];
		minV = min(minV, s[i]);
	}

	cout << minV << endl;
	return 0;
}

Measured memory_bytes: 1792
import itertools
N, K = [int(_) for _ in input().split()]
P = [int(_) - 1 for _ in input().split()]
C = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_right(self, p, v):  # apply operator from the right side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(dat[p], v)
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_left(self, p, v):  # apply operator from the left side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(v, dat[p])
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        vl = vr = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                vl = f(vl, dat[l])
                l += 1
            if r & 1:
                r -= 1
                vr = f(dat[r], vr)
            l >>= 1
            r >>= 1
        return f(vl, vr)


ans = -10**20
se = set()
for start in range(N):
    if start in se:
        continue
    now = start
    scores = []
    while True:
        if now in se:
            break
        se.add(now)
        scores += [C[now]]
        now = P[now]
    cyclelen = len(scores)
    cum = list(itertools.accumulate(scores * 3))
    st = SegmentTree(cum, max, -10**20)
    cycle, residue = divmod(K, cyclelen)
    ans = max([ans] + [
        st.query(start2 + 1, start2 + 1 + min(cyclelen, K)) - cum[start2]
        for start2 in range(cyclelen)
    ])
    if cum[-1] > 0 and cycle > 0:
        v = cum[-1] * cycle // 3 + max(
            st.query(0, start2 + residue + 1) - cum[start2]
            for start2 in range(cyclelen, 2 * cyclelen))
        ans = max(ans, v)
print(ans)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var input = Console.ReadLine();
            switch (input)
            {
                case "A":
                    Console.WriteLine("T");
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
                case "G":
                    Console.WriteLine("C");
                    break;
            }
        }
    }

}


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

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


void atcoder_beginner_contest111()
{
  int n;
  cin >> n;

  if (n % 111 == 0) cout << n << "\n";
  else
  {
    int a = n / 111;
    ++a;
    cout << a * 111 << "\n";
  }
}


void time_limit_exceeded()
{
  int N, T;
  cin >> N >> T;

  int ans = 1001;
  for (int i = 0; i < N; ++i)
  {
    int c, t;
    cin >> c >> t;

    if (t <= T && c < ans) ans = c;
  }
  if (ans == 1001) cout << "TLE\n";
  else cout << ans << "\n";
}


void palace()
{
  int n, t, a;
  cin >> n >> t >> a;

  double d_min = 1000;
  int ans = 0;
  for (int i = 1; i <= n; ++i)
  {
    int h;
    cin >> h;
    double d = (t - h * 0.006) - a;
    if (d < 0) d *= -1;
    if (d < d_min)
    {
      d_min = d;
      ans = i;
    }
  }
  cout << ans << "\n";
}


void B_114()
{
  string s;
  cin >> s;

  int ans = 1000;
  for (int i = 0; i < s.size() - 2;++i)
  {
    int now_s = stoi(s.substr(i,3));
    ans = min(ans, abs(753 - now_s));
  }
  cout << ans << "\n";
}



int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  //favorite_sound();

  //atcoder_beginner_contest111();
  //time_limit_exceeded();
  //palace();
  B_114();
}

Measured memory_bytes: 256