akhauriyash/Code-Regression huggingface dataset:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x,n=INTM()
    p=LIST()
    
    for i in range(101):
        if not x-i in p:
            print(x-i)
            break
        if not x+i in p:
            print(x+i)
            break
        
            
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9204
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/


pair<ll, ll> a[5100];

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
	return a.first + a.second < b.first + b.second;
}

int n;

ll dp[5100];

const ll INF = 1e18;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i].first >> a[i].second;
	sort(a, a + n, cmp);
	for (int i = 1; i <= n; ++i)
		dp[i] = INF;
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; j >= 0; --j) {
			if (dp[j] <= a[i].first) {
				dp[j + 1] = min(dp[j + 1], dp[j] + a[i].second);
			}
		}
	}
	for (int j = n; j >= 0; --j) {
		if (dp[j] < INF) {
			cout << j << "\n";
			return 0;
		}
	}
	return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i += 2) {
		cout << s.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 3624
while True:
	h,w=map(int,input().split())
	if h==0 and w==0:
		break
		
	for i in range(h):
		for j in range(w):
			if (i%2==0 and j%2==0) or (i%2==1 and j%2==1):
				print("#",end="")
			else:
				print(".",end="")
		print("")
	print("")
			


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n, q, b;
  string s;
  in3(n, q, s);
  vector<ll> c(n, 0);
  a = 0;
  rep2(i, 1, n){
    if(s[i - 1] == 'A' && s[i] == 'C')
      a++;
    c[i] = a;
  }
  rep(i, q){
    in2(a, b);
    out(c[b - 1] - c[a - 1]);
    memi;
  }
}

Measured memory_bytes: 1792
N, T = map(int, input().split())
A = list(map(int, input().split()))
dictA = {}
minA = 10**13
maxD = 0
for ai in A:
    minA = min(minA, ai)
    maxD = max(ai-minA, maxD)
    dictA[ai] = True
ans = 0
for ai in A:
    dictA[ai] = False
    if dictA.get(ai + maxD, False):
        ans += 1
print(ans)


Measured memory_bytes: 99156
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		sc.close();

		int ans = 1;
		int max = H[0];
		for (int i = 1; i < N; i++) {
			if (H[i] >= max) {
				ans++;
				max = H[i];
			}
		}
		System.out.println(ans);
	}
}


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

int main()
{
    /* ------- 宣言と入力 ------- */

    long long N, A, B;

    cin >> N >> A >> B;

    /* ------- 計算 ------- */

    long long red, blue;
    long long sum = A + B;

    long long ans = 0;

    ans += N / sum * A;

    if (N % sum < A)
    {
        ans += N % sum;
    }
    else
    {
        ans += A;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
sum=0
lis=sorted([list(map(int,input().split())) for _ in range(n)],key=lambda x:x[0]+x[1])
min=-10**18
for x in lis:
    if min<=x[0]-x[1]:
        sum=sum+1
        min=x[0]+x[1]
print(sum)




Measured memory_bytes: 33064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	string s; cin >> s;
	print((s == "ABC")? "ARC" : "ABC")
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define inf INT_MAX
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    else
    {
        ll t=power(a,b/2);
        if(b%2==0)
        return ((t%mod)*(t%mod))%mod;
        else
        return ((((t%mod)*(t%mod))%mod)*((a%mod)%mod))%mod;
    }
}
ll b[100001];
void solve()
{
ll n,k,i,j;
cin>>n>>k;
ll a[n+1];
f(i,0,n)
{
    cin>>a[i];
}
b[0]=0;
f(i,1,n)
{
    rf(j,i-1,max(i-k,0LL))
    {
        if(b[i]==-1)
            b[i]=abs(a[i]-a[j])+b[j];
        else
        b[i]=min(b[i],abs(a[i]-a[j])+b[j]);
    }
   // watch(b[i]);
}
/*f(i,0,n)
{
    cout<<b[i]<<" ";
}*/
cout<<b[n-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
   // cin>>t;
   memset(b,-1,sizeof(b));
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using vi  = vector<int>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define pow2(i) (1<<i)
#define BIT(X,i) ((X>>i)&1)
#define DEBUG(x) cerr<<__LINE__<<": "<<#x<<" = "<<x<<"\n"
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e9;

int main() {
    string s; cin >> s;
    int N = s.length();

    vi albits(N+1, 0);
    rep(i,N) {
        int c = s[i] - 'a';
        albits[i+1] ^= pow2(c);
        albits[i+1] ^= albits[i];
    }
    vi dp((1<<26), INF);
    vi ans(N+1, INF);
    dp[albits[0]] = 0;
    ans[0] = 0;
    rep(i,N) {
        rep(j,27) {
            int x = pow2(j) / 2;
            chmin(ans[i+1], dp[albits[i+1]^x] + 1);
        }
        chmin(dp[albits[i+1]], ans[i+1]);
    }
    cout << ans[N] << endl;
    return 0;
}


Measured memory_bytes: 264324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();
    
    ll n; cin >> n;
    VL divs;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            divs.push_back(i);
            if (i * i != n)divs.push_back(n / i);
        }
    }

    ll ans = 0;
    each(i, divs) {
        ll m = i - 1;
        if (m == 0)continue;
        if (n / m == n % m)ans += m;
    }

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


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

int main(){
    string w;cin >> w;
    int L;L = w.size();

    int flag = true;
    for (int i = 0;i < L;i++){
        char c;c = w.at(i);
        int count = 0;
        for (int j = 0;j < L;j++){
            if (c == w.at(j)){
                count++;
            }
        }
        if (count%2 == 1){
            flag = false;
            break;
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

typedef long long ll;
const int maxn=1e5+10;
int n,a[maxn],bit[maxn<<1];

inline void add(int x){
	while(x<maxn<<1){
		++bit[x];
		x+=x&-x;
	}
}
inline int sum(int x){
	int res=0;
	while(x){
		res+=bit[x];
		x-=x&-x;
	}
	return res;
}
inline bool check(int res){
	ll cnt=0;
	memset(bit,0,sizeof(bit));
	for(int i=1,t=maxn;i<=n;++i){
		add(t);
		t+=a[i]>=res?1:-1;
		cnt+=sum(t);
	}
	return cnt>=(n*(n+1ll)/2+1)/2;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	int l=1,r=1e9;
	while(l<r){
		int mid=l+r+1>>1;
		if(check(mid))
			l=mid;
		else
			r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1536
import java.math.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	//初期フィールド・メソッド---------------------------------------------
	static Scanner sc = new Scanner(System.in);
	static int min(int... ar) {Arrays.sort(ar); return ar[0];}
	static int max(int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
	//------------------------------------------------------------


	//フィールド追加場所-----------------------------------------------
	//------------------------------------------------------------


	//メソッド追加場所------------------------------------------------
	//------------------------------------------------------------


	//mainメソッド---------------------------------------------------
	public static void main(String[] args) {
		int n = sc.nextInt(); sc.nextLine();
		
		for (int i=0; i<n; i++) {
			out.println(sc.nextLine().replace("Hoshino","Hoshina"));
		}
	}
	//------------------------------------------------------------
}


Measured memory_bytes: 26508
N = int(input())
S = ""
if N == 1:
    print("1")
elif N == 0:
    print("0")
else:
    while N != 1:
        if abs(N)%2 == 1:
            N = (N-1)//(-2)
            S += "1"
        else:
            N = N//(-2)
            S += "0"
    S += "1"
    print(S[::-1])


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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

void solve(int t) {
    int n;
    cin >> n;
}

int main(int argc, char *argv[])
{
    ll v = 0;
    int k, cnt = 0;
    cin >> k;

    int mx_iteration = 1e8;

    if (k%2==0) {
        cout <<"-1";
        return 0;
    }
    
    while(mx_iteration--) {
        cnt++;
        v = (v*10+7)%k;
        if (!v) {
            cout << cnt<<endl;
            return 0;
        }
    }
    cout << "-1";

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=10000000;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
ll int check(ll int mid,ll int a[],ll int n)
{
    ll int an=0;
    for(int i=0;i<n;i++)
       {
           if(a[i])
           {
           ll int j=mid/a[i];
           //cout<<j<<endl;
           int o=n;
           int y;
           if(a[i]<0)
           {
               if(abs(mid)%abs(a[i])&&mid<0)
               j=j+1;
           y=a+o-lower_bound(a+i+1,a+o,j);
           //cout<<y<<"&"<<endl;
           }
           else
            y=upper_bound(a+i+1,a+o,j)-a-i-1;
           //cout<<y<<"&"<<endl;
           an+=y;
           }
           else 
           {
               if(mid>=0) an+=(n-i-1);
           }
       }
       return an;
}
int main()
{
   ll int n,k;
   cin>>n>>k;
   ll int a[n];
   fo(i,0,n)
   cin>>a[i];
   sort(a,a+n);
   ll int s=-1e18,e=1e18,id=0;
   while(s<=e)
   {
       ll int mid=(s+e)/2,an=0;
       an=check(mid,a,n);
       //cout<<mid<<" "<<an<<endl;
       if(an<k) s=mid+1;
       else if(an>=k)
       {
           id=mid;
           e=mid-1;
       }
       
   }
   //cout<<check(-67,a,n);
   cout<<id<<endl;
   
}

Measured memory_bytes: 1792
#include <queue>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int H, W, N;
int main() {
	cin >> H >> W >> N;
	vector<string> s(H);
	vector<int> x(N + 1), y(N + 1);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 'S') x[0] = j, y[0] = i;
			else if (isdigit(s[i][j])) x[s[i][j] - 48] = j, y[s[i][j] - 48] = i;
		}
	}
	vector<vector<int> > G(H * W);
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] != 'X' && s[i + 1][j] != 'X') {
				int v1 = i * W + j, v2 = v1 + W;
				G[v1].push_back(v2);
				G[v2].push_back(v1);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (s[i][j] != 'X' && s[i][j + 1] != 'X') {
				int v1 = i * W + j, v2 = v1 + 1;
				G[v1].push_back(v2);
				G[v2].push_back(v1);
			}
		}
	}
	int ret = 0;
	for (int i = 0; i < N; i++) {
		vector<int> dist(H * W, -1); dist[y[i] * W + x[i]] = 0;
		queue<int> que; que.push(y[i] * W + x[i]);
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int i : G[u]) {
				if (dist[i] == -1) {
					dist[i] = dist[u] + 1;
					que.push(i);
				}
			}
		}
		ret += dist[y[i + 1] * W + x[i + 1]];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 42424
#include <bits/stdc++.h>
using namespace std;
int n, h[100010];
int dp[100010];
int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &h[i]);
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3; i<=n; i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d", dp[n]);
}


Measured memory_bytes: 1024
/*
 * Aizu Online Judge
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author yoshkur
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			DataController controller = new DataController();
			controller.setDataFromLine(br);
			br.close();
			System.out.println(controller.getResult());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

class DataService {

	private List<DataEntity> entities = new ArrayList<>();
	private DataEntity entity;

	public DataService() {
	}

	public List<DataEntity> getEntities() {
		return entities;
	}

	public void setEntities(List<DataEntity> entities) {
		this.entities = entities;
	}

	public DataEntity getEntity() {
		if (this.entity == null) {
			this.entity = new DataEntity();
		}
		return entity;
	}

	public void setEntity(DataEntity entity) {
		this.entity = entity;
	}
}

class DataEntity {

	Integer num0;
	Integer num1;

	public Integer getNum0() {
		return num0;
	}

	public void setNum0(Integer num0) {
		this.num0 = num0;
	}

	public Integer getNum1() {
		return num1;
	}

	public void setNum1(Integer num1) {
		this.num1 = num1;
	}

}

class DataController {

	private static final String RETCODE = System.getProperty("line.separator");
	public static final String SEPARATOR = " ";

	private final DataService ejb;

	public DataController() {
		this.ejb = new DataService();
	}

	public void setDataFromLine(BufferedReader br) throws IOException {
		String[] values = br.readLine().trim().split(SEPARATOR);
		this.ejb.getEntity().setNum0(Integer.valueOf(values[0]));
		this.ejb.getEntity().setNum1(Integer.valueOf(values[1]));
	}

	public void setDataFromLines(BufferedReader br) throws IOException {
		String line;
		while ((line = br.readLine()) != null) {
			DataEntity entity = new DataEntity();
			String[] values = line.trim().split(SEPARATOR);
			entity.setNum0(Integer.valueOf(values[0]));
			entity.setNum1(Integer.valueOf(values[1]));
			this.ejb.getEntities().add(entity);
		}
	}

	public String getResult() {
		String result = null;
		NumberFormat nf = new DecimalFormat("0.00000");
		StringBuilder sb = new StringBuilder();
		sb.append(this.ejb.getEntity().getNum0() / this.ejb.getEntity().getNum1());
		sb.append(SEPARATOR);
		sb.append(this.ejb.getEntity().getNum0() % this.ejb.getEntity().getNum1());
		sb.append(SEPARATOR);
		sb.append(nf.format(BigDecimal.valueOf(this.ejb.getEntity().getNum0().doubleValue() / this.ejb.getEntity().getNum1().doubleValue())));
		result = sb.toString().trim();
		return result;
	}
}

Measured memory_bytes: 26008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
string s;

int dp[25][2];
const int mod = 1e9 + 7;

int tens[100005];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  n = s.size();
  dp[0][n % 2] = 1;
  tens[0] = 1;
  for(int i = 1; i <= n; i++)
    tens[i] = (tens[i - 1] * 10) % 13;
  for(int i = n - 1; i >= 0; i--) {
    int step = i % 2;
    for(int rest = 0; rest <= 12; rest++)
    	dp[rest][step] = 0;
    for(int rest = 0; rest <= 12; rest++) {
      if(s[i] != '?') {
        int nw = (rest + (s[i] - '0') * tens[n - 1 - i]) % 13;
        dp[nw][step] += dp[rest][!step];
        if(dp[nw][step] >= mod) dp[nw][step] -= mod;
      } else {
        for(int dig = 0; dig <= 9; dig++) {
          int nw = (rest + dig * tens[n - 1 - i]) % 13;
          dp[nw][step] += dp[rest][!step];
          if(dp[nw][step] >= mod) dp[nw][step] -= mod;
        }
      }
    }
  }
  cout << dp[5][0] << endl;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

long long gcd(long long x, long long y) {
    long long r;
    if(x < y) swap(x, y);

    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

long long lcm( long long m, long long n ) {
    // 引数に０がある場合は０を返す
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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

    long long ans = 1;
    rep(i,n){
        long long a;
        cin >> a;
        ans = lcm(ans, a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S, K := ReadString(), ReadInt()
	oneChars := true
	for _, si := range []byte(S) {
		if si != S[0] {
			oneChars = false
			break
		}
	}
	if oneChars {
		fmt.Println(len(S) * K / 2)
		return
	}

	if S[0] != S[len(S)-1] {
		fmt.Println(K * count(S))
	} else {
		c1 := count(S)
		c2 := count(S + S)
		fmt.Println((K-1)*(c2-c1) + c1)
	}
}

func count(s string) int {
	ans := 0
	seq := 1
	for i := 1; i < len(s); i++ {
		if s[i] == s[i-1] {
			seq++
		} else {
			ans += seq / 2
			seq = 1
		}
	}
	ans += seq / 2
	return ans
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n >> a;
       Yes(n%500<=a);
       
return 0;
}


Measured memory_bytes: 256
# coding:utf-8
# bit全探索
n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]
ans = 12 * (10 ** 5) + 1

for bit in range(2 ** n):
    tmp_book = [0] * m
    price = 0
    for i in range(n):
        if ((bit >> i) & 1):
            price += book[i][0]
            for j in range(m):
                tmp_book[j] += book[i][j + 1]
    if all(item >= x for item in tmp_book):
        ans = min(price, ans)

if ans != 12 * (10 ** 5) + 1:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

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

int main(void){
    int a,b;
    cin>>a>>b;
    
    cout<<gcd(a,b)<<endl;

	return 0;
}


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

# define ll long long



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   string s1,s2;
   int cnt=0;
   cin>>s1>>s2;
   for(int i=0;i<s1.length();i++){
    if(s1[i]!=s2[i])
        cnt++;
   }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3880
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		op := nextString()
		b, _ := nextInt()

		if op == "?" {
			break
		}

		c := 0
		if op == "+" {
			c = a + b
		} else if op == "-" {
			c = a - b
		} else if op == "*" {
			c = a * b
		} else if op == "/" {
			c = a / b
		}
		fmt.Println(c)
	}
}



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


void solve(long long a, long long b, long long c){
    cout << min(a,b)+min(max(a,b), c) << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 1e18
for ai in a:
    s.append(s[-1] + ai)
for i in range(1, n):
    ans = min(ans, abs(s[i] - (s[-1] - s[i])))
print(ans)

Measured memory_bytes: 87120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

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

  int n, w;
  cin >> n >> w;

  long w1, w2, w3, w4, v;
  cin >> w1 >> v;

  w2 = w1+1;
  w3 = w1+2;
  w4 = w1+3;

  vector<long> v1;
  vector<long> v2;
  vector<long> v3;
  vector<long> v4;

  v1.push_back(v);

  map<long, vector<long>> m;
  m.insert({w1, v1});
  m.insert({w2, v2});
  m.insert({w3, v3});
  m.insert({w4, v4});

  rep(i, n-1) {
    int ww, vv;
    cin >> ww >> vv;
    m.at(ww).push_back(vv);
  }

  v1 = m.at(w1);
  v2 = m.at(w2);
  v3 = m.at(w3);
  v4 = m.at(w4);

  sortvinv(v1);
  sortvinv(v2);
  sortvinv(v3);
  sortvinv(v4);

  vector<long> vv1;
  vector<long> vv2;
  vector<long> vv3;
  vector<long> vv4;

  vv1.push_back(0);
  vv2.push_back(0);
  vv3.push_back(0);
  vv4.push_back(0);

  rep(i, v1.size()) {
    vv1.push_back(vv1[i]+v1[i]);
  }
  rep(i, v2.size()) {
    vv2.push_back(vv2[i]+v2[i]);
  }
  rep(i, v3.size()) {
    vv3.push_back(vv3[i]+v3[i]);
  }
  rep(i, v4.size()) {
    vv4.push_back(vv4[i]+v4[i]);
  }

  long res = 0;

  rep(i, vv1.size()) {
    rep(j, vv2.size()) {
      rep(k, vv3.size()) {
        rep(l, vv4.size()) {
          if(i*w1 + j*w2 + k*w3 + l*w4 > w) {
            continue;
          }
          res = max(res, vv1[i] + vv2[j] + vv3[k] + vv4[l]);
        }
      }
    }
  }

  cout << res << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<char> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    int count=0;
    for(int i=0;i<N-2;i++){
        if(A.at(i)=='A'&&A.at(i+1)=='B'&&A.at(i+2)=='C'){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 10000
int a[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int H, A;
  cin >> H >> A;

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

  int hp = H;
  int cnt = 0;
  while (hp > 0) {
    hp = hp - A;
    cnt++;
  }

  cout << cnt << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))

def vote(a,m):
  a.sort(reverse=True)
  if a[m-1] >= sum(a)/(4*m):
      return True
  else:
      return False
    
ans = "Yes" if vote(A,M) else "No"
print(ans)

Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

long long int B[55],P[55],S[55];

long long int sol(long long int n,long long int x){
  //if(n==0 && x==1) return 1;
  if(x<=n) return 0;
  //printf(":::%lld %lld\n",n,x);


  if(x==((S[n])/2)) return P[n-1];
  if(x==((S[n]+1)/2)) return P[n-1]+1;
  if(x==S[n]) return P[n];

  if(x>(S[n]+1)/2 && x<=S[n]){
    return P[n-1] +1 +sol(n-1,x-S[n-1]-2);
  }
  else{
    return sol(n-1,x-1);
  }
}

int main(){
  long long int n,x;
  cin>>n>>x;
  B[0]=0;
  P[0]=1;
  S[0]=1;
  for(int i=1;i<=n+1;i++){
    B[i]=B[i-1]*2 + 2;
    P[i]=P[i-1]*2 + 1;
    S[i]=B[i]+P[i];
    //printf(": %lld %lld %lld\n",B[i],P[i],S[i]);
  }
  cout<<sol(n,x)<<endl;

  return 0;
}

Measured memory_bytes: 256
import math

N, S = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

A = [x - S for x in X]

def lcd(a,b):
    a = abs(a)
    b = abs(b)
    a,b = min(a,b), max(a,b)
    if a == 0:
        return b
    return lcd(b%a, a)


ret = A[0]
for a in A:
    ret = lcd(ret, a)

print(ret)



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

using namespace std;

typedef long long ll;

#define REP(i, a, b) for (i = a; i < b; i++)
#define REP_ITER(it, v) for (it = v.begin(); it != v.end(); it++)

#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(0)

#define TEST(test) \
    int test;      \
    cin >> test;   \
    while (test--)

#define cll(a, b) cin >> a >> b
#define YES cout << "YES\n"
#define NO cout << "NO\n"

#define vi vector<int>
#define vi_iterator vector<int>::iterator

#define si set<int>
#define si_iterator set<int>::iterator

double pi = 2 * acos(0.0);
int i, j;
int main()
{
    FASTIO;
    ll n,odd=0;
    cin >> n;
    ll arr[n];
    REP(i,0,n){
        cin >> arr[i];
        if(arr[i]%2==1){
            odd++;
        }
    }
    if(odd%2==1)NO;
    else YES;
}

Measured memory_bytes: 4412
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char s[1005],t[1005];
int main()
{
	cin>>s;
	cin>>t;
	int n = strlen(s);
	int l = strlen(t);
	if(n > l) cout<<"GREATER"<<endl;
	else if(n < l) cout<<"LESS"<<endl;
	else {
		int flag = 0;
		for(int i = 0; i < n; i++){
			if(s[i] > t[i]) {
				flag = 1;
				break;
			}
			else if(s[i] < t[i]) {
				flag = 2;
				break;
			}
		}
		if(flag == 1) cout<<"GREATER"<<endl;
		else if(flag == 2) cout<<"LESS"<<endl;
		else if(flag == 0) cout<<"EQUAL"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
char s;
int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>s;
  if(s >= 'a' and s <= 'z') cout<<"a"<<endl;
  else cout<<"A"<<endl;
  return 0;
}


Measured memory_bytes: 3644
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>x;i--)
typedef long long ll;
using namespace std;

int main(){
    ll x,y;
    cin >>x>>y;
    cout<<x+y/2<<endl;
    
    
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	/*cout << left << " " << mid << " " << right << endl;
	cout << "L[" << n1 << "] {";*/
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
		//cout << " " << L[i];
	}
	//cout << "}" << endl << "R[" << n2 << "] {";
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
		//cout << " " << R[i];
	}
	//cout << "}" << endl;
	L[n1] = R[n2] = SENTINEL;

	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) A[k] = L[i++];
		else A[k] = R[j++];

	}
}

void mergeSort(int A[], int n, int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
		/*for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << A[i];
		}
		cout << endl;*/
	}
}

int main()
{
	static int A[MAX], n, i;
	cnt = 0;

	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &A[i]);;

	mergeSort(A, n, 0, n);

	for (i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);

	return 0;
}

Measured memory_bytes: 5136
#include<bits/stdc++.h>
#define int long long
using namespace std;

int cost(int a[] , int n , int val) {
	int res = 0;
	for(int i = 0; i < n; i++) res += ((a[i] - val)*(a[i] - val));
	return res;
}

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

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 1e9+7;
    for(int i = -200; i <= 200; i++) {
		int res = cost(a , n , i);
		if(ans > res) ans = res;
	}
	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

struct link {
	struct link *next;
	int val;
};

struct link *newval(struct link *prev, int val)
{
	struct link *p = prev, *pp = NULL;
	for (; p; pp = p, p = p->next) {
		if (p->val == val)
			return prev;
		if (p->val > val)
			break;
	}
	struct link *l = malloc(sizeof(struct link *));
	if (pp) {
		pp->next = l;
		l->next = p;
		l->val = val;
		return prev;
	}
	l->next = prev;
	l->val = val;
	return l;
}

struct link *update(struct link *me, struct link *prev, int diff)
{
	for (struct link *p = prev; p; p = p->next) {
		me = newval(me, abs(p->val + diff));
		me = newval(me, abs(p->val - diff));
	}
	return me;
}

int main(int argc, char **argv)
{
	int H, W;
	scanf("%d %d", &H, &W);
	int A[80][80], B[80][80];
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++)
			scanf("%d", &A[h][w]);
	}
	int D[80][80];
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			scanf("%d", &B[h][w]);
			// get diff
			D[h][w] = abs(A[h][w] - B[h][w]);
		}
	}
#if 0
	struct link *p[80][80] = {0}; // NULL
	p[0][0] = newval(NULL, D[0][0]);
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (h > 0)
				p[h][w] = update(p[h][w], p[h - 1][w], D[h][w]);
			if (w > 0)
				p[h][w] = update(p[h][w], p[h][w - 1], D[h][w]);
		}
	}
	for (struct link *l = p[H-1][W-1]; l; l = l->next)
		fprintf(stderr, "%d\n", l->val);
	printf("%d\n", p[H-1][W-1]->val);
#endif
	static int p[80][80][80*80*2 + 128] = {0};
	int hw = D[0][0];
	p[0][0][hw] = 1;
	int m = hw;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			for (int k = 0; k <= m; k++) {
				int k1 = abs(k + D[h][w]);
				int k2 = abs(k - D[h][w]);
				if (h>0 && p[h-1][w][k]) {
					p[h][w][k1] = 1;
					p[h][w][k2] = 1;
					if (k1 > m)
						m = k1;
					if (k2 > m)
						m = k2;
				}
				if (w>0 && p[h][w-1][k]) {
					p[h][w][k1] = 1;
					p[h][w][k2] = 1;
					if (k1 > m)
						m = k1;
					if (k2 > m)
						m = k2;
				}
			}
		}
	}
	for (int k = 0; k <= m; k++) {
		if (p[H-1][W-1][k]) {
			printf("%d\n", k);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 321792
n = int(input())

b = n%26
if b == 0:
    ans = "z"
    b = 26
else:    
    ans = chr(b+96)
i = 2
while 1:
    c = chr(((n-b)%26**i)//26**(i-1)+96)
    if ((n-b)%26**i)//26**(i-1) == 0:
        if n == b:
            break
        else:
            ans += "z"
            b += 26**i
    elif c != "`":
        ans += c
        b += (n-b)%26**i
    i += 1
print(ans[::-1])

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)

typedef long long ll;


const int SIZE=5+1e6;
const int INF=10+1e9;
bool A[SIZE];
bool ans[SIZE];
bool dx[]={0,0,1,1},dy[]={0,1,0,1};
ll n;
bool issure(bool x[SIZE]){
  rep(i,n){
    if(x[i]==A[i]) if(x[(i+1)%n]!=x[(i-1+n)%n])return false;
    if(x[i]!=A[i]) if(x[(i+1)%n]==x[(i-1+n)%n])return false;
  }
  return true;
}
int main(){
  cin>>n;
  string s;

  cin>>s;
  for(int i=0;i<n;i++){
    A[i]=s[i]=='o';
  }
  bool answer = false;
  for(int i=0;i<4;i++){
    ans[0]= dx[i];
    ans[1]= dy[i];
    FOR(j,2,n){
      if(ans[j-1]==A[j-1])ans[j]=ans[j-2];
      else ans[j]=!ans[j-2];
    }
    if(issure(ans)){
      rep(j,n)
      cout<<(ans[j]?'S':'W');
      cout<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    string s;
    cin >> s;
    int k = (s[0]-'0')*100 + (s[1]-'0')*10 + (s[2]-'0');
    int ans = abs(753-k);
    for (int i = 1; i < (int) s.size()-2; i++){
        k = (s[i]-'0')*100 + (s[i+1] - '0')*10 + (s[i+2]-'0');
        ans = min(ans, abs(k-753));
    }
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 100000; ++i)
    {
        double x = (i * 1.0) * (8.0 / 100.0);
        double y = (i * 1.0) * (1.0 / 10.0);
        int p = x, q = y;
        if (a == p && b == q) { cout << i << '\n'; return 0; }
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 256
from collections import Counter


N, M = map(int, input().split())
A = list(map(int, input().split()))

s = [0] * (N + 1)

for i in range(N):
    s[i + 1] = s[i] + A[i]
    s[i + 1] %= M

c = Counter(s)

ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)

Measured memory_bytes: 17312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll n, m;    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i], a[i] >>= 1;

    while(!(a[0]%2)){
        REP(i, n){
            if(a[i]%2){
                cout << 0 << endl;
                return 0;
            }
            a[i] >>= 1;
        }
        m >>= 1;
    }
  
    REP(i, n) 
        if(!(a[i]%2)){
            cout << 0 << endl; 
            return 0;
        }
    ll lc = a[0];
    REP(i, n) lc = lcm(lc, a[i]);
    cout << (m/lc)/2 + (m/lc)%2<< endl;
    
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
bool is_prime(long long n){
    for(long long i = 2; i*i <= n ; i++){
        if(n%i == 0)return false;
    }
    return n != 1;
}
int main() {
  int n;
  cin >> n;
  vector<int> res;
  for (int i = 2; i <= 55555; i++) {
    if (is_prime(i) && i % 5 == 1) {
      res.emplace_back(i);
    }
  }
  rep(i,n) {
    cout << res[i] << " ";
  }
  cout << endl;
  return 0;
} 

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

int main() {
    int n;
    string s;
    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A,B;
  cin >> A >> B;
  long long a=A, b=B, c=A%B;
  while(c>0){
    a=b;
    b=c;
    c=a%b;
//  cout <<a<<" "<<b<<" "<<c<<endl;
  }
  long long ans=A*B/b;
  cout << ans << endl;
}

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

using namespace std;

int main(void) {
  int N, D;
  cin >> N >> D;
  int X[N][D];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  int s = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int tmp = 0;
      for (int k = 0; k < D; k++) {
        tmp += pow(X[i][k] - X[j][k], 2);
      }
      if (tmp == pow(floor(sqrt(tmp)), 2)) {
        s++;
        //cout << tmp << endl;
      }
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int N = sc.nextInt();
			// 整数の入力
			// スペース区切りの整数の入力
			int K = sc.nextInt();


			ArrayList<Integer> stateList = new ArrayList<Integer>();
					
			for (int i = 0; i < N;i ++ ){
				// 整数の入力
				// スペース区切りの整数の入力
				stateList.add(sc.nextInt());
			}
			 
			Collections.sort(stateList);

			int sum = 0;
			int j = N - K  ;
			for(int i= j ;i < N ;i++){
					
				sum = sum + stateList.get(i);
	        	//System.out.println(stateList.get(i));
			}

       		// 出力
        	System.out.println(sum);
		}
}


Measured memory_bytes: 22868
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
A.sort()
B.sort()
cnta = [0]*29
cntb = [0]*29
for idx in range(N):
    a, b = A[idx], B[idx]
    for i in range(29):
        if (1<<i) & a:
            cnta[i] = 1 - cnta[i]
        if (1<<i) & b:
            cntb[i] = 1 - cntb[i]

carry = [0]*30
bwa = [0]*N
bwb = [0]*N
for i in range(29):
    m = (1<<(i+1))-1
    bwbc = sorted([b&m for b in B])
    bwac = sorted([m+1 if a&m == 0 else m&(-(a&m)) for a in A])
    r = N
    for idx in range(N-1, -1, -1):
        a = bwac[idx]
        while r and bwbc[r-1] >= a:
            r -= 1
        carry[i+1] += N - r
        
ans = 0
for i in range(29):
    if (carry[i] + (cnta[i]+cntb[i])*N) % 2 == 1:
        ans |= 1<<i
print(ans)

Measured memory_bytes: 141148