akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int64 n,m;
  cin>>n>>m;
  vector<int64> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  std::sort(a.begin(), a.end(), std::greater<>());
  vector<int64> cum(n);
  cum[0]=a[0];
  for(int i=1;i<n;i++){
    cum[i]=cum[i-1]+a[i];
  }

  int64 result=0;
  int64 v_min=0,v_max=200001,v_mid=100000;
  while(v_max-v_min>1){
    int64 count=0;
    int64 tmp_result=0;
    for(int left=0;left<n;left++){
      int64 right_min=-1,right_max=n,right_mid=(right_max+right_min)/2;
      while(right_max-right_min>1){
        if(v_mid <= a[left] + a[right_mid]){
          right_min=right_mid;
        }else{
          right_max=right_mid;
        }
        right_mid=(right_max+right_min)/2;
      }
      tmp_result+=a[left]*(right_min+1);
      if(right_min>=0) tmp_result+=cum[right_min];
      count+=right_min+1;
    }

    if(count>=m){
      v_min=v_mid;
    }else{
      v_max=v_mid;
    }
    v_mid=(v_max+v_min)/2;
  }

  int64 count=0;
  for(int left=0;left<n;left++){

    int64 right_min=-1,right_max=n,right_mid=(right_max+right_min)/2;
    while(right_max-right_min>1){
      if(v_mid <= a[left] + a[right_mid]){
        right_min=right_mid;
      }else{
        right_max=right_mid;
      }
      right_mid=(right_max+right_min)/2;
    }
    result+=a[left]*(right_min+1);
    if(right_min>=0) result+=cum[right_min];
    count+=right_min+1;
  }

  result-=(count-m)*v_mid;



  cout<<result<<endl;

  



  return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] cnt = new int[100];
            int n = in.nextInt();
            for (int i = 1; i <= n; i++) {
                int k = i;
                for (int j = 2; j * j <= k; j++) {
                    while (k % j == 0) {
                        cnt[j]++;
                        k /= j;
                    }
                }
                if (k > 1) {
                    cnt[k]++;
                }
            }
            int ans = 0;
            int tmp = 0;
            for (int i = 1; i < 100; i++) {
                for (int j = 1; j < 100; j++) {
                    for (int k = 1; k < 100; k++) {
                        if (i == j || j == k || k == i) continue;
                        if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) {
                            tmp++;
                        }
                    }
                }
            }
            ans += tmp / 2;
            for (int i = 1; i < 100; i++) {
                for (int j = 1; j < 100; j++) {
                    if (i == j) continue;
                    if (cnt[i] >= 14 && cnt[j] >= 4) ans++;
                    if (cnt[i] >= 24 && cnt[j] >= 2) ans++;
                }
            }
            for (int i = 1; i < 100; i++) {
                if (cnt[i] >= 74) ans++;
            }
            out.println(ans);
        }
    }

    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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


Measured memory_bytes: 22512
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long calc(long long N, string X, long long cnt, long long tab[222222]){
    if(cnt<0) return 0;
    long long ret = 0;
    for(long long i=N-1; i>=0; i--){
        long long j = N-1-i;
        if(X[i]=='1') ret += tab[j];
    }
    return ret;
}

long long tab1[222222];
long long tab2[222222];

long long func(long long x){
    if(x==0) return 0;
    long long cnt = __builtin_popcountll(x);
    x = x % cnt;
    return 1 + func(x);
}

int main(){
    long long N;
    string X;
    cin >> N >> X;
    long long cnt = 0;
    for(long long i=0; i<N; i++)
        if(X[i]=='1') cnt++;
    if(cnt-1>0){
        tab1[0] = 1%(cnt-1);
        for(long long i=1; i<=200000; i++)
            tab1[i] = (tab1[i-1]*2)%(cnt-1);
    }
    tab2[0] = 1%(cnt+1);
    for(long long i=1; i<=200000; i++)
        tab2[i] = (tab2[i-1]*2)%(cnt+1);

    long long a=0, b=0;
    if(cnt-1>0) a = calc(N, X, cnt-1, tab1);
    b = calc(N, X, cnt+1, tab2);
    vector<long long> ans;
    for(long long i=N-1; i>=0; i--){
        long long j = N-1-i;
        long long tmp;
        if(X[i]=='0'){
            tmp = b;
            tmp += tab2[j];
            tmp %= (cnt+1);
        }else{
            if(cnt==1){
                ans.push_back(-1);
                continue;
            }
            tmp = a;
            tmp += (cnt-1-tab1[j]);
            tmp %= (cnt-1);
        }
        ans.push_back(tmp);
    }
    reverse(ans.begin(), ans.end());

    for(long long i=0; i<N; i++){
        if(ans[i]==-1) cout << 0 << endl;
        else cout << func(ans[i])+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 8744
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<std::pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    a.at(i).first = i;
    std::cin >> a.at(i).second;
  }
  std::sort(a.begin(), a.end(),
            [](const auto &a, const auto &b) { return a.second > b.second; });

  std::vector<int> ans(n);
  for (auto &v : a) {
    if (a.at(0).first == v.first)
      ans.at(v.first) = a.at(1).second;
    else
      ans.at(v.first) = a.at(0).second;
  }

  for (auto &v : ans) {
    std::cout << v << std::endl;
  }
}


Measured memory_bytes: 3968
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};
function segTree(n){
	var u = n-1, x = 2;
	while(u)u >>= 1, x <<= 1;
	this.seg = Array(x-1).fill(2e9);
	this.l = x >> 1;
	//console.log('init:',n,x,this.seg,this.l);
  }
  segTree.prototype={
	get:function(x){
	  x += this.l-1;
	  var r = 2e9;
	  while(x >= 0){
		if(this.seg[x] < r)r = this.seg[x];
		x = (x-1)>>1;
	  }
	  if(r === 2e9)r = -1;
	  return r;
	},
	update:function(l,r,t){
		//console.log('update-----',l,r,t);
	  var v = this.seg;
	  q(l,r,0,this.l,0);
	  function q(l,r,x,y,i){
		//console.log('q--l:',l,'r:',r,'x:',x,'y:',y,'i:',i);
		if(l === x && r === y){v[i] = t;return;}
		var m = x+y >> 1;
		if(m < r)
		  if(l < m){
			q(l,m,x,m,i+i+1);q(m,r,m,y,i+1<<1);
		  }
		  else
			q(l,r,m,y,i+1<<1);
		else
		  q(l,r,x,m,i+i+1);
	  }
	  //this.printing();
	},
	printing:function(){
	  console.log(this.seg[0]);
	  let s=[]; 
	  for(let i=1;i<=2;i++){
		s.push(this.seg[i]);
	  }
	  console.log(s.join(' '));
	  s=[];
	  for(let i=3;i<=6;i++){
		s.push(this.seg[i]);
	  }
	  console.log(s.join(' '));
	  s=[];
	  for(let i=7;i<=14;i++){
		s.push(this.seg[i]);
	  }
	  console.log(s.join(' '));
	},
  }
//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim().split('\n');
	let temp2 = mapint(temp[0]);
	let n = temp2.shift();
	let q = temp2.shift();

	let s = new Array(n);
	for(let i=1;i<=n;i++){
		s[i-1] = mapint(temp[i]);
	}

	let d = new Array(q);
	for(let i=1;i<=q;i++){
		d[i-1] = parseInt(temp[n+i]);
	}

	var st = new segTree(q);
	s.sort((a,b)=>b[2]-a[2]);
	for(var i = 0; i < n; i++){
	  if(s[i][1]-s[i][2]-1<d[0])continue;
	  var l = lower_bound(d,0,q,s[i][0]-s[i][2]);
	  var r = lower_bound(d,l,q,s[i][1]-s[i][2]);
	  if(l<r)st.update(l,r,s[i][2]);
	}
	var ans = Array(q);
	for(var i = 0; i < q; i++){
	  ans[i] = st.get(i);
	}
	console.log(ans.join("\n"));
	//st.printing();
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'
const ll mod=1000000007;
ll Pow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}return res;
}

const int mx=8010;
ll f[mx];
ll inv(ll n){
	return Pow(n,mod-2);
}
ll ncr(int n,int r){
	return (((f[n]*inv(f[r]))%mod)*inv(f[n-r]))%mod;
}
int main()
{
	f[0]=1;
	for(int i=1;i<mx;i++)f[i]=(f[i-1]*i)%mod;


	ll s;
	cin>>s;
	ll an=0;
	for(int n=1;;n++){
		if(s-n*3<0)break;
		ll ss=s-n*3;
		an+=ncr(ss+n-1,ss);
		an%=mod;
	}
	cout<<an<<endl;
	return 0;
}

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

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


int main(){
	ll A;
	ll B;
	cin >> A >> B;
	
	ll val = gcd(A,B);
	ll temp = val;
	
	ll ans = 0;
	
	for (ll i = 2; i*i <= val; ++i) {
		if(val % i == 0) {
			while (val % i == 0) {
				val /= i;
			}
			ans++;
		}
	}
	if(val != 1){
		ans++;
	}
	
	cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main()
{
		ll mod =  998244353;
		int n,k;
		//set<int>vals;
		cin>>n>>k;
		pair<int,int>range[k];
		for(int i=0;i<k;i++)
		{
			int l,r;
			cin>>l>>r;
			range[i]={l,r};
			/*for(int i=l;i<=r;i++)
				vals.insert(i);*/
		}
		sort(range,range+k);
		ll ways[n+1];
		memset(ways,0,sizeof(ways));
		ways[1]=1;
		ways[2]=-1;
		for(int i=1;i<=n;i++)
		{
			if(i>1)
				ways[i]=(ways[i-1]+ways[i])%mod;
			for(int j=0;j<k;j++){
				if(range[j].first+i>n)
					continue;
				ways[i+range[j].first]=(ways[i]+ways[i+range[j].first])%mod;
				
				if(range[j].second+i+1>n)
					continue;
				ways[i+range[j].second+1]=(ways[i+range[j].second+1]-ways[i])%mod;
			}
	//	ways[i] += ways[i-1];
		}
		/*for(int i=2;i<=n;i++)
		{
			for(int j=0;j<k;j++)
				ways[i] = ways[i]+ways[i-1];
		}*/
		if(ways[n]<0)
			ways[n]=mod+ways[n];
		cout<<ways[n]<<"\n";
	
}


Measured memory_bytes: 5140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long a = GetLong();
		long b = GetLong();
		long c = GetLong();
		long d = GetLong();

		long max = long.MinValue;
		chmax(ref max, a * c);
		chmax(ref max, a * d);
		chmax(ref max, b * c);
		chmax(ref max, b * d);
		WriteLine(max);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  string s;
  cin>>s;
  bool f=true;
  if(s[2]!=s[3]) f=false;
  if(s[4]!=s[5]) f=false;
  YesNo(f);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	// cin >> tt;
	f(i,0,tt)
		test();
	return 0;
}

void test(){
	int n;
	cin >> n;
	vector<pii> a(n);
	for(auto &i : a) cin >> i.F >> i.S;
	map<pii,int> mm;
	if(n==1){
		cout << "1\n"; return;
	}
	f(i,0,n){
		f(j,0,n){
			if(i!=j){
				mm[{a[i].F-a[j].F, a[i].S-a[j].S}]++;
			}
		}
	}	
	int ma = 0;
	for(auto  el : mm){
		ma = max(ma,el.S);
	}
	cout << n-ma << "\n";
}

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

const int MAX_N = 101;

int A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, T;
    cin >> N >> M >> T;
    for (int i = 0; i < N; i++) cin >> A[i];
    int ans = A[0] - M;
    for (int i = 1; i < N; i++) {
        ans += max(0, A[i] - A[i - 1] - 2 * M);
    }
    ans += max(0, T - A[N - 1] - M);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
// by piano
int n, a[4100], u, v;
std :: vector<int> g[4100];
inline bool dfs(int u, int fa) {
	int s = !(fa == 0 || a[fa] > a[u]);
	for(auto v:g[u]) if(v != fa) s |= !dfs(v, u);
	return s;
}
main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	for(int i = 1; i <= n - 1; i ++) scanf("%d%d", &u, &v), g[u].push_back(v), g[v].push_back(u);
	for(int i = 1; i <= n; i ++) if(dfs(i, 0)) printf("%d ", i);
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;

struct diverta2019_b{
  int N;
  vector<pair<ll, ll>> D;
  
  void init(){
    cin >> N;
    D.resize(N);
    for(auto&& x:D){
      cin >> x.first >> x.second; 
    }
  }
  
  void solve(){
    init();
    sort(D.begin(), D.end());
    int ans = N == 1 ? 1 : 51;
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        int p = D[j].first - D[i].first;
        int q = D[j].second - D[i].second;
        vector<bool> ok(N, false);
        int cost = 0;
        for(int f=0;f<N;f++){
          if(!ok[f])cost++;
          ok[f] = true;
          for(int t=0;t<N;t++)
            if(D[f].first + p == D[t].first
               && D[f].second + q == D[t].second)
              ok[t] = true;
        }
        // cerr << " " << i << " " << j;
        // cerr << " " << p << " " << q;
        // cerr << " " << cost << endl;
        ans = min(ans, cost);
      }
    }
    cout << ans << endl;
  }
  
};

int main(){
  diverta2019_b ins;
  ins.solve();
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] mcxi = { 'm', 'c', 'x', 'i' };
		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			String[] input = new String[2];
			int[] convert = new int[2];
			for (int l = 0; l < input.length; l++) {
				input[l] = scanner.next();
				int a = 1;
				int[] num = new int[4];
				for (int j = 0; j < input[l].length(); j++) {
					char letter = input[l].charAt(j);
					for (int k = 0; k < mcxi.length; k++) {
						if (letter == mcxi[k]) {
							num[k] = a;
							a = 1;
							break;
						}
						if (k == mcxi.length - 1) {
							a = Character.getNumericValue(letter);
						}
					}
				}
				for (int j = 0; j < num.length; j++) {
					convert[l] += num[j] * Math.pow(10, 3 - j);
				}
			}

			String result = String.valueOf(convert[0] + convert[1]);
			while (result.length() < 4) {
				result = "0" + result;
			}
			for (int j = 0; j < result.length(); j++) {
				int number = Character.getNumericValue(result.charAt(j));
				if (number > 1) {
					System.out.print(number);
				}
				if (number > 0) {
					System.out.print(mcxi[j]);
				}
			}

			System.out.print("\n");

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 30896
#include <stdio.h>
struct segTree{
	int value[1200010];
	void setValue(int ind, int val, int l=0, int r=300000, int v=1)
	{
		if(l==r) value[v] = val;
		else
		{
			int h = (l+r)/2;
			if(ind<=h) setValue(ind,val,l,h,2*v);
			else setValue(ind,val,h+1,r,2*v+1);
			value[v] = value[2*v]>value[2*v+1]?value[2*v]:value[2*v+1];
		}
	}
	int getMax(int L, int R, int l=0, int r=300000, int v=1)
	{
		if(L<=l&&r<=R) return value[v];
		else if(r<L) return 0;
		else if(R<l) return 0;
		else
		{
			int h = (l+r)/2;
			int s1 = getMax(L,R,l,h,2*v);
			int s2 = getMax(L,R,h+1,r,2*v+1);
			return s1>s2?s1:s2;
		}
	}
}T;

int x[300010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	for(int i=1;i<=a;i++)
	{
		int L = x[i]-b>=0?x[i]-b:0;
		int R = x[i]+b<=300000?x[i]+b:300000;
		int value = T.getMax(L,R);
		T.setValue(x[i],value+1);
	}
	printf("%d",T.getMax(0,300000));
}

Measured memory_bytes: 7008
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 200005
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";
ll rems[MAX_INT];

ll modMul(ll X, ll Y) {
	return (X * Y) % 2019;
}
ll modSum(ll X, ll Y) {
	return (X + Y) % 2019;
}


int main() {
	cin >> S;
	ll rem = 0;
	ll val = 1;
	// ll temp = 0;
	reverse(S.begin(), S.end());
	fi(i, 0, S.size(), 1) {
		// rem = modSum(modMul(rem, 10ll), (S[i] - '0'));
		rem = modSum(modMul(val, (S[i] - '0')), rem);
		val = modMul(val, 10ll);
		rems[i] = rem;
		// val *= 10;
		// temp ;
	}
	map<ll, ll> mp;
	mp[0]++;
	ll ans = 0;
	fi(i, 0, S.size(), 1) {
		// cout << rems[i] << " ";
		ans += mp[rems[i]]++;
	}
	cout << ans << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 5240
N = int(input())
L_list = [int(e) for e in input().split()]

L_list.sort(reverse=True)

Longest_L=L_list[0]
all_L=0
for i in range(1,N):
  all_L+=L_list[i]
  
if all_L>Longest_L:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    value = 0
    cost = 0
    for j in range(n):
        if ((i >> j) & 1):
            value += v[j]
            cost += c[j]
        ans = max(ans, value - cost)

print(ans)


Measured memory_bytes: 73672
#include<stdio.h>
int len(char *a){
	int i;
	int count=0;
	for(i=0;a[i]!='\0';i++)count++;
	return count;
	
	}
int main(){
	char a[10000];
	int flag=1;
	int i,count;
	scanf("%s",a);
	int l=len(a);
	for(i=0;i<l;i++){
		if(a[0]!='A')flag=0;
		if(a[l-1]=='C')flag=0;
		if(a[1]=='C')flag=0;
		
		}
		count=0;
		for(i=2;i<l-1;i++){
			if(a[i]=='C')count++;
			}
	if(count!=1)flag=0;
	if(a[1]<'a')flag=0;
	for(i=2;i<l;i++){
		if(a[i]!='C'){
			if(a[i]<'a'){
				flag=0;
				break;
			}
			}
		}
		if(flag==1)printf("AC\n");
		else printf("WA");
	return 0;
	}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main(){
    int N;
    scanf("%d", &N);
    char a[N];
    scanf("%s", a);
    long int ans = 0;
    for(int i = 0; i <= 10; i++){
        for(int j = 0; j <= 10; j++){
            for(int k = 0; k <= 10; k++){
                int u = 0;
                for(int l = 0; l < N; l++){
                    if(u == 0 && a[l] - '0' == i) {
                        u++;
                        continue;
                    }
                    if(u == 1 && a[l] - '0' == j) {
                        u++;
                        continue;
                    }
                    if(u == 2 && a[l] - '0' == k) {
                        u++;
                        break;
                    }
                }
                if(u == 3) ans++;
            }
        }
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 256
#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 << "\n";

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

  string s;
  CIN(s);

  if (s == "SUN")
    COUT(7);
  if (s == "MON")
    COUT(6);
  if (s == "TUE")
    COUT(5);
  if (s == "WED")
    COUT(4);
  if (s == "THU")
    COUT(3);
  if (s == "FRI")
    COUT(2);
  if (s == "SAT")
    COUT(1);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define MEM(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef pair<int,int>pii;
const int mod = 1e9 + 7;
int main() {
    string s;
    cin >> s;
    cout << s[0];
    cout << s.size() - 2;
    cout << s[(int)s.size()-1] << endl;
}


Measured memory_bytes: 256
import sys
N=int(input())
a=list(map(int,input().split()))
for i in range(N):
  if a[i]%2==1:
    pass
  else:
    if a[i]%3!=0 and a[i]%5!=0:
      print('DENIED')
      sys.exit()
    else:
      pass
print('APPROVED')

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

int main () {
	int h, w; cin >> h >> w;
	int matrix[10][10];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> matrix[i][j];
	int in[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> in[i][j];
	for (int k = 0; k < 10; k++)
		for (int i = 0; i < 10; i++)
			for (int j = 0; j < 10; j++)
				matrix[i][j] = min(matrix[i][j], matrix[i][k]+matrix[k][j]);
	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (in[i][j] != -1 and in[i][j] != 1)
				ans += matrix[in[i][j]][1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import math

n = int(input())
P = []
#very small でWAなので、rで割ってかけ直すのをやめてみる
#atanを使ってみる
#0またいだときがおかしいか
for i in range(n):
    x, y = map(int, input().split( ))
    rad = math.atan2(x, y)
    P.append([rad, x, y])

P.sort()
P = P + P 


x0 = 0
y0 = 0

mx = 0

for i in range(n):
    vx = 0
    vy = 0
    for j in range(n):
        vx += P[i+j][1]
        vy += P[i+j][2]
        v = vx**2 + vy**2
        mx = max(v,mx)
print(math.sqrt(mx))


Measured memory_bytes: 3188
loop {
    n, w, d = gets.split.map &:to_i
    break if w == 0
    a = [nil, [w, d]]
    n.times { 
        i, s = gets.split.map &:to_i
        w, d = a.delete_at(i) 
        s %= (w + d)
        if s < w.to_f/2
            a += [[s, d], [w-s, d]]
        elsif s < w
            a += [[w-s, d], [s, d]]
        elsif s < w + d.to_f/2
            a += [[w, s-w], [w, d-s+w]]
        else
            a += [[w, d-s+w], [w, s-w]]
        end 
    }
    a.shift
    puts a.map{|w, d| w * d}.sort.join(" ")
}  

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N, M; cin >> N >> M;
	vector<int> A(N);

	int sum = 0;
	REP(i,N){
		cin >> A[i];
		sum += A[i];
	}	

	SORT(A);
	double boder = sum / (4.0*M);

	int cnt = 0;
	REP(i,N){
		if(A[N-i-1] >= boder) cnt++;
	}
	
	if(cnt >= M) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static long modpow(long a, long b, long m) {
		long ret = 1;
		while(b > 0) {
			if((b & 1) == 1) ret = ret * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return ret;
	}
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(modpow(a, b, 1000000007));
	}
}

Measured memory_bytes: 26324
#include<stdio.h>
#include<math.h>
  int main(){
    int i,j,n,tmp,count=0;
    scanf("%d",&n);

    for(i=0;i<n;i++){
      scanf("%d",&tmp);
      for(j=2;j<=sqrt(tmp);j++){
        if(tmp%j == 0) break;
      }
      if(j>sqrt(tmp)||sqrt(tmp)<2){
        count++;
      }
    }

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

    return 0;
  }



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

int vec[100];
int main(){
  
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  
  int Alice;
  int Bob;
  int max = 0;
  int tmp = 0;
  for (int i = 0; i<N; i++){
    for (int j = i + 1; j<N; j++){
    	if(vec[i]<=vec[j]){
    		tmp = vec[i];
          	vec[i] = vec[j];
          	vec[j] = tmp;
        }
    }
  }
  
  for(int i = 0; i<N; i++){
    if (i%2 == 0){
    	Alice += vec[i];
    }
    else{
    	Bob += vec[i];
    }
  }
  
  cout<<Alice-Bob<<endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = 4
b = 7

max_a_loop , _ = divmod(N, a)
max_b_loop , _ = divmod(N, b)
# print(max_a_loop)
# print(max_b_loop)
total = 0
ans = "No"

for i in range(max_a_loop+1):
    total = a*i
#     print(total)

    if total == N:
        ans = "Yes"
    for j in range(max_b_loop+1):
        total += b*j
#         print(total)

        if total == N:
            ans = "Yes"
print(ans)

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

int main(){
    int N, A;
    cin >> N >> A ;
    int num = N % 500;
    string ans;
    
    if (num <= A) {
        ans = "Yes";
    } else ans = "No";
    
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int p=1e9+7;

void up(int &a,int b){(a+=b)>=p&&(a-=p);}

ll f[101][3];

int T,k;
ll x,y,ans;

void dfs(ll a,ll b,int t)
{
    if(t+1==k){ans+=((y-a)/b+(x-a)/b)%p;return;}

    for(a+=b;f[k-t][1]*b+f[k-t][2]*a<=x&&f[k-t+1][1]*b+f[k-t+1][2]*a<=y;a+=b)
	dfs(b,a,t+1);
}

int main()
{
    f[1][0]=f[1][1]=f[2][0]=f[2][2]=1;
    for(int i=3;i<=100;++i)
	for(int j=0;j<=2;++j)
	    f[i][j]=f[i-2][j]+f[i-1][j];
    
    scanf("%d",&T);
    for(;T--;)
    {
	scanf("%lld%lld",&x,&y);
	if(x>y)std::swap(x,y);

	if(x<2){printf("1 %lld\n",y%p);continue;}

	for(k=2;f[k][0]<=x&&f[k+1][0]<=y;++k);
	if((k-=2)<2){printf("1 %lld\n",x*y%p);continue;}

	ans=0;
	for(int i=2;f[k][1]+f[k][2]*i<=x&&f[k+1][1]+f[k+1][2]*i<=y;++i)
	    dfs(1,i,1);
	printf("%d %lld\n",k,ans%p);
    }
    
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,cnt;
double ans;
int a[10] = {0,1,2,3,4,5,6,7,8};
double x[10],y[10];
double dis(double x1,double y1,double x2,double y2){
	return sqrt(1.0*(x1-x2)*(x1-x2) + 1.0*(y1-y2) * (y1-y2));
}
double solve(){
	double sum = 0;
	for(int i = 1;i < n;i++){
//		cout << x[a[i]] << " " << y[a[i]] << endl;
		sum += 1.0*dis(x[a[i]],y[a[i]],x[a[i-1]],y[a[i-1]]);
	}
	return sum;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0;i < n;i++) cin >> x[i] >> y[i];
	do{
		ans += solve();
		cnt++;
	}while(next_permutation(a,a+n));	
	printf("%.12lf\n",ans/cnt);
	return 0; 
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
S = input()
num = []
pre = S[0]
cnt = 0
for s in S:
    if s == pre:
        cnt += 1
    else:
        num.append(cnt)
        pre = s
        cnt = 1
num.append(cnt)

if S[0] == '>':
    num = [1] + num
if S[-1] == '<':
    num += [1]

ans = 0
for i in range(0, len(num), 2):
    b = max(num[i], num[i+1])
    c = min(num[i], num[i+1])
    ans += (b*(b+1))//2 + ((c-1)*c)//2
print(ans)

Measured memory_bytes: 8220
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long a, b, x;
    
    cin >> a >> b >> x;
    if(x >= a && a + b >= x)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
        
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define for(i,s,n) for(int i=s;i<n;i++)
#define vii vector<int>
int t = 1, n, OO = 1e14;
int dp[2][3001][3001];
vii v;
int solve(bool p = 0, int first = 0, int last = n - 1) {
	if (first > last) return 0;
	int& ret = dp[p][first][last];
	if (~ret) return ret;
	ret = -OO;
	int r1 = solve(!p, first, last - 1);
	int r2 = solve(!p, first + 1, last);
		ret = max({ ret,v[last] - r1,v[first] - r2 });
	
	return ret;
}
signed main()
{
	fast;

	//cin>>t;
	while (t--)
	{
		memset(dp, -1, sizeof dp);
		cin >> n;
		v = vii(n);
		for (i, 0, n) cin >> v[i];
		cout << solve() << endl;
	}
}


Measured memory_bytes: 144572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

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

	int k, a, b;
	cin >> k >> a >> b;
	int ans = (b / k) - ((a - 1) / k);
	if(ans > 0) {
		cout << "OK";
	}
	else {
		cout << "NG";
	}

	return 0;
}

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int32_t main() {
    io();
    int t=1;
    //primegen();
    //cin>>t;
    int k;
    cin>>k;
    int k1 = k;
    int val=7;
    int ans = -1;
if(val%k==0) ans = 1;
else {
    for(int pr=0; pr<=k; pr++) {
      val = (val*10 + 7)%k;
      if(val==0) {
        ans = pr+2;
        break;
      }
    }}
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, max, min;
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r0 = sc.nextInt();
        int r1 = sc.nextInt();
       
        max = r1 - r0;
        min = Math.min(r0, r1);
        
        for(i = 2; i < n; i++) {
        	int r = sc.nextInt();
        	max = Math.max(max, r-min);
        	min = Math.min(min, r);
        }
        System.out.println(max);
	}
}


Measured memory_bytes: 98804
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<bool> vb;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 1000000000;
const int N = 200007, M = N;
ll i,j,x,cnt,par,n;

void solve() {
 string s1,s2;
 cin>>s1>>s2;
 int cnt = 0;
 int n = s1.length();
 for(int i=0;i<n;i++) {
    if(s1[i] != s2[i]) cnt++;
 }
 cout<<cnt<<"\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

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

    return 0;
}




Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 55
#define maxm 100010
#define inf 1000000007
#define mod 1000000007
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int T;
int n;
int a[maxn][maxn],fa_a[maxn],fa_b[maxn],deg[maxn];
struct Graph{
    int head[maxn],nxt[maxn*2],to[maxn*2],tot;
    void add(int u,int v)
    {
        tot++;
        nxt[tot]=head[u];
        head[u]=tot;
        to[tot]=v;
    }
    void dfs(int x,int las,int *fa)
    {
        for(int i=head[x];i;i=nxt[i])
        {
            if(to[i]==las)  continue;
            fa[to[i]]=x;
            dfs(to[i],x,fa);
        }
    }
    void init()
    {
        memset(head,0,sizeof(head));tot=0;
    }
}A,B;
int book[maxn];
int degx[maxn];
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
queue<int>q;
bool check()
{
    for(int i=1;i<=n;i++)
      if(!degx[i]&&book[i])  q.push(i);
    while(q.size())
    {
        int now=q.front();q.pop();
        for(int i=head[now];i;i=nxt[i])
        {
            degx[to[i]]--;
            if(!degx[to[i]])  q.push(to[i]);
        }
    }
    for(int i=1;i<=n;i++)
      if(book[i]&&degx[i])  return false;
    return true;
}
int solve(int rt,int x)
{
    memset(degx,0,sizeof(degx));
    tot=0;memset(head,0,sizeof(head));
    A.dfs(x,0,fa_a);fa_a[x]=rt;fa_a[rt]=0;
    B.dfs(rt,0,fa_b);fa_b[rt]=0;
    int res=0;
    for(int i=1;i<=n;i++)  book[i]=(fa_a[i]!=fa_b[i]),res+=book[i];
    for(int i=1;i<=n;i++)
    {
        if(i==rt)  continue;
        if(!book[i]&&book[fa_a[i]])  return inf;
        if(book[i]&&book[fa_a[i]])  add(i,fa_a[i]),degx[fa_a[i]]++;
        if(book[i]&&book[fa_b[i]])  add(fa_b[i],i),degx[i]++;
    }
    if(check())  return res;
    return inf;
}
int main()
{
    T=read();
    while(T--)
    {
        A.init();B.init();
        memset(a,0,sizeof(a));
        memset(deg,0,sizeof(deg));
        n=read();int ans=inf;
        for(int i=1;i<n;i++)
        {
            int x=read(),y=read();
            A.add(x,y);A.add(y,x);
            deg[x]++;deg[y]++;
            a[x][y]=a[y][x]=1;
        }
        for(int i=1;i<n;i++)
        {
            int x=read(),y=read();
            B.add(x,y);B.add(y,x);
        }
        for(int i=1;i<=n;i++)
        {
            if(deg[i]!=1)  continue;
            for(int j=1;j<=n;j++)
            {
                if(i==j)  continue;
                ans=min(ans,solve(i,j)+(!a[i][j]));
            }
        }
        if(ans==inf)  puts("-1");
        else          printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main
{
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	
    	String[] posArr = br.readLine().split(" ");
    	
    	int atox = Math.max(Integer.parseInt(posArr[0]), Integer.parseInt(posArr[1]))
    			   - Math.min(Integer.parseInt(posArr[0]), Integer.parseInt(posArr[1]));
    	int btox = Math.max(Integer.parseInt(posArr[0]), Integer.parseInt(posArr[2]))
    			   - Math.min(Integer.parseInt(posArr[0]), Integer.parseInt(posArr[2]));
    	if (atox > btox) {
    		System.out.println("B");
    	} else {
    		System.out.println("A");
    	}
		
		
		
 
    }
 
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> t(n),x(n),y(n);
	for(int i = 0; i < n; i++){
		cin >> t[i] >> x[i] >> y[i] ;
	}

	int now_x = 0,now_y = 0,now_t=0;
	bool flag = true;
	for(int i = 0; i < n; i++){
		int d = abs(now_x-x[i]) + abs(now_y-y[i]);
		if(!(d <= t[i] - now_t && (t[i] - now_t - d)% 2 == 0)){
			cout << "No" << endl;
			return 0;
		}
		now_x = x[i], now_y = y[i], now_t = t[i];
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<cstdlib>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}
/*
13で割って5余る・・・
ユークリッド

常識的に言って、
0~10000までの中で13で割って5余る数って言ったら
10000 / 13 の値がだいたい相当する

保留

i文字までで13で割って5余る数dp[i]
 */

int dp[100001][13];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int div = 1e9+7;

    dp[n][0] = 1;

    int r = 1;
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == '?') {
            for (int j = 0; j < 13; j++) {
                for (int k = 0; k < 10; k++) {
                    int tmp = k * r;
                    dp[i][(j+tmp)%13] = (dp[i][(j+tmp)%13] + dp[i+1][j]) % div;
                }

            }
        } else {
            int k = ctoi(s[i]);
            for (int j = 0; j < 13; j++) {
                int tmp = k * r;
                    dp[i][(j+tmp)%13] = (dp[i][(j+tmp)%13] + dp[i+1][j]) % div;
            }
        }
        r = (r * 10) % 13;
    }
    cout << dp[0][5] % div << "\n";
    
}


Measured memory_bytes: 5504
k = 72
kk = k // 4
K = 1<<k
nu = lambda L: int("".join([hex(K+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    ###
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    ###
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    ###
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

N, A, B = map(int, input().split())
P = 10**9+7

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)
C = lambda n, k: fact(n, T) * pow(fact(k, T) * fact(n-k, T), P-2, P) % P
 
print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)

Measured memory_bytes: 31168