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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl

ll gcdl(ll a,ll b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

ll lcml(ll a,ll b){
    return a/gcdl(a,b)*b;
}

int gcd(int a,int b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int a;
    cin>>a;
    int g=a,m=a;
    REP(i,n-1){
        cin>>a;
        g=gcd(g,a);
        chmax(m,a);
    }
    //cout<<m<<" "<<g<<endl;
    if(k<=m&&!(k%g)){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
(* O(1) *)
let a, b = Scanf.scanf " %d %d" @@ fun a b -> a, b
let f0 x = if x mod 2 = 1 then (x + 1) / 2 mod 2 else x / 2 mod 2 lxor x
let f a b = if a = 0 then f0 b else f0 (a - 1) lxor f0 b
let _ = f a b |> Printf.printf "%d\n"

Measured memory_bytes: 384
X,N =  map(int,input().split())
N_List = list(map(int,input().split()))
ct = 0
pos = 0
while True:
    if pos == 0:
        if X not in N_List:
            ans = X
            break
        else:
            pos += 1
    elif pos > 0:
        if X-pos not in N_List:
            ans = X - pos
            break
        elif X + pos not in N_List:
            ans = X + pos
            break
        else:
            pos += 1
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    IN(a,b,c,d,e,f);
    int ans1=0,ans2=0;
    for(int x=0;100*a*x <= f;x++){
        for(int y=0;100*b*y <= f-100*a*x;y++){
            if(x==0&&y==0) continue;
            for(int z=0;c*z<=f-100*a*x-100*b*y;z++){
                for(int w=0;d*w<=f-100*a*x-100*b*y-c*z;w++){
                    int wat = 100*a*x+100*b*y;
                    int sug = c*z+d*w;
                    if(wat*e<sug*100) break;
                    if(ans1==0){
                        ans1 = wat+sug;
                        ans2 = sug;
                    }
                    if(sug*ans1>(wat+sug)*ans2){
                        ans1 = wat+sug;
                        ans2 = sug;
                    }
                }
            }
        }
    }
    printf("%d %d\n",ans1,ans2);
}

Measured memory_bytes: 256
s = input()
n = len(s)

bf = 0
wf = 0

for i in range(n):
    c = '0' if i % 2 == 0 else '1'
    if s[i] == c:
        wf += 1
    else:
        bf += 1

print(bf if bf < wf else wf)

Measured memory_bytes: 3188
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main():
    N = int(input())
    A = input_nums()
    C = collections.Counter(A)

    X = {}
    Y = {}
    maxv = 0
    for k, v in C.items():
        if v >= 2:
            X[k] = cmb(v, 2)
            maxv += X[k]
        else:
            X[k] = 0
        if v >= 3:
            Y[k] = cmb(v-1, 2)
        else:
            Y[k] = 0

    ANS = {}
    for k in Y.keys():
        ANS[k] = maxv - (X[k] - Y[k])

    for a in A:
        print(ANS[a])

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s, t, c;

	cin >> s;
	cin >> t;

	for (int i = 0; i < s.size(); i++)
	{
		c.push_back(s[i]);
		c.push_back(t[i]);
	}

	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
#define MAXR 50001
#define MAXC 21

int coin_num[MAXC][MAXR];
int C[MAXC];
int n, m;

void dp() {
    int minv = MAXR;

    for (int i=0; i<m; i++) {
        coin_num[i][0] = 0;
        for (int j=1; j<=n; j++) {
            if (i==0) {
                if (j%C[i]==0) {
                    coin_num[i][j] = j/C[i];
                } else coin_num[i][j] = MAXR;
            } else {
                if (j>=C[i]) {
                    coin_num[i][j] = min(coin_num[i-1][j], coin_num[i][j-C[i]]+1);
                } else {
                    coin_num[i][j] = coin_num[i-1][j];
                }
            }
        }
    }

    for (int i=0; i<m; i++) {
        minv = min(coin_num[i][n], minv);
    }

    printf("%d\n", minv);
}

int main() {
    scanf("%d %d", &n, &m);

    for (int i=0; i<m; i++) {
        scanf("%d", &C[i]);
    }

    dp();

    return 0;
}


Measured memory_bytes: 6612
#include <iostream>

int main(){
    int N,A,B,C,D,e,f;
    std::cin>>N>>A>>B>>C>>D;
    e = (N/A+!!(N%A))*B;
    f = ((N/C+!!(N%C))*D);
    std::cout<<(e>=f?f:e)<<'\n';
}



Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int,int> P; // cost, vertex number

struct edge {
    int to;
    int cost;
};

#define INF 1000000

int main()
{
    int n,k;

    cin >> n >> k;

    while(n!=0 || k!=0) {
        int ord,a,b,c;
        vector<edge> G[100];

        for(int i=0; i<k; ++i) {
            cin >> ord;

            if(ord==1) {
                cin >> a >> b >> c;
                edge e_temp;
                e_temp.cost=c;
                e_temp.to=b-1;
                G[a-1].push_back(e_temp);
                e_temp.to=a-1;
                G[b-1].push_back(e_temp);
            } else {
                priority_queue<P,vector<P>,greater<P> > que;
                int d[100];

                fill(d,d+100,INF);

                cin >> a >> b;

                d[a-1]=0;
                que.push(P(0,a-1));

                while(!que.empty()) {
                    P p=que.top(); que.pop();
                    int v=p.second;
                    if(d[v]<p.first) continue;
                    for(int j=0; j<(int)G[v].size(); ++j) {
                        edge e=G[v][j];
                        if(d[e.to]>d[v]+e.cost) {
                            d[e.to]=d[v]+e.cost;
                            que.push(P(d[e.to],e.to));
                        }
                    }
                }

                cout << (d[b-1]==INF?-1:d[b-1]) << endl;
            }

        }


        cin >> n >> k;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;
int main(){
  int a, b; cin >> a >> b;
  int ans = max(a - b * 2, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ll p[11];
int main()
{
    ll a,b,c;
    sl(a);
    sl(b);
    sl(c);
    p[a]++;
    p[b]++;
    p[c]++;
    if(p[5]==2&&p[7]==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3636
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            total = 500 * a + 100 * b + 50 * c
            if total == X:
                count = count + 1

print(count)

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

/* macros */
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vt vector
#define pb push_back
#define fi first
#define se second
#define pi pair<int,int>
#define tc int t;cin>>t;while (t--){solve();}
#define notc solve();
#define newline cout << "\n";
#define mod 1000000007
#define ret return 0;
#define sz(x) (int)x.size();
#define rep(i,a,b) for(int i=a;i<b;i++)
#define srt(x) sort(x.begin(), x.end())
#define inf 1e9;

int n,k;
vi nums;

int dp[100005];
int go(int pos){
    
    if (pos == n){
        return 0;
    }
    
    if (dp[pos] != -1){
        return dp[pos];
    }
    
    int ans = INT_MAX;
    for (int i=1;i<=k;i++){
        if (pos+i <= n)
            ans = min(ans, go(pos+i) + abs(nums[pos] - nums[pos+i]));
    }
    
    return dp[pos] = ans;
}

void solve(){
    cin>>n>>k;
    nums.clear();
    nums.resize(n+1);
    rep(i,1,n+1) cin>>nums[i];
    memset(dp, -1, sizeof dp);
    int ans = go(1);
    cout << ans << "\n";
}

int32_t main(){
    fastio
    notc
    ret
}


Measured memory_bytes: 9512
h,w=map(int,input().split())
m=min((0--h//3-h//3)*w,(0--w//3-w//3)*h)
for i in range(1,h):
  a,b,c=sorted((i*w,-~w//2*(h-i),w//2*(h-i)))
  m=min(m,c-a)
for i in range(1,w):
  a,b,c=sorted((i*h,-~h//2*(w-i),h//2*(w-i)))
  m=min(m,c-a)
print(m)

Measured memory_bytes: 3064
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		String input = new java.util.Scanner(System.in).nextLine();
		String[] input2 = input.split(" ");
		int a = Integer.parseInt(input2[0]);
		int b = Integer.parseInt(input2[1]);
		int c = Integer.parseInt(input2[2]);
		int[] s = new int[3];
		s[0] = a;
		s[1] = b;
		s[2] = c;
		Arrays.sort(s);
		System.out.println(s[0] + " " +  s[1] + " " + s[2]);
	}
}

Measured memory_bytes: 17192
// Ryo Kamoi
//#define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

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

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

int INF = 1000000000;

int n, k;
double prob;

int coin_count(int deme) {
  int output = 0;
  int point = deme;
  while (k > point) {
    point *= 2;
    output ++;
  }
  return output;
}

int main(){
  cin >> n >> k;
  prob = 0.0;

  for(int i=1; i<=n; i++) {
    int num = coin_count(i);
#ifdef DEBUG
    cout << num << endl;
#endif
    prob += pow(0.5, num) / (double)n;
  }

  printf("%.12lf\n", prob);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

namespace ConsoleApp2
{
    class Program {
        static void Main(string[] Args) {
            var chars = new List<char> { 'A', 'T', 'C', 'G' };

            var convs = new List<char>(ReadLine().ToCharArray()).Select(chars.Contains).ToList<bool>();

            int res = 0;
            int tmp = 0;
            for(int i = 0;i < convs.Count(); i++) {
                if (convs[i]) tmp++;
                else {
                    res = Math.Max(res, tmp);
                    tmp = 0;
                }
            }
            res = Math.Max(res, tmp);

            WriteLine(res);

            ReadLine();
        }
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
int n,k,a[101];
bool f[100010];
int main(){
	read(n);read(k);
	for(re int i=1;i<=n;i++) read(a[i]);
	for(re int i=1;i<=k;i++){
		for(re int j=1;j<=n;j++){
			if(i>=a[j] && !f[i-a[j]]) f[i]=1;
		}
	}
	if(f[k]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n, ans = 0,o=0,x=0;
	string s;
	bool flag;

	cin >> s;

	s.push_back('x');

	vector<string> a;

	string buf;

	forll(i, 0, s.size() - 1)
	{
		buf.push_back(s[i]);

		if (s[i] == s[i + 1])
		{
			a.push_back(buf);
			buf.clear();
		}
		else if (s[i + 1] == 'x')
		{
			a.push_back(buf);
			buf.clear();
		}
	}

	forll(i, 0, a.size())
	{
		if (i % 2 == 0)
			o += a[i].size();
		else
			x += a[i].size();
	}
	
	cout << min(o,x);
}

Measured memory_bytes: 5876
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <iomanip>
#include <math.h>
using namespace std;
typedef long long ll;
 
int main() {
    int a, b;
    cin >> a>> b;
    cout << 6 / a / b << endl;
}

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

int main() {
  int s1, s2, s3, s1s2s3, i;
  cin >> s1s2s3;
  i=s1s2s3;
  s1=i/100;
  s2=(i-s1*100)/10;
  s3=(i-s1*100-s2*10)/1;
  cout << s1 + s2 + s3 << endl;
}

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 inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int n;
    cin >> n;
    if(n%2==0) cout << n << endl;
    else cout << 2*n << endl;
    return 0;
}


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

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int cnt=0;
    
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(X == 500*i+100*j+50*k) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
  int cnt = 0;
  string s;

  cin >> s;

  for (int i = 0; i < (int)s.size(); i++) {
    for (int j = i + 1; j < (int)s.size(); j++) {
      if (s[i] == s[j]) cnt++;
    }
  }

  if (cnt == 2)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vll g[MAX];
int vis[MAX];
vector <pll> ed;
int c[MAX];
void dfs(int cur, int par)
{
    vis[cur] = 1;
    for(auto x : g[cur])
    {
        if(vis[x] == 0)
            dfs(x, cur);
        if(vis[x] == 1 && x != par)
            ed.pb(mp(cur, x)), c[cur]++;
    }
    if(par != -1)
    {
        if(c[cur] % 2 == 0)
            ed.pb(mp(par, cur)), c[par]++;
        else
            ed.pb(mp(cur, par)), c[cur]++;
    }
    vis[cur] = 2;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, m, u, v, i;
    cin >> n >> m;
    for(i = 0; i < m; i++)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    if(m % 2 == 1)
    {
        cout << "-1\n";
        return 0;
    }
    dfs(1, -1);
    for(auto x : ed)
        cout << x.F << ' ' << x.S << endl;
    return 0;
    return 0;
}

Measured memory_bytes: 45168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <int mod>
struct ModInt
{
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p)
    {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p)
    {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p)
    {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p)
    {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const
    {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0)
        {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const
    {
        ModInt ret(1), mul(x);
        while (n > 0)
        {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p)
    {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a)
    {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
    static ModInt factorial(ll n)
    {
        if (n == 0)
            return 1;
        ModInt<mod> tmp(n);
        for (int i = 1; i < n; i++)
        {
            tmp *= ModInt<mod>(n - i);
        }
        return tmp;
    }
    static ModInt Combination(ll n, ll k)
    {
        return factorial(n) / (factorial(n - k) * factorial(k));
    }
};

using mint = ModInt<(int)1e9 + 7>;
int main()
{
    int N;
    cin >> N;
    vint C(N + 1);
    rep(i, N)
    {
        cin >> C[i + 1];
    }
    sort(C.begin() + 1, C.end(), greater<ll>());
    mint ans = 0;
    for (size_t i = 1; i < N + 1; i++)
    {
        ans += mint(C[i]) * (i + 1);
    }
    cout << ans * mint(4).pow(N - 1);
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;
int a[110000], h[110000];
pint p[110000];
vint rev[110000];
void dfs(int v, int ch) {
    if (h[v] < 0)return;
    h[v] = ch;
    for (int i = 0; i < rev[v].size(); i++)dfs(rev[v][i], ch + 1);
}
signed main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++)cin >> a[i];
    int ans = 0;
    if (a[1] != 1)a[1] = 1, ans++;
    for (int i = 2; i <= N; i++)rev[a[i]].push_back(i);
    dfs(1, 0);
    for (int i = 2; i <= N; i++)p[i] = pint(h[i], i);
    sort(p + 2, p + N + 1), reverse(p + 2, p + N + 1);
    for (int i = 2; i <= N; i++) {
        int cur = p[i].second;
        if (h[cur] <= K)continue;
        for (int j = 0; j < K - 1; j++)cur = a[cur];
        dfs(cur, LLONG_MIN);
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13824
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((c > a && c < b) || (c < a && c > b)){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
string s;
int c[200000];
int main(void){
    cin >> N;
    cin >> s;
    if(s[0] == 'W' or s[2*N-1] == 'W'){
        cout << 0 << endl;
        return 0;    
    }
    c[0] = 0; c[2*N-1] = 1;
    int L_count = 0, R_count = 0;
    for(int i=1;i<2*N-1;i++){
        if(s[i-1] != s[i]) c[i] = c[i-1];
        else c[i] = abs(c[i-1]-1);
        if(c[i]==0) L_count++;
        else R_count++;
    }
    if(L_count!=R_count){
        cout << 0 << endl;
        return 0;
    }
    ll count = 1, count0 = 0;
    for(int i=0;i<2*N;i++){
        if(c[i] == 0) count0++;
        else{
            count = (count*count0)%1000000007;
            count0--;    
        }    
    }
    cout << (count*((ll)F(N).n))%1000000007 << endl;
    return 0;
}


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

int main()
{
    int n; cin >> n;
    int f[200010];
    int ans[200010] = {0};

    for (int i = 1; i <= n; i++) cin >> f[i];

    for (int i = n; i > 0; i--) {
        int num = 0;
        for (int j = 1; j*i <= n; j++) {
            num += ans[i*j];
        }
        num %= 2;
        if (num != f[i]) ans[i] = 1;
    }

    int num = 0;
    for (int i = 1; i <= n; i++) num += ans[i];
    cout << num << endl;
    for (int i = 1; i <= n; i++) {
        if (ans[i]) cout << i << " ";
    }

    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

map<P, ll> m;

// n C x: n個からx個選ぶパターン数
ll choose(int n, int x) {
  if (m.find(P(n, x)) != m.end()) return m[P(n, x)];

  ll p = 1, q = 1;
  rep(i, x) {
    p *= (n - i);
    q *= (i + 1);
  }

  return m[P(n, x)] = p / q;
}

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

  vector<int> as(n);
  rep(i, n) cin >> as[i];

  map<int, int> m1;
  rep(i, n) {
    int a = as[i];
    if (m1.find(a) == m1.end()) m1[a] = 0;
    m1[a]++;
  }

  ll sum = 0;
  auto it = m1.begin();
  while(it != m1.end()) {
    int k = it->F;
    int c = it->S;
    sum += choose(c, 2);
    it++;
  }

  rep(i, n) {
    int a = as[i];
    ll res = sum;

    if (m1.find(a) != m1.end()) {
      res -= choose(m1[a], 2);
      if (m1[a] - 1 >= 2) {
        res += choose(m1[a] - 1, 2);
      }
    }
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 8320
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var p = Array.ConvertAll(ReadLine().Split(' '), double.Parse);
        var dp = new double[num+1, num+1];
        dp[1, 0] = 1-p[0];
        dp[1, 1] = p[0];
        for(var i = 2; i <= num; i++)
        {
            for(var j = 0; j <= num; j++)
            {
                dp[i, j] = j == 0 ? dp[i - 1, j] * (1 - p[i - 1]) : dp[i - 1, j] * (1 - p[i - 1]) + dp[i - 1, j - 1] * p[i - 1];
            }
        }
        var sum = 0d;
        for (var i = num / 2 + 1; i <= num; i++)
            sum += dp[num, i];
        WriteLine(sum);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int main() { 	
 int A,C,D,E,F,G;
 string B;
 cin >>A;
    if(A==1){
        cout <<"1.0000000000"<<endl; 
    }else if(A%2==0){
	cout <<"0.5000000000"<<endl; 
    }else if(A%2==1){
         float AA,BB;
         AA=A;
         BB=A/2+1;
        cout <<BB/AA<<endl; 
    }
 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M, X) = Read3Longs();
            var C = new long[N];
            var A = new long[N, M];
            for (long i = 0; i < N; i++)
            {
                var l = ReadLongs();
                C[i] = l[0];
                for (int j = 0; j < M; j++)
                {
                    A[i, j] = l[j + 1];
                }
            }

            var min = long.MaxValue;
            var hasAnswer = false;
            var max = Math.Pow(2, N);
            for (int i = 0; i < max; i++)
            {
                var bit = Convert.ToString(i, 2).PadLeft((int)N, '0');
                var sumCost = 0L;
                var totalA = new long[M];
                for (int j = 0; j < N; j++)
                {
                    if (bit[j] == '0') continue;
                    sumCost += C[j];
                    for (int k = 0; k < M; k++)
                    {
                        totalA[k] += A[j, k];
                    }
                }

                if (totalA.All(x => x >= X))
                {
                    min = Math.Min(min, sumCost);
                    hasAnswer = true;
                }
            }

            if (!hasAnswer)
            {
                return -1;
            }

            return min;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 29612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N;
char S[200000][12];
int n[200000];

int main( int argc, char *argv[] )
{
    int i;

    if( scanf( "%d", &N ) != 1 ) {
        printf( "N read error!\n" );
        exit( -1 );
    }

    for( i=0; i<N; i++ ) {
        n[i] = 0;
        if( scanf( "%10s", (char *) &S[i] ) != 1 ) {
            printf( "N read error!\n" );
            exit( -1 );
        }
    }

    qsort( S, N, sizeof(S[0]), strcmp );

    int start = 0;
    int end = start +1;
    int max = 0;

    while( end < N ) {

        while( !strcmp( S[start], S[end] ) ) end++;

        n[start] = end - start;
        if( n[start] > max ) max = n[start];
        start = end;
    }

    for( i=0; i<N; i++ )
        if( n[i] == max ) puts( S[i] );
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int numOf1 = 0;
        int numOf2 = 0;
        int numOf3 = 0;
        for (int i = 0; i < n; i++) {
            int p = sc.nextInt();
            if (p <= a) {
                numOf1++;
            } else if (a + 1 <= p && p <= b) {
                numOf2++;
            } else if (b + 1 <= p) {
                numOf3++;
            }
        }

        int min = Math.min(numOf1, Math.min(numOf2, numOf3));
        System.out.println(min);
    }
}


Measured memory_bytes: 23636
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    String s = "";
    if (r < 1200){
      s = "ABC";
    }else if (r < 2800){
      s = "ARC";
    }else{
      s = "AGC";
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 35632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<vector<int> > nyu(int h, int w) {
	vector<vector<int> > a(h + 2, vector<int>(w + 2, h*w + 1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i + 1][j + 1];
		}
	}
	return a;
}
vector<int> nyu1(int n) {
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	return c;
}
int main() {
	int n,k;
	cin >> n >> k;
	vector<int> h;
	h = nyu1(n);
	sort(h.begin(), h.end());
	int ans = 1000 * 1000 * 1000;
	for (int i = 0; i + k <= n; i++) {
		int x = h[i];
		int y = h[i + k-1];
		ans = min(ans, y - x);
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{

    int n, k;

    cin >> n >> k;

    int h[n+2];

     long long ans = 0, cnt = 0;

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

    int temp = 0;

     sort(h, h + n);

   /* for(int i = 0; i < n; i++)
    {
       cout << h[i] << " ";
    }*/

    for(int i = 0; i < n - k; i++)
    {
       //cout << h[i] << endl;
       ans += (long long)h[i];
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}
ll dp[2005][4005]={0};
int main(){
  string s; cin>>s;
  ll n=s.length(),rnum=0,bnum=0;
  vector<ll> rsum,bsum;
  rsum.push_back(0);
  bsum.push_back(0);
  for(int i=0;i<n;i++){
    ll R=0,B=0;
    if(s[i]=='0') R+=2;
    else if(s[i]=='1'){
      R++;
      B++;
    }
    else B+=2;
    rnum+=R;
    rsum.push_back(rnum);
    bnum+=B;
    bsum.push_back(bnum);
  }
  set_frac(n+10);
/*  for(int i=0;i<=n;i++) cout<<rsum[i]<<" ";
  cout<<endl;
  for(int i=0;i<=n;i++) cout<<bsum[i]<<" ";
  cout<<endl; */
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    for(int r=0;r<n;r++){
      if(rsum[i+1]>=r+1) dp[i+1][r+1]+=dp[i][r];
      if(bsum[i+1]>=(i+1-r)) dp[i+1][r]+=dp[i][r];
      dp[i+1][r+1]%=mod;
      dp[i+1][r]%=mod;
    }
  }
  //cout<<rnum<<" "<<bnum<<endl;
  ll ans=0;
/*  for(int i=0;i<=n;i++){
    for(int j=0;j<=rnum;j++) cout<<dp[i][j]<<" ";
    cout<<endl;
  } */
  for(int i=0;i<=n;i++){
    if(rnum<i) continue;
    ll kans=nCr(n,rnum-i);
    kans*=dp[n][i];
    kans%=mod;
    ans+=kans;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 61696
import math

N = int(input())
a = list(map(int, input().split()))

N2 = 0
N4 = 0
oth = 0

for i in a:
    if i % 4 == 0:
        N4 += 1
    elif i % 2 == 0:
        N2 += 1
    else:
        oth += 1

if N2 == 0:
    if N4+1 >= oth:
        print("Yes")
    else:
        print("No")
else:
    if N4 >= oth:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 15020
#include <iostream>

using namespace std;

int main()
{
    int n,i;
    long long s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
            s+=i;
    }
    cout<<s;
    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s >> s;
  int x = 0, ans = x;
  for (char c : s) {
    x += (c == 'I' ? 1 : -1);
    ans = max(ans, x);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#define N 500005
using namespace std;

int n, m, z, num, cnt, l, r;
char b[5], a[N];
set<int> v[30];
int main()
{
	int i,j, t1, t2;
	cin >> n;
	scanf ("%s", &a[1]);
	cin >> m;
	for (i = 1; i <= n; i++) {
		num = a[i] - 'a';
		v[num].insert(i);
	}
	for (i = 0; i < 26; i++) v[i].insert(n + 100);
	while (m--) {
		scanf ("%d %d", &z,&t1);
		if (z == 1) {
			scanf ("%s", b);
			num = a[t1] - 'a';
			v[num].erase(t1);
			num = b[0] - 'a';
			v[num].insert(t1);
			a[t1] = b[0];
		} else {
			scanf ("%d", &t2);
			cnt = 0;
			for(i = 0; i < 26; i++) {
				l = *(v[i].lower_bound(t1));
				r = *(v[i].upper_bound(t2));
				if (l != r) cnt++;
			}
			printf("%d\n", cnt);
		}
	}
    return 0;
}


Measured memory_bytes: 24192
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1000000007;

fn powmod(a: i64, p: i64, m: i64) -> i64 {
    let mut ret = 1i64;
    let mut aa = a;
    let mut pp = p;
    while pp >= 1 {
        if pp & 1 == 1 {
            ret *= aa;
            ret %= m;
        }
        aa = aa * aa % m;
        pp >>= 1;
    }
    ret
}


fn main() {
    let (n, c): (usize, usize) = read();
    let a: Vec<usize> = readnc();
    let b: Vec<usize> = readnc();

    let mut ranges: Vec<(usize, usize)> = vec![];
    for i in 0..n {
        ranges.push((a[i], b[i]));
    }

    let mut pow_k: Vec<Vec<i64>> = vec![vec![0; 401]; 401];
    for k in 0..401 {
        let mut sum: i64 = 0;
        for i in 1..401 {
            sum += powmod(i, k, MOD);
            if sum >= MOD {
                sum -= MOD;
            }
            pow_k[k as usize][i as usize] = sum;
        }
    }

    let mut memo: Vec<Vec<i64>> = vec![vec![-1; c+1]; n+1];

    println!("{}", dfs(0, c, &ranges, &pow_k, &mut memo));
}

fn dfs(i: usize, left: usize, range: &Vec<(usize, usize)>, pow_k: &Vec<Vec<i64>>, memo: &mut Vec<Vec<i64>>) -> i64 {
    if memo[i][left] != -1 {
        return memo[i][left]
    }
    if i == range.len() {
        let ret = if left == 0 { 1 } else { 0 };
        memo[i][left] = ret;
        return ret;
    }

    let rng = range[i];
    let mut sum = 0;
    for u in 0..left+1 {
        let mut p = pow_k[u][rng.1] - pow_k[u][rng.0-1] + MOD;
        if p >= MOD {
            p -= MOD;
        }
        sum += p * dfs(i+1, left-u, range, pow_k, memo) % MOD;
        if sum >= MOD {
            sum -= MOD;
        }
    }
    memo[i][left] = sum;
    sum
}

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

int main(){
  string S;
  cin>>S;
  int lengthS=S.length();
  int dif=753;
  int numX=0;
  for(int i=0;i<lengthS-2;i++){
    numX=(S.at(i)-'0')*100+(S.at(i+1)-'0')*10+(S.at(i+2)-'0');
    dif=min(dif,abs(numX-753));
    
    
  }
  cout <<dif<<endl;
  return 0;
}

    
    

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int a[N];
  int b[N];
  
  for(int i = 0;i < N;i++)
    scanf("%d",&a[i]); 
  for(int i = 0;i < N;i++)
    b[a[i] - 1] = i + 1;
  for(int i = 0;i < N;i++)
    printf("%d ",b[i]);
  
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << N); ++bit)

int main()
{
    string S;
    cin >> S;
    ll N = S.length() - 1;
    ll Ans = stoll(S.substr(0, 1));
    string A;
    repb(bit, N, 0)
    {
        repi(i, N, 0)
        {
            if (bit & (1 << i))
            {
                Ans += stoll(S.substr(S.length() - 1 - i, 1));
            }
            else
            {
                Ans -= stoll(S.substr(S.length() - 1 - i, 1));
            }
            // cout << "ANS:" << Ans << endl;
        }

        if (Ans == 7)
        {
            cout << S.substr(0, 1);
            repd(i, N - 1, 0)
            {
                if (bit & (1 << i))
                {
                    cout << "+" << S.substr(S.length() - i - 1, 1);
                }
                else
                {
                    cout << "-" << S.substr(S.length() - i - 1, 1);
                }
            }
            cout << "=7" << endl;
            return 0;
        }
        Ans = stoll(S.substr(0, 1));
    }

    return 0;
}

Measured memory_bytes: 256
a, b = map(int,input().split())
A = [[0]*b for i in range(a)]
B = [0] * b

for i in range(a):
    A[i] = list(map(int,input().split()))

for i in range(b):
    B[i] = int(input())

for i in range(a):
    s=0
    for j in range(b):
        s+=A[i][j]*B[j]
    print(s)

Measured memory_bytes: 5948
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;

ll mem[MAX];
ll N;

ll rec(ll n) {
  if(n==0) return 0;
  if(n<0) return INF;
  if(mem[n]!=-1) return mem[n];
  ll i;
  ll res=INF;
  
  for(i=1; i<=n; i*=6) chmin(res, rec(n-i)+1);
  for(i=1; i<=n; i*=9) chmin(res, rec(n-i)+1);
  
  return mem[n]=res;
}

int main(void) {
  cin >> N;
  
  memset(mem, -1, sizeof(mem));
  pt(rec(N));
}






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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<long long> A;
  vector<long long> C;
  map<long long, int> B;
  
  for (int i = 0; i < N; i++) {
    long long in;
    
    cin >> in;
    
    A.push_back(in);
    
    if (find(C.begin(), C.end(), in) == C.end()) {
      C.push_back(in);
    }
  }
  
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  
  for (int i = 0; i < N; i++) {
    B[A[i]]++;
  }
  
  int ans = 0;
  
  for (int i = 0; i < C.size(); i++) {
  for (int j = i + 1; j < C.size(); j++) {
  for (int k = j + 1; k < C.size(); k++) {
    if (C[i] + C[j] > C[k]) {
      ans += B[C[i]] * B[C[j]] * B[C[k]];
    }
  }
  }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int x = b-a+1;
		for(int i = 0; i < k; i++) {
			if(k > x) {
				for(int j = 0; j <= b-a; j++) {
					System.out.println(a+j);
				}
				break;
			}
			System.out.println(a+i);
		}
		for(int i = k - 1; i >= 0; i-=1) {
			if(a+k-1 < b - i) {
				System.out.println(b-i);
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 23252
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e3+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/

ll dp[MXN][MXN];
int n;
vector <pair<ll, int>> v;
ll solve (int l, int r) {
	
	if (r < l) {
		return 0;
	}
	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	
	int i = n - (r - l + 1);
	
	return dp[l][r] = max (v[i].first * abs (v[i].second - l) + solve (l + 1, r), v[i].first * abs (v[i].second - r) + solve (l, r - 1));
}

int main(){
	FASTIO
	
	
	
	cin >> n;
	
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		v.push_back ({x, i});
	}
	memset (dp, -1, sizeof dp);
	sort (v.rbegin(), v.rend());
	
	cout << solve (0, n - 1) << endl;
	
    return 0;
}

/*

*/


Measured memory_bytes: 35296
import math
from decimal import *

def main():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int, input().split())
        T.append(t)
        A.append(a)

    for i in range(N - 1):
        if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
            mul = Decimal(max(math.ceil(T[i] / T[i + 1]), math.ceil(A[i] / A[i + 1])))
            A[i + 1] *= mul
            T[i + 1] *= mul
    print(T[N - 1] + A[N - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 5204