akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
    int n; cin >> n;
    double sum = 0;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        sum += (double)1/a;
    }
    printf("%.10f\n", 1/sum);
    return 0;
}

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


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

void Div(int dividend, int divisor, int a[])
{
    for (int i = 0; i < divisor; ++i)
    {
        a[i] = dividend / divisor + ((dividend % divisor > i) ? 1 : 0);
    }
}

int main()
{
    LL H, W;
    cin >> H >> W;
    int H3[3];
    int W3[3];
    int H2[2];
    int W2[2];
    Div(H, 3, H3);
    Div(W, 3, W3);
    Div(H, 2, H2);
    Div(W, 2, W2);
    LL ans = 1e10;
    // v * v
    {
        LL Smax = H * W3[0];
        LL Smin = H * W3[2];
        ans = min(ans, Smax - Smin);
    }
    // h * h
    {
        LL Smax = H3[0] * W;
        LL Smin = H3[2] * W;
        ans = min(ans, Smax - Smin);
    }
    // v * h
    {
        for (LL w = 1; w < W; ++w)
        {
            LL w0 = w;
            LL w1 = W - w;
            LL S0 = H * w0;
            LL S1 = H2[0] * w1;
            LL S2 = H2[1] * w1;
            ans = min(ans, max(max(S0, S1), S2) - min(min(S0, S1), S2));
        }
    }
    // h * v
    {
        for (LL h = 1; h < H; ++h)
        {
            LL h0 = h;
            LL h1 = H - h;
            LL S0 = h0 * W;
            LL S1 = h1 * W2[0];
            LL S2 = h1 * W2[1];
            ans = min(ans, max(max(S0, S1), S2) - min(min(S0, S1), S2));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//use proconio::input;
use std::cmp::max;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        w: usize,
        d: [(usize, u64); n],
    }
    let mut dp = vec![vec![0; w + 1]; n];
    for j in d[0].0..(w + 1) {
        dp[0][j] = d[0].1;
    }
    for i in 1..n {
        for j in 0..(w + 1) {
            if j >= d[i].0 {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - d[i].0] + d[i].1);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    println!("{}", dp[n - 1].iter().max().unwrap());
}


Measured memory_bytes: 106748
#include<iostream>
#include<string>

using namespace std;

int main(){
    string S;

    cin >> S;

    size_t size = S.length();

    int a = ((size - 1) / 2);
    int b = ((size + 3) / 2) - 1;

    string str1 = S.substr(0, a);
    string str2 = S.substr(b, size - 1);

    if(str1 == str2){
        cout << "Yes" << endl;
    }else{
        cout << "No"<< endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    int N;  cin >> N;
    vector<int> v(N);  rep(i, N) cin >> v[i];

    sort(v.begin(), v.end());
    double ans = 0;
    ans += v[0] / pow(2, N-1);
    rep1(i, N) {
        ans += v[i] / pow(2, N-i);
    }

    cout << fixed << setprecision(5) << ans;

    return 0;
}

Measured memory_bytes: 256
data = []

while 1:
    data.append(list(map(int, input().split())))
    if data[-1] == [-1,-1,-1]:
        data.pop(-1)
        break

for i in range(len(data)):
    TOTAL = data[i][0] + data[i][1]

    if data[i][0] * data[i][1] < 0:
        print('F')
        continue
    elif TOTAL >= 80:
        print('A')
        continue
    elif TOTAL >= 65:
        print('B')
        continue
    elif TOTAL >= 50:
        print('C')
        continue
    elif TOTAL >= 30:
        if data[i][2] >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int  K, X;
  cin >> K >> X;
  if (K * 500 >= X) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input()) 
s = [input() for i in range(N)]
LIS=[]
for i in range(N):
  LIS.append(''.join(sorted(s[i])))
LIS.sort()
n=0
prestr=LIS[0]
count=1
for st in LIS[1:]:
  if st==prestr:
    n+=count
    count+=1
  else:
    count=1
    prestr=st
print(int(n))

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

int main(){
  int x, y;
  cin >> x >> y;
  
  for(int i = 0; i < x+1; i++){
    if(i*2 + (x-i)*4 == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
n,k=map(int,input().split())
l=list(map(int,input().split()))

ll=[]
for i in range(n):
    ll.append((l[i]+1)/2)

lll=[]
for i in range(n-k+1):
    if i==0:
        lll.append(sum(ll[0:k]))
    else:
        lll.append(lll[i-1]+ll[i+k-1]-ll[i-1])

print(max(lll))

Measured memory_bytes: 26140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

vector<int> G[100001];
ll dp[100001][2];
bool done[100001];
void rec(int i){
    if(done[i]) return;
    done[i] = true;
    dp[i][0] = 1;
    dp[i][1] = 1;
    for(int j:G[i]){
        if(done[j]) continue;
        rec(j);
        dp[i][0] = dp[i][0]*(dp[j][0]+dp[j][1])%MOD;
        dp[i][1] = dp[i][1]*dp[j][0]%MOD;
    }
}


int main(){


    int n;
    cin >> n;
    fill_n(done, 100001, false);
    rep(i, n-1){
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    rec(1);
    ppp((dp[1][0]+dp[1][1])%MOD);

    return 0;
}


Measured memory_bytes: 11520
#include<stdio.h>

int main( void ){
   int i,j;
   int n;
   int flag = 0;
   scanf("%d", &n);
   for(i = 0; i < 10; i++){
      for(j = 0; j < 10; j++){
         if(n == j*i){
            printf("Yes\n");
            flag = 1;
            break;
            return 0;
         }
      }
      if(flag == 1){
         break;
      }
   }
   if(flag == 0){
      printf("No\n");
   }
   return 0;
}
   


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int n, y;
  cin >> n >> y;

  REP(i, n + 1)
  {
    REP(j, n + 1)
    {
      if (i + j > n)
      {
        continue;
      }
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y)
      {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    vi a(n);
    REP(i,n)cin>>a[i];
    int cnt = 0;
    vi b = a;
    while(true){
      REP(i,n) a[i] = count(ALL(b),b[i]);
      if(b==a)break;
      b=a;
      ++cnt;
    }
    cout<<cnt<<endl;
    cout<<b[0];
    REPR(i,n)cout<<" "<<b[i];
    cout<<endl;
  }
  return 0;
}

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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

typedef long long ll;

typedef pair<int,int> pii;//to id

int N;
vector<pii> G[100010];

ll A[100010];
ll ans[100010];
bool flag = false;
int id = -1;

int DFS(int v, int p = -1)
{
    int ret = 1;
    for(int i = 0; i < G[v].size(); i++)
    {
        pii e = G[v][i];
        if(e.fi == p)continue;
        int num = DFS(e.fi, v);
        if(N == num * 2)
        {
            flag = true;
            id = e.se;
            ans[e.se] = 0;
        }
        else ans[e.se] = abs(A[v] - A[e.fi]) / abs((N - num) - num);
        ret += num;
    }
    return ret;
}

ll DFS2(int v,ll d, int p = -1)
{
    ll ret = d;
    for(int i = 0; i < G[v].size(); i++)
    {
        pii e = G[v][i];
        if(e.fi == p)continue;
        ret += DFS2(e.fi, d + ans[e.se], v);
    }
    return ret;
}

int main()
{
    cin >> N;
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        cin >> a >> b;
        G[a].push_back(mk(b, i));
        G[b].push_back(mk(a, i));
    }
    for(int i = 0; i < N; i++)cin >> A[i + 1];

    DFS(1);

    if(flag)
    {
        ll sum = DFS2(1, 0);
        ans[id] = (A[1] - sum) / (N / 2);
    }

    for(int i = 0; i < N - 1; i++)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
double w[15],d[15],num[15];
int n;

double weight(int bit){
	double ret = 0;
	for(int i = 0 ; i < n ; i++){
		if( bit & (1<<i) )ret += w[i];
	}
	return 70+20*ret;
}

int main(){
	cin >> n;
	
	vector< vector<double> > dp(1<<15,vector<double>(15,(1<<25))); 
	vector< vector<int> > prevPos(1<<15,vector<int>(15,0)); 
	vector< vector<int> > prevBit(1<<15,vector<int>(15,0));
	
	rep(i,n){
		cin >> num[i] >> d[i] >> w[i];
	}
	
	rep(i,n) dp[(1<<i)][i] = 0.0;
	for(int bit = 1; bit < (1<<n) ; bit++){ // visit info
		for(int i = 0; i < n ; i++){		// prev
			for(int j = 0; j < n ; j++){	// now
				if(bit & (1<<j) )continue;
				int nBit = bit | (1<<j);
				double newDist = dp[bit][i] + fabs(d[i]-d[j]) / ( 2000.0 / weight(bit) );
				
				if(dp[nBit][j] > newDist){
					prevPos[nBit][j] = i;
					prevBit[nBit][j] = bit;
					dp[nBit][j] = newDist;
				}
			}
		}
	}
	vector<int> route;
	int outBit = (1<<n)-1 ,outPos = -1;
	double minCheck = (1<<25);
	
	rep(i,n)if(minCheck > dp[outBit][i]){
		outPos = i;
		minCheck = dp[outBit][i];
	}
	
	route.push_back(outPos);
	while(prevBit[outBit][outPos] != 0){
		int a = prevPos[outBit][outPos] , 
			b = prevBit[outBit][outPos] ;
		outPos = a, outBit = b;
		route.push_back(outPos);
	}
	reverse(route.begin(),route.end());
	
	rep(i,route.size())
		cout << (i?" ":"") << num[route[i]];
	cout << endl;
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,rem,count=0;
    cin>>n;
    while (n>0)
    {
        rem=n%10;
        if (rem==7)
        {
            count++;
            cout<<"Yes"<<endl;
            break;
        }
        n=n/10;
    }
    if (count==0)
        cout<<"No"<<endl;
}



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

int main(){
  #define int int64_t
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<int> A(X);
  vector<int> B(Y);
  vector<int> C(Z);
  vector<int> V;
  for(int i=0;i<X;i++){
    cin>>A.at(i);
  }for(int i=0;i<Y;i++){
    cin>>B.at(i);
  }for(int i=0;i<Z;i++){
    cin>>C.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  for(int i=0;i<X;i++){
    for(int j=0;j<Y;j++){
      for(int k=0;k<Z;k++){
        if((i+1)*(j+1)*(k+1)<=K){
          V.push_back(A.at(i)+B.at(j)+C.at(k));
        }
      }
    }
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  for(int i=0;i<K;i++){
    cout<<V.at(i)<<"\n";
  }
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0]<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
 int main() {
  int H, W;
  while (1) {
   std::cin >> H >> W;
   if (H == 0 && W == 0) break;
   for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
     if (i == 1 || i == H) {
      std::cout << "#";
     } else {
      if (j == 1 || j == W) {
       std::cout << "#";
      } else {
       std::cout << ".";
      }
      }
     }
     std::cout <<std::endl;
    }
    std::cout <<std::endl;
   }

 return 0;


}
   


Measured memory_bytes: 2984
#include<stdio.h>
int main ()
{
  int a,e,i,k;
  scanf("%d",&a);
  for(i=0;i<4;i++){
    scanf("%d",&e);
  }
  scanf("%d",&k);
  if(e-a>k){
    puts(":(");
  }else{
    puts("Yay!");
  }
  return 0;
}


Measured memory_bytes: 128
//include
//------------------------------------------
#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 <bits/stdc++.h>

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)
#define fore(i,a) for(auto &i:a)

//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;
 

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

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



int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;++i)
    {
    cin >> a[i];
    }
    sort(a,a+N);
    int pos=0;
    int tmp=0;
    int ans=0;
    int count=0;
    int b[a[N-1]+100]={0};
    for(int i=0;i<N;++i){
        ++b[a[i]];
        ++b[a[i]-1];
        ++b[a[i]+1];
    }
        sort(b,b+a[N-1]+100,greater<int>());
    cout << b[0];
}

Measured memory_bytes: 1024
#include <stdio.h>
int a, b, c;
int n;
int x, y, z;
int small(int i, int j)
{
	return i < j ? i : j;
}
int main(void)
{
	scanf("%d %d %d", &x, &y, &z);
	a = small(small(x, y), z);
	b = small(x, y) + small(y, z) + small(x, z) - a * 2;
	c = x + y + z - a - b;
	n = (b - a) / 2 + (c - b) + 2*((b - a) % 2);
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll a[1005];
ll sums[1005]={0};
ll dp[405][405];
ll func(ll l,ll r)
{
	if(l==r)
		return 0;
	if(dp[l][r]!=-1)
		return dp[l][r];
	ll i;
	ll xyz=99999999999999999;
	for(i=l; i<r; i++)
	{
		ll ans=func(l,i)+func(i+1,r)+sums[r]-sums[l-1];
		xyz=min(xyz,ans);
	}
	return dp[l][r]=xyz;
}
int main()
{
	boost
	ll n,i,j;
	cin>>n;
	for(i=1; i<=n; i++)
	{
		cin>>a[i];
		sums[i]=sums[i-1]+a[i];
	}
	for(i=0; i<405; i++)
		for(j=0; j<405; j++)
			dp[i][j]=-1;
	ll ans=func(1,n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws IOException {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String W = in.readLine();

			int A= Integer.parseInt(W.split(" ")[0]);
			int B= Integer.parseInt(W.split(" ")[1]);
			int C= Integer.parseInt(W.split(" ")[2]);


         System.out.println(C+" "+A+" "+ B);
	}

}


Measured memory_bytes: 22996
def main():
    n,m,x = map(int,input().split())
    a = [list(map(int,input().split())) for i in range(n)]
    res = 10**18
    from itertools import product
    for i in product(range(2), repeat=n):
        tmp = 0
        rikai = [0]*m
        okflg = False
        for j in range(n):
            if i[j] == 1:
                tmp += a[j][0]
                okflg = True
                for k in range(1,m+1):
                    rikai[k-1] += a[j][k]
                    if rikai[k-1] < x:
                        okflg = False
                if okflg == True:
                    break
        if okflg == True:
            res = min(tmp,res)
    if res == 10**18:
        print(-1)
    else:
        print(res)

if __name__ == '__main__':
    main()



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

int main() {
 int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(string &x: s) cin>>x;
  vector<int> dx={1,0,0,-1};
  vector<int> dy={0,1,-1,0};
  bool flag=true;
  for(int x=0;x<w;x++){
    for(int y=0;y<h;y++){
      if(s[y][x]=='#'){
        int count=0;
     	 for(int i=0;i<4;i++){
       	 int X=x+dx[i];
       	 int Y=y+dy[i];
       	 if(X>=0&&X<w&&Y>=0&&Y<h&&s[Y][X]=='#') count++;
         }
        if(count==0) flag=false;
      }
    }
  }
 if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
money = [list(input().split()) for i in range(N)]
ans = 0

for i in range(N):
    money[i][0] = float(money[i][0])


for x, u in money:
    if u == 'JPY':
        ans += x
    else:
        ans += 380000 * x

print(ans)


Measured memory_bytes: 38256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	std::string S;
	in >> N >> S;

	LL ans = 0;
	rep(i, N - 3 + 1)
	{
		if (S.substr(i, 3) == "ABC") ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    let s = f 1000000000 k
    print $ length [i | i <- [0..s], n >= k ^ i]

f n k | n < k = 0
      | otherwise = 1 + f (n `div` k) k

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll i;
  ll a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=llabs(a[0]-a[1]);
  dp[2]=llabs(a[0]-a[2]);
  for(i=3;i<n;i++)
    dp[i]=min(dp[i-1]+llabs(a[i-1]-a[i]),dp[i-2]+llabs(a[i-2]-a[i]));
  cout<<dp[n-1]<<endl;
}

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

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

  string s, t;
  cin >> s >> t;

  int ans = 0;
  for (int i = 0; i < s.length(); ++i) if (s[i] != t[i]) ++ans;

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-ff;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
int n;
int f[200005],g[200005];
int tot,head[200005],nx[400005],to[400005];
void jia(int aa,int bb)
{
	tot++;
	nx[tot]=head[aa];
	to[tot]=bb;
	head[aa]=tot;
	return;
}
void dfs(int rt,int fa)
{
	int sum=0,cs=0;g[rt]=0;
	for(int i=head[rt];i;i=nx[i])
	{
		int yy=to[i];
		if(yy==fa) continue;
		dfs(yy,rt);sum+=f[yy];cs++;
		g[rt]^=(g[yy]+1);
	}
	if(sum%2||cs%2) f[rt]=1;
	return;
}
int main()
{
	n=read();
	for(int i=1;i<n;++i)
	{
		int x=read(),y=read();
		jia(x,y);jia(y,x);
	}
	dfs(1,1);
	if(g[1]) puts("Alice");
	else puts("Bob");
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

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

  int n;
  cin >> n;
  double ans = static_cast <double> (n - n / 2) / n;
  cout << fixed << setprecision (15) << ans << endl;
}


Measured memory_bytes: 256
def resolve():
	n,m=map(int,input().split())
	
	if n>1 and m>1:
		print((n-2)*(m-2))
	elif n==1:
		if m==1:
			print(1)
		else:
			print(m-2)
	elif m==1:
		print(n-2)
resolve()

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

#define rep(i, n) for(int i = 0, i_length = (n); i < i_length; i++)
#define MOD 1000000007
#define ll long long

int main() {
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC" << endl;
	else {
		cout << "ABC" << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int N, answer = 1;
    cin >> N;
    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int cnt = H[0];

    for (int i = 1; i < N; i++)
    {
        if (H[i] >= cnt)
        {
            cnt = H[i];
            answer++;
        }
    }
    cout << answer << 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(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
const LL INF = 1LL<<60;
const int SIZE=1001;
int a[SIZE],b[SIZE];
VI edge[SIZE];
VI cedge[SIZE];
int N,M;
int directed[SIZE];
int bridges=0;
int bridgesP[SIZE];
bool searched[SIZE];
bool beused[SIZE];
bool isDAG(){
	queue<int> qu;
	FOR(i,1,N+1){
		if(cedge[i].size()==0) qu.push(i);
	}
	int times=0;
	while(!qu.empty()){
		int now=qu.front();
		qu.pop();
		times++;
		REP(i,edge[now].size()){
			int next=edge[now][i];
			directed[next]++;
			if(directed[next]==cedge[next].size()) qu.push(next);
		}
	}
	//cout << " " <<times << endl;
	return times==N;
}
int bridge(int now,int from){
	if(searched[now]){
		if(beused[now]){
			bridgesP[now]++;
			return beused[now];
		}
		return 0;
	}
	searched[now]=true;
	beused[now]=true;
	//cout << now << endl;
	int inbrids=0;
	REP(i,cedge[now].size()){
		int next=cedge[now][i];
		if(next!=from)
			inbrids+=bridge(next,now);
	}
	beused[now]=false;
	if(inbrids-bridgesP[now]==0&& from!=-1) bridges++;
	return inbrids-bridgesP[now];
}
bool solve(int x){
	FOR(i,1,N+1){
		edge[i].clear();
		cedge[i].clear();
		directed[i]=0;
		searched[i]=false;
		bridgesP[i]=0;
	}
	bridges=0;
	REP(i,M){
		if(x!=i){
			edge[a[i]].PB(b[i]);
			cedge[b[i]].PB(a[i]);
		}
	}
	if(!isDAG()) return false;
	//cout <<" FO" << endl;
//	cout << x << endl;
	REP(i,M){
		if(x!=i){
			cedge[a[i]].PB(b[i]);
		}
	}
	bridge(1,-1);
//	cout << bridges << endl;
	FOR(i,1,N+1){
		if(!searched[i]) return false;
	}
	if(bridges>=2) return true;
	return false;
}
int main(){
	cin >> N >> M;
	REP(i,M){
		cin >> a[i] >> b[i];
	}
	REP(i,M){
		if(solve(i)){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3244
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64,
    }

    let x_abs = x.abs();
    let move_num = x_abs / d;
    let pos = x_abs % d;

    let ans;
    if move_num > k {
        ans = x_abs - d*k;
    } else {
        let remaining_move = k - move_num;
        if remaining_move % 2 == 0 {
            ans = pos;
        } else {
            ans = (pos - d.abs()).abs();
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=20;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=130000;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp=ans[p];
    ans[p]=rand()%ntype+1;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void solve(int times){
    max_score=evaluate();
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    for(int i=0;i<3000;++i) change();
    Output();
}


Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int a[200000];
int p[200001];
set<int> lt;
set<int> rt;
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		p[a[i]]=i;
	}
	lt.insert(-1);
	rt.insert(n);
	for(int i=1;i<n+1;i++)
	{
		auto l=lt.lower_bound(p[i]);
		l--;
		auto r=rt.lower_bound(p[i]);
		cerr<<(*r)<<" "<<(*l)<<endl;
		ans+=(ll)(*r-p[i])*(ll)(p[i]-*l)*(ll)i;
		lt.insert(p[i]);
		rt.insert(p[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 20608
package main

import (
	"fmt"
	"math"
	"sort"
)

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

func main() {
	var t int
	fans := 1012345678
	menus := [5]int{}
	order := []int{0, 1, 2, 3, 4}
	for i := 0; i < 5; i++ {
		fmt.Scan(&t)
		menus[i] = t
	}

	var ans int
	for NextPermutation(sort.IntSlice(order)) {
		ans = 0
		for j := 0; j < len(menus); j++ {
			for ans%10 != 0 {
				ans++
			}
			ans += menus[order[j]]
		}
		fans = int(math.Min(float64(fans), float64(ans)))
	}

	fmt.Println(fans)
}


Measured memory_bytes: 512
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int64_t i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    string s;   cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

struct edge { int to, fine, cost, camp; };
vector<edge> G[100];
int n, m, h, k, p;
void init(int n) {
	rep(i, n)G[i].clear();
}
bool freefine[9];
int s, g;
int d[100][25];
struct vertice {
	int dis, id, hour;
	bool operator<(const vertice &v)const {
		if (dis != v.dis)return v.dis < dis;
		if (id != v.id)return id < v.id;
		return hour < v.hour;
	}
};
priority_queue<vertice> q;
int dijkstra() {
	rep(i, n) {
		rep(j, h + 1) {
			d[i][j] = mod;
		}
	}
	d[s][0] = 0; q.push({ 0,s,0 });
	while (!q.empty()) {
		vertice v = q.top(); q.pop();
		rep(j, G[v.id].size()) {
			int to = G[v.id][j].to;
			int nh = v.hour + G[v.id][j].cost;
			if (nh > h)continue;
			int nd = v.dis + G[v.id][j].fine;
			if (freefine[G[v.id][j].camp])nd = v.dis;
			if (nd < d[to][nh]) {
				d[to][nh] = nd; q.push({ d[to][nh],to,nh });
			}
		}
	}
	int res = mod;
	rep(i, h + 1) {
		res = min(res, d[g][i]);
	}
	return res;
}

int passport[256]; int cop[256];
int freezone[256]; int passcost[256];
void calc() {
	fill(passport, passport + (1 << k), mod);
	passport[0] = 0;
	//rep(j, (1 << k))cout << passport[j] << endl;
	rep(i, p) {
		//rep(j, (1 << k))cout << passport[j] << endl;
		rep(j, (1 << k)) {
			cop[j] = passport[j];
			// cout << passport[j] << endl;
		}
		rep(j, (1 << k)) {
			int to = j | freezone[i];
			cop[to] = min(cop[to], passport[j] + passcost[i]);
			//cout << i<<" "<<passcost[i] << endl;
		}
		rep(j, (1 << k)) {
			passport[j] = cop[j];
		}
	}
}
int main() {
	while (cin >> n >> m >> h >> k, n) {
		init(n);
		rep(i, m) {
			int a, b, fine, cost, camp;
			cin >> a >> b >> fine >> cost >> camp; a--; b--; camp--;
			G[a].push_back({ b,fine,cost,camp });
			G[b].push_back({ a,fine,cost,camp });
		}
		int ans = mod;
		cin >> s >> g; s--; g--;
	    cin >> p;
		//cout << ans << endl;
		rep(i, p) {
			freezone[i] = 0;
			int l, cost; cin >> l >> cost;
			passcost[i] = cost;
			rep(j, l) {
				int k_; cin >> k_; k_--; freezone[i] += (1 << k_);
			}

		}
		calc();
		rep(i, (1 << k)) {
			rep(j, k) {
				freefine[j] = (i&(1 << j));
			}
			ans = min(ans, passport[i] + dijkstra());
			//cout << i << " " << passport[i] << " " << dijkstra() << endl;
		}
		if (ans == mod)cout << -1 << endl;
		else cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int d;
	std::cin >> d;
	
	if (d==25) {
	    std::cout << "Christmas" << std::endl;
	    
	}else if(d==24) {
	    std::cout << "Christmas Eve" << std::endl;
	    
	}else if(d==23) {
	    std::cout << "Christmas Eve Eve" << std::endl;
	    
	}else if(d==22) {
	    std::cout << "Christmas Eve Eve Eve" << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  int min = 1e9;
  string t;
  int t_i;
  for (int i = 0; i < s.length() - 2; i++){
    t = s.substr(i, 3);
    t_i = stoi(t);
    if (abs(753 - t_i) < min){
      min = abs(753 - t_i);
    }
  }
  say(min);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(b<a)
        printf("0\n");
    else if(n==1&&a!=b)
        printf("0\n");
    else{
        long long down=(n-1)*a+b;
        long long up=(n-1)*b+a;
        if(down>up) swap(up,down);
        printf("%lld\n",up-down+1);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
using namespace std;
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
int n, m;
int p[11];
int ans = 0;
vector<int>v[11];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int k;
		cin >> k;
		rep(j, k) {
			int s;
			cin >> s;
			v[i].push_back(s);
		}
	}
	rep(i, m) {
		cin >> p[i];
	}
	rep(i, m) {
		sort(all(v[i]));
	}
	rep(i, (1 << n)) {
		int cnt[11];
		rep(j, m) cnt[j] = 0;
		rep(j, n) {
			if ((i >> j) & 1) {
				rep(k, m) {
					if (binary_search(all(v[k]), j + 1)) {
						cnt[k]++;
					}
				}
			}
		}
		bool can = true;
		rep(j, m) {
			if (cnt[j] % 2 != p[j]) can = false;
		}
		if (can) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
string str;
bool ok;
int main()
{
	cin >> str;
	int l = str.length();
	for (int i = 0;i < l;i++)
	{
		if (str[i] == 'C') ok = true;
		if (str[i] == 'F' && ok)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
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);}// to W
  void roll_x(){ roll(0, 1, 5, 4);}// to N
  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;
  }
  void move(char ch){
     if ( ch == 'E' ) for ( int i = 0; i < 3; i++ ) roll_y();
     if ( ch == 'W' ) roll_y();
     if ( ch == 'N' ) roll_x();
     if ( ch == 'S' ) for ( int i = 0; i < 3; i++ ) roll_x();
  }
 };

  int main(){
    Cube c;
    string com;

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

    for ( int i = 0; i < com.size(); i++ ) c.move(com[i]);

    cout << c.f[0] << endl;

   return 0;
}


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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n,h,A,B,M=0;
    cin>>h>>n;
    vector<long long>a(n),b(n);
    long long dp[20001];
    for(int i=0;i<20001;i++){dp[i]=1e9+7;}
    dp[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        A=a[i];B=b[i];
M=max(M,a[i]);
        while(A<20001){
        dp[A]=min(dp[A],B);
        A+=a[i];B+=b[i];
        }
    }
    for(int i=0;i<20001;i++){
        for(int j=0;j<n;j++){
            if(i+a[j]<20001)dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
            else{continue;}
        }
    }
    for(int i=h;i<=M+h;i++){
dp[h]=min(dp[h],dp[i]);
}
    cout<<dp[h];
}


Measured memory_bytes: 384
while True:
        H, W = map(int, input().split())
        if H == 0 and W == 0:
                break
        countl = 0

        while True:
                if W == 0:
                        break
                if countl == H:
                        break
                elif countl % 2 == 0:
                        countll = 0
                        while True:
                                if countll % 2 == 0:
                                        print('#', end='')
                                        countll += 1
                                else:
                                        print('.', end='')
                                        countll += 1
                                if countll == W:
                                        print()
                                        break
                elif countl % 2 == 1:
                        countll = 0
                        while True:
                                if countll % 2 == 0:
                                        print('.', end='')
                                        countll += 1
                                else:
                                        print('#', end='')
                                        countll += 1
                                if countll == W:
                                        print()
                                        break
                countl += 1
        print()

Measured memory_bytes: 9076
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n;
  cin >> n;
  vl a(n),b(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  ll suma = accumulate(ALL(a),0LL);
  ll sumb = accumulate(ALL(b),0LL);  
  if(suma < sumb){
    cout << -1 << endl;
    return 0;
  }
  vector<ll> idch;
  priority_queue<ll>  qu;
  ll chsum = 0;
  int ans = 0;
  REP(i,n){
    if(a[i]-b[i]<0){
      chsum -= a[i]-b[i];
      ans++;
    }else{
      qu.push(a[i]-b[i]);
    }
  }
  while(chsum>0){
    int c = qu.top(); qu.pop();
    chsum -= c;
    ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    // 100要素の配列で初期化
    vector<int> vec(3);

    for (int i = 0; i < 3; i++)
    {
        cin >> vec.at(i);
    }

    cout << vec.at(2) << ' ' << vec.at(0) << ' ' << vec.at(1) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	vector<vector<int>> c(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		rep(j,b[i]){
			int x;
			cin >> x;
			--x;
			c[i].push_back(x);
		}
	}
	vector<int> dp((1<<n), INF);
	dp[0] = 0;
	rep(S,(1<<n)){
		rep(i,m){
			int nextS = S;
			rep(j,b[i]){
				nextS |= (1<<c[i][j]);
			}
			chmin(dp[nextS], dp[S] + a[i]);
		}
	}
	if(dp[(1<<n)-1] == INF) cout << -1 << endl;
	else cout << dp[(1<<n)-1] << endl;
	return 0;
}


Measured memory_bytes: 3724
import heapq

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort()

h=[]
ans=0
j=0

for i in range(1,m+1):
    while j<n:
        if ab[j][0]>i:
            break
        else:
            heapq.heappush(h,-ab[j][1])
            j += 1
            
    if h!=[]:
        k=-heapq.heappop(h)
        ans+=k

print(ans)


Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long A=a*c,B=a*d,C=b*c,D=b*d;
    long long E=max(A,B);
    long long F=max(C,D);
    cout <<max(E,F)<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
string a;
  cin >> a;
  if (a.at(1)=='R'){
  cout << "ABC" << endl;
  }
  else{
  cout << "ARC" << endl;
  }
}


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

double area(double a, double b, double c)
{
  double s = (a+b+c)/2.0;
  return sqrt(s * (s-a) * (s-b) * (s-c));
}

int main()
{
  int a, l, x;
  double s0, area0;
  double sa, area_slack;

  while (cin >> a >> l >> x)
  {
    area0 = area(a, l, l);
    area_slack = area(l, (l+x)/2.0, (l+x)/2.0);
    printf("%.10f\n", area0 + 2 * area_slack);
  }
  return 0;
}

Measured memory_bytes: 1192