akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(input())
B=list(input())
C=list(input())
ans=0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i]:
        ans+=0
    elif A[i]==B[i] or B[i]==C[i] or A[i]==C[i]:
        ans+=1
    else:
        ans+=2
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

const ll mod=998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  mint ans=0;
  mint res=m-1;
  mint res2=1;
  res=res.pow(n-1);
  
  rep(num,k+1){
    ans+=(res*res2);
    res/=(m-1);
    res2=res2*(n-num-1)/(num+1);
  }
  ans*=m;
  if(m==1&&n-1==k) cout<<1<<endl;
  else cout<<ans.x<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int N, A[100001], temp, i;

	scanf("%d", &N);

	for (i = 1; i <= N; i++) {
		scanf("%d", &temp);
		A[temp] = i;
	}

	for (i = 1; i <= N; i++) {
		if (i == N) {
			printf("%d", A[i]);
		}

		else {
			printf("%d ", A[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 1152
while True:
    h, w = list(map(int, input().split()))
    if h == 0 and w == 0:
        break

    for row in range(h):
        if row == 0 or row == h - 1:
            print("#" * w)
        else:
            print("#{}#".format("." * (w - 2)))

    print()


Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n, cnt = 0, ans = 0;
    string s, t;
    cin >> n >> s >> t;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - i; j++) {
            if (s[j + i] == t[j]) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
        cnt = 0;
    }

    cout << 2 * n - ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

#define P 998244353

int dif2(int a, int b){return a<b?b-a:a-b;}

char s[301];
int a[602];
int b[602];
int d[602][602][804];
int main(void){
	int n=nextstr(s);
	int K=nextint();
	int m=0;
	for(int i=0; i<n; i++){
		if(s[i]=='0'){
			m++;
		}else{
			a[m]++;
		}
	}
	m++;
	b[m-1]=a[m-1];
	for(int i=m-2; i>=0; i--){
		b[i]=b[i+1]+a[i];
	}
	d[m][0][0]=1;
	for(int i=m-1; i>=0; i--){
		for(int j=0; j<=b[i]; j++){
			for(int k=0; k<=b[i]*2; k++){
				for(int l=0; l<=j; l++){
					int p=k-dif2(a[i],l);
					if(p>=0){
						d[i][j][k]+=d[i+1][j-l][p];
						d[i][j][k]%=P;
					}
				}
			}
		}
	}
	long ans=0;
	for(int k=K<b[0]?K*2:b[0]*2; k>=0; k--){
		ans+=d[0][n-m+1][k];
	}
	ans%=P;
	printf("%ld\n", ans);
}


Measured memory_bytes: 71988
// BEGINNNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    
    int n;
    cin >> n;
    
    int * arr = new int[n];
    
    for(int i=0;i<n;i++)
        cin >> arr[i];
    
    int count=0;
    for(int i=1;i<n-1;i++)
    {
        if((arr[i] > arr[i+1] && arr[i]<arr[i-1]) || (arr[i] <arr[i+1] && arr[i]>arr[i-1]))
            ++count;
    }
    cout<<count<<endl;
    delete[] arr;
    return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())

abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

#print(abcd_list)
list_tmp = []
for i in range(1, M + 1):
    list_tmp.append(i)

comb_A = list(itertools.combinations_with_replacement(list_tmp, N))


max_score = 0
for A in comb_A:
    tmp_score = 0
    for q in range(Q):
        A_a = A[abcd_list[q][0] - 1]
        A_b = A[abcd_list[q][1] - 1]

        if(A_b - A_a == abcd_list[q][2]):
            tmp_score += abcd_list[q][3]
        
    max_score = max(max_score, tmp_score)

print(max_score)

Measured memory_bytes: 21624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int counter=0;
    int result=0;
    cin >> N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A[i]; 
    }
    while(1){
        for(int i=0;i<N;i++){
            if(A[i]%2==0){
            A[i]=A[i]/2;
            counter++;
            }else{
                result=counter/N;
                cout << result << endl;
                return 0;
        }
    }}
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int pd(int a)
{
    int i=1,ans=0;
    for(i=1;i<=a;i++)
    {
        if(a%i==0)
            ans++;
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    int i,k=0;
    for(i=1;i<=n;i++)
    {
        if(pd(i)==8&&i%2==1)
            k++;
    }
    cout<<k<<endl;
        return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int h, w;
    int[][] board;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        h = sc.nextInt();
        w = sc.nextInt();
        board = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                board[i][j] = sc.nextInt();
            }
        }
        solve();
    }

    void solve() {
        int[][] dp = new int[h][w];
        for (int i = 0; i < h; i++) {
            dp[i][0] = board[i][0] == 0 ? 1 : 0;
        }
        for (int i = 1; i < w; i++) {
            dp[0][i] = board[0][i] == 0 ? 1 : 0;
        }
        int maxWidth = 0;
        for (int i = 0; i < h; i++) {
            if (dp[i][0] == 1) {
                maxWidth = 1;
                break;
            }
        }
        for (int i = 1; i < w; i++) {
            if (dp[0][i] == 1) {
                maxWidth = 1;
                break;
            }
        }
        for (int i = 1; i < h; i++) {
            for (int j = 1; j < w; j++) {
                if (board[i][j] == 1) {
                    continue;
                }
                int temp = dp[i - 1][j - 1] + 1;
                temp = Math.min(temp, dp[i - 1][j] + 1);
                temp = Math.min(temp, dp[i][j - 1] + 1);
                dp[i][j] = temp;
                maxWidth = Math.max(maxWidth, dp[i][j]);
            }
        }
        System.out.println(maxWidth * maxWidth);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Measured memory_bytes: 99164
#include <stdio.h>
 
int main() {
char a;
char ch[120];
char c[120];
char b[120];
int i,j,k,l,m,n,o;
m = 0;
n = 0;
i=0;
l=0;
 
while(1) {
scanf("%c",&a);
 
if(a == '\n') {
 break;
}
 
ch[i] = a;
i=i+1;
 
}
 
j=0;
while(1) {
scanf("%c",&a);
if(a == '\n') {
break;
}
c[j] = a;
j +=1;
}
/*??????????????§??\??????*/
 
for(k=0;k<i;k++) {
 
if(c[0] == ch[k] ) {       /*???????????????????????¨?????????????????? */
 l = k;
n = 0;                         /* ??????????????´???????????????*/
for(m=0;m<i-k;m++) {         /* c[k]????????????????§????????????? */
n = n +1;
l  +=1;
b[m] = ch[l-1];
}
l=0;
for(m=n;m<n+1+k;m++) {
l +=1;
b[m] = ch[l-1];            
}
o=0;
for(n=0;n<j;n++) {
/*printf("b[%d] = %c\n c[%d] = %c\n",n,b[n],n,c[n]); */
if(b[n] == c[n]){
o +=1;
}
}
}
 
/* printf("i = %d\nj = %d\n",i,j); */
 
 
if(o == j) {
printf("Yes\n");
break;
} else if(k==i-1) {
printf("No\n");
}
}
  
return 0;
 
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    vector<LL> a(n), x(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x[i] = a[i];
    }
    sort(a.begin(), a.end());
    LL m1 = a[(n - 1) / 2], m2 = a[n / 2];

    for (int i = 0; i < n; i++) {
        if (x[i] <= m1) {
            cout << m2 << endl;
        } else {
            cout << m1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//ABC 109 D
int main(void) {
	
	ll h, w;
	cin >> h >> w;
	vector<vector<ll>> a = vector<vector<ll>>(h+1, vector<ll>(w+1));
	rep(i, 1, h+1) {
		rep(j, 1, w + 1) cin >> a[i][j];
	}
	vector<string> ans = vector<string>();
	
	ll row = 1, col = 1;
	ll count = 0;
	bool goRight = true;
	while (count < h * w) {
		ll rowNext, colNext;
		count++;
		if (goRight) {
			if (col == w && row % 2 == 1) {
				colNext = col;
				rowNext = row + 1;
				goRight = false;
			}
			else {
				colNext = col + 1;
				rowNext = row;
			}
		}
		else {
			if (col == 1 && row % 2 == 0) {
				colNext = col;
				rowNext = row + 1;
				goRight = true;
			}
			else {
				colNext = col - 1;
				rowNext = row;
			}
		}
		if (a[row][col] % 2 == 1 && rowNext > 0 && colNext > 0 && rowNext < h + 1 && colNext < w + 1) {
			string s = to_string(row) + " " + to_string(col) + " " + to_string(rowNext) + " " + to_string(colNext);
			ans.push_back(s);
			a[rowNext][colNext]++;
		}
		row = rowNext;
		col = colNext;
	}
	cout << ans.size() << endl;
	rep(i, 0, ans.size()) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 12916
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
//?????????????????????double??§
struct Point{ double x, y; };
//Point????¨?????????????setter getter
Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };
//?????????point????????????????¨????????????????????????????
//????????????????????????????????????
Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}
//??????????????????v1*v2+v1*v2
double dot(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}
//????????????
double cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}
//norm??§?????????????????????
double onenorm(const Vector &v)
{
    return abs(v.vx) + abs(v.vy);
}
//counter clock 
int ccw(const Point &P0, const Point &P1, const Point &P2)
{  //?????????????????????????????????
    Vector V1 = set_v(P0, P1);
    Vector V2 = set_v(P0, P2);
    //???????±???????
    double c = cross(V1, V2);
    //????????????????????????,????¨?????????????????????????????¨???¨???
    if(c > 0){ return 1; }else if(c < 0){ return -1; }
    if(dot(V1, V2) < 0){ return -2; }
    //?????????V1?????????????°????????????????????????????????????????
    if(onenorm(V1) < onenorm(V2)){ return 2; }
    return 0;
}

int main()
{
    int q;
    scanf("%d", &q);
    //double??§?????£?????????
    double x0, y0, x1, y1, x2, y2, x3, y3;
    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        //??????????????§?¨??????????
        Point P0 = set_p(x0, y0), P1 = set_p(x1, y1), P2 = set_p(x2, y2), P3 = set_p(x3, y3);
        if(ccw(P0, P1, P2) * ccw(P0, P1, P3) <= 0 && ccw(P2, P3, P0) * ccw(P2, P3, P1) <= 0){
            printf("1\n");
        }else{
            printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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


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

int arr[201][201];

void warshall(int v)
{
    for(int k=1;k<=v;k++)
        for(int i=1;i<=v;i++)
            for(int j=1;j<=v;j++)
                    arr[i][j] = min(arr[i][j], arr[i][k]+arr[k][j]);
}

void init(int v)//設定INF 
{
    for(int i=1;i<=v;i++)
        for(int j=1;j<=v;j++)
            if(i!=j)
                arr[i][j] = 100000000;
}

int main()
{
    int v,e,r,x,y,d,ans=2147483647;
    cin>>v>>e>>r;//v城市數量 , e=edge邊 , r要問經過的城市順序 
    vector<int> R;
    for(int i=0;i<r;i++)
	{
        cin>>x;
        R.push_back(x);
    }
    int S = R.size();
    sort(R.begin(),R.end());
    init(v);//設定INF 除了自己到自己是0之外，其他都是INF 

    for(int i=0;i<e;i++)
	{
        cin>>x>>y>>d;
        arr[x][y] = min(arr[x][y], d);
        arr[y][x] = min(arr[y][x], d);
    }

    warshall(v);

    int temp = 0;
    do{
        temp = 0;

        for(int i=0;i<r-1;i++)
        {
            temp += arr[R[i]][R[i+1]];
        }
        
        ans=min(ans,temp);
    }while(next_permutation(R.begin(),R.end()));

    cout<<ans<<endl;
}
/*  3 2 3
	1 3 2
	1 2 3
	2 3 5 
	*/

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	int A,B;
	scanf("%d %d",&A,&B);
	printf("%d %d\n",min(A,B),max(0,A+B-n));
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n[] = new int[5];
        int min = 0 , swap = 0 , index = 0 , sum = 0;

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

        for ( int i = 0 ; i < 5 ; i++ ) {
            min = 9;
            for ( int j = i ; j < 5 ; j++ ) {
                if (( n[j] % 10 ) == 0) {
                    min = ( 10 - ( n[j] % 10 ) );
                    index = j;                    
                } else if ( ( 10 - ( n[j] % 10 ) ) <= min )  {
                    min = ( 10 - ( n[j] % 10 ) );
                    index = j;
                }
            }
            swap = n[i];
            n[i] = n[index];
            n[index] = swap;
        }

        for ( int i = 0 ; i < 5 ; i++ ) {
            if (i < 4){ 
                if ( (n[i] % 10) != 0) {
                    sum += n[i];
                    sum += ( 10 - ( n[i] % 10 ) );
                } else {
                    sum += n[i];
                }
            } else if (i == 4) {
                sum += n[i];
            }
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << a / b << " " << a % b << " ";
  cout << fixed << setprecision(7) << (double)a / b << endl;
}



Measured memory_bytes: 3272
input_line = input().split(' ')
taka = int(input_line[0])
aoki = int(input_line[1])
numK = int(input_line[2])
result = ""
if taka + aoki <= numK:
  result = "0 0"
elif taka >= numK:
  result = str(taka - numK) + " " + str(aoki)
elif taka + aoki > numK:
  result = "0 " + str(taka + aoki - numK)
  
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,x,y;
    cin >> a >> b >> c >> d;
    x = c;
    y = d;
    while(x % y != 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }
    long long int lcm = c * d / y;
    cout << (b - a + 1) - ((b / c + b / d - b / lcm) - ((a - 1) / c + (a - 1) / d - (a - 1) / lcm));

    return 0;
}

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

void fnInput(int& rnTarget, vector<int>& rvnForbid)
{
  int nForbidSiz;
  cin >> rnTarget >> nForbidSiz;
  rvnForbid.resize(nForbidSiz);

  for (int& rnForbid : rvnForbid)
    cin >> rnForbid;
}

int fnMinAbsNum(int nTarget, const vector<int>& cnrvnForbid)
{
  map<int, int> mpForbid;

  for (int nForbid : cnrvnForbid)
    mpForbid[ nForbid ]++;

  int nPls = nTarget;
  while (mpForbid[nPls] != 0)
    nPls++;

  int nMns = nTarget;
  while (mpForbid[nMns] != 0)
    nMns--;

  if (abs(nTarget - nPls) < abs(nTarget - nMns))
    return nPls;
  else
    return nMns;
}
  
int main()
{
  int nTarget;
  vector<int> vnForbid ;

  fnInput(nTarget, vnForbid);
  cout << fnMinAbsNum(nTarget, vnForbid) << endl;

  return 0;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline

def solve():
    MOD = 998244353
    inv2 = pow(2, MOD-2, MOD)

    N, S = map(int, input().split())
    As = list(map(int, input().split()))

    dp = [0] * (S+1)
    dp[0] = pow(2, N, MOD)
    for A in As:
        for k in reversed(range(S-A+1)):
            dp[k+A] += dp[k] * inv2
            dp[k+A] %= MOD

    print(dp[-1])


solve()


Measured memory_bytes: 9284
def main():
    b = input()
    for i in range(len(b)):
        if b[i] == "A":
            print("T",end="")
        elif b[i] == "T":
            print("A",end="")
        elif b[i] == "C":
            print("G",end="")
        elif b[i] == "G":
            print("C",end="")
    print()
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;

	string a, b, c;
	char input[101];
	int i;
	int cnt = 0;
	int val;

	scanf("%d", &n);

	scanf("%s", input);
	a = input;
	scanf("%s", input);
	b = input;
	scanf("%s", input);
	c = input;

	for (i = 0; i < n; i++)
	{
		val = ((a[i] != b[i]) + (b[i] != c[i]) + (c[i] != a[i]));

		val -= !!val;

		cnt += val;
	}

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

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as d
from collections import deque

def bfs(adj, start, n):
	visited = [0] * (n + 1)
	tab = [0] * n
	q = deque([start])
	visited[start] = 1
	while q:
		s = q.popleft()
		for i in adj[s]:
			if visited[i] == 0:
				q.append(i)
				visited[i] = 1
				tab[i - 1] = tab[s - 1] + 1
	return tab

n, u, v = map(int, input().split())
adj = d(list)
for i in range(n - 1):
	a, b = map(int, input().split())
	adj[a].append(b)
	adj[b].append(a)

takahashi = bfs(adj, u, n)
aoki = bfs(adj, v, n)
res = -1
for i in range(n):
	if takahashi[i] <= aoki[i]:
		res = max(res, aoki[i] - 1)

print(res)

Measured memory_bytes: 35516
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: u64 = read();
    let b: u64 = read();

    let mut gcd = gcd(a, b);
    let mut ans = 1;

    for i in 2..gcd.isqrt() + 2 {
        if gcd % i == 0 {
            ans += 1;
            while gcd % i == 0 {
                gcd /= i;
            }
        }
    }
    if gcd != 1 {
        ans += 1;
    }

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

fn gcd(n: u64, m: u64) -> u64 {
    if n % m == 0 {
        m
    } else {
        gcd(m, n % m)
    }
}

trait IntegerSqrt {
    fn isqrt(&self) -> Self;
}

impl IntegerSqrt for u64 {
    fn isqrt(&self) -> Self {
        if *self < 2 {
            *self
        } else {
            let s = (*self >> 2).isqrt() << 1;
            let l = s + 1;
            if l * l > *self {
                s
            } else {
                l
            }
        }
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string N;
    cin >> N;

    int M = N.size();
    ll dp[M+1][2];
    dp[0][0] = 0;
    dp[0][1] = 1;

    REP(i, M) {
        int s = N[i] - '0';

        // exact
        dp[i+1][0] = min(dp[i][0] + s, dp[i][1] + s + 1);

        // bigger
        dp[i+1][1] = min(dp[i][0] - s, dp[i][1] - s - 1) + 10;
    }

    cout << min(dp[M][0], dp[M][1] + 1) << endl;
    
}


Measured memory_bytes: 17052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
	string S;
	cin >> S;
	int N = S.size();
	sort(S.begin(), S.end());
	vector<pair<char, bool>> jdg(26);
	char invec = 'a';
	rep(i, 26){
		jdg[i].first = invec;
		jdg[i].second = true;
		invec++;
	}
	bool ch = true;
	rep(i, N){
		rep(j, 26){
			if(S[i] == jdg[j].first){
				jdg[j].second = false;
			}
		}
	}
	rep(i, 26){
		if(jdg[i].second){
			cout << jdg[i].first << endl;
			ch = false;
			break;
		}
	}
	if(ch) cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
	int h,w;cin>>h>>w;
	char g[h][w];
	vector<pair<int,int>> vec;
	rep(i,h){
		rep(j,w){
			cin>>g[i][j];
			if(g[i][j]=='.') vec.push_back(make_pair(i,j));
		}
	}

	int ans=-1;
	int n=vec.size();
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int sy=vec[i].first,sx=vec[i].second;
			int ty=vec[j].first,tx=vec[j].second;
			int dist[h][w];
			rep(i,h) rep(j,w) dist[i][j]=inf;
			dist[sy][sx]=0;
			queue<pair<int,int>> q;
			q.push(make_pair(sy,sx));

			while(q.size()){
				pair<int,int> now=q.front();q.pop();
				rep(k,4){
					int ny=now.first+dy[k],nx=now.second+dx[k];
					if(ny>=0&&ny<h&&nx>=0&&nx<w&&dist[ny][nx]==inf&&g[ny][nx]=='.'){
						dist[ny][nx]=dist[now.first][now.second]+1;
						q.push(make_pair(ny,nx));
					}
				}
			}

			if(dist[ty][tx]==inf) break;
			ans=max(ans,dist[ty][tx]);
		}
	}

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

Measured memory_bytes: 384
import sys
N=int(input())
S=str(input())
M=str(input())
Mo=10**9+7
ans=1
i=0
if S[i]==M[i]:
  Ag=1
  ans=ans*3
  i+=1
else:
  Ag=2
  ans=ans*6
  i+=2
while i<N:
  if S[i]==M[i]:
    if Ag==1:#連続で楯だった
      ans=ans*2%Mo
      Ag=1
      i+=1
    elif Ag==2:#横の次のたてだった
      Ag=1
      i+=1
  else:#よこがでた
    if Ag==1:#たてのつぎのよこだった
      ans=ans*2%Mo
      Ag=2
      i+=2
    elif Ag==2:#連続でよこだった
      ans=ans*3%Mo
      Ag==2
      i+=2
print(ans%Mo)      

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


int main(){
  int num;
  cin >> num;
  int A,B,C,D;
  D = num % 10;
  num /= 10;
  C = num % 10;
  num /= 10;
  B = num % 10;
  A = num / 10;

  bool loop = true;
  while(loop){
    if(A+B+C+D == 7){
      cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
      break;
    }else if(A+B+C-D == 7){
      cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
      break;
    }else if(A+B-C+D == 7){
      cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
       break;
    }else if(A+B-C-D == 7){
      cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
      break;
    }else if(A-B+C+D == 7){
      cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
      break;
    }else if(A-B+C-D == 7){
      cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
      break;
    }else if(A-B-C+D == 7){
      cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
      break;
    }else if(A-B-C-D == 7){
      cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
      break;
    }else{
      loop = false;
    }
  }
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;

    int N = (1<<n);
    int M = (1<<m);

    vi row(M);
    vvi grid(N, row);

    for (int y=0;y<N;y++) {
        for (int x=0;x<M;x++) {
            int cur = 0;
            for (int i=0;i<10;i++) {
                int b = (1<<i);
                if (((x&b) > 0) && ((y&b) > 0)) cur++;
            }
            grid[y][x] = cur & 1;
        }
    }

    for (int y=1;y<N;y++) {
        for (int x=1;x<M;x++) {
            cout << (grid[y][x] ^ grid[y-1][x] ^ grid[y][x-1] ^ grid[y-1][x-1]);
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 5376
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int a[n];
    REP(i, n)
    {
        cin >> a[i];
    }
    int ans = n + x;
    for (int i = 0; i < n; i++)
    {
        int day = 1;
        while (day + a[i] <= d)
        {
            day += a[i];
            ans++;
        }
    }
    cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


int main()
{
    int n , a , b ;

    scanf("%d %d %d",&n,&a,&b) ;

    if( (b-a-1)%2==1 ) printf("Alice\n") ;
    else printf("Borys\n") ;

    return 0 ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 15;
const double inf = 1e100;

double mst[1<<MAX];
llint sum[1<<MAX];
int cnt[1<<MAX];
double f[1<<MAX];

double d[MAX][MAX];
int x[MAX], y[MAX], a[MAX];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) scanf("%d %d %d", &x[i], &y[i], &a[i]);

  REP(i, n) REP(j, n)
    d[i][j] = sqrt((x[i]-x[j])*1LL*(x[i]-x[j]) + (y[i]-y[j])*1LL*(y[i]-y[j]));

  REP(s, 1<<n) mst[s] = inf;
  REP(i, n) mst[1<<i] = 0;
  
  REP(s, 1<<n) {
    REP(i, n) {
      if (s & (1<<i)) {
        REP(j, n)
          mst[s | (1<<j)] = min(mst[s | (1<<j)], mst[s] + d[i][j]);
      }
    }
    REP(i, n)
      if (!(s & (1<<i))) {
        sum[s | (1<<i)] = sum[s] + a[i];
        cnt[s | (1<<i)] = cnt[s] + 1;
      }
  }


  f[0] = inf;
  FOR(s, 1, 1<<n) {
    for (int m = s; m > 0; m = (m - 1) & s) {
      f[s] = max(f[s], min(f[s ^ m], (sum[m] - mst[m]) / cnt[m]));
    }
  }
  printf("%.12lf\n", f[(1<<n)-1]);
  return 0;
}


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


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

using namespace std;
#define m 2019
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
   string s;
    cin>>s;
    
	int suf=0;
	long long as=0;
	int pot=1;
	vector<int> cnt_suf(m);
	cnt_suf[suf]++;
	for(int i=s.size()-1;i>=0;i--)
	{
		int dig=s[i]-'0';
		suf=(suf+dig*pot)%m;
		pot=(10*pot)%m;
		
		as+=cnt_suf[suf];
		cnt_suf[suf]++;
		
		
	}	
		
    

    cout<<as<<endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef int64_t in;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;




int main(){
    ll n; cin >> n;
    vl d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));

    ll ans = d[n/2] - d[n/2-1];
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define MEM(a,x) memset(a,x,sizeof(a))

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define IN freopen("262144.in","r",stdin)
#define OUT freopen("262144.out","w",stdout)


#define maxn 300005
#define INF 1000000000
#define mod 998244353LL
#define log 60

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct data{
    int x, y ,id ;
    bool operator<(data other) const{ return x < other.x ; }
}a[maxn];

int par[maxn] ;
int sz[maxn] ;
int findPar(int u)
{
    if(par[u]==u) return u;
    return par[u] = findPar(par[u]) ;
}

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

    for(int i=1 ; i<=n ; i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y) ;
        a[i].id = i ;
    }
    sort(a+1,a+n+1) ;

    for(int i=1 ; i<=n ; i++) par[i] = i ;
    vector< pair<pair<int,int>,int> > st ;

 //   DBG ;

    for(int i=1 ;i<=n ; i++)
    {
        st.pb( mp( mp(a[i].y,a[i].y) , a[i].id ) ) ;

        while( st.size() >= 2 && st[ (int)st.size() - 2 ].xx.xx < st.back().xx.yy )
        {
            int pu = findPar( st[ (int)st.size()-2 ].yy ) , pv = findPar( st.back().yy ) ;
            if( pu!=pv ) par[pu] = pv ;
            pair<pair<int,int>,int> p = st.back() ;
            st.pop_back() ;
            st.back().xx.xx = min( st.back().xx.xx , p.xx.xx ) ;
            st.back().xx.yy = max( st.back().xx.yy , p.xx.yy ) ;
        }
//        st.push( mp( a[i].id ,a[i].y) ) ;
    }

    for(int i=1 ; i<=n ; i++) sz[ findPar(i) ]++ ;

    for(int i=1 ; i<=n ; i++)
    {
        printf("%d\n",sz[ findPar(i) ] ) ;
    }

    return 0 ;
}


Measured memory_bytes: 11428
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 , 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" ) } ; }

fn main() {
    input! {
        n: u64, k: u64
    }
    let mut ret = k;
    for _ in 0..n-1 {
        ret *= k-1;
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int K, X;
  cin >> K >> X;

  for (int i = X - (K - 1); i <= X + (K - 1); i++){
    cout << i << " ";
  }
}


Measured memory_bytes: 3592
#include<stdio.h>
using namespace std;
int main()
{

char a[50],b[50];
int i,O=0,E=0;

scanf("%s%s",a,b);
for(i=0;a[i]!='\0';i++)
{
    if(a[i]!='\0' && O==0)
    {
        printf("%c",a[i]);
    }
    else
    {
        O=1;
    }

    if(b[i]!='\0' && E==0)
    {
        printf("%c",b[i]);
    }
    else
    {
        E=1;
    }


    if(O==1 && E==1)
    {
        break;
    }
}
printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
	double x, h, s1,s2;

	while (1)
	{
		scanf("%lf\n%lf", &x, &h);
		if (x == 0 && h == 0)
		{
			break;
		}
		s1 = x*x;
		s2 = sqrt((h*h) + (x*x / 4)) * 2 * x;
		printf("%.6f\n", (s1+s2));
	}

	return 0;
}


Measured memory_bytes: 648
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>a>>b>>c;
    if(a+b>=c) Yes;
    else No;
    return 0;
}


Measured memory_bytes: 3604
X = int(input())

a = []
for x in range(-150,150):
    a.append(x**5)
    
    
import itertools

seq = (x for x in range(300))
ptr = list(itertools.combinations(seq,2))

for i in range(len(ptr)):
    tmp = a[ptr[i][0]]-a[ptr[i][1]]
    if abs(tmp) == X:
        if tmp == X:
            A = ptr[i][0] - 150
            B = ptr[i][1] - 150
        else:
            A = ptr[i][1] - 150
            B = ptr[i][0] - 150
            
            
print(A,B)

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<ll> A(n); rep(i,n) std::cin >> A[i];

  ll ans = 0;
  rep(i,n) {
    if ( i == 0 ) continue;
    if ( A[i-1] <= A[i] ) continue;
    ans += A[i-1] - A[i];
    A[i] = A[i-1];
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 4780
import math
import statistics
a=int(input())
#b=int(input())
# c=[]
# for i in b:
#     c.append(i)
# e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
ans=0
count=0
for i in range(a):
    if ans+1 == f[i]:
        ans=f[i]
        count+=1
if count>0:   
    print(len(f)-count)
else:
    print(-1)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum+=A.at(i+1)-A.at(i);
  }
  cout << sum << endl;
  
}


Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())
    edges = [[] for _ in [0]*N]
    r_edges = [[] for _ in [0]*N]

    for _ in [0]*M:
        a, b = map(int, input().split())
        edges[a].append(b)
        r_edges[b].append(a)

    c = get_strongly_connected_components(edges, r_edges)
    group = [0]*N
    for i in range(len(c)):
        for v in c[i]:
            group[v] = i

    result = []
    append = result.append
    for _ in [0]*int(input()):
        a, b = map(int, input().split())
        append("1" if group[a] == group[b] else "0")

    print("\n".join(result))


def get_strongly_connected_components(edges, r_edges):
    import sys
    sys.setrecursionlimit(10**7)
    v_count = len(edges)
    order = [0]*v_count
    k = [1]

    def get_order(v):
        order[v] = 1
        for dest in edges[v]:
            if order[dest] == 0:
                get_order(dest)
        order[v] = k[0]
        k[0] += 1

    def get_components(v):
        order[v] = 0
        return [v] + [_v for dest in r_edges[v] if order[dest] > 0 for _v in get_components(dest)]

    [None for v in range(v_count) if order[v] == 0 and get_order(v)]
    return [get_components(v) for v, _ in sorted(enumerate(order), key=lambda x: x[1], reverse=True) if order[v] > 0]

if __name__ == "__main__":
    solve()

Measured memory_bytes: 24260
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=2e5+5;
int n,a[maxn],q[maxn],tl;
ll ans,f[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	n=rd(); 
	go(i,n+1,1) a[i]=rd();
	go(i,n+1,1){
		while(tl > 0 && a[q[tl]] > a[i]) tl--;
		f[i]=f[q[tl]]+(ll)(i-q[tl])*a[i];
		q[++tl]=i; ans+=f[i];
	}
	printf("%lld",ans);
	return 0;
}//Faze


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

const int MAX_N = 2e5;

int N, M;
vector<int> graph[MAX_N];
int used[MAX_N], dist[MAX_N];

void bfs(int s){
    for(int i = 0; i < N; i++) dist[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        used[v] = 1;
        for(auto nv: graph[v]){
            if(used[nv] == 0){
                dist[nv] = dist[v] + 1;
                Q.push(nv);
            }
        }
    }
    if(dist[N-1] <= 2) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}

int main(){
    cin >> N >> M;
    for(int i= 0; i < M; i++){
        int a, b; cin >> a >> b; a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    bfs(0);
    return 0;
}

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

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

    bool a=true;

    for (int i=0; i<N; i++) {
        if (vec.at(i)%2==0) {
            if (vec.at(i)%3!=0 && vec.at(i)%5!=0) {
                a=false;
            }
        }
    }
    if (a) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 3608
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

ll ans(ll a){
	ll ret=0;
	for(int i=57;i>=0;i--){
		ll pos=(1ll<<i);
		if(i==0){
			if(a%4<=2&&a%4>=1) ret++; 
		}
		else if(a/pos&&((a&1)==0)){
			ret^=pos;
		}
		if(i>1)a%=pos;
		//cout<<a<<endl;
	}
	return ret;
}

int main(){
	ll a,b;
	cin>>a>>b;
	//cout<<ans(b)<<endl;
	//cout<<ans(a-1)<<endl;
	cout<<(ans(b)^ans(a-1))<<endl;
      return 0;
}

Measured memory_bytes: 256
while True:
    try:
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
    except EOFError:
        break
    hit = sum(1 for i in range(4) if A[i] == B[i])
    blow = sum(1 for i in range(4) if A[i] in B) - hit
    print(hit, blow)

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVll = vector<Vll>;

char s[1000000];

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

  VVll t(3, Vll(n+1));
  VV pos(3, V());
  char dmc[3] = {'D', 'M', 'C'};

  rep(i, n) rep(j, 3) {
    t[j][i+1] = t[j][i];
    if (s[i] == dmc[j]) {
      ++t[j][i+1];
      pos[j].push_back(i);
    }
  }

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = 0;
    for (auto &c : pos[2]) ans += t[1][c] * (t[0][c] - t[0][max(c-k+1, 0)]);
    for (auto &a : pos[0]) ans -= t[1][a+1] * (t[2][min(a+k, n)] - t[2][a+1]);
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 32888
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    s = input()
    ss = s + s 
    t = input()
    flag = False
    

    for i in range(len(s)):

        count = 0
        for j in range(len(s)):
            if t[j] == ss[i + j]:
                count += 1
        if count == len(s):
            flag = True

    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9440
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int n,k;
char st[105];

int main() {
	scanf("%s",st+1);n=strlen(st+1);
	scanf("%d",&k);
	bool same=1;
	fo(i,1,n) same&=st[i]==st[1];
	if (same) {
		printf("%lld\n",(ll)n*k/2);
		return 0;
	}
	if (st[1]==st[n]) {
		int l=1,r=n;
		while (l<n&&st[l+1]==st[1]) l++;
		while (r>1&&st[r-1]==st[n]) r--;
		ll ans=l/2+(n-r+1)/2;
		ans+=(ll)(l+n-r+1>>1)*(k-1);
		int len=0;
		fo(i,l+1,r-1) 
			if (i==l+1||st[i]==st[i-1]) len++;
			else {
				ans+=(ll)len/2*k;
				len=1;
			}
		ans+=(ll)len/2*k;
		printf("%lld\n",ans);
		return 0;
	}
	ll ans=0;int len=0;
	fo(i,1,n) 
		if (i==1||st[i]==st[i-1]) len++;
		else {
			ans+=(ll)len/2*k;
			len=1;
		}
	ans+=(ll)len/2*k;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int date[5],i,total=0;
	for (i = 0; i < 5; i++) {
		scanf("%d",&date[i]);
		if (date[i] < 40)date[i] = 40;
		total += date[i];
	}
	printf("%d\n", total / 5);
	return 0;
}

Measured memory_bytes: 600