akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

const int MAX = 1100;
int memo[MAX][MAX];

int dfs(int x, int y){
  if(memo[x][y] != -1) return memo[x][y];

  for(int i = 2; i <= x; i += 2){
    if(dfs(x-i, y+i/2) == false) return memo[x][y] = true;
  }
  for(int i = 2; i <= y; i += 2){
    if(dfs(x+i/2, y-i) == false) return memo[x][y] = true;
  }

  return memo[x][y] = false;
}

signed main() {
  int X, Y;
  cin >> X >> Y;

  REP(i, MAX) REP(j, MAX) memo[i][j] = -1;
  memo[0][0] = false;
  memo[1][0] = false;
  memo[0][1] = false;

  REP(i, 100) REP(j, 100){
    dfs(i, j);
  }

  /* REP(i, 20){ */
  /*   REP(j, 20){ */
  /*     cout << memo[i][j]; SPBR(j, 20); */
  /*   } */
  /* } */

  if(abs(X-Y) <= 1) cout << "Brown" << "\n";
  else cout << "Alice" << "\n";

  return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll n; cin >> n;
    ll moto = n;
    int limit = sqrt(n) + 1;
    vector<ll> ans;
    for(int i = 2; i < limit; ++i) {
        if(n % i == 0) {
            int cnt = 0;
            while(n%i == 0) {
                cnt++;
                n /= i;
            }
            ans.push_back(cnt);
        }
    }
    if(n != 1) ans.push_back(1);
    /*for(int i = 0; i < (int)ans.size(); ++i) {
        cout << ans.at(i) << endl;
    }*/

    if(moto == 1) cout << 0 << endl;
    else {
        int anssss = 0;
        int rest = 0;
        for(int i = 0; i < (int)ans.size(); ++i) {
            for(int j = 1; ; ++j) {
                if(ans.at(i) >= j) {
                    anssss++;
                    ans.at(i) -= j;
                }else break;
            }
        }
        cout << anssss << endl;
    }
}

Measured memory_bytes: 3724
using System;

namespace id_0359cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var dateOfSemptermber = int.Parse(Console.ReadLine());
            DateTime date = new DateTime(2017, 9, dateOfSemptermber);
            System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
            Console.WriteLine(date.ToString("ddd", cultureInfo).ToLower());
        }
    }
}



Measured memory_bytes: 9460
#include <iostream>
#include <strstream>
#include <string>
#include <deque>
#include <vector>
#include <algorithm>
typedef unsigned int UINT;
using namespace std;

void heisone()
{
    cout << "Hello World\n";
}

void HeisTwo() 
{
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
}
typedef  void(* func)(void);
func funcs[3] = { nullptr,heisone ,HeisTwo};


int main(void) {
    int x;
    cin >> x;
    funcs[x]();
    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;

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

    // i-th index
    // j-th height
    // k-th change
    const long long init = 1e18;
    vector<vector<vector<long long>>> dp(
        N + 1,
        vector<vector<long long>>(
            N + 1,
            vector<long long>(
                K + 1, init)));
    dp[0][0][0] = 0;
    queue<pair<long long, long long>> q;
    q.push({0, 0});
    for (int i = 1; i <= N; i++)
    {
        set<pair<long long, long long>> tmp;
        while (!q.empty())
        {
            long long h = q.front().first;
            long long change = q.front().second;
            long long score = dp[i - 1][h][change];
            q.pop();
            dp[i][i][change] = min(dp[i][i][change], score + max(0ll, H[i] - H[h]));
            tmp.insert({i, change});
            if (change < K)
            {
                dp[i][h][change + 1] = min(dp[i][h][change + 1], score);
                tmp.insert({h, change + 1});
            }
        }
        for (pair<long long, long long> p : tmp)
        {
            q.push(p);
        }
    }
    long long ans = init;
    while (!q.empty())
    {
        ans = min(ans, dp[N][q.front().first][q.front().second]);
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 220160
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;
int main()
{
  int a=0,b=0,c=0,d=0,e=0,f=0,i=0,j=0;
  string s1,s2,s3;
  
  cin>>s1>>s2>>a>>b>>s3;
  if(s3==s1) cout<<a-1<<" "<<b<<endl;
  else if(s3==s2) cout<<a<<" "<<b-1<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	for(int i=0;i<=1000000;i++)
		if(a-i*100<=i*5&&a-i*100>=0)
		{
			cout<<1;
			return 0;
		}
	cout<<0;
}
//c

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
 
using namespace std;
 
typedef long long ll;

int n[20001];
int main(){
    int N;
    cin>>N;
    
    rp(i,0,N) {int x;cin>>x;n[x-1]=i;}
    rp(i,0,N) cout<<(N)*i+1<<" ";
    cout<<endl;
    rp(i,0,N) cout<<N*(N-i)+n[i]+1<<" ";
    cout<<endl;
    return 0;
};


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> A(n + 1);
    for(int i = 1; i <= n; i++) cin >> A[i];
    vector<int> left(n + 1, 0), right(n + 1, 0);
    left[1] = A[1];
    right[n] = A[n];
    for(int i = 2; i <= n; i++) left[i] = __gcd(left[i - 1], A[i]);
    for(int i = n - 1; i >= 0; i--) right[i] = __gcd(right[i + 1], A[i]);
    int ans = 1;
    for(int i = 1; i <= n; i++) ans = max(ans, __gcd(left[i - 1], right[i + 1]));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1408
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		Double[] v = new Double[n];
		Arrays.setAll(v, i -> Double.parseDouble(sc.next()));
		List<Double> list = new ArrayList<>(Arrays.asList(v));
		while(list.size() > 1){
			list.sort(Comparator.naturalOrder());
			double x = list.get(0), y = list.get(1);
			list.remove(x);
			list.remove(y);
			list.add((x + y) / 2);
		}
		System.out.println(list.get(0));
	}
}


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

ll f(ll a, ll b) {
  if(a < b) return f(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    ll k, ans = 0;
    cin >> k;

    ans = k*(k+1)/2;

    for (int i=2; i<=k; i++) {
        for (int j=1; j<i; j++) {
            ans += 6*f(i, j);
        }
    }

    for (int i=3; i<=k; i++) {
        for (int j=2; j<i; j++) {
            for (int t=1; t<j; t++) {
                ll ab = f(j, t);
                ans += 6*f(i, ab);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    if(s.front() != 'A'  || (s[1] < 'a' || s[1] >  'z') || (s.back() < 'a' || s.back() >  'z')){
        cout << "WA";
        return 0;
    }
    int count = 0;
    for(int i = 2; i < s.size()-1; i++){
        if(s[i] == 'C'){
            count++;
            if(count > 1){
                cout << "WA";
                return 0;
            }
            continue;
        }
        if(s[1] < 'a' || s[1] >  'z'){
            cout << "WA";
            return 0;
        }
    }
    if(count == 1)cout << "AC";
    else cout << "WA";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,count=0,temp;
  char s[210000];
scanf("%s",s);

  n=W_Length(s);
  for(i=0;i<n;i++){
    temp=s[i]-'0';
    count+=temp;
  }
if(count%9==0){
  printf("Yes");
  return 0;
}
  
  printf("No");
return 0;
    
}


Measured memory_bytes: 1888
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
char curr_val ;
int main()
{
    IOS
    // READ("test.txt");
    //WRITE("");
    ll n, a ;
    cin >> n ;
    ll sum =1,i=1 ;
    while(i < n)
    {
        i*=2;
        if(i>n)
            break;
        sum+=i;
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Ll long long
using namespace std;
const Ll N=2e5+5;
Ll a[N],c[N],b[N],v[N];
Ll n,m,ans,sum,ma;
int main()
{
	scanf("%lld%lld",&n,&m);
	for(Ll i=1;i<=n;i++)scanf("%lld",&c[i]);
	for(Ll i=2;i<=n;i++)ans+=(c[i]-c[i-1]+m)%m;
	for(Ll i=2;i<=n;i++){
		Ll l=c[i-1],r=c[i];
		if(l>r)r+=m;
		a[l+2]++;
		a[r+1]--;
		b[r+1]+=(r-l-1);
	}
	for(Ll i=1;i<=m*2;i++){
		sum+=a[i];
		v[i]=v[i-1];
		v[i]-=b[i];
		v[i]+=sum;
	}
	for(Ll i=1;i<=m;i++)ma=max(ma,v[i]+v[i+m]);
	printf("%lld",ans-ma);
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int f;

ll division(ll n)
{
    //char ans[MAX_N];
   ll con=0;
    bool flag = true;
    ll k = 0,s = 0,t = 0;

    while(1)
    {
        ll it=s;
        t = s*10 + 7;
        con++;
        if(t/n>0 || t == 0)
        {

            s = t%n;
            flag = false;
        }
        else
        {
            s = t;

        }
        if(!flag){if(it==s){f=0;return con;}}
        if(!flag){if(s==0){f=1;return con;}}
    }

}
int main()
{

   ll k;
   cin>>k;
   int y=k%10;
   int iu=0,i;
   for(i=1;i<=9;i++)
    if(i*y%10==7)iu=1;
    if(iu==0){printf("-1\n");return 0;}
   ll c=division(k);
   if(f==1||c==1)printf("%lld\n",c);
   else printf("-1\n");
    return 0;
}


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

int main(){
	int n;
	double s=0;
	cin >> n;
	int a[n][2];
	for(int i=0;i<n;i++)
		cin >> a[i][0] >> a[i][1];
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			s+=sqrt(pow((a[i][0]-a[j][0]),2)+pow((a[i][1]-a[j][1]),2));
		}
	}
	printf("%.10f",2*s/n);
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M;
vector<int> x, s;
int par(int a) {
    if (x[a] == a) return a;
    return x[a] = par(x[a]);
}
int ans = 1;
void unite(int a, int b) {
    int pa = par(a), pb = par(b);
    if (pa == pb) return;
    s[pa] += s[pb];
    x[pb] = pa;
    ans = max(ans, s[pa]);
}
int main () {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        x.push_back(i);
        s.push_back(1);
    }
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        unite(A, B);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4972
mod = 998244353
N = int(input())
D = list(map(int,input().split()))

ans = 1
c = [0]*N
for i in range(N):
    c[D[i]] += 1
    if i != 0 and D[i] == 0:
        ans = 0


if len(set(D)) != max(D)+1:
    ans = 0
for i in range(1,N-1):
    ans *= pow(c[i],c[i+1],mod)
    ans %= mod

print(ans)

Measured memory_bytes: 59444
import numpy as np


n,d=map(int,input().split())
x=[]
cnt=0
X=[]
for i in range(n):
    x=input().split()
    x=[int(i) for i in x]
    X.append(x)


for i in range(n,0,-1):
    for j in range(i-1,0,-1):
        a=np.array(X[i-1])
        b=np.array(X[j-1])
        u=b-a
        u=np.linalg.norm(u)
        if(int(u)==u):
            cnt+=1

        
print(cnt)


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (auto &p : P) {
    cin >> p;
  }
  int min_p = 1e6;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] <= min_p) {
      ans++;
    }
    chmin(min_p, P[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    vector<ll> r(2e5+70),l(2e5+7,0);
    rep(i,n){
        if(i+p[i]>=0 && i+p[i]<2e5+5){
            r[i+p[i]]++;
        }
        if(i-p[i]>=0 && i-p[i]<2e5+5){
            l[i-p[i]]++;
        }
    }
    ll ans=0;
    rep(i,2e5){
        ans+=r[i]*l[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7160
#include <iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cctype>
#include<iterator>
#include <stdio.h>
#include <string.h>
#include <sstream>
//#include<conio.h>
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define M_PI 3.14159265358979323846
#define mod 1000000007
#define endl "\n"
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


const int N = 5e6 + 5, inf = 2e9;


int main()
{
	MEGA_MIND
		ll n, num[15][15] = {};
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; ++i) 
	{
		string s = to_string(i);
		int a = s.front()-'0';
		int b = s.back()-'0';
		if (!a || !b) 
			continue;
		num[a][b]++;
	}
	for (int a = 1; a < 10; ++a) 
	{
		for (int b = 1; b < 10; ++b) 
		{
			res += num[a][b] * num[b][a];
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    val n = readLine()!!.toInt()
    val vs: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    val cs: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    
    var totalprice = 0.toInt()
    
    for(i in 0 until vs.size){
        if(vs[i] - cs[i] >= 0)
        totalprice = totalprice + vs[i] - cs[i]
    }
    
    println(totalprice)
}


Measured memory_bytes: 37612
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main() 
{
    ll a, b, n, x, ans;
    cin >> a >> b >> n;

    if(n % b == 0) {
        cout << (ll)((n - 1) * a / b) - a * (ll)((n - 1) / b) << endl;
    }
    else {
        /*x = n;
        ans = (ll)(x * a / b) - a * (ll)(x / b);
        x--;
        while(x >= n - (n % b) - 1 && x >= 1) {
            if(ans < (ll)((x) * a / b) - a * (ll)((x) / b));
                ans = (ll)((x) * a / b) - a * (ll)((x) / b);
            x--;
        }*/
        cout << max((ll)(n * a / b) - a * (ll)(n / b), (ll)((n - (n % b) - 1) * a / b) - a * (ll)((n - (n % b) - 1) / b)) << endl;
    }
}

Measured memory_bytes: 3632
#!/usr/bin/ruby
def gauss(a)
	if !a || a.length==0 then return nil end
	n=a.length
	n.times{|i|
		if a[i][i]==0
			if (i+1).step(n-1){|j|
				if a[j][i]!=0
					i.step(n){|k| a[i][k]+=a[j][k]}
					break
				end
			}
				return nil
			end
		end
		n.times{|j|
			if j!=i then
				r = Rational(a[j][i],a[i][i])
				i.step(n){|k| a[j][k] = a[j][k] - a[i][k]*r}
			end
		}
	}

	n.times{|i|
		x=Rational(a[i][i],1)
		a[i].length.times{|j|
			a[i][j] /= x
		}
	}

	return a
end

uaz=gets.split.map(&:to_i)
enemy=[0]+gets.split.map(&:to_i).zip(uaz).map{|x,y|-x+y}
b0=[1]+gets.split.map(&:to_i).zip(uaz).map{|x,y|x-y}
b1=[1]+gets.split.map(&:to_i).zip(uaz).map{|x,y|x-y}
b2=[1]+gets.split.map(&:to_i).zip(uaz).map{|x,y|x-y}
sol=gauss([b0,b1,b2,enemy,[1,0,0,0]].transpose)
puts sol && sol.map(&:last).all?{|e|0<=e&&e<=1} ? :MISS : :HIT

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << endl;

int main() {
  string S, T;
  CIN(S >> T);

  int c = 0;

  if (S[0] == T[0]) c++;
  if (S[1] == T[1]) c++;
  if (S[2] == T[2]) c++;

  COUT(c);


  return 0;
}


Measured memory_bytes: 256
import fractions
a, b, c, d = map(int, input().split())
 
def wareruzu(x):
    if b < x:
        return 0
    start_a = a if a % x == 0 else a - (a % x) + x
    end_b = b - (b % x) # bより小さい最大の値。
    m = end_b - start_a
    return int(m // x) + 1
 
all_n = b - a + 1
print(all_n - wareruzu(c) - wareruzu(d) + wareruzu((c*d) // fractions.gcd(c,d)))

Measured memory_bytes: 5432
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
main()
{
	int n,x;
	cin>>n>>x;
	int arr[n+1];
	arr[n] = x;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n+1);
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		v.push_back(arr[i]-arr[i-1]);
	}
	int ans = __gcd(v[0],v[1]);
	for(int i=2;i<v.size();i++)
	{
		ans = __gcd(ans,v[i]);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
set<string> set_substring;
set<string>::iterator it;
string str,minstr,t;
char sz[5001];
int k;
void ProcessSubString(string s,int n)//ProcessSubStrng=>PSS=>PhotoShopSoftwere
{
	int i,j;
	for(i=0;i<n;i++)
		for(j=0;j<n-i;j++)
			set_substring.insert(s.substr(j,i+1));
}
int main()
{
	scanf("%s",sz);
	str=sz;
	scanf("%d",&k);
	minstr=str;
	if(str.length()>=k)
	{
		for(int i=0;i<str.length()-k;i++)
		{
			t=str.substr(i,k);
			if(t<minstr)
			{
				minstr=t;	
				ProcessSubString(minstr,k);	
			}	
		}
		ProcessSubString(str.substr(str.length()-k),k);
	}
	else
		ProcessSubString(str,str.length());
	it=set_substring.begin();
	for(int i=0;i<k-1;i++)
		it++;
	printf("%s\n",(*it).c_str());
}
	//str.substr(0,5);

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,b,i,c=1;
    scanf("%d %d",&n,&b);
    for(i=0;i<=100;i++)
    {
            n=n/b;
            if(n!=0)
            {
                c=c+1;
            }
    }
    printf("%d",c);
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        w: usize,
        c: [[usize; 10]; 10],
        a: [[i64; w]; h]
    }
    let mut count = vec![0; 10];
    for i in 0..h {
        for j in 0..w {
            if a[i][j] >= 0 {
                count[a[i][j] as usize] += 1;
            }
        }
    }
    let mut ans = 0;
    for i in 0..10 {
        ans += count[i] * dijkstra(i, 1, &c).unwrap();
    }
    println!("{}", ans);
}

use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Debug, PartialEq, Eq)]
struct State(usize, usize);

impl Ord for State {
    fn cmp(&self, other: &Self) -> Ordering {
        other.1.cmp(&self.1)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn dijkstra(s: usize, t: usize, adj: &Vec<Vec<usize>>) -> Option<usize> {
    let n = adj.len();
    let mut pq = BinaryHeap::new();
    pq.push(State(s, 0));
    let mut dist = vec![usize::max_value(); n];
    dist[s] = 0;
    while let Some(st) = pq.pop() {
        if st.0 == t {
            return Some(st.1);
        }
        for i in 0..n {
            let d = st.1 + adj[st.0][i];
            if d < dist[i] {
                dist[i] = d;
                pq.push(State(i, d));
            }
        }
    }
    None
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
char c[maxn];
int e,w,n,s;
int main(){
	scanf("%s",c + 1);
	int len = strlen(c + 1);
	for(int i = 1; i <= len; i++)
	{
		if(c[i] == 'E') e = 1;
		if(c[i] == 'W') w = 1;
		if(c[i] == 'N') n = 1;
		if(c[i] == 'S') s = 1;
	}
	if((e ^ w) || (n ^ s))
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define N 111111
using namespace std;
int ar[N];
int main(void)
{
	int n;
	scanf("%d", &n);
	int i, j, k;
	for (i = 0; i < n; ++i) scanf("%d", ar + i);
	sort(ar, ar + n);
	printf("%d ", ar[n - 1]);
	k = (ar[n - 1] + 1) / 2;
	j = lower_bound(ar, ar + n, k) - ar;
	int l = j - 1, r = (j == n - 1 ? j : j + 1);
	int min_v = abs(k - ar[j]), ans = ar[j];
	if (abs(k - ar[l]) <= min_v) {
		min_v = k - ar[l];
		ans = ar[l];
	}
	if (abs(k - ar[r]) < min_v) ans = ar[r];
	printf("%d", ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
ll n, a[100010], b[100010], c[100010], sma[100010], lar[100010], ans;
const ll mod =1000000007;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	for (int i = 0; i < n; i++)
	{
		int lb = -1, ub = n;
		while (lb + 1 < ub)
		{
			int mid = (lb + ub) / 2;
			if (a[mid] < b[i])
			{
				lb = mid;
			}
			else
			{
				ub = mid;
			}
		}
		sma[i] = lb + 1;
		lb = -1, ub = n;
		while (lb + 1 < ub)
		{
			int mid = (lb + ub) / 2;
			if (c[mid] > b[i])
			{
				ub = mid;
			}
			else
			{
				lb = mid;
			}
		}
		lar[i] = n - ub;
	}
	for (int i = 0; i < n; i++)
	{
		ans += sma[i] * lar[i];
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 4096
import numpy as np

n, m = list(map(int, input().split()))

a = np.zeros(n, int)
b = np.zeros(n, int)

count = 0
v = 0

for i in range(n):
    ai, bi = list(map(int, input().split()))
    a[i] = ai
    b[i] = bi

for i in a.argsort():
    if count + b[i] <= m:
        v += a[i] * b[i]
        count += b[i]
    else:
        v += a[i] * (m - count)
        break
print(v)


Measured memory_bytes: 16568
#include<bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define For(i, j, k) for(register int i = (j); i <= (k); ++i)
#define Forr(i, j, k) for(register int i = (j); i >= (k); --i)
using namespace std;

template <typename T>
inline void read(T &x){
	T p = 1, c = getchar();
	x = 0;
	while(!isdigit(c)){
		if(c == '-') p = -1;
		c = getchar();
	}
	while(isdigit(c)){
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= p;
}

template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

inline void File(){
#ifndef ONLINE_JUDGE
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif
}

typedef long long ll;
int x, y, n;

int main(){
	read(n);
	while(n--){
		read(x), read(y);
		int val = (int) sqrt(1ll * x * y);
		int ans = 2 * (int) sqrt(1ll * x * y) - 1;
		if(1ll * val * val == 1ll * x * y && x != y) ans--;
		if(1ll * val * (val + 1) >= 1ll * x * y) ans--;
		printf("%d\n", ans);
	}
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int p = 700;
  
  for(int i = 0; i < 3; i++){
    if(S.at(i) == 'o') p += 100;
  }
  cout << p << endl;   
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var N, D int
	count := 0
	sc.Split(bufio.ScanWords)

	N, D = nextInt(), nextInt()

	D *= D
	var X, Y int

	for i := 0; i < N; i++ {
		X, Y = nextInt(), nextInt()

		if X*X+Y*Y <= D {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 4908
#include "bits/stdc++.h"
#include "vector"
#include "algorithm"

int main()
{
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;

  bool bottom = y - r >= 0;
  bool top = H >= y + r;
  bool left = x - r >= 0;
  bool right = W >= x + r;

  if (bottom && top && left && right)
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3084
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <climits>
using namespace std;
 
#define MOD 1000000009LL
 
typedef long long LL;
typedef pair<LL,LL> pLL;
typedef vector<LL> vLL;
typedef vector<vLL> vvLL;
 
vvLL make(int n){
	return vvLL(n, vLL(n));
}
 
void mul(vvLL &x, const vvLL &y){
	int n = x.size();
	vvLL z = make(n);
	for(int i = 0; i < n; ++i)
	for(int j = 0; j < n; ++j)
	for(int k = 0; k < n; ++k){
		z[i][j] = (z[i][j] + x[i][k] * y[k][j]) % MOD;
	}
	x.swap(z);
}
 
void pow(vvLL &x, LL y){
	int n = x.size();
	vvLL z = make(n);
	for(int i = 0; i < n; ++i){
		z[i][i] = 1;
	}
	while(y){
		if(y & 1){ mul(z, x); }
		mul(x, x);
		y >>= 1;
	}
	z.swap(x);
}
 
int main(){
	LL w, h, n;
	int T = 0;
	while(scanf("%lld%lld%lld", &w, &h, &n), w){
		vector<pLL> v(n + 1);
		vLL ys;
		LL x, y;
		for(int i = 0; i < n; ++i){
			scanf("%lld%lld", &x, &y);
			v[i] = pLL(y, x);
			if(y > 1 && y < h){
				ys.push_back(y);
			}
		}
		v[n] = pLL(LLONG_MAX, LLONG_MAX);
		sort(v.begin(), v.end());
		ys.push_back(1);
		ys.push_back(h);
		sort(ys.begin(), ys.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());
		vvLL a = make(w), s = make(w);
		for(int i = 0; i < w; ++i){
			a[i][i] = s[i][i] = 1;
			if(i != 0){ s[i][i - 1] = 1; }
			if(i != w - 1){ s[i][i + 1] = 1; }
		}
		int k = 0;
		while(v[k].first <= 1){ ++k; }
		for(int i = 1; i < ys.size(); ++i){
			vvLL b = s;
			pow(b, ys[i] - ys[i - 1]);
			mul(a, b);

			while(v[k].first == ys[i]){
				x = v[k].second - 1;
				if(x >= 0 && x < w){
					for(int j = 0; j < w; ++j){
						a[j][x] = 0;
					}
				}
				++k;
			}
		}
		 
		printf("Case %d: %lld\n", ++T, a[0][w - 1]);
	}
}

Measured memory_bytes: 1284
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

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

	vector<ll> v(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += max(0ll, v[i] - c[i]);
	}
	dump(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

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

	while (1) {
		memset(str, '\0', sizeof(str));
		scanf("%s", &str);

		if (str[0] == '0') {
			break;
		}

		int sum = 0;
		for (i = 0; str[i] != '\0'; i++) {
			if (str[i] >= '0' && str[i] <= '9') {
				sum += (str[i] - 0x30);
			}
		}
		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 536
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int t = sc.nextInt();
		int[] R = inpNum(t);

		int mp = maxProfit(R);
		System.out.println(mp);
		sc.close();
	}

	private static int maxProfit(int[] R) {
		int max_p = R[1] - R[0];
		int min_p = R[0];
			for(int j = 1; j < R.length; j++) {
					max_p = Math.max(max_p, R[j] - min_p);
					min_p = Math.min(min_p, R[j]);
			}
		return max_p;
	}

	private static int[] inpNum(int n) {
		int[] nums = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		return nums;
	}
}


Measured memory_bytes: 100872
#include<bits/stdc++.h>
using namespace std;
 
int main(){
   string s;
  cin>>s;
  int count=0;
  int n=s.size();
  for(int i=0;i<n;i++){
    if(s[i]=='7'){
      count++;
      cout<<"Yes"<<endl;
      break;
    }
  }
  if(count!=1){
  cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n;
	 int am=0;
	 int vis[105]={0};
	 cin>>n;
	 for(int i=1;i<=n;i++)
	 { if(i%2)vis[i]=1;
	 else continue;
	 	 for(int j=1;j<=n;j++)
	 	 {
	 	 	 if(!vis[j])
	 	 	  {
	 	 	  	 if(i%2==1&&j%2==0)
	 	 	  	   am++;
				}
		  }
	 }
	 printf("%d\n",am);
}

Measured memory_bytes: 256
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int a[100010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int t;
	
	cin>>t;int m;cin>>m;
	for(int i=0;i<t;i++)cin>>a[i];
	int sum=0;
	for(int i=0;i<t;i++)sum+=a[i];
	int k=sum%(4*m);
	sum/=(4*m);int cnt=0;
	
	for(int i=0;i<t;i++)
	{
		if(a[i]<sum);
		else if(a[i]==sum&&k>0);
		else cnt++;
	}
	
	cout<<(cnt<m ? "No" : "Yes");
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for (auto &&x : P) {
        cin >> x;
        x--;
    }
    for (auto &&x : C) {
        cin >> x;
    }

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        // 循環する要素を求める（Pi != i なので自分自身へループしない）
        vector<int64_t> v;
        for (int j = i;; j = P[j]) {
            v.push_back(C[j]);
            // 開始時点に戻ったら終了
            if (P[j] == i)
                break;
        }
        // 循環する要素の長さ
        int m = v.size();
        // 循環する要素の合計
        auto sum = accumulate(begin(v), end(v), 0LL);
        int64_t cur = 0;
        for (int r = 1; r <= m; ++r) {
            if (r > K)
                break;
            cur += v[r - 1];
            // 先頭からスコアを加算し、残りの長さに対して何回循環するか数える
            ans = max(ans, cur + (K - r) / m * max(sum, 0LL));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

int main()
{   int a,b,c,n,m,k,i,x,y,min=114514;
    char s[101],t[101];
    scanf("%s",s);
    for(i=0;i<strlen(s)-2;i++){
        if(abs(((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0'))-753)<min){
            min=abs((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')-753);
        }
    }
    printf("%d",min);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include <deque>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include<numeric>
using namespace std;
#define ll  long long
#define pb push_back
#define sz(v)               ((int)((v).size()))
#define all(x)          (x).begin(),(x).end()
#define REP(i, v)       for(int i=0;i<sz(v);i++)
using namespace std;
typedef pair<int,int> pii;
#define f first
#define s second
bool can(string &s,string &t) {
	for (int i = 0 ; i < sz(s) ; ++i) {
		if (i + sz(t) - 1 < sz(s)) {
			bool ok = 1;
			for (int j = 0 ; j < sz(t) ; ++j) {
				if (s[i + j] != t[j]) {
					if (s[i + j] != '?') ok = 0;
				}
			}
			if (ok) {
				return 1;
			}
		}
	}
	return 0;
}
int main() {
	string s,t; cin >> s >> t;
	if (sz(t) > sz(s)) {
		cout << "UNRESTORABLE\n";
		return 0;
	}
	REP(i,s) {
		if (s[i] == '?') {
			for (char j = 'a' ; j <= 'z' ; ++j) {
				s[i] = j;
				if (can(s,t)) break;
			}
		}
	}

	if (!can(s,t)) cout << "UNRESTORABLE\n";
	else cout << s << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        String str1 = in.next();
        String str2 = in.next();
        int a = Integer.parseInt(str1);
        int b = Integer.parseInt(str2);
        int S = a * b;
        int L = 2*(a + b);
        System.out.println(S+" "+L);
    }
    
}

Measured memory_bytes: 26148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		//Input
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int x_2000 = Integer.parseInt(sc.next());
		sc.close();

		//logic
		for(int i = 2001; i <= 2010; i++) {
			System.out.println(saiki(r, D, x_2000, i));
		}
	}

	public static int saiki(int r,int D, int x, int k) {
		if (k == 2000) {
			return x;
		}else {
			return r * saiki(r, D, x, k-1) - D;
		}
	}

}


Measured memory_bytes: 21716
N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
xs = [_ - xs[0] for _ in xs]
diffs = [xs[i]-xs[i-1] for i in range(1, len(xs))]
def gcd(a, b):
    if(a<b): return gcd(b, a)
    if a % b == 0:
      return b
    else:
      r = a % b
      return gcd(b, r)

prev = diffs[0]
for cur in diffs[1:]:
    prev = gcd(prev, cur)
print(prev)

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

int main () {
  int r, g, b;
  cin >> r >> g >> b;
  int num = r * 100 + g * 10 + b;
  if (num % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  a -= b;
  if(a < 0) a = 0;
  cout << a << endl;
              
                                                                                               
                                                                                               
  
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec));
  ll sum = 0;
  rep(i,n){
    REP(j,i+1,n){
      REP(l,j+1,n){
        t1 = vec[i];
        t2 = vec[j];
        t3 = vec[l];
        if(t1 != t2 && t2 != t3 && t1 + t2 > t3){
          //cout << t1 << t2 << t3 << endl;
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3612
import collections
n, k = map(int, input().split())
s = [int(i) for i in input()]
c = []
prv = 1
cnt = 0
for i in s:
    if prv != i:
        c.append(cnt)
        cnt = 1
        prv = i
    else:
        cnt += 1
if cnt > 0:
    c.append(cnt)
if prv == 0:
    c.append(0)
que = collections.deque([c[0]])
res =c[0]
ans = c[0]
m = len(c) // 2
for i in range(m):
    if len(que) == 2*k + 1:
        res -= que.popleft() + que.popleft()
    que.append(c[2*i +1])
    que.append(c[2*i +2])
    res += c[2*i+1] + c[2*i+2]
    ans = max(res, ans)
print(ans)
        

Measured memory_bytes: 5392
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

string a, b, n;
int x;

int main(){

    cin >> a >> b;
    
    n = a + b;

    x = stoi(n);

    if(sqrt(x) == int(sqrt(x))){
        cout << "Yes";
        return 0;
    }

    cout << "No";
    




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
from itertools import groupby
s=input()
n=len(s)
s=list(s)
gr=groupby(s)
a=[]
for k,g in gr:
    a.append(len(list(g)))

ans=0
nn=len(a)
if s[0]=='<':
    for i in range(nn):
        if i%2==0:
            if i==nn-1:
                if nn%2==1:
                    ans+=a[i]*(a[i]+1)//2
                else:
                    t_max=max(a[i],a[i+1])
                    t_min=min(a[i],a[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(a[i],a[i+1])
                t_min=min(a[i],a[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+1)//2                
else:
    for i in range(nn):
        if i==0:
            t_max=a[i]
            ans+=t_max*(t_max+1)//2
            continue
        if i%2==1:
            if i==nn-1:
                if nn%2==0:
                    ans+=a[i]*(a[i]+1)//2
                else:
                    t_max=max(a[i],a[i+1])
                    t_min=min(a[i],a[i+1])
                    t_min-=1
                    ans+=t_max*(t_max+1)//2
                    ans+=t_min*(t_min+1)//2
            else:
                t_max=max(a[i],a[i+1])
                t_min=min(a[i],a[i+1])
                t_min-=1
                ans+=t_max*(t_max+1)//2
                ans+=t_min*(t_min+1)//2 

print(ans)




Measured memory_bytes: 11824
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n,m,a=0,b=n,x,y;cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        a=max(a,x);
        b=min(b,y);
    }
    n=b-a+1;
    cout<<max(n,0);
}

Measured memory_bytes: 256
s = input()
n = len(s) - 1
tmp = ""
ans = 0

for i in range(2 ** n):
    sep = [0] * n
    nums = []
    for j in range(n):
        if (i >> j) & 1:
            sep[j] = 1
    for ind, su in enumerate(s):
        tmp += su
        if ind < len(sep):
            if sep[ind] == 1:
                tmp += ","
    ans += sum(list(map(int, tmp.split(","))))
    tmp = ""

print(ans)

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

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

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

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

int main(){
	ll n;
	static ll h[5002],p[5002];
	scanf("%lld",&n);
	rep(i,n)scanf("%lld%lld",&h[i],&p[i]);
	
	P1 w[5002];
	rep(i,n){
		w[i] = mp1( h[i]+p[i] , h[i] , p[i] );
	}
	sort(w,w+n);
	
	static ll dp[5002][5002];
	rep(i,5002)rep(j,5002)dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i,n){
		rep(j,i+1){
			if(dp[i][j] <= w[i].sc.fr){
				dp[i+1][j+1] = min ( dp[i+1][j+1] , dp[i][j] + w[i].sc.sc );
			}
			dp[i+1][j] = min ( dp[i+1][j] , dp[i][j] );
		}
	}
	rrep(i,5002){
		if(dp[n][i] != INF){
			cout << i << endl;
			return 0;
		}
	}
}
	



Measured memory_bytes: 195968